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