开发者

django registration urls

I am quite new to Django (have a background in python), and I am trying to build a simple webpage (normal stuff: registration, shopping cart, payments etc).

To this end, I am using the django-registration package and I have followed the instructions on: http://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/

I have to say, I quite like it, and got it to work: and the registration pages loo开发者_如何学Gok like admin panels. Now, I would like do some customization and I started off by including my own base.html. In the django-registration, I have some default templates, and the login temlates look like:

{% extends "base.html" %}
{% load i18n %}

{% block content %}
<form method="post" action=".">
{{ form.as_p }}

<input type="submit" value="{% trans 'Log in' %}" />
<input type="hidden" name="next" value="{{ next }}" />
</form>

<p>{% trans "Forgot password" %}? <a href="{% url auth_password_reset %}">{% trans   "Reset your account" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url registration_register %}">{% trans  "Register Now" %}</a>!</p>
{% endblock %}

First, when I changed the I base.html to my own path, the page does not seem to render properly (although I see the text content, but the graphics are all missing), and I have noticed that all the links have gone a level down. For example, my Homepage ref has gone down to mysite.com/accounts/login/Homepage rather then my orginal mysite.com/Homepage.

As I unserstand, my url mappings do not seem right, but I cannot seem to find the url conf links. My current url conf looks like:

urlpatterns = patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
(r'^$', index),
(r'^Homepage$', index),
(r'^AboutUs$', AboutUs),
(r'^ContactUs$', ContactUs),
(r'^admin/(.*)', admin.site.root),
(r'^accounts/', include('registration.urls')),
(r'^$', direct_to_template,
        { 'template': 'index.html' }, 'index'),

Where do I find the registration url confs such as /accounts/login etc and the corresponding mapings?

Sorry if this is 101 django question!


Django registration supports pluggable backends, where the URLConf is provided by the backend module. You can take a look at the default backend urls on bitbucket.

The django-registration docs provide a pretty decent overview of how to set up your own templates. Basically, you want to create your own versions of each of the templates listed on that page. Django-registration does not provide any starter templates, but the docs are pretty clear about which context variables are available to each template.

Your URLConf looks OK, except that you don't want to have Django serving your media files. Assuming you're using Django 1.3, have a look at the staticfiles page in the docs. Basically, you use {{ STATIC_URL }} in your templates, get rid of the media/ URLConf entry, and things should Just Work on the development server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