Closed
Description
Python version
3.9.13
Django version
4.1
Package version
0.20.0
in the admin page i'm trying to add a row to the table MaintenanceServiceSupplierContact that has a foreign key connection to a different table.
this is the model for that table:
class MaintenanceServiceSupplierContact(models.Model):
service_supplier = models.ForeignKey(MaintenanceServiceSupplier, on_delete=models.PROTECT)
name = MyCITextField(verbose_name=_('Name'), blank=True, max_length=200)
phone1 = PhoneNumberField(blank=True, null=True)
phone2 = PhoneNumberField(blank=True, null=True)
def __str__(self):
return '%s - %s' % (self.name, (self.phone1 or self.phone2))
here i click the + sign to add a new service supplier, this is the model for MaintenanceServiceSupplier
class MaintenanceServiceSupplier(models.Model):
type = models.ManyToManyField(MaintenanceServiceSupplierType)
name = MyCITextField(verbose_name=_('Company Name'), unique=True, max_length=200)
def __str__(self):
return self.name
@property
def support_types(self):
return '%s' % ', '.join(list(self.type.values_list('name', flat=True)))
@property
def contacts(self):
names = list(self.maintenanceservicesuppliercontact_set.values_list('name'))
if not names:
return None
names_filtered = [list(filter(None, lst)) for lst in names]
full_list = []
for i in range(len(names_filtered)):
full_list.append('[' + ', '.join(names_filtered[i]) + ']')
return '%s' % ' '.join(full_list)
so after I clicked the + button to add another item on that foreign table and then click save, i get the following javascript error:
Uncaught TypeError: Cannot read properties of undefined (reading 'pathname')
at updateRelatedSelectsOptions (RelatedObjectLookups.js:95:35)
at dismissAddRelatedObjectPopup (RelatedObjectLookups.js:126:17)
at popup_response.js:40:27
at popup_response.js:49:3