Django表单类中的语法错误无效

时间:2015-05-14 08:03:53

标签: python django django-forms

SyntaxError at /
invalid syntax (forms.py, line 5)
Request Method: POST
Request URL:    http://127.0.0.1:8000/
Django Version: 1.6.1
Exception Type: SyntaxError
Exception Value:    
invalid syntax (forms.py, line 5)
ExceptionLocation: C:\Users\chiragbagla\Desktop\skillshare\src\signups\views.py in <module>, line 5
Python Executable:  C:\Users\chiragbagla\Desktop\skillshare\Scripts\python2.exe
Python Version: 2.7.9

我的view.py代码的一部分如下

from django.shortcuts import render, render_to_response, RequestContext

# Create your views here.

from .forms import SignUpForm

def home(request):

form = SignUpForm(request.POST or None)

if form.is_valid():
    save_it = form.save(commit=False)
    save_it.save()

return render_to_response("signup.html", locals(), context_instance=RequestContext(request))

我的forms.py代码的一部分如下

from django import forms

from .models import SignUp

class SignUpForm(forms.ModelForm):
    class meta:
        model=SignUp

我的url.py代码的一部分如下

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
 url(r'^$', 'signups.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)

我想在网页上显示使用signup.html创建的注册表单,但该表单未显示在浏览器的网页上。

所以,请告诉我我犯的错误在哪里???

1 个答案:

答案 0 :(得分:3)

像错误一样指出:

class meta:

应该......

class Meta: