Das ist mein models.py-Code.Kann jemand mich wissen lassen, was mit diesem Code falsch ist?So lösen Sie TypeError: __init __() hat ein unerwartetes Schlüsselwort-Argument '_MAX_LENGTH' in Django
from django.db import models
from unittest.util import _MAX_LENGTH
class Album(models.Model):
artist = models.CharField(_MAX_LENGTH=250)
album_title = models.CharField(_MAX_LENGTH=500)
genre = models.CharField(_MAX_LENGTH=100)
album_logo = models.CharField(_MAX_LENGTH=1000)
class Song(models.Model):
album = models.ForeignKey(Album, on_delete = models.CASCADE)
file_type = models.CharField(_MAX_LENGTH=10)
song_title = models.CharField(_MAX_LENGTH=250)
Während Befehl Python manage.py Migrationen Musik läuft, erhalte ich diesen Fehler
Traceback (most recent call last):
File "/home/sunil/workspace/DjangoApp1/manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/sunil/workspace/DjangoApp1/music/models.py", line 5, in <module>
class Album(models.Model):
File "/home/sunil/workspace/DjangoApp1/music/models.py", line 6, in Album
artist = models.CharField(_MAX_LENGTH=250)
File "/usr/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1081, in __init__
super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument '_MAX_LENGTH'
Kann mir jemand mitteilen, wie dieses Problem zu lösen?
@MoinuddinQuadri, Danke für das Zeigen. Ich habe es entsprechend korrigiert. – falsetru
Danke, Falsetru, ich habe meinen Fehler und jetzt funktioniert es :) –