Hi folks,
I’ve been not around here for a while. My project is resting sincoe October 2023. It was considered completed so far. Now I made the “mistake” to run an update with all outdated modules in requirements.txt including the Django Version itself.
Before that, everything was working as intended, since the update i get this error message when trying to start the testserver in PyCharm:
ERRORS:
<class ‘employees.admin.KeysAdmin’>: (admin.E013) The value of ‘filter_horizontal[0]’ cannot include the ManyToManyField ‘room’, because that field manually specifies a relationship model.
The error refers to this code fragment:
@admin.register(Keys)
class KeysAdmin(admin.ModelAdmin):
list_display = ['key']
list_display_links = ['key']
search_fields = ['key']
ordering = ['key']
filter_horizontal = ['room']
and this is corresponding to these models:
class Rooms(models.Model):
room = models.CharField(max_length=25, unique=True)
cylinder = models.CharField(max_length=25, null=True, blank=True)
description = models.CharField(max_length=100, null=True, blank=True)
restricted_access = models.BooleanField(default='0')
def __str__(self):
return self.room
class Meta:
verbose_name = 'Raum'
verbose_name_plural = 'Räume'
ordering = ['room']
class Keys(models.Model):
key = models.CharField(max_length=25, unique=True)
comment = models.CharField(max_length=100, null=True, blank=True)
room = models.ManyToManyField(Rooms, through='LockingAuthorisations')
def __str__(self):
return self.key
class Meta:
verbose_name = 'Schlüssel'
verbose_name_plural = 'Schlüssel'
ordering = ['key']
class LockingAuthorisations(models.Model):
key = models.ForeignKey(Keys, null=True, blank=True, on_delete=models.CASCADE)
room = models.ForeignKey(Rooms, null=True, blank=True, on_delete=models.CASCADE)
class Meta:
verbose_name = 'Schliessberechtigung'
verbose_name_plural = 'Schliessberechtigungen'
ordering = ['key']
Due to several other tasks I have to complete at the moment, I didn’t had time to read any changelogs concerning the updated modules. Will do so as soon as I can manage it but maybe someone around here has a simple hint, what changes have to be made to get it working again? The installed DjangoVersion is now 5.0.1.
Thx for any efforts to help me out