猿问

AttributeError: 'ContactUs' 对象没有属性 'model'

任何人都可以帮助我,我尝试在 python-django 上创建联系表单,当我尝试在数据库上进行迁移时,我收到错误“AttributeError:'ContactUs' 对象没有属性'模型'”

模型.py


from django.db import models



class Form(models.Model):

    first_name = models.CharField(max_length=100)

    last_name = models.CharField(max_length=100)

    date = models.DateTimeField()

    month = models.DateTimeField()

    year = models.DateTimeField()

    sender = models.EmailField()

    message = models.CharField()

    licence = models.CharField(max_length=100)

    zipCode = models.CharField(max_length=100)

    phoneNumber = models.CharField(max_length=100)

    cdlType = models.CharField(max_length=100)



class ContactUs(models.Model):

    first_name = models.CharField(max_length=100)

    last_name = models.CharField(max_length=100)

    sender = models.EmailField()

    message = models.CharField()

    phoneNumber = models.CharField(max_length=100)

表格.py


from django import forms



class ContactForm(forms.Form):

    first_name = forms.CharField(max_length=100, required=True)

    last_name = forms.CharField(max_length=100, required=True)

    date = forms.DateTimeField(required=True)

    month = forms.DateTimeField(required=True)

    year = forms.DateTimeField(required=True)

    sender = forms.EmailField(required=True)

    message = forms.CharField(required=True)

    licence = forms.CharField(max_length=100, required=True)

    zipCode = forms.CharField(max_length=100, required=True)

    phoneNumber = forms.CharField(max_length=100, required=True)

    cdlType = forms.CharField(max_length=100, required=True)



class ContactUs(forms.Form):

    first_name = forms.CharField(max_length=100, required=True)

    last_name = forms.CharField(max_length=100, required=True)

    sender = forms.EmailField(required=True)

    message = forms.CharField(required=True)

    phoneNumber = forms.CharField(max_length=100, required=True)

一开始我制作了仅用于发送邮件的联系表格,但后来我修改了它,因为我需要在站点管理中显示数据。


慕侠2389804
浏览 160回答 2
2回答

慕婉清6462132

您可以将多个模型注册为列表admin.site.register([Form, ContactUs])
随时随地看视频慕课网APP

相关分类

Python
我要回答