Thanks a lotttt :)
but there is a new error
The Error:
Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF token missing or incorrect.
In general, this can occur when there is a genuine Cross Site Request
Forgery, or when Django's CSRF
mechanism<http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ref-contrib-csrf>has
not been used correctly. For POST forms, you need to ensure:
- The view function uses
RequestContext<http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext>for
the template, instead of
Context.
- In the template, there is a {% csrf_token %} template tag inside each
POST form that targets an internal URL.
- If you are not using CsrfViewMiddleware, then you must use
csrf_protecton any views that use the
csrf_token template tag, as well as those that accept the POST data.
You're seeing the help section of this page because you have DEBUG = True in
your Django settings file. Change that to False, and only the initial error
message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.
On Wed, Sep 29, 2010 at 10:39 AM, Yo-Yo Ma <[email protected]> wrote:
> (r'^login/', include('macrohms.views.login')), is incorrect.
>
> the include() function, pertaining to urls.py is for including other
> URL confs (so you can have sub-sections of your site contain their own
> urls.py). You'll want to replace that line with:
>
> url(r'^login/$', 'macrohms.views.login')),
>
> Note, I changed two additional things - I changed your tuple to a
> url() function call instead, and I added a $ at the end of the URL
> pattern (denotes the end of a string in regex). The url() function is
> the "cool" way to define URLs.
>
> On Sep 28, 10:41 pm, Saad Sharif <[email protected]> wrote:
> > Hi all,
> >
> > I created a simple login form
> >
> > My code:
> > <form method="post" action="/login/" ENCTYPE="multipart/form-data"
> > dojoType="dijit.form.Form" >{% csrf_token %}
> > username <input>
> > password <input type="password">
> > <button> login <input type="submit" value="Submit">
> > </form>
> >
> > In views.py i added
> >
> > def login(request):
> > return render_to_response('login.html')
> >
> > In urls.py i added
> >
> > (r'^login/', include('macrohms.views.login')),
> >
> > The Error when i press login button:
> > ImportError at /login/
> >
> > No module named login
> >
> > Request Method: POST Request URL:http://localhost:8000/login/ Django
> > Version: 1.2.3 Exception Type: ImportError Exception Value:
> >
> > No module named login
> >
> > Exception Location:
> >
> /home/saad/www/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg/django/utils/importlib.py
> > in import_module, line 35 Python Executable: /home/saad/www/bin/python
> Python
> > Version: 2.6.5 Python Path: ['/home/saad/www/webapps/macrohms',
> > '/home/saad/www/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
> > '/home/saad/www/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg',
> > '/home/saad/www/lib/python2.6/site-packages/Django-1.2.3-py2.6.egg',
> > '/home/saad/www/lib/python2.6/site-packages/Coffin-0.3.3-py2.6.egg',
> > '/home/saad/www/lib/python2.6/site-packages/Jinja2-2.5.2-py2.6.egg',
> > '/home/saad/www/lib/python2.6/site-packages/WTForms-0.6.1-py2.6.egg',
> > '/home/saad/www/lib/python2.6',
> '/home/saad/www/lib/python2.6/plat-linux2',
> > '/home/saad/www/lib/python2.6/lib-tk',
> > '/home/saad/www/lib/python2.6/lib-old',
> > '/home/saad/www/lib/python2.6/lib-dynload', '/usr/lib/python2.6',
> > '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> > '/home/saad/www/lib/python2.6/site-packages'] Server time: Tue, 28 Sep
> 2010
> > 23:40:56 -0500
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> 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 [email protected].
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.