Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural key support #708

Open
lucemia opened this issue Feb 1, 2021 · 2 comments
Open

Natural key support #708

lucemia opened this issue Feb 1, 2021 · 2 comments

Comments

@lucemia
Copy link

lucemia commented Feb 1, 2021

Looks like taggit doesn't yet support loaddata / dumpdata with natural keys.
https://docs.djangoproject.com/en/3.1/topics/serialization/#natural-keys

It will be great if django-taggit can add this feature.

@rtpg
Copy link
Contributor

rtpg commented Apr 13, 2021

@lucemia here I guess you're suggesting that we just use a straightforward mapping of tag text to do a lookup? Seems pretty doable (with the usual caveats for custom tag types)

@Trafire
Copy link
Contributor

Trafire commented Jul 22, 2024

Natural Keys Support

We have added natural keys support to the custom Tag model in the Django taggit library. This allows you to identify objects by human-readable identifiers rather than by their database ID.

python manage.py dumpdata taggit.Tag --natural-foreign --natural-primary > tags.json

python manage.py loaddata tags.json

By default tags use the name field as the natural key.

You can customize this in your own custom tag model by setting the natural_key_fields property on your model the required fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants