Issue: I have an existing database, so the guide in
https://docs.djangoproject.com/en/1.8/howto/legacy-databases/ to inspect db
and created models.py .
That table does NOT have an 'id' column, and the created models.py doesn't
have 'id' either, and the class is unmanaged (managed=False). But when I
use Django to create page, the system failed, saying the 'id' is not found
in the table. Somehow the query included 'id' in the select fields.
After a little bit of digging, I changed
/usr/local/lib/python2.7/dist-packages/django/db/models/options.py:
Old:
line 284-287:
else:
auto = AutoField(verbose_name='ID', primary_key=True,
auto_created=True)
model.add_to_class('id', auto)
New:
else:
if self.managed:
auto = AutoField(verbose_name='ID', primary_key=True,
auto_created=True)
model.add_to_class('id', auto)
Then my class will not get into this "AutoField" action to add 'id' in the
query.
Looks like an apparent bug. This change works well for me. Please check and
confirm whether this should be commit into you code base.
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/7dd7a80b-3b7c-4cb1-ab31-219c6c3ad3c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.