Typeerror: __ init __ () received an unexpected keyword argument 'max_length'

  • Python version 3.3
  • Django version 1.5.2

Settings.py - Admin Enabled, changed time zone

urls.py - Admin Enabled.

__init__.py - empty

i created the file "models.py"

 from django.db import models from django.contrib import admin # Create your models here. class Post(models.Model): title = models.CharField(max_lenght=128, verbose_name=u"Title") desc = models.TextField(verbose_name=u"News Text") datetimestamp = models.DateTimeField(auto_now=True, verbose_name=u"Date,/Time") 

And when I try to manage.py syncdb .

I get a typeerror :__init__() got an unexpected keyword argument ' max_length ' error typeerror :__init__() got an unexpected keyword argument ' max_length '

I am new to Python \ Django. Googled for 2 days and no answer. The answers I found were - type max_lenght instead of maxlenght becouse version 0.96

modles β†’ model

Some old Django with new Python and ect ...

The problem is models.py. I ask you for help. Thanks.

+6
source share
2 answers

You made a mistake max_length (you inverted g and t ), which makes the argument with the name max_lenght unknown to Python.

+9
source

I got the same error even if I typed max_Length . It turns out that in Python 3.7 and Django 2.14, the argument name has changed to max_length ("L" in lowercase).

0
source

Source: https://habr.com/ru/post/1501180/


All Articles