简体   繁体   中英

Django custom save model admin page

When overriding the django save_model method, how do I extract the key value. Let's say the admin page has a input for the key "name". How do I extract that value in the method:

def save_model(self, request, obj, form, change):
    //request.name?

You can access a field by making use of form.cleaned_data , like this:

def save_model(self, request, obj, form, change):
    name = form.cleaned_data['name']
    # ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM