K
K
Kamral Magaramov2020-12-03 15:00:04
Django
Kamral Magaramov, 2020-12-03 15:00:04

How to solve this problemTypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead?

While creating a model for user , a
TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead.

#settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib. staticfiles',
'account',
'obshaga_structure',
]

AUTH_USER_MODEL='account.Users'

#account.models

class Users(AbstractUser):
is_student = models.BooleanField(
default=False,
help_text=('Select this field if you are a student'),
verbose_name='Student'
)
is_university = models.BooleanField(
default=False,
help_text=('Select this field if you are a university'),
verbose_name='University'
)
is_abiturient= models.BooleanField(
default=False,
help_text=('Select this field if you are an applicant'),
verbose_name='Applicant'
)

first_name = models.CharField(max_length=100,
verbose_name='Name')
second_name=models.CharField(max_length =100,
verbose_name='Last Name')
middle_name=models.CharField(max_length=100,
verbose_name='Middle Name')
age=models.PositiveIntegerField(
verbose_name='Age'
)
number_school=models.PositiveIntegerField(
verbose_name='School Number'
)
date_of_graduation=models .DateField(null=True, blank=True,
verbose_name='End Date')
number_of_registration_attestat=models.PositiveIntegerField(
help_text=('Please enter your passport number'),
verbose_name='Attest registration number'
)
city=models.CharField(
verbose_name='Country'
)
name_of_university=models.CharField(
verbose_name='University name'
)
number_of_licence=models.PositiveIntegerField(
help_text=('Please enter your license number'),
verbose_name='License registration number'
)
M_T_R_N=models.PositiveIntegerField(
help_text=('Please enter PSRN number' ) ,
verbose_name ='PSRN number'

)

date_of_foundation=models.DateField(
auto_now=True,
help_text="Please use this format:"
" YYYY-MM-DD.",
verbose_name='University Foundation Date'
)

course=models.PositiveIntegerField(
verbose_name='Course'

)
groups = models.PositiveIntegerField(
help_text='Please enter only numbers',
verbose_name='Group'
)
budget_form_of_training=models.BooleanField(
default=False,
help_text=('Please select this option if you are '
'learning from the budget form'),
verbose_name='Budget form of education'
)
commercial_form=models.BooleanField(
default=False,
help_text=('Please select this item if you are '
'studying on a plan form'),
verbose_name='Commercial form of education'
)

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