L
L
Lolo Penguin2019-11-25 16:19:50
Django
Lolo Penguin, 2019-11-25 16:19:50

How can I redirect the user after registration so that everyone has a unique personal account?

I somehow got these scripts that carry out registration, and in general, I can’t understand in any way:
how, after registration, each user will have his own personal account?
how do I work with each page of my personal account?
And how to make a personal account created for the user after registration?

views

from django.shortcuts import render, redirect
from django.http import Http404, HttpResponseRedirect
# вход
from django.contrib.auth import authenticate, login
# регистрация
from .forms import regForm


# регистрация
def regDef(request):

    if request.method == "POST":
        form = regForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'lk.html')
    else:
        form = regForm()

    return render(request, 'reg_vhod/reg.html', {'reg': form})

forms
from django import forms
from .models import regModel


# регистрация
class regForm(forms.ModelForm):

    class Meta:
        model = regModel
        fields = ('name_regModel', 'inn_regModel', 'site_regModel', 'tel_regModel', 'tel2_regModel', 'email_regModel', 'login_regModel', 'password_regModel',)

models
from django.db import models

class regModel(models.Model):
    name_regModel = models.CharField('Название компании', max_length = 40)
    site_regModel = models.URLField('Сайт (не обязат.)', blank = True, null = True)
    inn_regModel = models.CharField('ИНН организации', max_length = 15)
    email_regModel = models.EmailField('Эл/почта')
    tel_regModel = models.CharField('Телефон', max_length = 18)
    tel2_regModel = models.CharField('Телефон (не обязат.)', max_length = 18, blank = True, null = True)

    login_regModel = models.CharField('Логин', max_length = 50)
    password_regModel = models.CharField('Пароль', max_length = 50)
    

    def __str__(self):
        return self.name_regModel

    class Meta:
        verbose_name = 'партнёр'
        verbose_name_plural = 'партнёры'

urls (applications)
from django.urls import path
from . import views

urlpatterns = [
    path('', views.regDef, name = 'regCompani'),
]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question