google-code-export / django-simple-captcha

Automatically exported from code.google.com/p/django-simple-captcha
MIT License
0 stars 0 forks source link

Captcha form is empty when captcha.urls is not included. An error should be raised instead. #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
Fedora 10. PIL 1.1.6.  django-simple-captcha-0.1.7

Please provide any additional information below.
I tried a basic catpcha form. As soon as I include a CaptchaField() in my
form, the form becomes empty (no field at all, just the submit button) and
there is no error in the runserver. However, each time  I invoke the form a
record is created in the captcha_captchastore table. Thanks for your
assistance.

Original issue reported on code.google.com by mrec...@gmail.com on 4 Jun 2010 at 9:12

GoogleCodeExporter commented 9 years ago
Which version of Python and Django are you using?

Original comment by mbonetti on 4 Jun 2010 at 9:23

GoogleCodeExporter commented 9 years ago
Django version 1.2.1 & Python 2.5.2
Thanks

Original comment by mrec...@gmail.com on 4 Jun 2010 at 9:34

GoogleCodeExporter commented 9 years ago
Okay, and would you mind to attach or paste your form class?

Original comment by mbonetti on 4 Jun 2010 at 10:25

GoogleCodeExporter commented 9 years ago
from django.db import models
from django.forms import ModelForm
from datetime import date
from django import forms
from django.contrib.auth.models import User
from captcha.fields import CaptchaField

...
class RegisterForm(forms.Form):
  prenom = forms.CharField(max_length=30)
  nom =  forms.CharField(max_length=30)
  email =  forms.EmailField()
  login = forms.CharField(max_length=30)
  password1 = forms.CharField(max_length=30, min_length=6, widget=forms.PasswordInput())
  password2 = forms.CharField(max_length=30, min_length=6, widget=forms.PasswordInput())
  captcha = CaptchaField()  

Original comment by mrec...@gmail.com on 4 Jun 2010 at 10:38

GoogleCodeExporter commented 9 years ago
That seems ok. 

One last thing, from your project root dir please run 'manage.py test captcha'  

Does that report any errors?

Original comment by mbonetti on 4 Jun 2010 at 2:52

GoogleCodeExporter commented 9 years ago
[mrechte@linux2 helipuces]$ ./manage.py test captcha
Creating test database 'default'...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table puces_classe
Creating table puces_marque
Creating table puces_article
Creating table captcha_captchastore
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
Installing index for admin.LogEntry model
Installing index for puces.Article model
No fixtures found.
..........
----------------------------------------------------------------------
Ran 10 tests in 1.191s

OK
Destroying test database 'default'...

Original comment by mrec...@gmail.com on 4 Jun 2010 at 4:42

GoogleCodeExporter commented 9 years ago
Okay, your form is okay, the tests run fine, ... last thing that could be 
broken is the config, could you paste the 
captcha related settings from your settings.py?

Also, how do you display the form in your template, i.e. {{ form.as_p }}, 
as_table,... ?

Original comment by mbonetti on 5 Jun 2010 at 9:15

GoogleCodeExporter commented 9 years ago
Here is the settings.py file content:
*************************************

# Django settings for helipuces project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2'  # 'postgresql_psycopg2', 'postgresql',
'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'helipuces_prod'             # Or path to database file if 
using sqlite3.
DATABASE_USER = 'helipuces'             # Not used with sqlite3.
DATABASE_PASSWORD = 'choucas'         # Not used with sqlite3.
DATABASE_HOST = 'localhost'             # Set to empty string for localhost. 
Not used
with sqlite3.
#DATABASE_HOST = 'postgresql.alwaysdata.com' # Set to empty string for 
localhost. Not
used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with 
sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Paris'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'fr-fr'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '()*5z6hbqiixbu8!-3vt6t9$lpsq=lv^@t-ej*#u*0w&(*kb&+'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'helipuces.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/home/mrechte/python/django/helipuces/templates'
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'helipuces.puces',
    'helipuces.mytest',
    'captcha'
)

This the model rendered by the view
***********************************

<html>
<body>
<h1>Création d'un compte</h1>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}

<form action="/accounts/register/" method="post">
{{ form.as_p }}
<input type="submit" value="Envoyer" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
</body>
</html>

Original comment by mrec...@gmail.com on 5 Jun 2010 at 8:19

GoogleCodeExporter commented 9 years ago
Oh, did you include captcha.urls from your main urls.py?

Original comment by mbonetti on 6 Jun 2010 at 6:11

GoogleCodeExporter commented 9 years ago
You are right. I did not include it. With the inclusion it is now working. 
Thanks a
lot for your help. May be there should be some kind of error message when this
happens. Also could you please explain the meaning of this captcha.url ?

Original comment by mrec...@gmail.com on 6 Jun 2010 at 5:07

GoogleCodeExporter commented 9 years ago
Definitely, I'll have to add an error message in this situation, I'll use this 
ticket to track the issue.

By including captcha.urls you basically define an URL that will be used to 
display the image, which is obviously 
required.

Original comment by mbonetti on 6 Jun 2010 at 6:13

GoogleCodeExporter commented 9 years ago
Fixed as of r54 and will be included in the next release. Thank you for the 
error report!

Original comment by mbonetti on 6 Jun 2010 at 8:27