Sorry I was not clear. Please find the models and requirements below. As we can see from the models below, tags belong to a particular station. I am adding/editing data in these 2 models in a single page (as shown in the screen shot below), through my app’s Django admin. My requirement is when I choose a station name from a drop down, all the tags related to this station should load via AJAX automatically. Currently I am choosing a station name and I click save and continue editing in Django admin and after the page refresh all tags for that station name gets loaded. Waiting for the page refresh to load all tags belonging to a station name is very time consuming when adding details in bulk. Hence looking for ways to make an AJAX call every time the station name changes so that the tags are pulled and send back to the admin form asynchronously.
In Models.py
class Station(FeedmachineModel):
slug = models.SlugField(unique=True)
name = models.TextField()
domain = models.TextField()
timezone = models.TextField(choices=TIMEZONE_CHOICES)
class Meta:
ordering = ['slug']
def __str__(self):
return self.slug + ': ' + self.domain
class Tag(CmsObject, FeedmachineModel):
name = models.TextField()
station = models.ForeignKey(‘Station’, on_delete=models.CASCADE)
objects = TagManager()
def __str__(self):
return f'{self.name}'
