If you're using the admin interface to add new items of your model, you can set up a ModelAdmin
in your admin.py
and utilize prepopulated_fields
to automate entering of a slug:
class ClientAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('name',)}
admin.site.register(Client, ClientAdmin)
Here, when the user enters a value in the admin form for the name
field, the slug
will be automatically populated with the correct slugified name
.