That is exactly what I want to do, I can't seem to understand exactly how to implement that and have it populate in the template. Do I just define the variable in the views and then in the template use {{ variable_name }} where I need it? Because I tried that first and it didn't work. So, maybe I'm just not sure what it is I'm doing exactly ;)
Thanks for any help! On Oct 10, 1:09 pm, Brett Epps <brett.e...@quest.com> wrote: > I may be misunderstanding your question, but it sounds like you need to > use Page.objects.get or Page.objects.filter (in your view function) to > look up the particular objects that you want to send to the template. > > Brett > > On 10/10/11 9:53 AM, "xenses" <code...@gmail.com> wrote: > > > > > > > > >This may seem like a very simple question and I have just missed the > >answer in the piles of documentation and tutorials that I've read over > >the past two days. I'm new to Django and trying to implement an > >internal site at work, and I'm the only Python/Django person we have, > >so this is all on me. > > >What I am doing is this: I have a set of .html files, templates, which > >are named testn.html (i.e. test1.html, test2.html, etc) Each template > >extends base.html, but they each have at least 2 divs that I need to > >populate with HTML that is entered in the admin interface and stored > >in the Page model. What I need to do is this: > > >from the url parse what test is being requested: > > >url(r'^test(\d{1})/$', test), > > >cal the test view: > > >def test(request, testn): > > try: > > testn = str(testn) > > return direct_to_template(request, template="test%s.html" % > >testn) > > except ValueError: > > raise Http404() > > >And then return the template, but with the correct object attached to > >it, filtered by name. I can't find a way to do this, all that I can > >find are ways that make me grab all the objects (and where do I do > >this? In models.py or views.py? There are conflicting thoughts on > >this). I really just need to grab the one object, and if it has the > >fields I need, to populate the template with them. Is there an easy > >way to do this that won't require me to loop over all objects? > > >Thank you so much for any help or insight! > >--Laura C. > > >-- > >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.