Answer the question
In order to leave comments, you need to log in
How to authorize a user NOT using django.contrib.auth?
Good afternoon Toaster.
I'm trying to implement my registration / authorization on Django.
I did the registration like this (the checks will still be added):
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))
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)
urlpatterns = [
# url(r'^admin/', include(admin.site.urls)),
url(r'^registration/', views.registration),
url(r'^login/', views.login)
]
Answer the question
In order to leave comments, you need to log in
password=password
No need to compromise the personal data of users. Why didn't you like contrib.auth?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question