Re: user profile in Django

2021-06-28 Thread Kelvin Sajere
I suggest that you use the AbstractUser model that django officially
recommends.

from django.contrib.auth.models AbstractUser

class User(AbstractUser):
age : models.IntegerField(default=0)
is_student : models.BooleanField(default=False)
# extra profile information

Then also make sure in your settings file you point your auth model to this
class

AUTH_USER_MODEL = ‘app_name.User’

This is the safest and easiest way build profiles. You can equally use the
AbstractBaseUser model if you need some more flexibility, but for most use
case, the AbstractUser model would do.

On Mon, Jun 28, 2021 at 14:17 Abdoulaye Koumaré 
wrote:

> If you're new the best way to create a profile is by using django signals
> you'll get more information about that at
> https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
> .
>
> On Sunday, 27 June 2021 at 21:46:28 UTC suabiut wrote:
>
>> You can use the user model, do something like that
>>
>> class user_register(models.Model):
>>   user = models.OneToOneField(User,on_delete=models.CASCADE)
>>   join_date = models.DateTimeField(default=timezone.now)
>>
>> To view the user profile, you can do something like this.
>>
>> def user_profile(request, username):
>> user = User.objects.get(username=username)
>> context = {
>>"user": user
>> }
>>
>>
>> return render(request, 'profile.html', context)
>>
>> profile.html
>>
>> {{user.username}}
>> {{user.first_name}}
>>
>>
>> On Mon, Jun 28, 2021 at 2:43 AM Samir Areh  wrote:
>>
>>> Hello
>>> I'm new to django. i want to create a user profile. I want to know the
>>> best way to do this. 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/f84c5af2-12f1-41d3-9002-f0bc96f0371fn%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a66be5bb-fff2-4b7e-a76c-4072fc5a3586n%40googlegroups.com
> 
> .
>
-- 
KeLLs

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADYqDX0g6bVJ41UOA8x_3UaE6RLRu1msBRTLLt_7f8%2BKaX%2BCqg%40mail.gmail.com.


Re: user profile in Django

2021-06-28 Thread Abdoulaye Koumaré
If you're new the best way to create a profile is by using django signals 
you'll get more information about that 
at 
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
 
.

On Sunday, 27 June 2021 at 21:46:28 UTC suabiut wrote:

> You can use the user model, do something like that
>
> class user_register(models.Model):
>   user = models.OneToOneField(User,on_delete=models.CASCADE)
>   join_date = models.DateTimeField(default=timezone.now)
>
> To view the user profile, you can do something like this.
>
> def user_profile(request, username):
> user = User.objects.get(username=username)
> context = {
>"user": user
> }
>
>
> return render(request, 'profile.html', context)
>
> profile.html
>
> {{user.username}}
> {{user.first_name}}
>
>
> On Mon, Jun 28, 2021 at 2:43 AM Samir Areh  wrote:
>
>> Hello
>> I'm new to django. i want to create a user profile. I want to know the 
>> best way to do this. 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f84c5af2-12f1-41d3-9002-f0bc96f0371fn%40googlegroups.com
>>  
>> 
>> .
>>
>
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a66be5bb-fff2-4b7e-a76c-4072fc5a3586n%40googlegroups.com.


Re: user profile in Django

2021-06-27 Thread sum abiut
You can use the user model, do something like that

class user_register(models.Model):
  user = models.OneToOneField(User,on_delete=models.CASCADE)
  join_date = models.DateTimeField(default=timezone.now)

To view the user profile, you can do something like this.

def user_profile(request, username):
user = User.objects.get(username=username)
context = {
   "user": user
}


return render(request, 'profile.html', context)

profile.html

{{user.username}}
{{user.first_name}}


On Mon, Jun 28, 2021 at 2:43 AM Samir Areh  wrote:

> Hello
> I'm new to django. i want to create a user profile. I want to know the
> best way to do this. 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f84c5af2-12f1-41d3-9002-f0bc96f0371fn%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y6cWAGpoS8GsxjZuAFQ2tp8aJy0Qj-38YvqHGdm3vEeYg%40mail.gmail.com.


Re: User profile

2019-01-17 Thread senthu nithy
Thank you ANi and Alex. I will refer both links
K.Senthuja
Undergraduate Student (UOJ),
https://www.linkedin.com/in/senthuja/
https://medium.com/@senthujakarunanithy


On Thu, Jan 17, 2019 at 8:41 PM Alex Kimeu  wrote:

> First you need to create a model for the User Profile.
>
> On Thu, 17 Jan 2019, 17:49 ANi 
>> Do you mean you want to create your custom user model?
>> Two ways to do it,
>> 1. create a profile model and use foreign key to the user model that
>> Django provided.
>> 2. create a custom user model like this
>> https://wsvincent.com/django-custom-user-model-tutorial/
>>
>>
>> senthu nithy於 2019年1月17日星期四 UTC+8下午8時47分41秒寫道:
>>>
>>> I am new Django framework. I want to create a user profile for my app.
>>> But i start to create the user profile then i direct to create Admin
>>> profile which is already created in Django. I want to create a user
>>> Profile. Can you direct me?
>>>
>> --
>> 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/94a197bc-1440-43cf-9af7-0c31da09cf4b%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CACYP3VG4PsTMPd7Sj0LGkbqNUdU135K2D9Ven-VXV91vMiJhTw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALEaTU6EfXskkuD%3Dfn3_on83kx0V%3D1qXaeQ7sQk9kVYheibJ4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User profile

2019-01-17 Thread Alex Kimeu
First you need to create a model for the User Profile.

On Thu, 17 Jan 2019, 17:49 ANi  Do you mean you want to create your custom user model?
> Two ways to do it,
> 1. create a profile model and use foreign key to the user model that
> Django provided.
> 2. create a custom user model like this
> https://wsvincent.com/django-custom-user-model-tutorial/
>
>
> senthu nithy於 2019年1月17日星期四 UTC+8下午8時47分41秒寫道:
>>
>> I am new Django framework. I want to create a user profile for my app.
>> But i start to create the user profile then i direct to create Admin
>> profile which is already created in Django. I want to create a user
>> Profile. Can you direct me?
>>
> --
> 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/94a197bc-1440-43cf-9af7-0c31da09cf4b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CACYP3VG4PsTMPd7Sj0LGkbqNUdU135K2D9Ven-VXV91vMiJhTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User profile

2019-01-17 Thread ANi
Do you mean you want to create your custom user model?
Two ways to do it,
1. create a profile model and use foreign key to the user model that Django 
provided.
2. create a custom user model like this 
https://wsvincent.com/django-custom-user-model-tutorial/


senthu nithy於 2019年1月17日星期四 UTC+8下午8時47分41秒寫道:
>
> I am new Django framework. I want to create a user profile for my app. But 
> i start to create the user profile then i direct to create Admin profile 
> which is already created in Django. I want to create a user Profile. Can 
> you direct me?
>

-- 
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/94a197bc-1440-43cf-9af7-0c31da09cf4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User Profile Creation

2011-12-20 Thread Piotr Zalewa

You can't do it in admin site without tinkering.
If you create users inside a view (i.e. during the registration 
process), there is no need to use signals - you can simply create a 
profile with data from registration form.


If you use django forms, use them with prefix kwarg, this will allow to 
simply divide request to User and Profile fields.


https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

zalun

On 12/15/11 22:46, bazaarsoft wrote:

