I'm trying to create fixtures for my Django application. We have our own 
app that provides per-object permissions. It uses a GenericForeignKey to 
assign permissions to many different models. I need the ability to define 
fixtures for these custom permissions. However, I'm having trouble 
understanding how to do this properly. All of my own models have natural 
keys defined. My object permission model has a uuid field, which is 
auto-generated in the overridden save function. It's also defined as the 
natural key for this model. When I dump existing object permissions, the 
JSON includes the object_id so it's not using the natural key. Here's an 
example:

{
>
>     "pk": 7, 
>
>     "model": "vault.vault", 
>
>     "fields": {
>
>         "groups": [], 
>
>         "uuid": "11d62a7b-6e38-4baf-8938-fb475d8aca52", 
>
>         "system": true, 
>
>         "object_id": 3, 
>>
>         "content_type": [
>
>             "myapp", 
>
>             "mymodel"
>
>         ], 
>
>         "permissions": [], 
>
>         "public": false, 
>
>         "users": []
>
>     }
>
> }
>
>
>
I can't use this fixture as it's referencing an object ID. How do I use 
natural keys when dumping/loading fixture data for models that use generic 
relations? Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d978155-a274-4137-970d-dd8dabb3dcf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to