from django.shortcuts import render, redirect
from django.urls import reverse
from accounts.forms import (
RegistrationForm,
EditProfileForm
)
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserChangeForm, PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.decorators import login_required
def register(request):
if request.method =='POST':
form = RegistrationForm(request.POST)
if form.is_valid():
form.save()
return redirect(reverse('accounts:home'))
else:
form = RegistrationForm()
Я поменял, теперь получаю ошибку 'ManyToManyDescriptor' object has no attribute 'add'
заменил на это
lamer = Group.objects.get(name='Companis')
user = form.save(commit=False)
user.is_active = True
User.groups.add(lamer)
user.save()