Monday, August 23, 2010

Re: Prepopulate some fields in a admin add form

First, just to make absolutely clear you understand, the "user's name"
isn't the foreign key itself -- that would be the user's ID. The
user's name is what would be displayed to help you *select* the
correct ID, under the hood.

To the question at hand, it's quite simple to add a method to your
ModelAdmin class that will act on the foreign key field for your user:

http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

On Aug 21, 2:59 am, gondor <condor.c...@gmail.com> wrote:
> I have a simple admin model for inputting a note with a date into the
> database.  In addition to that I want to prepopulate with the users
> name when the add new entry button is clicked.  The users name is a
> foreign key to the user table.
>
> Does anyone know how to do that?
>
> Any help is appreciated.
>
> Thank you

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate