diff -ur django-1.0/Django-1.0/django/db/models/base.py django-1.0.patched/Django-1.0/django/db/models/base.py
old
|
new
|
|
11 | 11 | import django.db.models.manager # Imported to register signal handler. |
12 | 12 | from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError |
13 | 13 | from django.db.models.fields import AutoField |
14 | | from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField |
| 14 | from django.db.models.fields.related import RelatedField, OneToOneRel, ManyToOneRel, OneToOneField |
15 | 15 | from django.db.models.query import delete_objects, Q, CollectedObjects |
16 | 16 | from django.db.models.options import Options |
17 | 17 | from django.db import connection, transaction, DatabaseError |
… |
… |
|
340 | 340 | |
341 | 341 | self.save_base(raw, parent) |
342 | 342 | setattr(self, field.attname, self._get_pk_val(parent._meta)) |
| 343 | for field in meta.local_fields: |
| 344 | if isinstance(field, RelatedField): |
| 345 | if getattr(self, field.attname) is None and getattr(self, field.name) is not None: |
| 346 | setattr(self, field.attname, getattr(self, field.name).pk) |
343 | 347 | |
344 | 348 | non_pks = [f for f in meta.local_fields if not f.primary_key] |
345 | 349 | |
diff -ur django-1.0/Django-1.0/tests/modeltests/m2m_and_m2o/models.py django-1.0.patched/Django-1.0/tests/modeltests/m2m_and_m2o/models.py
old
|
new
|
|
43 | 43 | >>> i3.save() |
44 | 44 | >>> i3.cc.add(r) |
45 | 45 | |
| 46 | >>> f = User(username='fred') |
| 47 | >>> i4 = Issue(num=4, client=f) |
| 48 | >>> f.save() |
| 49 | >>> i4.save() |
| 50 | |
46 | 51 | >>> from django.db.models.query import Q |
47 | 52 | |
48 | 53 | >>> Issue.objects.filter(client=r.id) |