Pass Django Choices or Foreign Key data to Vue 3

Viewed 113

I have the following code:

  from django_countries.fields import CountryField

....

class Book(models.Model):
    country = CountryField()
    authors = models.ForeignKey(Author, on_delete=models.CASCADE, related_name='instances')
    cover = models.CharField(choices=BOOK_COVER_CHOICES, max_length=64)
....

The regular Django serializer would display the fields in the Django API as dropdowns.

Is there a way to get that information straight from the same Django API view and use it in Vue 3? Or do I have to perform Vue->Django API request for each field to get the needed information?

0 Answers
Related