Hello,
I created a simple Django model based on some database view. It looks
like that:
class Person(models.Model):
name = models.CharField(max_length=200)
class Meta:
db_table = 'bambo_person_view'
In my database (Postgresql) I created this view and I gave it rules,
so it is possible to insert into this view, update it and delete from
it.
However, when I enter the admin panel and try to add a new person, I
got such exception:
(...)
494. self.save_model(request, new_object, form,
change=False)
File "/var/lib/python-support/python2.5/django/contrib/admin/
options.py" in save_model
376. obj.save()
File "/var/lib/python-support/python2.5/django/db/models/base.py" in
save
311. self.save_base(force_insert=force_insert,
force_update=force_update)
File "/var/lib/python-support/python2.5/django/db/models/base.py" in
save_base
383. result = manager._insert(values,
return_id=update_pk)
File "/var/lib/python-support/python2.5/django/db/models/manager.py"
in _insert
138. return insert_query(self.model, values, **kwargs)
File "/var/lib/python-support/python2.5/django/db/models/query.py" in
insert_query
894. return query.execute_sql(return_id)
File "/var/lib/python-support/python2.5/django/db/models/sql/
subqueries.py" in execute_sql
312. self.model._meta.db_table,
self.model._meta.pk.column)
File "/var/lib/python-support/python2.5/django/db/backends/postgresql/
operations.py" in last_insert_id
58. cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" %
(table_name, pk_name))
File "/var/lib/python-support/python2.5/django/db/backends/util.py" in
execute
19. return self.cursor.execute(sql, params)
As you can see, after succesfull insert, Django calls function
last_insert_id. This function takes a look at the sequence
bambo_person_view_id_seq, which does not exist. If I could force it to
look at the proper sequence - I mean, bambo_person_id_seq - everything
would be ok. But I can't find the way to force it.
What can I do? What is the official way of using insertable database
views in Django?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.