私はPythonの初心者で、ビュー、URLを使用してフォームを操作しています...私のプロジェクト名はprojec1で、アプリケーション名はusersappです
これは私の **usersapp/views.py ** です
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from users.form import ContactForm
def contact(request):
if request.method == "POST":
contact_form = ContactForm(request.POST)
if contact_form.is_valid():
success = True
username = contact_form.cleaned_data['username']
password = contact_form.cleaned_data['password']
else:
contact_form = ContactForm()
return render_to_response('contact.html', {'contact_form': contact_form})
これは私のusersapp/contact.html です
{%block title%}
Contact
{%endblock%}
{%block content%}
<h2>Contact</h2>
<form action ='.' method = 'POST'>
{{contact_form.as_p}}
<input type ="Submit" name = "submit" value = "send">
</form>
{%endblock%}
これは私のusersapp/form.py です
from django import forms
class ContactForm(forms.Form):
username = forms.CharField()
password = forms.CharField()
これは私のprojec1/urls.pyです
from django.conf.urls import patterns, include, url
from django.conf.urls.defaults import *
from users.views import login
from users.views import contact
urlpatterns = patterns('',
('^contact/$', contact),
)
私はこのエラーに直面しています
TypeError at /
Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4.3
Exception Type: TypeError
Exception Value:
Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
私のエラーは次のとおりです。
NameError at /contact
name 'forms' is not defined
Request Method: GET
Request URL: http://127.0.0.1:8000/contact
Django Version: 1.4.3
Exception Type: NameError
Exception Value:
name 'forms' is not defined
Exception Location: C:\Users\Documents\MyProjects\projec1\users\form.py
in<module>,line 2
Python Executable: C:\Python27\python.exe
誰かガイドしてください、よろしくお願いします