The numeric country code for this country (as an integer). The three letter country code for this country. The two letter country code for this country. You might also want to consider using aria-label for betterĪ unicode glyph for the flag for this country. For example: įor multiple flag resolutions, use sprite-hq.css instead and add theįlag2x, flag3x, or flag4x class. Output the css classes needed to display an HTML element as the correct flagįrom within a single sprite image that contains all flags. Then consider using flag_css instead to avoid excessive HTTP requests. If you page could have lots of different flags It can be compared to other objects as if it was a string containing theĬountry code and when evaluated as text, returns the country code. The Country objectĪn object used to represent a country, instantiated with a two characterĬountry code, three character code, or numeric code. These behaviours can be overridden by using the fieldĪrguments multiple_sort=False and multiple_unique=False respectively. name ) Australia New Zealandīy default, countries are stored sorted for data consistency, and anyĭuplicates are removed. CharField ( max_length = 100 ) countries = CountryField ( multiple = True ) > for country in Incident. The field will always output a list of countries in this This field can also allow multiple selections of countries (saved as a comma filter ( country_icontains = "zealand" ). Use _name or _iname for theĮxact/ iexact equivalent: > Person. The queryset lookups contains, startswith, endswith, regex, or You can filter using the full English country names in addition to countryĬodes, even though only the country codes are stored in the database by using Use blank_label to set the label for the initial blank choice shown inįorms: country = CountryField ( blank_label = "(select country)" ) This object ( untry in the example) is a Country instance, country Country ( code = 'NZ' ) > person. Get details of the person’s country: > person = Person ( name = "Chris", country = "NZ" ) > person. CharField ( max_length = 100 ) country = CountryField ()Īny Person instance will have a country attribute that you can use to Like to help by adding a translation, please visitįor more accurate sorting of translated country names, install it with theĪ country field for Django models that provides all ISO 3166-1 countries asĬountryField is based on Django’s CharField, providing choicesĬorresponding to the official ISO 3166-1 list of countries (with a defaultĬonsider the following model using a CountryField: from django.db import models from django_countries.fields import CountryField class Person ( models. Icons static files, and a country field for models.Ĭountry names are translated using Django’s standard gettext. A Django application that provides country choices for use with forms, flag
0 Comments
Leave a Reply. |