I have an Django model as follows:
class BodyHeight(models.Model):
seats = models.ForeignKey(to=Seats)
name = models.CharField(max_length=127, null=True, blank=True)
key = models.CharField(max_length=100, null=True)
data = models.TextField(null=True, blank=True)
class Meta:
verbose_name_plural = "Body heights"
def __str__(self):
return self.name
And in the data field I store the json data, as follows:
{"url": "https://some_url=/BE?category=COMMERCIAL, "images": ["url_to_some_image"]}
And I want to show in the Django admin panel only the url from that field.
Now I have:
class BodyHeightAdmin(admin.ModelAdmin):
search_fields = ('name', )
list_display = ('id', 'name', 'key', )
list_display_links = ('id', 'name', 'key', )
admin.site.register(BodyHeight, BodyHeightAdmin)
That is without the data field. If I add the data
field in list_display
it shows than whole json (ugly format), but I want only the url
.
Any idea how to do that?