user689388
user689388

Reputation: 1

Prepopulate initial values for fields in the Django Admin without slugifying

In the Django admin, I can set a slug field to fill in automatically using prepopulated_fields. How can I set a field to fill in using a different function, for example just basic concatenation instead of lowercase and spaces-to-hyphens ?

Upvotes: 0

Views: 387

Answers (1)

There is no out of the box support for this (assuming you're talking replacing the exact, live editing that preopulated_fields provides).

The slug function is written in JavaScript, in django/contrib/admin/media/js/urlify.js

You could potentially insert a new script in the ModelAdmin extra JS property, but make sure your admin page doesn't actually need the "real" slugify script :)

Upvotes: 1

Related Questions