Wednesday, February 2, 2011

Django Project - handling call to the "root" url?

I need to handle a call to the root url for a site more elegantly than my current.

At the moment I have:

#urls.py
    (r'^$', 'myproj.myapp.views.root'),
    #and
    (r'^admin/', include(admin.site.urls)),

#views.py
def root(request):
    """Handle a call to the / (root) URL address"""
    return redirect('/admin/')

This works, but the extra "admin/" that has been added sticks out like a sore thumb on address bar the main page (which doubles as the login page).

However, when I alter the root() function to:

def root(request):
    return render_to_response('admin/login.html', None)
    
This causes a loop condition i.e. displays the page OK, but trying to login just redisplays the page... any ideas how to make this work as intended?

Thanks
Derek

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment