TypeError: Field.__init__() got an unexpected keyword argument 'max_lenth'

Dijango series part 1 section 3 (building a data model)
after adding store & tags apps , if i tried to create a new app (likes app) it shows me that error:

Traceback (most recent call last):
File “/home/muhammed/projects/back_end_Django/pro1/project1/manage.py”, line 22, in
main()
File “/home/muhammed/projects/back_end_Django/pro1/project1/manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “/usr/lib/python3/dist-packages/django/core/management/init.py”, line 419, in execute_from_command_line
utility.execute()
File “/usr/lib/python3/dist-packages/django/core/management/init.py”, line 395, in execute
django.setup()
File “/usr/lib/python3/dist-packages/django/init.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “/usr/lib/python3/dist-packages/django/apps/registry.py”, line 114, in populate
app_config.import_models()
File “/usr/lib/python3/dist-packages/django/apps/config.py”, line 301, in import_models
self.models_module = import_module(models_module_name)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “”, line 883, in exec_module
File “”, line 241, in _call_with_frames_removed
File “/home/muhammed/projects/back_end_Django/pro1/project1/store/models.py”, line 41, in
class Order(models.Model):
File “/home/muhammed/projects/back_end_Django/pro1/project1/store/models.py”, line 51, in Order
payment_status = models.CharField(max_lenth=1, choices=Payment_Status_Choices, default=Pending)
File “/usr/lib/python3/dist-packages/django/db/models/fields/init.py”, line 1005, in init
super().init(*args, **kwargs)
TypeError: Field.init() got an unexpected keyword argument ‘max_lenth’

The error is telling you the exact issue; max_lenth is invalid. You have misspelled it.

1 Like

The error is caused by a typo in the code: max_lenth should be max_length.