In all the examples I've seen of creating the user profile at the time
a User is created, I always see the use of the signal and the profile
table's fields (except for user) have to be nullable. I don't see a
way to break in to the creation process using the signal scheme such
that you can pass in valid data for initial creation. I have all the
form elements for both the User object an my profile object - I just
can't get them to my version of the create_profile method.

Is this correct - a user profile can't have any required fields
(required in the model) except user because the only way to create it
is through the signal?



--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-27 Thread James
Doh! As much as I read in the forms section, I skipped the ModelForms part, 
even though that's what I was using!

Thanks again!

James

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik

Yeah, it's documented. Right at the tippy-top of the ModelForms docs.

http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/



--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik

On 04/26/2011 06:04 PM, Kenny Meyer wrote:

On Tue, Apr 26, 2011 at 4:17 PM, Shawn Milochik  wrote:

If you're creating a ModelForm that already has data in the database, don't
pass in request.POST. Instead, pass in the instance with the 'instance'
keyword argument.

For example, if it was a ModelForm for the User object: form =
UserForm(instance = request.user)

Thanks, I had the same question and passing an instance worked fine
for me. Isn't this documented somewhere?



You know, I assume it must be documented because I know it. However, I 
was unable to find it by doing a quick search of the docs. Maybe I read 
it in a book.


I'll do a little more looking for it and if I don't find it I'll open a 
ticket to improve the documentation. It'll be an easy ticket to work on.


Shawn

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-26 Thread Kenny Meyer
On Tue, Apr 26, 2011 at 4:17 PM, Shawn Milochik  wrote:
> If you're creating a ModelForm that already has data in the database, don't
> pass in request.POST. Instead, pass in the instance with the 'instance'
> keyword argument.
>
> For example, if it was a ModelForm for the User object: form =
> UserForm(instance = request.user)
Thanks, I had the same question and passing an instance worked fine
for me. Isn't this documented somewhere?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-26 Thread James
That did it. 99% of the time the data will be there; I can write
exception clauses for when it isn't. I think I'll use this method,
though I had just discovered the "initial" dictionary argument as
well, a few minutes before I noticed your reply. Is there a spot in
the Django docs that explains this in more detail? I haven't been able
to find it.

Thank you very much!

James

On Apr 26, 3:17 pm, Shawn Milochik  wrote:
> If you're creating a ModelForm that already has data in the database,
> don't pass in request.POST. Instead, pass in the instance with the
> 'instance' keyword argument.
>
> For example, if it was a ModelForm for the User object: form =
> UserForm(instance = request.user)

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik
If you're creating a ModelForm that already has data in the database, 
don't pass in request.POST. Instead, pass in the instance with the 
'instance' keyword argument.


For example, if it was a ModelForm for the User object: form = 
UserForm(instance = request.user)





--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User profile display problem in change user form

2010-04-21 Thread Jx
Thanks Tracey! it works :)

yea actually i did the tutorial, i cant believe i missed out that
part. Looks like i need more brushing up.


On Apr 22, 10:36 am, Karen Tracey  wrote:
> On Wed, Apr 21, 2010 at 10:20 PM, Jx  wrote:
> > [snip]
> > When i view the change user page, my country field is displayed as a
> > drop down box as intended, but the contents of the drop down box is
> > the "Country Object" instead of my intention to display the name of
> > the country.
>
> Your Country model needs a __unicode__ method to define what a Country
> should look like for display. This method is covered fairly early in the
> tutorial:
>
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-t...
>
> (If you have not worked through the tutorial it is a really good first step
> to pick up stuff like this, and it is not very long.)
>
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User profile display problem in change user form

2010-04-21 Thread Karen Tracey
On Wed, Apr 21, 2010 at 10:20 PM, Jx  wrote:

> [snip]
> When i view the change user page, my country field is displayed as a
> drop down box as intended, but the contents of the drop down box is
> the "Country Object" instead of my intention to display the name of
> the country.
>
>
Your Country model needs a __unicode__ method to define what a Country
should look like for display. This method is covered fairly early in the
tutorial:

http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api

(If you have not worked through the tutorial it is a really good first step
to pick up stuff like this, and it is not very long.)

Karen

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



Re: User profile form

2010-04-05 Thread Michał Klich
I managed to display form but with fields i`d like to not show or at
least disable modifications, like username and email.
Still would like some help on this .

On Apr 2, 4:36 pm, Michał Klich  wrote:
> Thanks anyway :)
>
> I could create my own view and update respective database records but this
> would be my last resort.
> I know this can be achieved as i am displaying my ExtendedUser form during
> registration. I feel stupid, i am displaying it so i could have omit some
> fields and use it. I`ll dig around a little more.
>
> Dnia piątek 02 kwietnia 2010 o 14:52:05 Carl Zmola napisał(a):
>
>
>
>
>
> > This is  about the limits of my knowledge.
> > My goal was to use it in the admin and I succeeded.
>
> > If you write your own view, you can do anything you want, you just have
> > to figure out how :-)
>
> > On 04/02/2010 08:26 AM, Michał Klich wrote:
> > > Ok, thanks.
> > > Can this be done in regular view but not Admin?
> > > Would it be necessery to use formset along with inline?
> > > I`d appreciate if you shed some light on this.
>
> > > Thank you
>
> > > Dnia czwartek 01 kwietnia 2010 o 22:29:40 Carl Zmola napisał(a):
> > >> The standard way to extend user is through the user profile.
> > >> The following thread talked about showing user profile fields in the
> > >> Auth User admin form.
>
> > >>http://groups.google.com/group/django-users/browse_thread/thread/2af584b
> > >> 66b 8a38a3
>
> > >> This should be doable with the model manager, but you will have to play
> > >> around with it some.
> > >> Or you should just create your own form.
>
> > >> Carl
>
> > >> On 04/01/2010 08:30 AM, Michał Klich wrote:
> > >>> Hello,
>
> > >>> I am writing website and i`d like to implement profile managment. Basic
> > >>> thing would be to edit some of user details by themself, like first and
> > >>> last name etc. Now, i had to extend User model to add my own stuff, and
> > >>> email address. I am having troubles with displaying form. Example will
> > >>> describe better what i would like achieve.
>
> > >>> This is mine extended user model.
>
> > >>> class UserExtended(models.Model):
> > >>>       user = models.ForeignKey(User, unique=True)
>
> > >>>       kod_pocztowy = models.CharField(max_length=6,blank=True)
> > >>>       email  = models.EmailField()
>
> > >>> This is how my form looks like.
>
> > >>> class ProfilUzytkownika(ModelForm):
> > >>>       class Meta:
> > >>>           model = User
>
> > >>> That code displays lots of fields, most of them are not for users to
> > >>> edit, i could exclude them, but i would still miss ones from mine
> > >>> UserExtended class.
>
> > >>> Is there a way to inherit User model in UserExtended modelform and then
> > >>> exclude fields? I tried but obviously failed.
> > >>> Or i a down to creating my own form and updating particular fields?
>
> > >>> I am back to reading docs but will wait for any responses.
>
> > >>> Thanks for help.
>
> --
> Michał Klich
>
> klich.mic...@gmail.com
> mic...@michalklich.comhttp://www.michalklich.com
>
>  signature.asc
> < 1KViewDownload

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



Re: User profile form

2010-04-02 Thread Michał Klich
Thanks anyway :)

