Добрый день, Тостер.
Пытаюсь реализовать свою регистрацию/авторизацию на Django.
Регистрацию сделал вот таким образом (проверки еще будут дописаны):
views.py
def registration(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
login = form.cleaned_data['login']
password = form.cleaned_data['password']
name = form.cleaned_data['name']
surname = form.cleaned_data['surname']
email = form.cleaned_data['email']
user = User(login = login, password = password, name = name, surname = surname, email = email)
user.save()
return render_to_response('registration.html', RequestContext(request))
else:
form = RegistrationForm()
return render_to_response('registration.html', {'form' : form}, RequestContext(request))
models.py
class User(models.Model):
login = models.CharField(max_length=30, unique=True)
password = models.CharField(max_length=30)
name = models.CharField(max_length=30)
surname = models.CharField(max_length=30)
email = models.CharField(max_length=100, unique=True)
urls.py
urlpatterns = [
# url(r'^admin/', include(admin.site.urls)),
url(r'^registration/', views.registration),
url(r'^login/', views.login)
]
Как теперь залогинить юзера без использования django.contrib.auth?