내 웹 사이트의 등록 프로세스를 시작하려고합니다. 나는 Python 3.3.5와 Django 1.6을 사용하고있다.'forms'라는 모듈이 없습니다. Django
No module named 'forms'
이라는 오류 메시지가 나타납니다. 나는 Python/Django에 상당히 익숙하다.
Views.py :
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.contrib import auth
from django.core.context_processors import csrf
from django.contrib.auth.forms import UserCreationForm
from forms import MyRegistrationForm
def register_user(request):
if request.method == 'POST':
form = MyRegistrationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
else:
form = MyRegistrationForm()
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response('register1.html', args)
def register_success(request):
return render_to_response('register_success.html')
Forms.py
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class MyRegistrationForm(UserCreationForm):
email = forms.EmailField(required=True)
class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(MyRegistrationForm, self).save(commit=False)
user.email = self.cleaned_data['email']
# user.set_password(self.cleaned_data['password1'])
if commit:
user.save()
return user
forms.py이 views.py와 같은 폴더에있는 다음
내 파일입니다. django.forms import MyRegistrationForm에서 시도했지만 오류cannot import name MyRegistrationForm
이 발생합니다.
폴더에 __ init __.py 파일이 있습니까? –