I could create my own view and update respective database records but this 
would be my last resort.
I know this can be achieved as i am displaying my ExtendedUser form during 
registration. I feel stupid, i am displaying it so i could have omit some 
fields and use it. I`ll dig around a little more.

Dnia piątek 02 kwietnia 2010 o 14:52:05 Carl Zmola napisał(a):
> This is  about the limits of my knowledge.
> My goal was to use it in the admin and I succeeded.
> 
> If you write your own view, you can do anything you want, you just have
> to figure out how :-)
> 
> On 04/02/2010 08:26 AM, Michał Klich wrote:
> > Ok, thanks.
> > Can this be done in regular view but not Admin?
> > Would it be necessery to use formset along with inline?
> > I`d appreciate if you shed some light on this.
> > 
> > Thank you
> > 
> > Dnia czwartek 01 kwietnia 2010 o 22:29:40 Carl Zmola napisał(a):
> >> The standard way to extend user is through the user profile.
> >> The following thread talked about showing user profile fields in the
> >> Auth User admin form.
> >> 
> >> http://groups.google.com/group/django-users/browse_thread/thread/2af584b
> >> 66b 8a38a3
> >> 
> >> This should be doable with the model manager, but you will have to play
> >> around with it some.
> >> Or you should just create your own form.
> >> 
> >> Carl
> >> 
> >> On 04/01/2010 08:30 AM, Michał Klich wrote:
> >>> Hello,
> >>> 
> >>> I am writing website and i`d like to implement profile managment. Basic
> >>> thing would be to edit some of user details by themself, like first and
> >>> last name etc. Now, i had to extend User model to add my own stuff, and
> >>> email address. I am having troubles with displaying form. Example will
> >>> describe better what i would like achieve.
> >>> 
> >>> This is mine extended user model.
> >>> 
> >>> class UserExtended(models.Model):
> >>>   user = models.ForeignKey(User, unique=True)
> >>>   
> >>>   kod_pocztowy = models.CharField(max_length=6,blank=True)
> >>>   email  = models.EmailField()
> >>> 
> >>> This is how my form looks like.
> >>> 
> >>> class ProfilUzytkownika(ModelForm):
> >>>   class Meta:
> >>>   model = User
> >>> 
> >>> That code displays lots of fields, most of them are not for users to
> >>> edit, i could exclude them, but i would still miss ones from mine
> >>> UserExtended class.
> >>> 
> >>> Is there a way to inherit User model in UserExtended modelform and then
> >>> exclude fields? I tried but obviously failed.
> >>> Or i a down to creating my own form and updating particular fields?
> >>> 
> >>> I am back to reading docs but will wait for any responses.
> >>> 
> >>> Thanks for help.

-- 
Michał Klich

klich.mic...@gmail.com
mic...@michalklich.com
http://www.michalklich.com


signature.asc
Description: This is a digitally signed message part.


Re: User profile form

2010-04-02 Thread Michał Klich
Ok, thanks.
Can this be done in regular view but not Admin?
Would it be necessery to use formset along with inline?
I`d appreciate if you shed some light on this.

Thank you

Dnia czwartek 01 kwietnia 2010 o 22:29:40 Carl Zmola napisał(a):
> The standard way to extend user is through the user profile.
> The following thread talked about showing user profile fields in the
> Auth User admin form.
> 
> http://groups.google.com/group/django-users/browse_thread/thread/2af584b66b
> 8a38a3
> 
> This should be doable with the model manager, but you will have to play
> around with it some.
> Or you should just create your own form.
> 
> Carl
> 
> On 04/01/2010 08:30 AM, Michał Klich wrote:
> > Hello,
> > 
> > I am writing website and i`d like to implement profile managment. Basic
> > thing would be to edit some of user details by themself, like first and
> > last name etc. Now, i had to extend User model to add my own stuff, and
> > email address. I am having troubles with displaying form. Example will
> > describe better what i would like achieve.
> > 
> > This is mine extended user model.
> > 
> > class UserExtended(models.Model):
> >  user = models.ForeignKey(User, unique=True)
> >  
> >  kod_pocztowy = models.CharField(max_length=6,blank=True)
> >  email  = models.EmailField()
> > 
> > This is how my form looks like.
> > 
> > class ProfilUzytkownika(ModelForm):
> >  class Meta:
> >  model = User
> > 
> > That code displays lots of fields, most of them are not for users to
> > edit, i could exclude them, but i would still miss ones from mine
> > UserExtended class.
> > 
> > Is there a way to inherit User model in UserExtended modelform and then
> > exclude fields? I tried but obviously failed.
> > Or i a down to creating my own form and updating particular fields?
> > 
> > I am back to reading docs but will wait for any responses.
> > 
> > Thanks for help.

-- 
Michał Klich

klich.mic...@gmail.com
mic...@michalklich.com
http://www.michalklich.com


signature.asc
Description: This is a digitally signed message part.


Re: User profile form

2010-04-01 Thread Carl Zmola

The standard way to extend user is through the user profile.
The following thread talked about showing user profile fields in the 
Auth User admin form.


http://groups.google.com/group/django-users/browse_thread/thread/2af584b66b8a38a3

This should be doable with the model manager, but you will have to play 
around with it some.

Or you should just create your own form.

Carl

On 04/01/2010 08:30 AM, Michał Klich wrote:

Hello,

I am writing website and i`d like to implement profile managment. Basic thing
would be to edit some of user details by themself, like first and last name
etc. Now, i had to extend User model to add my own stuff, and email address.
I am having troubles with displaying form. Example will describe better what i
would like achieve.

This is mine extended user model.
class UserExtended(models.Model):
 user = models.ForeignKey(User, unique=True)

 kod_pocztowy = models.CharField(max_length=6,blank=True)
 email  = models.EmailField()

This is how my form looks like.
class ProfilUzytkownika(ModelForm):
 class Meta:
 model = User

That code displays lots of fields, most of them are not for users to edit, i
could exclude them, but i would still miss ones from mine UserExtended class.

Is there a way to inherit User model in UserExtended modelform and then
exclude fields? I tried but obviously failed.
Or i a down to creating my own form and updating particular fields?

I am back to reading docs but will wait for any responses.

Thanks for help.


   


--
Carl Zmola
301-562-1900 x315
czm...@woti.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: User profile creation forms

2009-09-16 Thread Rodney Topor

Without having to use django-registration or django-profile, I've
discovered that it's easy enough to seamlessly concatenate a user form
and a profile form for data entry, then to create a separateuser
object and profile object from the same resulting request.POST, then
connect and save the objects.  Quite straightforward in the end.

On Sep 10, 8:28 pm, V  wrote:
> On szept. 10, 06:51, RodneyTopor wrote:
>
> > Suppose one wants to store additional information about a user in a
> > separate profile class as described in the documentation.  When a user
> > registers, the form displayed should show (all) fields from class User
> > and (some) fields from class Profile.
>
> > What is the best way to define this form?
>
> > What is the best way to process the form data in a view to create the
> > user instance and associated profile instance?
>
> > I'm sorry if this is a naive question.  Neither the documentation nor
> > The Django Book appear to answer it.  It seems to me to be a common
> > situation.
>
> > Rodney
>
> another option is to use django-registration[1] and django-profiles[2]
> then set the success_url after account activation to the user profile
> page
>
> or
>
> create a user registration form, that saves profile data as well
> django-registration might work with a formwizard as well, but I wasn't
> thinking much about this
>
> [1] bitbucket.org/ubernostrum/django-registration/
> [2] bitbucket.org/ubernostrum/django-profiles/
>
> cheers, V
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile creation forms

2009-09-10 Thread V

