Monday, August 30, 2010

Re: How to display the user profile in the admin interface?

Thanks, I did run syncdb and added myapp to the INSTALLED_APPS.
"Company" appears in the admin interface under myapp.

But what I wanted to do is to show the UserProfile fields in the
Add/Change user page.

I was thinking in subclassing django.contrib.auth.admin.UserAdmin and
adding the UserProfile fields to the fieldsets, unregister(User) and
register(User, UserWithProfileFields)

is there another way?

On 30 August 2010 16:30, Sithembewena Lloyd Dube <zebra05@gmail.com> wrote:
> Don't forget to run manage.py syncdb to create table/s for your model/s.
>
> On Mon, Aug 30, 2010 at 5:28 PM, Sithembewena Lloyd Dube <zebra05@gmail.com>
> wrote:
>>
>> Hi João,
>>
>> Add myapp.UserProfile to the INSTALLED_APPS global variable of your
>> settings.py file, and in your admin.py file, import the model/s.
>>
>> On Mon, Aug 30, 2010 at 5:04 PM, João Rodrigues <jvrodrigues@gmail.com>
>> wrote:
>>>
>>> I have a company model
>>>
>>> class Company(models.Model):
>>>    name = models.CharField(max_length=50)
>>>    address = models.TextField()
>>>    phone = models.CharField(max_length=15)
>>>    fax = models.CharField(max_length=15)
>>>
>>> and I wanted to associate each user to a company, so I read
>>>
>>> http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
>>> added AUTH_PROFILE_MODULE = "myapp.UserProfile" to settings.py and
>>> created a UserProfile model
>>>
>>> class UserProfile(models.Model):
>>>    user = models.OneToOneField(User)
>>>    company = models.OneToOneField(Company)
>>>
>>>
>>> How do I make it appear in the admin interface?
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>> http://www.lloyddube.com
>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>
> --
> 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.
>

--
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.

No comments:

Post a Comment