Opened 9 years ago
Closed 9 years ago
#25794 closed Bug (invalid)
loaddata with UUIDs as natural foreign keys does not work anymore
Reported by: | Gunnar Scherf | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.9rc1 |
Severity: | Normal | Keywords: | UUID loaddata --natural-foreign |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When I run dumpdata with a model which has a UUIDField as a natural key, the dump can not be loaded anymore.
manage.py dumpdata --natural-foreign myapp manage.py loaddata myapp
The model :
class ApplicationManager(models.Manager): def get_by_natural_key(self, uuid): return self.get(uuid=uuid) class Application(models.Model): uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=True) ...
The dump looks like this
[ { "model": "accounts.applicationrole", "fields": { "application": [ "ec1e39cb-e3e7-46c7-87b7-70ace4165d13" ], ...
The error message in loaddata is:
'(UUID('ec1e39cb-e3e7-46c7-87b7-70ace4165d13'),)' is not a valid UUID.
Change History (3)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Sorry, made a mistake in natural_key, which worked in django 1.8
def natural_key(self): return (self.application.natural_key(), self.role.natural_key())
correct definition:
def natural_key(self): return self.application.natural_key() + self.role.natural_key()
Note:
See TracTickets
for help on using tickets.
Please provide the minimum bit necessary for the "accounts.applicationrole" model too. If possible, could you bisect the regression?