Opened 17 years ago

Closed 17 years ago

#5240 closed (invalid)

error in tutorial

Reported by: cristi.tudose@… Owned by: Jacob
Component: Documentation Version: 0.96
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

hi.

Today I have started learn django. It's amazing !!!
But !

URL: http://www.djangoproject.com/documentation/tutorial01/

polls/models.py

from django.db import models

class Poll(models.Model):

question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

class Choice(models.Model):

poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()

It's not max_length=200 ! it's maxlength=200

after execution:

devserver # python manage.py sql polls
mysite.polls: init() got an unexpected keyword argument 'max_length'
1 error found.
Traceback (most recent call last):

File "manage.py", line 11, in <module>

execute_manager(settings)

File "/usr/local/lib/python2.5/site-packages/django/core/management.py", line 1678, in execute_manager

execute_from_command_line(action_mapping, argv)

File "/usr/local/lib/python2.5/site-packages/django/core/management.py", line 1626, in execute_from_command_line

mod_list = [models.get_app(app_label) for app_label in args[1:]]

File "/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line 40, in get_app

mod = load_app(app_name)

File "/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line 51, in load_app

mod = import(app_name, {}, {}, models)

File "/usr/local/www/apache22/data/cristi.prosportequipment.ro/mysite/../mysite/polls/models.py", line 3, in <module>

class Poll(models.Model):

File "/usr/local/www/apache22/data/cristi.prosportequipment.ro/mysite/../mysite/polls/models.py", line 4, in Poll

question = models.CharField(max_length=200)

TypeError: init() got an unexpected keyword argument 'max_length'

polls.poll: "question": CharFields require a "maxlength" attribute.
polls.choice: "choice": CharFields require a "maxlength" attribute.

If I'm wrong, excuse me.
I use django on a FreeBSD box. And I installed django from ports.

Thanks !

Change History (1)

comment:1 by Russell Keith-Magee, 17 years ago

Resolution: invalid
Status: newclosed

max_length is a recent change (i.e., post 0.96 release). The tutorial is correct for the current subversion trunk, and the tutorial contains a link to the old 0.96 tutorial.

Note: See TracTickets for help on using tickets.
Back to Top