gpt4 book ai didi

django - __init__() 得到了一个意外的关键字参数 'min_length'

转载 作者:行者123 更新时间:2023-12-02 09:17:07 26 4
gpt4 key购买 nike

<分区>

我收到以下错误:

...
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/luowensheng/Desktop/QIYUN/Project/officialWeb/frontend/models.py", line 93, in <module>
class User(models.Model):
File "/Users/luowensheng/Desktop/QIYUN/Project/officialWeb/frontend/models.py", line 97, in User
phone = models.CharField(min_length=11, max_length=11)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/db/models/fields/__init__.py", line 1061, in __init__
super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'min_length'

我的模型代码如下:

class User(models.Model):
username = models.CharField(max_length=16)
password = models.CharField(max_length=16)
real_name = models.CharField(max_length=12)
phone = models.CharField(min_length=11, max_length=11) # this is the line 97
email = models.EmailField()
qq = models.CharField(max_length=10)
address = models.CharField(max_length=64)
id_card = models.CharField(min_length = 18, max_length=18)
id_card_img_front = models.CharField(max_length=256)
id_card_img_back = models.CharField(max_length=256)
nickname = models.CharField(max_length=16)
profile = models.CharField(max_length=256)

为什么会出现该错误?顺便问一下,是否有更好的方法将电话长度限制为 11

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com