diff -r 541e95e66878 django/db/models/options.py
a
|
b
|
|
385 | 385 | cache[obj] = model |
386 | 386 | for klass in get_models(include_auto_created=True, only_installed=False): |
387 | 387 | for f in klass._meta.local_fields: |
388 | | if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: |
| 388 | if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta: |
389 | 389 | cache[RelatedObject(f.rel.to, klass, f)] = None |
390 | 390 | self._related_objects_cache = cache |
391 | 391 | |
… |
… |
|
422 | 422 | cache[obj] = model |
423 | 423 | for klass in get_models(only_installed=False): |
424 | 424 | for f in klass._meta.local_many_to_many: |
425 | | if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta: |
| 425 | if f.rel and not isinstance(f.rel.to, basestring) and self == f.rel.to._meta: |
426 | 426 | cache[RelatedObject(f.rel.to, klass, f)] = None |
427 | 427 | if app_cache_ready(): |
428 | 428 | self._related_many_to_many_cache = cache |
diff -r 541e95e66878 tests/modeltests/invalid_models/invalid_models/models.py
a
|
b
|
|
| 1 | #encoding=utf-8 |
1 | 2 | """ |
2 | 3 | 26. Invalid models |
3 | 4 | |
… |
… |
|
218 | 219 | class InvalidSetDefault(models.Model): |
219 | 220 | fk = models.ForeignKey('self', on_delete=models.SET_DEFAULT) |
220 | 221 | |
| 222 | class UnicodeForeignKeys(models.Model): |
| 223 | """Foreign keys which can translate to ascii should be OK, but fail if they're not.""" |
| 224 | good = models.ForeignKey(u'FKTarget', to_field='good') |
| 225 | also_good = models.ManyToManyField(u'FKTarget') |
| 226 | |
| 227 | # In Python 3 this should become legal, but currently causes unicode errors |
| 228 | # when adding the errors in core/management/validation.py |
| 229 | #bad = models.ForeignKey(u'★') |
| 230 | |
| 231 | |
221 | 232 | model_errors = """invalid_models.fielderrors: "charfield": CharFields require a "max_length" attribute that is a positive integer. |
222 | 233 | invalid_models.fielderrors: "charfield2": CharFields require a "max_length" attribute that is a positive integer. |
223 | 234 | invalid_models.fielderrors: "charfield3": CharFields require a "max_length" attribute that is a positive integer. |