Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Hmm...I see. How do you choose what variables are available to which view? It seems like anything I put in context_processors is available anywhere, and I'm not sure I want that. I think I am getting closer, but I am now getting a SiteProfileNotAvailable error. Here is my stack trace: http://dpa

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
You could use a context processor, which is basically a function that adds variables to *every* template that gets called from a properly setup view. I assume the view you are using does apply context processors, and defining one is as easy as: http://stackoverflow.com/questions/3722174/django-tem

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Sorry, I meant I was hoping to avoid diving into defining my own views until later. On Jul 11, 1:08 pm, Brent wrote: > So I need to create a custom view? (I can't use an existing view)? I > was hoping to avoid diving into templates until later, after I've > become a little more familiar with the

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
So I need to create a custom view? (I can't use an existing view)? I was hoping to avoid diving into templates until later, after I've become a little more familiar with the python/html code. On Jul 11, 11:48 am, Andre Terra wrote: > This is done in your view: > > https://docs.djangoproject.com/e

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
This is done in your view: https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext Cheers On Mon, Jul 11, 2011 at 3:12 PM, Brent wrote: > Is this done in urls.py? > > On Jul 11, 10:55 am, Andre Terra wrote: > > Pass user.get_profile() as a template variabl

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Is this done in urls.py? On Jul 11, 10:55 am, Andre Terra wrote: > Pass user.get_profile() as a template variable instead by adding it to the > template context. > > Cheers, > André > > > > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent wrote: > > Okay, thanks. This is really helpful. > > > I am

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Okay, thanks. This is really helpful. I am having trouble calling get_profile() from within my profile.html template, though. Here is my stack trace: http://dpaste.com/566583/ I tried calling get_profile without the (), which got rid of the error, but no data showed up. On Jul 11, 10:15 am, And

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Pass user.get_profile() as a template variable instead by adding it to the template context. Cheers, André On Mon, Jul 11, 2011 at 2:50 PM, Brent wrote: > Okay, thanks. This is really helpful. > > I am having trouble calling get_profile() from within my profile.html > template, though. Here is

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
All you have to do is add the following code to your models.py (or any other module that gets loaded by django, for that matter): # models.py from django.db.models import signals def create_user_profile(sender, instance, created, **kwargs): if created: UserProfile.objects.create(user

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
I am having trouble with this line of the tutorial: "You need to register a handler for the signal django.db.models.signals.post_save on the User model, and, in the handler, if created=True, create the associated user profile." It seems I need to edit the User model. I am confused, though, because

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Wherever you would reference a user instance, reference UserProfile.user instead If you need to find out a profile from request.user, you can use request.user.get_profile() or the longer UserProfile.objects.get(user_id= request.user.id) Cheers, André On Mon, Jul 11, 2011 at 1:48 PM, Brent wrot

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Michał Sawicz
Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > How do I use a foreign key, though? In other words, how do I tell my > code to look at UserProfile rather than just user? https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users -- Michał (Saviq) S

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Thanks for the responses. How do I use a foreign key, though? In other words, how do I tell my code to look at UserProfile rather than just user? On Jul 10, 5:08 am, Jonas Geiregat wrote: > Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven: > > > > > This is not good design. I

Re: Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Jonas Geiregat
Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven: > > This is not good design. If you want to store some extra fields for a User - > i would define just another model called ProfileDetails, FK it to User and > use it as such. That's also how I would do it, some example cod

Re: Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Venkatraman S
On Sun, Jul 10, 2011 at 1:05 PM, Brent wrote: > Hi all, > > I am attempting to follow this tutorial: > > http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/ > > But I am receiving this error: > AttributeError at /login/ > 'NoneType' object has no attribute 'D

Re: extending User

2010-09-03 Thread djnubbio
takn again On 3 Set, 18:40, Shawn Milochik wrote: > Yes, the password stored will only ever be the hash type, hash salt, > and hash. You should never store it in plain text. > > If you're interested you can look at the actual model. You might be > interested in these functions: set_password(), ge

Re: extending User

2010-09-03 Thread Shawn Milochik
Yes, the password stored will only ever be the hash type, hash salt, and hash. You should never store it in plain text. If you're interested you can look at the actual model. You might be interested in these functions: set_password(), get_hexdigest(), and check_password(). These make it clear what

Re: extending User

2010-09-03 Thread djnubbio
a, ok tank you. Your post clarify me much woolly things in my mind. So I understand that password field will not be treated in standard manner, and it needs to be managed very carefully. Its purpose is only to store the final encrypted password, isn't it? On 3 Set, 17:14, Shawn Milochik wrote

Re: extending User

2010-09-03 Thread Shawn Milochik
You should exclude the password field in your overridden model form. If you want to have a password added at the time of user registration then you can add an additional charfield to the form (make sure to use the "password" widget). You should probably add two such fields so you can compare them t

Re: extending User

2010-09-03 Thread djnubbio
here they are: import string # Django settings for djapps project. #... modifica ng ROOT_URLCONF = 'djapps.urls' import os PROJECT_DIR = os.path.dirname(globals()["__file__"]) #...

Re: extending User

2010-09-03 Thread Federico Maggi
On 03/set/2010, at 12:54, djnubbio wrote: > How can I handle it? which function have i to attach to that url? Could you tell us your urls and settings, and in particular the INSTALLED_APPS variable? -- You received this message because you are subscribed to the Google Groups "Django user

Re: Extending User model

2009-01-27 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 21:44 +0100, Alex Rades wrote: [...] > my situation is: It's a site for students and companies, where > students can post their data and search for internships, and companies > post their data, internship opportunities, and search for students. > > So, students have to fill

Re: Extending User model

2009-01-27 Thread Alex Rades
On Tue, Jan 27, 2009 at 5:12 AM, Malcolm Tredinnick wrote: > > On Tue, 2009-01-27 at 00:11 +0100, Alex Rades wrote: >> Hi, >> I need to have two sets of users in my application: One is the Person >> and the other is the Company. So, I have to decide between going with >> the userprofile way or in

Re: Extending User with a profile

2009-01-27 Thread Oleg Oltar
Os my bug. It was a mistype in a model. Exception gone now On Tue, Jan 27, 2009 at 8:43 PM, Oleg Oltar wrote: > Hi! > I want to add a profile to every user, that I can register in my > application. In future it should contain such fields as avatar, email, > about_me fields > > I found a snip

Re: Extending User model

2009-01-26 Thread Malcolm Tredinnick
On Tue, 2009-01-27 at 00:11 +0100, Alex Rades wrote: > Hi, > I need to have two sets of users in my application: One is the Person > and the other is the Company. So, I have to decide between going with > the userprofile way or inheriting from User. > > The problem with userprofile is that i can

Re: Extending User Model with obligatory fields

2008-09-07 Thread [EMAIL PROTECTED]
Step 1: Write something like this in the appropriate app's models.py class CustomUser(User): client=models.ForeignKey('Client') Step 2: Either create your own ModelAdmin that extends django.contrib.auth.admin.UserAdmin or just use UserAdmin outright. Step 3: Create a middleware that runs a

Re: Extending User model with model inheritance?

2008-06-13 Thread James Bennett
On Fri, Jun 13, 2008 at 10:54 PM, meppum <[EMAIL PROTECTED]> wrote: > With the query refactoring branch being merged to the trunk I wanted > to finally move some of the data I had put on my user profiles to a > derrived user model. I didn't see this mentioned in the documentation > and I wanted to

Re: Extending User

2008-06-03 Thread Alessandro Ronchi
Alessandro Ronchi ha scritto: > > > On 2 Giu, 00:33, puff <[EMAIL PROTECTED]> wrote: > >> I'm stumped. What am I missing? The edit_inline doesn't work. Anyone managed to make it? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net - Il mio blog http://www.soasi.com - Svil

Re: Extending User

2008-06-03 Thread Alessandro Ronchi
On 2 Giu, 00:33, puff <[EMAIL PROTECTED]> wrote: > I'm stumped. What am I missing? > > Thanks for any help. I've the same problem. If I manage to have the profile saved and I then edit the User, it reset the profile one time every two. Please help us! --~--~-~--~~~--

Re: extending user model, a different approach

2007-07-26 Thread Amit Upadhyay
On 7/26/07, James Bennett <[EMAIL PROTECTED]> wrote: > > On 7/25/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > > I realized a new way to extend user models, it is simpler than official > > get_profile approach of django[1] as there is only one model to work > with, > > and relationships are kept o

Re: extending user model, a different approach

2007-07-25 Thread James Bennett
On 7/25/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > I realized a new way to extend user models, it is simpler than official > get_profile approach of django[1] as there is only one model to work with, > and relationships are kept on the right model, and gives a less hacky feel > than "replaces_

Re: extending user model, but keep getting type error for user.id

2007-01-12 Thread hotani
One more thing: If I do what it says, and send it the user in the form of a class, it will continue, but after running "newprofile.save()", nothing is written to the db table. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: Extending User

2006-12-09 Thread [EMAIL PROTECTED]
Sorry. Can't believe I forgot to mention that part! The error was that theid could not be found in the database. Which made no sense to me since I was trying to create a new user. I was able to do this, however, after much experimentation: new_user = user_profile.objects.create(user_id=the_user

Re: Re: Extending User

2006-12-09 Thread James Bennett
On 12/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > new_profile = user_profile(user=some_user) > > but it gives me an error. What error? Without seeing the exact error message, it's hard to debug ;) -- "May the forces of evil become confused on the way to your house." -- George Carlin

Re: Extending User

2006-12-09 Thread [EMAIL PROTECTED]
I am having this exact issue. How does one instantiate a userprofile object? I've tried something like new_profile = user_profile(user=some_user) but it gives me an error. I'm really not sure what to do, I follow the guide linked above but now I'm stuck. Thanks in advance. -Dougal On Dec 2,

Re: Extending User

2006-12-02 Thread scum
> 1. You have to explicitly instantiate and save a UserProfile object > before get_profile() will do anything -- Django will not implicitly > create objects for you in the shell like that. > This is what I need to know. Thanks James. --~--~-~--~~~---~--~~ You

Re: Extending User

2006-12-01 Thread James Bennett
On 12/1/06, scum <[EMAIL PROTECTED]> wrote: > >>> a = User() > >>> a.save() > >>> a.get_profile() > Traceback (most recent call last): > ... > DoesNotExist: UserProfile matching query does not exist. Well, two things are going wrong here. 1. You have to explicitly instantiate and save a UserProf

Re: Extending User

2006-12-01 Thread Jay Parlar
On 12/1/06, scum <[EMAIL PROTECTED]> wrote: > > Trying to extend the user group using this model code: > > class UserProfile(models.Model): > user = models.ForeignKey(User, unique=True, > edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1, > max_num_in_admin=1,num_extra_on_chang

Re: Re: Re: Re: Extending user model in 0.95?

2006-08-25 Thread James Bennett
On 8/25/06, Jakub Labath <[EMAIL PROTECTED]> wrote: > Internal dispatcher sounds good :-). Only thing that worries my is the > word internal. Is this something that is likely to stay or will this > be gone when the next version comes along. The decision I'll make will > likely have long lasting im

Re: Re: Re: Extending user model in 0.95?

2006-08-25 Thread Jakub Labath
Hi All, On 8/25/06, James Bennett <[EMAIL PROTECTED]> wrote: > > Check out Django's internal dispatcher; whenever an instance of a > model is saved, the dispatcher signals 'pre_save' and 'post_save' are > fired before and after the save, respectively, with information about > the class of model w

Re: Re: Re: Extending user model in 0.95?

2006-08-25 Thread James Bennett
On 8/24/06, Jakub Labath <[EMAIL PROTECTED]> wrote: > I think I'm with the 20% just the extra fields is not enough in my case. > I will need the ability to call my functions before and/or after the > User object is saved in django user admin. For example > somebody changes user's email in admin I

Re: Re: Extending user model in 0.95?

2006-08-25 Thread Joe Rose
I hate how hackish it is, actually.  Unfortunately for me, I need it to work, and work now, so ...On 8/24/06, Jakub Labath < [EMAIL PROTECTED]> wrote:I guess the Foreign Key solution suggested by Joe would actually work here. Since the inline objects are getting saved with parents and Ican just ove

Re: Re: Re: Extending user model in 0.95?

2006-08-24 Thread Vance Dubberly
Wow you're even in worse shape than I am. :) I Foreign Keyed my user profiles ( it's very hackish, PHP 3 hackish ) and had expected to need to write my own app to manage them whether I could subclass User or not. Asking the Admin Tool to acknowledge an extended user object is really being unreason

Re: Re: Extending user model in 0.95?

2006-08-24 Thread Jakub Labath
Hi, > On 8/9/06, Vance Dubberly <[EMAIL PROTECTED]> wrote: > > I very much want to subclass User as I have more than one kind of user > > and each has a different type of profile. > > Which is a different situation from probably 80% of the needs people > have for extending the User model. I thin

Re: Re: Extending user model in 0.95?

2006-08-09 Thread James Bennett
On 8/9/06, Vance Dubberly <[EMAIL PROTECTED]> wrote: > I very much want to subclass User as I have more than one kind of user > and each has a different type of profile. Which is a different situation from probably 80% of the needs people have for extending the User model. > Until we get proper

Re: Extending user model in 0.95?

2006-08-09 Thread James Bennett
On 8/9/06, Chris Kelly <[EMAIL PROTECTED]> wrote: > If I am understanding correctly now, does this mean I have to manage the > creation of the user profile object (and also any other classes tied to a > user) when I create the user? Yes; OneToOne requires that an object exist on both ends of the

Re: Re: Extending user model in 0.95?

2006-08-09 Thread Vance Dubberly
I could not disagree with this more. I very much want to subclass User as I have more than one kind of user and each has a different type of profile. You have the option of changing the user model. Copy it to your local app and change it. Until we get proper inheritence ( a huge flaw in django

Re: Extending user model in 0.95?

2006-08-09 Thread Chris Kelly
Rockin. thanks for the heads up. it does look like the profile approach is the way to go. I first thought of subclassing as an approach coming from a C++ish background, where one can drop a subclass in place of a parent class to replace/ add functionality. It appears that the user class is a little

Re: Extending user model in 0.95?

2006-08-09 Thread James Bennett
On 8/9/06, Chris Kelly <[EMAIL PROTECTED]> wrote: > and it appears that using a one-to-one mapping (the > article's preferred method) is discouraged. I'm launching a campaign to have that line purged from the official documentation, with extreme prejudice. OneToOneField isn't going away and, AFAI

Re: Extending user model in 0.95?

2006-08-09 Thread Waylan Limberg
You can find the current status and well as a nice summary of the proposal for model inheritance here[1]. However, I believe this it not yet complete and perhaps not even usable yet (You'll have to check the latest threads linked from the wiki page for that). [1] http://code.djangoproject.com/wik

Re: Extending user model in 0.95?

2006-08-09 Thread James Bennett
On 8/9/06, Joe <[EMAIL PROTECTED]> wrote: > I know this is a bit "hackish", but it will work until model > inheritance is straightened out. What people actually want is not "a subclass of User that has extra fields"; what people actually want is "User with extra fields". There's a big important d

Re: Extending user model in 0.95?

2006-08-09 Thread Joe
Use a user profile. Define a model similar to the following: [code] from django.db import models from django.contrib.auth.models import User class Profile(models.Model): #add extra fields you want here user =models.ForeignKey(User ,unique=True,edit_inline=models.S

Re: Extending User model after magic-removal

2006-06-11 Thread Marcin Kaszynski
Luke Plant <[EMAIL PROTECTED]> writes: > This is actually quite interesting. You would need to alter your > patch a bit so that it works for models with 'app_label' defined -- > the "model_module.__name__.split('.')[-2]" logic should exist in > only one place. Good point. Another problem I ran

Re: Extending User model after magic-removal

2006-06-10 Thread Luke Plant
On Friday 09 June 2006 18:02, Marcin Kaszynski wrote: > I just spent some time looking for a way to extend the User model in > a way that would allow me to: > > 1. add fields to the model itself, > 2. use the standard admin interface to edit them, > 3. keep changes to Django minimal and generic.

Re: Extending User

2006-01-30 Thread Roberto Aguilar
I've done this with the latter approach. I made a person model that had more person-specific information and made the user field a foreign key and added the edit_inline option to have the information right there in the user interface: user = meta.ForeignKey(auth.User, edit_inline=meta.STACKED, n

Re: Extending User

2006-01-30 Thread char
That did it. Thanks.

Re: Extending User

2006-01-30 Thread Max Battcher
char wrote: I've seen a couple of approaches on this mailing list for adding application specific fields to the User class. The first involves extending auth.User but this seems a little complex, and was specifically labeled an "advanced" method. It doesn't seem like you should have to break out