Skip to content

Commit

Permalink
Add modules and migrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarcruz committed Jul 5, 2015
1 parent 31f2a97 commit da68c28
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
30 changes: 30 additions & 0 deletions world_regions/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django_countries.fields


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='Region',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=25)),
('code', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='RegionCountry',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('country', django_countries.fields.CountryField(unique=True, max_length=2)),
('region', models.ForeignKey(related_name='countries', to='simple_regions.Region')),
],
),
]
Empty file.
15 changes: 15 additions & 0 deletions world_regions/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.db import models
from django_countries.fields import CountryField


class Region(models.Model):
name = models.CharField(max_length=25)
code = models.CharField(max_length=3)

def __unicode__(self):
return self.name


class RegionCountry(models.Model):
country = CountryField(unique=True)
region = models.ForeignKey(Region, related_name="countries")
3 changes: 3 additions & 0 deletions world_regions/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.

0 comments on commit da68c28

Please sign in to comment.