On szept. 10, 06:51, Rodney Topor  wrote:
> Suppose one wants to store additional information about a user in a
> separate profile class as described in the documentation.  When a user
> registers, the form displayed should show (all) fields from class User
> and (some) fields from class Profile.
>
> What is the best way to define this form?
>
> What is the best way to process the form data in a view to create the
> user instance and associated profile instance?
>
> I'm sorry if this is a naive question.  Neither the documentation nor
> The Django Book appear to answer it.  It seems to me to be a common
> situation.
>
> Rodney

another option is to use django-registration[1] and django-profiles[2]
then set the success_url after account activation to the user profile
page

or

create a user registration form, that saves profile data as well
django-registration might work with a formwizard as well, but I wasn't
thinking much about this

[1] bitbucket.org/ubernostrum/django-registration/
[2] bitbucket.org/ubernostrum/django-profiles/

cheers, V
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile problems

2009-08-19 Thread Justin

Figured it out.  Apparently when I did my intial test I did not have a
profile create for the user which was causing a different error.

the correct string was 'engine.UserProfile'

Justin

On Aug 19, 10:11 am, Justin  wrote:
> I am sure this is a newbie mistake but I can't seem to find exactly
> the right setting.  I have create a user profile class.  I am trying
> to attach into my django project via the AUTH_PROFILE_MODULE setting
> in the settings.py file.
>
> The error I get is as follows when I try to retrieve the profile>>> from 
> django.contrib.auth.models import User
> >>> from engine.models import *
> >>> user = User.objects.get(pk=1)
> >>> prof = user.get_profile()
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> models.py", line 285, in get_profile
>     self._profile_cache = model._default_manager.get
> (user__id__exact=self.id)
> AttributeError: 'NoneType' object has no attribute '_default_manager'
>
> My AUTH_PROFILE_MODULE = 'engine.UserProfile'
>
> Rough project layout
>
> /logi - site folder
> /logi/engine/models model folder
> /logi/engine/views views folder
>
> The userprofile exists within the /logi/engine/models folder in a file
> call models_file.py.  so the full path to my user profile class is /
> logi/engine/models/models_file.py
>
> I have tried several variations of the AUTH_PROFILE_MODULE string but
> none seems to work.
>  engine.UserProfile
>  models.UserProfile
>  logi.UserProfile
>
> User Class as defined
> class UserProfile(models.Model):
>
>         panel_id = models.IntegerField()
>         email = models.EmailField()
>         status = models.CharField(max_length=1)
>         user = models.ForeignKey(User, unique=True)
>
>         def __unicode__(self):
>                 return "%s - %s" % (self.panel_id, self.email)
>
>         class Meta:
>                 app_label = 'engine'
>
> Any help would be appreciated,
>   I am sure this is something simple.
>
> Thanks,
>   Justin
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile get_profile() error

2009-05-16 Thread Karlw

Thanks!  Works great now.

On May 15, 8:07 pm, Sam Chuparkoff  wrote:
> On Fri, 2009-05-15 at 19:53 -0400, Joshua Williams wrote:
> > When trying to access a user defined profile, using get_profile, I
> > am  
> > getting an error when accessing the profile for a user.  Just so I  
> > have my bases covered, here is my model class:
>
> > class UserDetail(models.Model):
> >      Position =  models.ManyToManyField(Position, blank=True)
> >      pkUser = models.ForeignKey(User, unique=True)
>
> You must name your ForeignKey field 'user' instead of 'pkUser'. I don't
> see that in the doc, but it is clear in get_profile().
>
> sdc
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile get_profile() error

2009-05-15 Thread Sam Chuparkoff

On Fri, 2009-05-15 at 19:53 -0400, Joshua Williams wrote:
> When trying to access a user defined profile, using get_profile, I
> am  
> getting an error when accessing the profile for a user.  Just so I  
> have my bases covered, here is my model class:
> 
> class UserDetail(models.Model):
>  Position =  models.ManyToManyField(Position, blank=True)
>  pkUser = models.ForeignKey(User, unique=True)

You must name your ForeignKey field 'user' instead of 'pkUser'. I don't
see that in the doc, but it is clear in get_profile().

sdc



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile in Admin

2009-05-01 Thread Kevin Audleman

Can't answer your question directly, but it looks as if you are trying
to extend the field list for a user. In this case you should check out
the proper way of doing it using AUTH_PROFILE_MODULE:

http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#storing-additional-information-about-users

Kevin


On May 1, 8:20 am, CrabbyPete  wrote:
> I created the following:
>
> class Profile(models.Model):
>     user        = models.ForeignKey(User, unique=True)
>     phone       = models.CharField(max_length=15,  blank = True, null
> = True, unique = True)
>
>    def __unicode__(self):
>         return self.user.username
>
> But when I look at it in the Admin. It shows  the Profile and that I
> have 2 users, but does not display the username to select. Help?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile Problem

2009-04-07 Thread hc w
Hi , Dougal

I did read django's offical recommendation of user profile.  just don't want to 
add one more table for one more attribute.and some say the way I present is 
helpful to understand the magic of Django. unfortunately this way seems not 
recommended by offical group.  I just want to know is this a bug of mod_python 
or maybe the problem lies somewhere else?  thanks a lot anyway! 

Best Regards,

/sky

--- 09年4月7日,周二, Dougal Matthews  写道:

发件人: Dougal Matthews 
主题: Re: User Profile Problem
收件人: django-users@googlegroups.com
日期: 2009年4月7日,周二,下午8:33

Why do you want to change the User model?
This might be a useful read for you if you want to store more info about a 
user...http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users


Dougal


---
Dougal Matthews - @d0ugal 
http://www.dougalmatthews.com/




2009/4/7 hc w 


Hii, all 
I just want to add a foreign key--'FourS'-- to the user model .I have modified 
it as following.it works on our dev env in windows but failed in product env in 
linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can anyone tell me why 
and some solution?  Thanks

 MODEL: 
from django.db import modelsfrom django.contrib.auth.models import Userfrom 
cyt.glorail.models import FourS


from django.contrib.admin import validation
# Create your models here.#class UserProfile(models.Model):#    user = 
models.ForeignKey(User,unique=True)

#    dealer = models.ForeignKey(FourS)#    class
 Meta:#        db_table = u'auth_userprofile'   from django.contrib.auth.admin 
import UserAdmin   import datetime   class ProfileBase(type):   def 
__new__(cls, name, bases, attrs):   

        module = attrs.pop('__module__')       parents = [b for b in bases 
if isinstance(b, ProfileBase)]       if parents:           fields = []  
             for obj_name, obj in attrs.items():   

                if isinstance(obj, models.Field): fields.append(obj_name)   
            User.add_to_class(obj_name, obj)            UserAdmin.fieldsets = 
list(UserAdmin.fieldsets)   

            UserAdmin.fieldsets.append((name, {'fields': fields}))       
return super(ProfileBase,
 cls).__new__(cls, name, bases, attrs)          class Profile(object):  
 __metaclass__ = ProfileBase class MyProfile(Profile):   dealer = 
models.ForeignKey(FourS)

    #dealer = models.IntegerField(null=True, 
blank=True,db_column='dealer_id')        ERROR MESSAGE: 
ImproperlyConfigured at /admin/auth/user/1/

'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is missing 
from the form.Request Method: GET Request URL: 
http://192.168.0.116/admin/auth/user/1/ 

Exception Type: ImproperlyConfigured Exception Value: 
'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is missing 
from the form. Exception Location:
 /usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in 
check_formfield, line 254 Python Executable: /usr/local/bin/python Python 
Version: 2.5.4 Python Path: ['/pyweb', 
'/usr/local/lib/python2.5/site-packages/django', 
'/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', 
'/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
 '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', 
'/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', 
'/usr/local/lib/python2.5/lib-dynload', 
'/usr/local/lib/python2.5/site-packages'] 






