Django

Code

Ticket #9727 (closed: duplicate)

Opened 7 months ago

Last modified 7 months ago

models.CharField(max_length should be maxlength. no underscore.

Reported by: coachjpg Assigned to: nobody
Milestone: Component: Documentation
Version: 1.0 Keywords:
Cc: jpg@post.harvard.edu Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

in http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

models.CharField?(max_length should be maxlength. no underscore.

class Poll(models.Model):

question = models.CharField?(max_length=200)

Following the example on the web page yields the error below. Removing the undescore from maxlength fixes this.

I presume this is a django version skew issue. Perhaps the top of the doc might mention what django version supported?

As a django newbie using the latest debian stable, this was confusing.

-jpg

Traceback (most recent call last):

File "manage.py", line 11, in ?

execute_manager(settings)

File "/var/lib/python-support/python2.4/django/core/management.py", line 1319, in execute_manager execute_from_command_line(action_mapping, argv) File "/var/lib/python-support/python2.4/django/core/management.py", line 1277, in execute_from_command_line

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

File "/var/lib/python-support/python2.4/django/db/models/loading.py", line 40, in get_app

mod = load_app(app_name)

File "/var/lib/python-support/python2.4/django/db/models/loading.py", line 51, in load_app

mod = import(app_name, , , models?)

File "/home/jpg/poll0/../poll0/polls/models.py", line 3, in ?

class Poll(models.Model):

File "/home/jpg/poll0/../poll0/polls/models.py", line 4, in Poll

question = models.CharField?(max_length=200)

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

jpg@T30:~/poll0$ dpkg -l | egrep "(deb|python)" ii debconf 1.5.11etch2 Debian configuration management system ii debconf-i18n 1.5.11etch2 full internationalization support for debcon ii debian-archive-keyring 2007.07.31~etch1 GnuPG archive keys of the Debian archive ii debianutils 2.17 Miscellaneous utilities specific to Debian ii doc-debian 3.1.5 Debian Project documentation, Debian FAQ and ii gdebi 0.1.6 Simple tool to install deb files ii iptables 1.3.6.0debian1-5 administration tools for packet filtering an ii libapache2-mod-python 3.2.10-4 Apache 2 module that embeds Python within th ii libcaca0 0.99.beta11.debian-2 colour ASCII art library ii libcdparanoia0 3.10+debian~pre0-4 audio extraction tool for sampling CDs (libr ii libcucul0 0.99.beta11.debian-2 low-level Unicode character drawing library ii libsdl1.2debian 1.2.11-8 Simple DirectMedia? Layer ii libsdl1.2debian-alsa 1.2.11-8 Simple DirectMedia? Layer (with X11 and ALSA ii python 2.4.4-2 An interactive high-level object-oriented la ii python-apt 0.6.19 Python interface to libapt-pkg ii python-cairo 1.2.0-1 Python bindings for the Cairo vector graphic ii python-central 0.5.12 register and build utility for Python packag ii python-django 0.95.1-1etch2 A high-level Python Web framework ii python-foomatic 0.7.7 Python interface to the Foomatic printer dat ii python-glade2 2.8.6-8 GTK+ bindings: Glade support ii python-gmenu 2.16.1-3 an implementation of the freedesktop menu sp ii python-gnome2 2.12.4-6 Python bindings for the GNOME desktop enviro ii python-gnome2-desktop 2.14.0-3 Python bindings for the GNOME desktop enviro ii python-gnome2-extras 2.14.3-1 Python bindings for the GNOME desktop enviro ii python-gnupginterface 0.3.2-9 Python interface to GnuPG (GPG) ii python-gtk2 2.8.6-8 Python bindings for the GTK+ widget set ii python-ipy 0.52-2 Python module for handling IPv4 and IPv6 add ii python-libxml2 2.6.27.dfsg-6 Python bindings for the GNOME XML library ii python-minimal 2.4.4-2 A minimal subset of the Python language (def ii python-newt 0.52.2-10 A NEWT module for Python ii python-numeric 24.2-7 Numerical (matrix-oriented) Mathematics for ii python-pyorbit 2.0.1-5 A Python language binding for the ORBit2 COR ii python-pysqlite2 2.3.2-2 python interface to SQLite 3 ii python-qt3 3.16-1.2 Qt3 bindings for Python ii python-selinux 1.32-3 Python bindings to SELinux shared libraries ii python-semanage 1.8-1 Python bindings for SELinux policy manipula ii python-sip4 4.4.5-4 Python/C++ bindings generator runtime librar ii python-support 0.5.6 automated rebuilding support for python modu ii python-uno 2.0.4.dfsg.2-7etch6 Python interface for OpenOffice?.org ii python-vte 0.12.2-5 Python bindings for the VTE widget set ii python-xdg 0.15-1.1 A python library to access freedesktop.org s ii python2.4 2.4.4-3+etch2 An interactive high-level object-oriented la ii python2.4-minimal 2.4.4-3+etch2 A minimal subset of the Python language (ver ii ssl-cert 1.0.14 Simple debconf wrapper for openssl ii xresprobe 0.4.23debian1 X Resolution Probe

Attachments

Change History

11/30/08 19:13:07 changed by ubernostrum

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

You are using an older packaged version of Django; from Django 1.0 onwards, max_length is correct. Because many, many, many people have attempted to use pre-1.0 versions of Django with the Django 1.0 documentation, please note also that the tutorial contains a section, titled "Errors about max_length", explaining this. If you're using an older version of Django you should use the documentation for the version you're using (Version 0.96, Version 0.95), but if you're just starting out with Django it is highly recommended you begin with the current Django release (1.0.2), since that is the version which will be forward-compatible, whereas pre-1.0 Django versions are not compatible with the Django 1.x release series and will involve serious upgrade headaches for you later on.

Also, please in the future search the ticket tracker for existing reports before filing a new one; this report is a duplicate of #8922, #8199, #8722, #7253, #7007, #6457, #5325, #5259, #5254, #5252, #5240, #5210, #5209, #5194, #5184, #5162, #5159, #5144, #5119 and #5117.


Add/Change #9727 (models.CharField(max_length should be maxlength. no underscore.)




Change Properties
Action