views:

52

answers:

2

Hi :) , I use Djnago a few weeks ago I started a django app and wrote these lines in model.py

    from django.db import models
class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_lenght=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.model.CharField(max_length=50)
    website = models.URLField()

class Author(models.Model):
    first_name = models.CharFiled(max_length=30)
    last_name = models.CharField(max_length=40)
    email = models.EmailField()

class Book(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)
    publisher = models.ForeignKey(Publisher)
    publication_date = models.DateField()

When I trying to Validate or sqlall

python manage.py validate
or 
python manage.py sqlall appname

It print this error message

            Traceback (most recent call last):
      File "manage.py", line 11, in <module>
        execute_manager(settings)
      File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
    438, in execute_manager
        utility.execute()
      File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
    379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "C:\Python27\lib\site-packages\django\core\management\base.py", line 191
     in run_from_argv
        self.execute(*args, **options.__dict__)
      File "C:\Python27\lib\site-packages\django\core\management\base.py", line 218
     in execute
        output = self.handle(*args, **options)
      File "C:\Python27\lib\site-packages\django\core\management\base.py", line 347
     in handle
        return self.handle_noargs(**options)
      File "C:\Python27\lib\site-packages\django\core\management\commands\validate.
    y", line 9, in handle_noargs
        self.validate(display_num_errors=True)
      File "C:\Python27\lib\site-packages\django\core\management\base.py", line 245
     in validate
        num_errors = get_validation_errors(s, app)
      File "C:\Python27\lib\site-packages\django\core\management\validation.py", li
    e 28, in get_validation_errors
        for (app_name, error) in get_app_errors().items():
      File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 146, i
     get_app_errors
        self._populate()
      File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 61, in
    _populate
        self.load_app(app_name, True)
      File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 78, in
    load_app
        models = import_module('.models', app_name)
      File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in i
    port_module
        __import__(name)
      File "C:\Documents and Settings\root\mysite\..\mysite\books\models.py", line
    , in <module>
        class Publisher(models.Model):
      File "C:\Documents and Settings\root\mysite\..\mysite\books\models.py", line
    , in Publisher
        address = models.CharField(max_lenght=50)
      File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", lin
     542, in __init__
        super(CharField, self).__init__(*args, **kwargs)
    TypeError: __init__() got an unexpected keyword argument 'max_lenght'

Please help me to fix this error

+2  A: 

The exception message couldn't be clearer:

TypeError: __init__() got an unexpected keyword argument 'max_lenght'

Here's the offending line, looks like a typo.

address = models.CharField(max_lenght=50)
                                   ^
Ben James
+7  A: 

don't want to be rude, but did you bother to read the error message?

unexpected keyword argument 'max_lenght'

(you've misspelled max_length)

Edit:

The sheer amount of error messages may be intimidating but there's a nice hint in the first line:

Traceback (most recent call last):

Start looking from the bottom, where indeed your error may be found.

Another tip (though no help this time) is to scan the code for errors in files you've written (as opposed to django library code), which is sometimes in the middle of the list.

second