好玩贺卡等你发,邮箱贺卡全新上线!












  ___ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile Problem

2009-04-07 Thread Dougal Matthews
Why do you want to change the User model?
This might be a useful read for you if you want to store more info about a
user...
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/7 hc w 

> Hii, all
>
> I just want to add a foreign key--'FourS'-- to the user model .I have
> modified it as following.it works on our dev env in windows but failed in
> product env in linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can
> anyone tell me why and some solution?  Thanks
>
> MODEL:
>
> from django.db import models
> from django.contrib.auth.models import User
> from cyt.glorail.models import FourS
>
> from django.contrib.admin import validation
>
> # Create your models here.
> #class UserProfile(models.Model):
> #user = models.ForeignKey(User,unique=True)
> #dealer = models.ForeignKey(FourS)
> #class Meta:
> #db_table = u'auth_userprofile'
>
> from django.contrib.auth.admin import UserAdmin
> import datetime
> class ProfileBase(type):
> def __new__(cls, name, bases, attrs):
> module = attrs.pop('__module__')
> parents = [b for b in bases if isinstance(b, ProfileBase)]
> if parents:
> fields = []
> for obj_name, obj in attrs.items():
> if isinstance(obj, models.Field): fields.append(obj_name)
>
> User.add_to_class(obj_name, obj)
> UserAdmin.fieldsets = list(UserAdmin.fieldsets)
> UserAdmin.fieldsets.append((name, {'fields': fields}))
> return super(ProfileBase, cls).__new__(cls, name, bases, attrs)
>
> class Profile(object):
> __metaclass__ = ProfileBase
>
> class MyProfile(Profile):
> dealer = models.ForeignKey(FourS)
> #dealer = models.IntegerField(null=True,
> blank=True,db_column='dealer_id')
>
> ERROR MESSAGE:
>
> ImproperlyConfigured at /admin/auth/user/1/
> 'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is
> missing from the form.Request Method: GET
> Request URL: http://192.168.0.116/admin/auth/user/1/
> Exception Type: ImproperlyConfigured
> Exception Value: 'UserAdmin.fieldsets[5][1]['fields']' refers to field
> 'dealer' that is missing from the form.
> Exception Location:
> /usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in
> check_formfield, line 254
> Python Executable: /usr/local/bin/python
> Python Version: 2.5.4
> Python Path: ['/pyweb', '/usr/local/lib/python2.5/site-packages/django',
> '/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg',
> '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
> '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5',
> '/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk',
> '/usr/local/lib/python2.5/lib-dynload',
> '/usr/local/lib/python2.5/site-packages']
>
>
> --
> 好玩贺卡等你发,邮箱贺卡全新上线! >
> 

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile in Admin interface (using trunk)

2008-06-23 Thread [EMAIL PROTECTED]

I am doing this in newforms-admin. As far as I cannot tell, you cannot
do this using the default root site, because the inline is diclared in
the parent model rather than the child model. The User creates and
registers with the default admin site on it's own, so you have to
declare your own AdminSite, subclass the
django.contrib.auth.admin.UserAdmin, and register Usey and your
subclassed object with your custom Adminsite object.

It works really well once I set it up.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-23 Thread Alessandro Ronchi
2008/6/23, Karen Tracey <[EMAIL PROTECTED]>:

> newforms-admin WILL be merged before Django 1.0, a recent discussion on the
> developer's list showed broad consensus that 1.0 without newforms-admin
> doesn't make any sense.
>
> I encourage anyone having this problem to try the newforms-admin branch and
> see if it solves the problem.  The branch is quite close to being ready for
> merge, and regularly updated with trunk changes.  Quite possibly the problem
> will just not exist over there, but if there is still an issue, you'll get
> more interest in fixing it on that codebase.

Testing in the new admin-newform branch is good before updating it on
1.0, but we're dealing with production applications, so a working
solution is necessary.
I'm happy because mine works with the modification of the core=True.
-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-23 Thread Karen Tracey
On Mon, Jun 23, 2008 at 6:40 AM, Deniz Dogan <[EMAIL PROTECTED]> wrote:

> From what I've heard it will be easier to do what we all seem to want
> in the newforms-admin branch, which should be merged by the time of
> the release of Django 1.0.
>

newforms-admin WILL be merged before Django 1.0, a recent discussion on the
developer's list showed broad consensus that 1.0 without newforms-admin
doesn't make any sense.

I encourage anyone having this problem to try the newforms-admin branch and
see if it solves the problem.  The branch is quite close to being ready for
merge, and regularly updated with trunk changes.  Quite possibly the problem
will just not exist over there, but if there is still an issue, you'll get
more interest in fixing it on that codebase.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-23 Thread Deniz Dogan

>From what I've heard it will be easier to do what we all seem to want
in the newforms-admin branch, which should be merged by the time of
the release of Django 1.0.

On Jun 21, 2:49 am, ristretto <[EMAIL PROTECTED]> wrote:
> You'd think, indeed.  I'm wondering if there's a work around or best
> practice way to handle it.  I noticed in the docs stating to wrap
> access to the user.get_profile() call around a try: except: and create
> it if you get an error.  But, I don't see how to do that simply in the
> Admin system.
>
> On Jun 21, 3:03 am, Deniz Dogan <[EMAIL PROTECTED]> wrote:
>
> > On 20 Juni, 05:26, <[EMAIL PROTECTED]> wrote:
>
> > > I have looked through the docs and search the group and web.  Seems 
> > > other's
> > > are asking the question, but I haven't seen an answer yet.
>
> > > class UserProfile(models.Model):
> > > country = models.ForeignKey(Country, core=True)
> > > user = models.ForeignKey(User, unique=True, 
> > > edit_inline=models.TABULAR,
> > > core=True)
>
> > > When Isavea User in theAdminpage, the country (from this UserProfile) is
> > > not getting saved.
>
> > > The list of Countries are shown in the menu, there are no errors, but the 
> > > DB
> > > table userprofile is empty, and when I come back to the Useradminpage, no
> > > country is selected.
>
> > > Seems that thesaveis getting dropped on the floor.
>
> > > I have
>
> > >   AUTH_PROFILE_MODULE = 'app.userprofile'
>
> > > set.  The system doesn't throw any errors.  Just doesn'tsave.
>
> > > I saw a post suggesting subclassing User and overriding saving tosavemy
> > >profile But, I can't find this recommended in the docs.  The documented way
> > > to  do this is has nothing to do with subclassing
>
> > > Please clarify.
>
> > I have the exact same problem. You'd think Django would have a neat
> > way of handling this, but it seems to me that it doesn't.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile in Admin interface (using trunk)

2008-06-22 Thread Alessandro Ronchi
2008/6/21, ristretto <[EMAIL PROTECTED]>:
>
>  Was there any solution to this?  I'm looking through the tickets,
>  wiki, docs, web, and now the source trying to figure out how to get my
>  profile data saved along with a User in the admin.  Anyone have that
>  working?   My situation is the same as this poster's, except I don't
>  get any error; I just get no profile record created.
>
>  If I create a new user, no profile record is created in the DB.
>
>  Incidentally, my profile model has one field which is a ForeignKey.
>
>  class UserProfile(models.Model):
> country = models.ForeignKey(Country, core=True)
> user = models.ForeignKey(User, unique=True,
>  edit_inline=models.TABULAR)

