Hello guys,
I am doing my first project in Django and I really need some help - I get this exception in the admin site
DoesNotExist at /admin/accounts/appcustomeruser/3/change/
AppStaffProfile matching query does not exist.
and this is in Pycharm console:
beauty_salon_manage_sistem.accounts.models.AppStaffProfile.DoesNotExist: AppStaffProfile matching query does not exist.
[22/Nov/2022 17:14:06] “GET /admin/accounts/appcustomeruser/3/change/ HTTP/1.1” 500 623959
in models.py:
class AppCustomerUser(models.Model):
MIN_LEN_FIRST_NAME = 2
MAX_LEN_FIRST_NAME = 40
MIN_LEN_LAST_NAME = 2
MAX_LEN_LAST_NAME = 40
MAX_LEN_PHONE_NUMBER = len('+359888888888')
MIN_LEN_PHONE_NUMBER = len('+359888888888')
#
# TODO Make it with enumerate!
GENDER_CHOICES = [('Male', 'Male'), ('Female', 'Female'), ('Do not show', 'Do not show'), ]
MAX_LEN_GENDER = len('Do not show')
#
HAIR_TYPES_CHOICES = [
('Straight hair', 'Straight hair'),
('Wavy hair', 'Wavy hair'),
('Curly hair', 'Curly hair'),
('Kinky hair', 'Kinky hair'),
('I am not sure', 'I am not sure'),
]
MAX_LEN_HAIR_TYPES = len('I am not sure')
HAIR_LONG_CHOICES = [
('Short hair', 'Short hair'),
('Middle hair', 'Middle hair'),
('Long hair', 'Long hair'),
('Very long hair', 'Very long hair'),
('I am not sure', 'I am not sure'),
]
MAX_LEN_HAIR_LONG = len('Very long hair')
MAX_LEN_FURTHER_EXPLANATION = 250
hair_stylist = models.ManyToManyField(AppBaseUser)
first_name = models.CharField(
max_length=MAX_LEN_FIRST_NAME,
null=False,
blank=False,
validators=[
validators.MinLengthValidator(MIN_LEN_FIRST_NAME),
validate_only_letters,
],
)
last_name = models.CharField(
max_length=MAX_LEN_LAST_NAME,
null=False,
blank=False,
validators=[
validators.MinLengthValidator(MIN_LEN_LAST_NAME),
validate_only_letters,
]
)
date_of_join = models.DateField(
auto_now_add=True,
blank=True,
)
phone_number = models.CharField(
max_length=MAX_LEN_PHONE_NUMBER,
validators=[validators.MinLengthValidator(MIN_LEN_PHONE_NUMBER), ],
null=False,
blank=False,
)
gender = models.CharField(
max_length=MAX_LEN_GENDER,
choices=GENDER_CHOICES,
)
hair_type = models.CharField(
max_length=MAX_LEN_HAIR_TYPES,
choices=HAIR_TYPES_CHOICES,
)
hair_long = models.CharField(
max_length=MAX_LEN_HAIR_LONG,
choices=HAIR_LONG_CHOICES,
)
further_explanation = models.TextField(
max_length=MAX_LEN_FURTHER_EXPLANATION,
null=True,
blank=True,
)
is_staff = models.BooleanField(default=False,)
is_superuser = models.BooleanField(default=False,)
@property
def get_full_name(self):
return f'{self.first_name} {self.last_name}'
@property
def full_name_and_phone_number(self):
return f'{self.get_full_name} - {self.phone_number}'
def __str__(self):
return f'{self.get_full_name} - {self.pk}'
class Meta:
verbose_name = 'Customer'
in views.py:
class CreateCustomer(CreateView):
template_name = 'accounts/adding_customer.html'
form_class = AddingCustomerForm
success_url = reverse_lazy('add customer')
in admin.py:
@admin.register(AppStaffProfile)
class AppStaffProfileAdmin(admin.ModelAdmin):
pass
I have correct records in my DB, but when I click on one of them in localhost:8000/admin it crashes