Commit 003139831016700d4834916c36a9c785d50a7afb

Authored by Felipe Henrique de Almeida Bormann
1 parent d4f5abc4

created marker model and subject relationship with them

subjects/migrations/0002_auto_20161226_2054.py 0 → 100644
... ... @@ -0,0 +1,27 @@
  1 +# -*- coding: utf-8 -*-
  2 +# Generated by Django 1.10 on 2016-12-26 23:54
  3 +from __future__ import unicode_literals
  4 +
  5 +from django.db import migrations, models
  6 +
  7 +
  8 +class Migration(migrations.Migration):
  9 +
  10 + dependencies = [
  11 + ('subjects', '0001_initial'),
  12 + ]
  13 +
  14 + operations = [
  15 + migrations.CreateModel(
  16 + name='Marker',
  17 + fields=[
  18 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
  19 + ('name', models.CharField(max_length=200, unique=True, verbose_name='Name')),
  20 + ],
  21 + ),
  22 + migrations.AddField(
  23 + model_name='subject',
  24 + name='markers',
  25 + field=models.ManyToManyField(to='subjects.Marker', verbose_name='markers'),
  26 + ),
  27 + ]
... ...
subjects/models.py
... ... @@ -8,6 +8,9 @@ from users.models import User
8 8  
9 9 from categories.models import Category
10 10  
  11 +class Marker(models.Model):
  12 + name = models.CharField( _("Name"), unique = True,max_length= 200)
  13 +
11 14 class Subject(models.Model):
12 15  
13 16 name = models.CharField( _("Name"), unique = True,max_length= 200)
... ... @@ -20,6 +23,8 @@ class Subject(models.Model):
20 23 init_date = models.DateField(_('Begin of Subject Date'))
21 24 end_date = models.DateField(_('End of Subject Date'))
22 25  
  26 + markers = models.ManyToManyField(Marker, verbose_name='markers')
  27 +
23 28 create_date = models.DateTimeField(_('Creation Date'), auto_now_add = True)
24 29 update_date = models.DateTimeField(_('Date of last update'), auto_now=True)
25 30  
... ... @@ -38,3 +43,4 @@ class Subject(models.Model):
38 43  
39 44  
40 45  
  46 +
... ...