相关疑难解决方法(0)

Django'RequestContext'未定义 - forms.ModelForm

我在尝试加载表单时遇到了请求上下文错误.

  1. 在我的models.py上创建了ModelForm
  2. 在我的视图上创建了def添加
  3. 链接到视图的URL

views.py

def add_company(request):
# Get the context from the request.
context = RequestContext(request)

# A HTTP POST?
if request.method == 'POST':
    form = CompanyForm(request.POST)

    # Have we been provided with a valid form?
    if form.is_valid():
        # Save the new category to the database.
        form.save(commit=True)

        # Now call the index() view.
        # The user will be shown the homepage.
        return index(request)
    else:
        # The supplied form contained errors - just print them to the terminal.
        print form.errors …
Run Code Online (Sandbox Code Playgroud)

python forms django django-forms

4
推荐指数
2
解决办法
9877
查看次数

标签 统计

django ×1

django-forms ×1

forms ×1

python ×1