I tried running
manage.py runserver
manage.py makemigrations
and manage.py migrate
but they all give me a TypeError
The error is
Traceback (most recent call last):
File "/Users/William/Documents/Start over/Simple/perputer/manage.py", line 22, in <module>
main()
File "/Users/William/Documents/Start over/Simple/perputer/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/William/Documents/Start over/Simple/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/William/Documents/Start over/Simple/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/Users/William/Documents/Start over/Simple/env/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/William/Documents/Start over/Simple/env/lib/python3.10/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/Users/William/Documents/Start over/Simple/env/lib/python3.10/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/William/Documents/Start over/Simple/perputer/words/models.py", line 4, in <module>
class Word(models):
TypeError: module() takes at most 2 arguments (3 given)
I haven't changed my manage.py and my models.py that's causing the error:
from django.db import models
# Create your models here.
class Word(models): <-- error
word = models.CharField(max_length = 26)
meaning = models.TextField(help_text = "A definition for the word attached to it.")
language = models.CharField(max_length = "20", editable = True)
Can somebody tell me what I'm doing wrong?
models
is a module, not a class. The class isdjango.db.models.Model
. Change the import to:and define the class with:
Any time you see this error (
TypeError: module() takes at most 2 arguments (3 given)
), it's because you inadvertently tried to inherit from a module, not the class it contains.