From 20675141c340ea3d2d6d8305f8ba0950d3bf974c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 25 Apr 2012 00:09:46 -0500 Subject: Add django_countries country code fields and population migrations This adds these columns and attempts to populate them with data from our existing country column data. Signed-off-by: Dan McGee --- mirrors/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mirrors/models.py') diff --git a/mirrors/models.py b/mirrors/models.py index 46753fac..79968412 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -3,6 +3,7 @@ from urlparse import urlparse from django.db import models from django.core.exceptions import ValidationError +from django_countries import CountryField class NullCharField(models.CharField): description = "String (up to %(max_length)s), NULL if value is empty" @@ -25,6 +26,7 @@ class Mirror(models.Model): tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES) upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) country_old = models.CharField(max_length=255, db_index=True) + country = CountryField(blank=True) admin_email = models.EmailField(max_length=255, blank=True) public = models.BooleanField(default=True) active = models.BooleanField(default=True) @@ -34,7 +36,7 @@ class Mirror(models.Model): notes = models.TextField(blank=True) class Meta: - ordering = ('country_old', 'name') + ordering = ('country', 'name') def __unicode__(self): return self.name @@ -70,6 +72,7 @@ class MirrorUrl(models.Model): mirror = models.ForeignKey(Mirror, related_name="urls") country_old = NullCharField(max_length=255, null=True, blank=True, db_index=True) + country = CountryField(blank=True) has_ipv4 = models.BooleanField("IPv4 capable", default=True, editable=False) has_ipv6 = models.BooleanField("IPv6 capable", default=False, -- cgit v1.2.3-2-g168b