Hi, first of all, your url patterns should look more like this: url(r'^main$','sample2_app.views.main', name="main"),
*remove trailing slash *remove file extension *add a name to this url in the template, instead of trying to access your views directly like "main.html", try using the url template tag - {% url main %}. You case should work, if you add a trailing slash to your (<a href="main.html/" ></a>), but it is not a good practice. P.S. Read the documentation, everything is there. You should start with the basic POLL app in the tutorials, to see how django works. Regards, On Wed, Nov 9, 2011 at 2:53 PM, vladik_KBR <vladik....@gmail.com> wrote: > Hi, I've only started to study the Python and web-programming as well. > I need to code a simple web-application with several pages to switch > between, but I don't know a proper way to redirect. How it could be > done using the Django? > Here is my code, wich doesn't work proper > > views.py > > from django.template.loader import get_template > from django.template import Context > from django.http import HttpResponse > > def main(request): > t = get_template('main.html') > html = t.render(Context()) > return HttpResponse(html) > > def gallery(request): > t = get_template('gallery.html') > html = t.render(Context()) > return HttpResponse(html) > > def about(request): > t = get_template('about.html') > html = t.render(Context()) > return HttpResponse(html) > > > > urls.py > > from django.conf.urls.defaults import patterns, include, url > from sample2_app.views import * > > urlpatterns = patterns('', > url(r'^main.html/$','sample2_app.views.main'), > url(r'^gallery.html/$','sample2_app.views.gallery'), > url(r'^about.html/$','sample2_app.views.about'), > ) > > > > Each html page contain this > > <ul id="menu-nav"> > <li class="nav-item"><a href="main.html">Main</a></li> > <li class="nav-item"><a href="gallery.html">Gallery</a></ > li> > <li class="nav-item"><a href="about.html">About</a></li> > </ul> > > > Thank you. > > -- > 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.