I have cut and trimmed this from of some of my own code, so may not be 100%:

class MyModelForm(ModelForm):

    class Meta:
        model = MyModel

    def __init__(self, *args, **kwargs):
        super(MyModelForm, self).__init__(*args, **kwargs)
        self.fields['my_field'].initial= 'some_value'


class MyModelAdmin(ModelAdmin):
    form = MyModelForm



On Saturday, 18 February 2017 08:35:54 UTC+2, sjsade...@gmail.com wrote:
>
> hi, i want set initial value for field when a model insert page loaded in 
> django admin.
> i think i can do this work with get_field_queryset method but in django 
> there is no toturial for get_field_queryset.
> how to do this work?
> thanks ...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d76d8743-8970-477b-bea2-0a7c8ba2ffd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to