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-template-inheritance-and-context/3731459#3731459

You can try step #3 once you feel confident enough to write views (they are
very simple!)


Cheers,
André Terra (airstrike)

On Mon, Jul 11, 2011 at 5:12 PM, Brent <brentba...@gmail.com> wrote:

> Sorry, I meant I was hoping to avoid diving into defining my own views
> until later.
>
> On Jul 11, 1:08 pm, Brent <brentba...@gmail.com> 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 python/html code.
> >
> > On Jul 11, 11:48 am, Andre Terra <andrete...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > This is done in your view:
> >
> > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-.
> ..
> >
> > > Cheers
> >
> > > On Mon, Jul 11, 2011 at 3:12 PM, Brent <brentba...@gmail.com> wrote:
> > > > Is this done in urls.py?
> >
> > > > On Jul 11, 10:55 am, Andre Terra <andrete...@gmail.com> 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 <brentba...@gmail.com>
> wrote:
> > > > > > 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, Andre Terra <andrete...@gmail.com> wrote:
> > > > > > > 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=instance)
> >
> > > > > > > signals.post_save.connect(create_user_profile, sender=User)
> >
> > > > > > > (assuming your profile model is called UserProfile, of course).
> >
> > > > > > > When django loads models.py, it will call that connect() method
> which
> > > > in
> > > > > > > turn makes create_user_profile get called every time the sender
> model
> > > > > > (User)
> > > > > > > is saved (hence the 'post_save').
> >
> > > > > > > More on this athttps://
> docs.djangoproject.com/en/dev/ref/signals/
> >
> > > > > > > Cheers,
> > > > > > > André Terra
> >
> > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent <brentba...@gmail.com>
> wrote:
> > > > > > > > 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
> > > > > > > > I am using the User model included in django.contrib, and I
> am very
> > > > > > > > hesitant to edit files that are not in my project directory.
> >
> > > > > > > > Is this bad design to be using a mix of things I've written
> on my
> > > > own,
> > > > > > > > and things that were already included in Django? (i.e. should
> I
> > > > write
> > > > > > > > everything from scratch?)
> >
> > > > > > > > Thanks.
> >
> > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz <mic...@sawicz.net> wrote:
> > > > > > > > > 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.
> > > > ..
> >
> > > > > > > > > --
> > > > > > > > > Micha³ (Saviq) Sawicz <mic...@sawicz.net>
> >
> > > > > > > > >  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-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.
> >
> > > > > > --
> > > > > > 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.
> >
> > > > --
> > > > 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.
>
> --
> 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.
>
>

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

Reply via email to