is there a way to get the same results of using pre-populated fields in django’s admin site for slug fields in a standard modelform
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well django is open source, so if you want to replicate certain behaviour you can read the code and pick and chose what you like. For instance, you can see that contrib.admin uses a script called urlify.js to do the dynamic slugging, with usage something like this:
… depending of course on where your admin media is served from (mine is from “/admin-media/”)
Or if you’re happy to do your slugifying in your view, you can use the function that’s used in django.template as the slugify filter: django.template.defaultfilters.slugify.