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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
15 matches
Mail list logo