H
H
hardwellZero2015-06-05 14:44:43
Django
hardwellZero, 2015-06-05 14:44:43

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))

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)
]

How to login user now without using django.contrib.auth?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2015-06-05
@hardwellZero

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 question

Ask a Question

731 491 924 answers to any question