[Django]-Django Tag model design

35πŸ‘

βœ…

If all you want to do is create a tag cloud, than that data model should be sufficient. I would make one modification:

tags = models.ManyToManyField(Tag,related_name='photos')

That will make reverse lookups in you photo views cleaner to read and easier to remember.

However, I would consider other use cases for your tags. Is a tag cloud the only thing you want to use the tagging for? Is there any meta data that the relationship should contain?

If you’re planning on having millions of rows, then caching is going to be as important as the data model.

Also, to avoid reinventing the wheel, see if anyone else has built a library that serves your purposes: http://www.djangopackages.com/grids/g/tagging/

πŸ‘€Arion

3πŸ‘

Handling tags youself could be a hard job.
You can easily use django library. Install it with pip

pip install django-taggit
πŸ‘€Shedrack

Leave a comment