On 5/29/07, Vincent Nijs <[EMAIL PROTECTED]> wrote: > > Russell, > > I think I am starting to get the basic idea of 'extends' for templates. > However, I don't get what I need to do to get my basic example (or your > example for that matter) to generate the page I want to see in my browser. > It doesn't just work the way php would here so I am guessing I need to add a > 'view' or do something with 'urls.py' or both but I can't figure out what > that would be since I am not processing anything or sending any information > to the page.
You're correct that the process is different to PHP. The Django process goes something like this: 1) You set up base.html as a page template for your entire site 2) You set up home.html, extending base.html, describing your home page content 3) You set up a view in views.py that renders home.html. 4) You set up an entry in urls.py that directs the URL '/home/' to the home view. All of the processing (calculations, database access, etc) that would normally happen on a PHP page happens in the view. The view produces a context that contains the result of that processing, and the template exposes pieces of the context. However, if you're not doing any processing, your view could be as simple as: from django.shortcuts import render_to_response def home_view(request): return render_to_response('home.html') When someone requests a URL that has been redirected to this view, Django responds by rendering your template, and returns the resulting HTML to be displayed in the client browser. This process is covered in the third tutorial: http://www.djangoproject.com/documentation/tutorial03/ Note that for simple cases, you may be able to use a generic view. These are views that cover simple use cases (just render a template, render a template for a single database object, render a template for a list of database objects, etc). Generic views are covered in the fourth tutorial. http://www.djangoproject.com/documentation/tutorial04/ Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---