How can I set a field in admin to be at the same time non-editable and prepopulated from other field ?
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.
From what I understand, prepopulate is there to prepopulate an editable field in the admin form. If you want to have one field’s content automatically generated based on another’s, then prepopulate is not what you want.
The way I usually do this is by setting the field to be non-editable, not prepopulating it, and overriding the model’s save() method to get the value from the other field as necessary.
For automatic unique slug generation, Ashok’s suggestion is the way to go.