Do not use the foreignkey as core, but another field. This works:
- - - - -
user = models.ForeignKey(User, unique=True,
edit_inline=models.STACKED, num_in_admin=1,min_num_in_admin=1,
max_num_in_admin=1,num_extra_on_change=0)

nomeditta = models.CharField("Nome Ditta", max_length=100, core=True)
- - - - -
-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User Profile in Admin interface (using trunk)

2008-06-21 Thread Johan Liseborn

On Sat, Jun 21, 2008 at 02:46, ristretto <[EMAIL PROTECTED]> wrote:
>
> Was there any solution to this?  I'm looking through the tickets,
> wiki, docs, web, and now the source trying to figure out how to get my
> profile data saved along with a User in the admin.  Anyone have that
> working?   My situation is the same as this poster's, except I don't
> get any error; I just get no profile record created.

I never got any suggestions, so I moved to a different solution (using
my own form in "application space"); it was not optimal, but it worked
well enough for my particular case.

I am not yet that familiar with newforms-admin, but I assume it would
allow for solving things like this, right?

Anyway, it would be interesting to hear if there is some form of
solution for this even before newforms-admin. I cannot imagine that we
are the only two people that have stumbled upon the problem... :-)


Cheers,

johan

-- 
Johan Liseborn

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-21 Thread Alessandro Ronchi
2008/6/21 ristretto <[EMAIL PROTECTED]>:
>> > I have looked through the docs and search the group and web.  Seems other's
>> > are asking the question, but I haven't seen an answer yet.


I have the same problem, but with every edit_inline foreign key.

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-20 Thread ristretto

You'd think, indeed.  I'm wondering if there's a work around or best
practice way to handle it.  I noticed in the docs stating to wrap
access to the user.get_profile() call around a try: except: and create
it if you get an error.  But, I don't see how to do that simply in the
Admin system.



On Jun 21, 3:03 am, Deniz Dogan <[EMAIL PROTECTED]> wrote:
> On 20 Juni, 05:26, <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have looked through the docs and search the group and web.  Seems other's
> > are asking the question, but I haven't seen an answer yet.
>
> > class UserProfile(models.Model):
> >     country = models.ForeignKey(Country, core=True)
> >     user = models.ForeignKey(User, unique=True, edit_inline=models.TABULAR,
> > core=True)
>
> > When Isavea User in theAdminpage, the country (from this UserProfile) is
> > not getting saved.
>
> > The list of Countries are shown in the menu, there are no errors, but the DB
> > table userprofile is empty, and when I come back to the Useradminpage, no
> > country is selected.
>
> > Seems that thesaveis getting dropped on the floor.
>
> > I have
>
> >   AUTH_PROFILE_MODULE = 'app.userprofile'
>
> > set.  The system doesn't throw any errors.  Just doesn'tsave.
>
> > I saw a post suggesting subclassing User and overriding saving tosavemy
> >profile But, I can't find this recommended in the docs.  The documented way
> > to  do this is has nothing to do with subclassing
>
> > Please clarify.
>
> I have the exact same problem. You'd think Django would have a neat
> way of handling this, but it seems to me that it doesn't.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile is not getting saved in admin

2008-06-20 Thread Deniz Dogan

On 20 Juni, 05:26, "Gene Campbell" <[EMAIL PROTECTED]> wrote:
> I have looked through the docs and search the group and web.  Seems other's
> are asking the question, but I haven't seen an answer yet.
>
> class UserProfile(models.Model):
> country = models.ForeignKey(Country, core=True)
> user = models.ForeignKey(User, unique=True, edit_inline=models.TABULAR,
> core=True)
>
> When I save a User in the Admin page, the country (from this UserProfile) is
> not getting saved.
>
> The list of Countries are shown in the menu, there are no errors, but the DB
> table userprofile is empty, and when I come back to the User admin page, no
> country is selected.
>
> Seems that the save is getting dropped on the floor.
>
> I have
>
>   AUTH_PROFILE_MODULE = 'app.userprofile'
>
> set.  The system doesn't throw any errors.  Just doesn't save.
>
> I saw a post suggesting subclassing User and overriding saving to save my
> profile  But, I can't find this recommended in the docs.  The documented way
> to  do this is has nothing to do with subclassing
>
> Please clarify.

I have the exact same problem. You'd think Django would have a neat
way of handling this, but it seems to me that it doesn't.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

You are correct, it should be:
AUTH_PROFILE_MODULE=userprofile.userprofile

I think the current documentation on this particular issue, needs to
be updated more properly, since the way it is currently written does
not agree with what you have showed me.

Thank you so much!

Rgs!/Fco

On Mar 28, 2:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 4:06 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi Again,
>
> > I also get errors if I try to use the get_profile() funtion:
>
> > from django.contrib.auth.models import User
> >from txm.userprofile.models import UserProfile
> >user= User.objects.get(username__exact=username)
> >profile = user.get_profile()
>
> > Here is the traceback:
> >http://dpaste.com/41883/
>
> This one looks like your AUTH_PROFILE_MODULE hasn't be set properly in
> settings.py.  From your earlier note I see you have it as 'txm.userprofile'
> but you've got your models.py that defines the UserProfile model under
> userprofile, not txm, so I think perhaps AUTH_PROFILE_MODULE is supposed to
> be 'userprofile.userprofile' for the way you have things set up.
>
> Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 4:06 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi Again,
>
> I also get errors if I try to use the get_profile() funtion:
>
> from django.contrib.auth.models import User
>from txm.userprofile.models import UserProfile
>user= User.objects.get(username__exact=username)
>profile = user.get_profile()
>
> Here is the traceback:
> http://dpaste.com/41883/
>

This one looks like your AUTH_PROFILE_MODULE hasn't be set properly in
settings.py.  From your earlier note I see you have it as 'txm.userprofile'
but you've got your models.py that defines the UserProfile model under
userprofile, not txm, so I think perhaps AUTH_PROFILE_MODULE is supposed to
be 'userprofile.userprofile' for the way you have things set up.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

HI Karen,

OK, I will leave Meta as "pass", which is sufficient, for now and I
thank you for your time and effort helping me.

I will wait on the get_profile() issue, I am using 0.97-pre.

Rgs!/Fco

On Mar 28, 2:14 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> >  ordering = ['auth_user.first_name','auth_user.last_name']
>
> Giving a model a default ordering based on a foreign key is not
> currently possible in either 0.96 or trunk.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread James Bennett

On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>  ordering = ['auth_user.first_name','auth_user.last_name']

Giving a model a default ordering based on a foreign key is not
currently possible in either 0.96 or trunk.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Nop, the suggestion does not work, look at the trace:

Traceback debug:
http://dpaste.com/41887/

Rgs!/Fco

