1
Via javascript. You’d also need to set up a view that knows how to return a that related author.
Example psuedo code jQuery
$(".my-admin-input").change(function() {
$.ajax({
url: 'path-to-my-view',
data: { author: $(this).val() },
success: function(response) { $(".author-city").val(response.author) })
});
});
def my_view(request):
return Author.objects.get(pk=request.GET['author']).city
You can sneak JS into django admins by…
- overloading admin templates
- overriding the relevant ModelAdmin template
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#custom-template-options - modifying the form class used in the admin and defining a Media class
https://docs.djangoproject.com/en/dev/topics/forms/media/
Source:stackexchange.com