while creating many-to-one relationship in django using Foreignkey Choicefield is appearing instead of CharField in Django Admin Panel
Code of Views.py
from django.http import JsonResponse
from .models import Name
def names_list(request):
MAX_OBJECTS = 1
name = Name.objects.all()
data = {"results": list(name.values("Name"))}
return JsonResponse(data)
Django admin panel is showing the intended dropdown selection list.
Origin is basically a foreign key of Country model. In the Django admin panel, foreign key fields are displayed as dropdown lists.
If you want to add countries you might need to
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.