小编Dor*_*rey的帖子

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

任何人都可以帮助我,我尝试在 python-django 上创建联系表单,当我尝试在数据库上进行迁移时,我收到错误“AttributeError: 'ContactUs' object has no attribute 'model'”

视图.py

from django.shortcuts import render
from .forms import ContactForm, ContactUs
from django.core.mail import EmailMessage
from django.shortcuts import redirect
from django.template.loader import get_template


def contact(request):
    form_class = ContactForm

    # new logic!
    if request.method == 'POST':
        form = form_class(data=request.POST)

        if form.is_valid():
            first_name = request.POST.get('first_name', '')
            last_name = request.POST.get('last_name', '')
            date = request.POST.get('date', '')
            month = request.POST.get('month', '')
            year = request.POST.get('year', '')
            sender = request.POST.get('sender', '')
            message = request.POST.get('message', '')
            licence = request.POST.get('licence', '') …
Run Code Online (Sandbox Code Playgroud)

python django attributeerror

3
推荐指数
1
解决办法
2719
查看次数

标签 统计

attributeerror ×1

django ×1

python ×1