Skip to content
Advertisement

Tag: slug

Why do I need to use SlugField in Django?

I searched on google and found this: “SlugField is a field for storing URL slugs in a relational database. SlugField is a column defined by the Django ORM. SlugField is actually defined within the django.db.” But still, the definition sounds a little complicated to me. I don’t even know what a slug is in this context and not sure about

How to auto generate slug from my Album model in django 2.0.4

I have an Album field with a list of Songs I would like to know how to generate slugs from the album title. I am following a tutorial which is using django 1.8 which uses regular expressions to implement this task. But from looking through the documentation they have introduced a more simpler approach (”). So can you help explain

Is there an easy way to populate SlugField from CharField?

Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. Answer for Admin in Django 1.0 and up, you’d need to use in your admin.py Your key in the prepopulated_fields dictionary is the field you want filled, and the value is a tuple of fields

Advertisement