I am using Django ModelForms. I have a dropdown selector that allows users to select the country. The country is part of the booking model and is defined using django_countries. For example,
In models.py
from django_countries import CountryField
class Booking(models.Model)
name = models.charField(max_length=100)
country = CountryField()
In views.py I want to be able to set a default selected item in the drop down menu, for example 'United Kingdom'. I know how to do this with text fields, however cannot get it to work with the CountryField(). For example,
booking = BookingForm(initial={'name': 'mr majeika'}) //works
booking = BookingForm(initial={'country': 'United Kingdom'}) //does not work
I was hoping someone out there may be able to point me in the right direction?