On Mar 28, 1:57 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 3:46 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi Karen,
>
> > Thanks for the pointer. I started looking as suggested, and found an
> > interesting link on the issue:
>
> >http://groups.google.com.mx/group/django-users/browse_thread/thread/b...
>
> > The above, makes me look into te details and understadn how vague my
> > question was. Still, I do not know how to do the following:
> > How can I configure my UserProfile metadata in order to order the data
> > in accordance to the User table fields (first_name, last_name), which
> > are pointed to by a ForeignKey in UserProfile (user).
>
> Does:
>
> ordering = ['auth_user.first_name','auth_user.last_name']
>
> not work?  auth_user is the table name for the User's table, I believe.
>
> Karen
>
>
>
> > Thank's/Fco
>
> > On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> > > [EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I have created a User profile, pointing to the User table, as per the
> > > > documentation; how can I access the User fields from the UserProfile
> > > > so I can place that in the metadata class?
>
> > > > userprofile.models.py
> > > >http://dpaste.com/41831/
>
> > > Your question is vague, so I'm not sure what you are asking.  If you've
> > got
> > > something that isn't working it helps people to help you if you tell
> > them
> > > what the symptoms are of its not working.  In this case looking at your
> > > model I'm guessing the ordering you are trying to specify isn't ordering
> > the
> > > way you expect or is throwing an error.  Ordering by related fields is,
> > I
> > > believe, a bit fragile in trunk (to be improved when queryset-refactor
> > is
> > > merged), but it might work for a simple relation.  I think it involves
> > > specifying the table name for the related field, but I don't recall the
> > > details.  You might try searching on "ForeignKey" and "ordering" on this
> > > list and you should find some pointers for how to do it.  If your
> > problem
> > > relates to something else please provide more details.
>
> > > Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Again,

I also get errors if I try to use the get_profile() funtion:

from django.contrib.auth.models import User
from txm.userprofile.models import UserProfile
user= User.objects.get(username__exact=username)
profile = user.get_profile()

Here is the traceback:
http://dpaste.com/41883/

Rgs!/Fco

On Mar 28, 1:46 pm, Francisco Benavides
<[EMAIL PROTECTED]> wrote:
> Hi Karen,
>
> Thanks for the pointer. I started looking as suggested, and found an
> interesting link on the 
> issue:http://groups.google.com.mx/group/django-users/browse_thread/thread/b...
>
> The above, makes me look into te details and understadn how vague my
> question was. Still, I do not know how to do the following:
> How can I configure my UserProfile metadata in order to order the data
> in accordance to the User table fields (first_name, last_name), which
> are pointed to by a ForeignKey in UserProfile (user).
>
> Thank's/Fco
>
> On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> > [EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I have created a User profile, pointing to the User table, as per the
> > > documentation; how can I access the User fields from the UserProfile
> > > so I can place that in the metadata class?
>
> > > userprofile.models.py
> > >http://dpaste.com/41831/
>
> > Your question is vague, so I'm not sure what you are asking.  If you've got
> > something that isn't working it helps people to help you if you tell them
> > what the symptoms are of its not working.  In this case looking at your
> > model I'm guessing the ordering you are trying to specify isn't ordering the
> > way you expect or is throwing an error.  Ordering by related fields is, I
> > believe, a bit fragile in trunk (to be improved when queryset-refactor is
> > merged), but it might work for a simple relation.  I think it involves
> > specifying the table name for the related field, but I don't recall the
> > details.  You might try searching on "ForeignKey" and "ordering" on this
> > list and you should find some pointers for how to do it.  If your problem
> > relates to something else please provide more details.
>
> > Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 3:46 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi Karen,
>
> Thanks for the pointer. I started looking as suggested, and found an
> interesting link on the issue:
>
> http://groups.google.com.mx/group/django-users/browse_thread/thread/bddbc4c71e8298ef/3d367268d297e89c?lnk=gst&q=%22ForeignKey%22+and+%22ordering%22#3d367268d297e89c
>
> The above, makes me look into te details and understadn how vague my
> question was. Still, I do not know how to do the following:
> How can I configure my UserProfile metadata in order to order the data
> in accordance to the User table fields (first_name, last_name), which
> are pointed to by a ForeignKey in UserProfile (user).
>

Does:

ordering = ['auth_user.first_name','auth_user.last_name']

not work?  auth_user is the table name for the User's table, I believe.

Karen


>
> Thank's/Fco
>
> On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
> >
> > [EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> >
> > > I have created a User profile, pointing to the User table, as per the
> > > documentation; how can I access the User fields from the UserProfile
> > > so I can place that in the metadata class?
> >
> > > userprofile.models.py
> > >http://dpaste.com/41831/
> >
> > Your question is vague, so I'm not sure what you are asking.  If you've
> got
> > something that isn't working it helps people to help you if you tell
> them
> > what the symptoms are of its not working.  In this case looking at your
> > model I'm guessing the ordering you are trying to specify isn't ordering
> the
> > way you expect or is throwing an error.  Ordering by related fields is,
> I
> > believe, a bit fragile in trunk (to be improved when queryset-refactor
> is
> > merged), but it might work for a simple relation.  I think it involves
> > specifying the table name for the related field, but I don't recall the
> > details.  You might try searching on "ForeignKey" and "ordering" on this
> > list and you should find some pointers for how to do it.  If your
> problem
> > relates to something else please provide more details.
> >
> > Karen
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Thanks for the pointer. I started looking as suggested, and found an
interesting link on the issue:
http://groups.google.com.mx/group/django-users/browse_thread/thread/bddbc4c71e8298ef/3d367268d297e89c?lnk=gst&q=%22ForeignKey%22+and+%22ordering%22#3d367268d297e89c

The above, makes me look into te details and understadn how vague my
question was. Still, I do not know how to do the following:
How can I configure my UserProfile metadata in order to order the data
in accordance to the User table fields (first_name, last_name), which
are pointed to by a ForeignKey in UserProfile (user).

Thank's/Fco

On Mar 28, 12:31 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have created a User profile, pointing to the User table, as per the
> > documentation; how can I access the User fields from the UserProfile
> > so I can place that in the metadata class?
>
> > userprofile.models.py
> >http://dpaste.com/41831/
>
> Your question is vague, so I'm not sure what you are asking.  If you've got
> something that isn't working it helps people to help you if you tell them
> what the symptoms are of its not working.  In this case looking at your
> model I'm guessing the ordering you are trying to specify isn't ordering the
> way you expect or is throwing an error.  Ordering by related fields is, I
> believe, a bit fragile in trunk (to be improved when queryset-refactor is
> merged), but it might work for a simple relation.  I think it involves
> specifying the table name for the related field, but I don't recall the
> details.  You might try searching on "ForeignKey" and "ordering" on this
> list and you should find some pointers for how to do it.  If your problem
> relates to something else please provide more details.
>
> Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile metadata problem

2008-03-28 Thread Karen Tracey
On Fri, Mar 28, 2008 at 12:42 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I have created a User profile, pointing to the User table, as per the
> documentation; how can I access the User fields from the UserProfile
> so I can place that in the metadata class?
>
> userprofile.models.py
> http://dpaste.com/41831/
>
>
Your question is vague, so I'm not sure what you are asking.  If you've got
something that isn't working it helps people to help you if you tell them
what the symptoms are of its not working.  In this case looking at your
model I'm guessing the ordering you are trying to specify isn't ordering the
way you expect or is throwing an error.  Ordering by related fields is, I
believe, a bit fragile in trunk (to be improved when queryset-refactor is
merged), but it might work for a simple relation.  I think it involves
specifying the table name for the related field, but I don't recall the
details.  You might try searching on "ForeignKey" and "ordering" on this
list and you should find some pointers for how to do it.  If your problem
relates to something else please provide more details.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile problem

2008-03-28 Thread Francisco Benavides

Hi Karen,

Thanks!

On Mar 27, 6:12 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Mar 27, 2008 at 6:45 PM, Francisco Benavides <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am in the process of adding more information to the user, managed
> > via django.contrib.auth.  I am getting an error in the admin
> > interface, when trying to add a profile to a given user. First time
> > the interface crashes, but the profile gets added, so the next time I
> > try to add the same profile, it naturally complains that it already
> > exists.
>
> > I have setup the AUTH_PROFILE_MODULE = 'txm.userprofile'
> > settings.py
> >http://dpaste.com/41684/
>
> > The profile is using user = models.ForeignKey(User, unique=True,
> > related_name='profile')
> > userprofile.model.py
> >http://dpaste.com/41685/
>
> > url.py
> >http://dpaste.com/41686/
>
> > The DEBUG data is in:
> >http://dpaste.com/41688/
>
> > Thx!/Fco
>
> Traceback shows the admin code is trying to log information about the new
> object created.  Ultimate error is in force_unicode and from the line above
> you can see force_unicode is being called on 'new_object', so that's
> probably an instance of your UserProfile model.  Checking its __unicode__
> method shows the problem:
>
> return '%i %s %s %s' % (self.user.first_name, self.user.last_name, self.
> materno, self.user.username)
>
> It's trying to format self.user.first_name (a string, I'd guess) as a %i
> (integer).  I think that %i should be %s.
>
> Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile problem

2008-03-27 Thread Karen Tracey
On Thu, Mar 27, 2008 at 6:45 PM, Francisco Benavides <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am in the process of adding more information to the user, managed
> via django.contrib.auth.  I am getting an error in the admin
> interface, when trying to add a profile to a given user. First time
> the interface crashes, but the profile gets added, so the next time I
> try to add the same profile, it naturally complains that it already
> exists.
>
> I have setup the AUTH_PROFILE_MODULE = 'txm.userprofile'
> settings.py
> http://dpaste.com/41684/
>
> The profile is using user = models.ForeignKey(User, unique=True,
> related_name='profile')
> userprofile.model.py
> http://dpaste.com/41685/
>
> url.py
> http://dpaste.com/41686/
>
> The DEBUG data is in:
> http://dpaste.com/41688/
>
> Thx!/Fco
>

Traceback shows the admin code is trying to log information about the new
object created.  Ultimate error is in force_unicode and from the line above
you can see force_unicode is being called on 'new_object', so that's
probably an instance of your UserProfile model.  Checking its __unicode__
method shows the problem:

return '%i %s %s %s' % (self.user.first_name, self.user.last_name, self.
materno, self.user.username)

It's trying to format self.user.first_name (a string, I'd guess) as a %i
(integer).  I think that %i should be %s.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile views - Does something like this make sense?

2007-06-18 Thread zenx

Thank you Gábor!

I will make "clear_old" a static method.

thanks!!!



On 18 jun, 15:27, Gábor Farkas <[EMAIL PROTECTED]> wrote:
> zenx wrote:
> > I want to show the user the latest users that have seen his profile.
> > So everytime a logged user views another user's profile a ProfieView
> > object is stored in the database (or the date is updated if the user
> > that is viewing the profile has already viewed it before). I know this
> > can make the database grow too much, so I think I can run a cron
> > script daily that deletes all profile views older than a week (see
> > clear_old method). I don't know if the code is 100% correct, but is
> > the concept ok? Does it make sense to add a new object to the database
> > everytime another user views a profile?
>
> > class ProfileViews(models.Model):
> > user = models.ForeignKey(User,related_name='latest_profile_views')
> > viewer = models.ForeignKey(User)
> > date = models.DateTimeField()
>
> > def clear_old(self):
> > d = datetime.now()-timedelta(weeks=1)
> > p = ProfileViews.objects.filter(date__lte=d)
> > p.delete()
>
> i think this approach makes sense.
>
> the only change i would recommend is to make "clear_old" into a static
> method.
>
> gabor


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile views - Does something like this make sense?

2007-06-18 Thread Gábor Farkas

zenx wrote:
> I want to show the user the latest users that have seen his profile.
> So everytime a logged user views another user's profile a ProfieView
> object is stored in the database (or the date is updated if the user
> that is viewing the profile has already viewed it before). I know this
> can make the database grow too much, so I think I can run a cron
> script daily that deletes all profile views older than a week (see
> clear_old method). I don't know if the code is 100% correct, but is
> the concept ok? Does it make sense to add a new object to the database
> everytime another user views a profile?
> 
> 
> class ProfileViews(models.Model):
> user = models.ForeignKey(User,related_name='latest_profile_views')
> viewer = models.ForeignKey(User)
> date = models.DateTimeField()
> 
> def clear_old(self):
> d = datetime.now()-timedelta(weeks=1)
> p = ProfileViews.objects.filter(date__lte=d)
> p.delete()
> 

i think this approach makes sense.

the only change i would recommend is to make "clear_old" into a static 
method.


gabor

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user profile.

2007-03-31 Thread James Bennett

On 3/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Why do I need this? I want the user profile and user account to be
> created by user on the same page. Any solutions how can I do it?

Display a single form with all the fields, and have your view create
both objects.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile and sliding date range data model?

2007-03-30 Thread Rob Hudson

James Bennett wrote:
> On 3/29/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>> I can't think of a way to account for "up to last 3 years" and "up to
>> the next 5 years" or variation thereof.
> 
> paid_up_until = models.DateField()
> 
> Then use Python's standard 'datetime.timedelta' to handle offets;
> e.g., if a member pays up for the next three years:
> 
> p = user.get_profile()
> p.paid_up_until += datetime.timedelta(days=3*365)
> p.save()

That's a good idea.  I'm thinking that once I implement that some user 
is going to have a gap in their dues... like maybe they paid in 05, 
skipped 06, and paid 07.  I think the club officers want to track that.

I had a thought that maybe this could just be tied to another table 
called paid_dues, with a user_id and years paid for.

But if Members has a FK to Users, would my Dues model be tied to Users 
or tied to Members?  I'll have to play with that and see how it renders 
out in the admin.

Thanks for the ideas.

-Rob

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile and sliding date range data model?

2007-03-30 Thread David Reynolds


On 30 Mar 2007, at 9:21 am, David Reynolds wrote:

>
> One of the things that annoys me about datetime is that it doesn't
> handle leap years properly. However, if you use python-dateutil[1] it
> has a relativedelta so you can do things like:
>
 datetime.date.today()+relativedelta(years=+3)
> datetime.date(2010, 3, 30)
>
> .. which will take into account leap years too.
>

Woops, forgot to say:

[1] http://labix.org/python-dateutil

-- 
David Reynolds
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile and sliding date range data model?

2007-03-30 Thread David Reynolds


On 30 Mar 2007, at 2:32 am, James Bennett wrote:

>
> On 3/29/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
>> I can't think of a way to account for "up to last 3 years" and "up to
>> the next 5 years" or variation thereof.
>
> paid_up_until = models.DateField()
>
> Then use Python's standard 'datetime.timedelta' to handle offets;
> e.g., if a member pays up for the next three years:
>
> p = user.get_profile()
> p.paid_up_until += datetime.timedelta(days=3*365)
> p.save()

One of the things that annoys me about datetime is that it doesn't  
handle leap years properly. However, if you use python-dateutil[1] it  
has a relativedelta so you can do things like:

 >>> datetime.date.today()+relativedelta(years=+3)
datetime.date(2010, 3, 30)

.. which will take into account leap years too.

-- 
David Reynolds
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: User profile and sliding date range data model?

2007-03-29 Thread James Bennett

On 3/29/07, Rob Hudson <[EMAIL PROTECTED]> wrote:
> I can't think of a way to account for "up to last 3 years" and "up to
> the next 5 years" or variation thereof.

paid_up_until = models.DateField()

Then use Python's standard 'datetime.timedelta' to handle offets;
e.g., if a member pays up for the next three years:

p = user.get_profile()
p.paid_up_until += datetime.timedelta(days=3*365)
p.save()

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---