1👍
you could do it by passing some values in GET, but this wont work always(e.g. for datefields etc..), i would do it with custom ModelAdmins with get_form method
class MyModelAdmin(admin.ModelAdmin):
def get_form(self, request, obj=None, **kwargs):
form = super(MyModelAdmin, self).get_form(request, obj, **kwargs)
form.base_fields['your_field_name'].initial = 'abcd'
return form
0👍
did you try simply adding it to a string?
reverse("admin:...")+"&fieldname=value"
you may need to use formating like this
return HttpResponseRedirect('%s%s'%(reverse("..."), '&field=value'))
depending on what your values are, you may need to also use a uri encoding routine (there are many ways to do this).
- [Answer]-Django sql use regex to check the phone number
- [Answer]-Need to create a user application in python-Django framework where based on input data will insert or update in the database
- [Answer]-Django model's value depending on other model's value
- [Answer]-Validate nested form in Django
- [Answer]-How get value of a list by a tuple in Django
Source:stackexchange.com