Buenas tardes, ya creaste un super usuario en django?,
creo que te hace falta correr python manage.py makemigrations
despues python manage.py migrate

intenta eso

El mié., 4 dic. 2019 a las 17:10, Tosin Ayoola (<tosinayoo...@gmail.com>)
escribió:

> halo guys, i'm working on a school management system that has multi user
> (student and staffs), i've created the model, views and form but i'm
> getting this error which i'm not familiar with. i'll b glad if anyone can
> help out
> below is the view, model, form and the err
>
> #forms
> class StudentSignupForm(UserCreationForm):
> class Meta(UserCreationForm.Meta):
> model = UserRole
> @transaction.atomic
> def save(self):
> user = super().save(commit=False)
> user.is_student = True
> if commit:
> user.save()
> return user
>
> class StaffSignupForm(UserCreationForm):
> class Meta(UserCreationForm.Meta):
> model = UserRole
> @transaction.atomic
> def save(self):
> user = super().save(commit=False)
> user.is_staff = True
> if commit:
> user.save()
> return user
>
>
> #views
> class StudentSignUp(CreateView):
> model = UserRole
> form_class = StudentSignupForm
> template_name = 'register/signup.html'
>
> def get_context_data(self, **kwargs):
> kwargs['user_type'] = 'student'
> return super().get_context_data(**kwargs)
> def student_valid_form(self, student_form):
> user = student_form.save()
> login(self.request, user)
> return redirect('students:student_index')
>
> class StaffSignup(CreateView):
> model = UserRole
> form_class = StaffSignupForm
> template_name = 'register/signup.html'
>
> def get_context_data(self, **kwargs):
> kwargs['user_type'] = 'staff'
> return super().get_context_data(**kwargs)
> def staff_valid_form(self, staff_form):
> user = staff_form.save()
> login(self.request, user)
> return redirect('staff:staff_index')
>
>
>
>
> #models
>
> class UserRole(AbstractUser):
> is_student = models.BooleanField(default=False)
> is_staff = models.BooleanField(default=False)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn71OveFEozZ7J7b%3DGMBgtB7LvurcoOgbDEiTQXX%3DO%3D9zTw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHLKn71OveFEozZ7J7b%3DGMBgtB7LvurcoOgbDEiTQXX%3DO%3D9zTw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
José Ángel Encinas
Ing. Tecnologias de la informacion


Cel:  6622267620  <6622267620>

   *                   Never give up...*
<http://mx.linkedin.com/in/jencinas> <http://twitter.com/encinasjangel>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF3iVr9wFwnFA8OqUJKJWvApxXydDAKc0LVoL32o_LTBtaqTOQ%40mail.gmail.com.

Reply via email to