On Saturday, 9 March 2013 04:56:52 UTC+11, frocco wrote:
>
> Hello,
>
> right now, if I create a user in admin, I have to also create their
> userprofile that I have defined in settings.
>
> Is there a way to automate this?
>
> Thanks
>
>
>
Hi,
If by automate you mean admin should allow you to fill in user profile
information at the same time as the user then you need to use admin
inlines. This will place the user profile form in the same page as the
user create page. An example is below:
In an admin.py file in your app (this assumes that your profile model is
called UserProfile)
admin.site.unregister(User) # don't use the default user ModelAdmin
class UserProfileInline(admin.TabularInline):
model = UserProfile # change this to whatever your actual profile model is
called and import it
class UserAdmin(admin.ModelAdmin):
inlines = [UserProfileInline]
admin.site.register(User, UserAdmin) # use the new ModelAdmin
Hope this helps.
Atul
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.