Browse Source

Add Herd model

tags/3-hours
Alireza Savand 1 year ago
parent
commit
53ef25d274
3 changed files with 44 additions and 0 deletions
  1. 1
    0
      .coveragerc
  2. 30
    0
      livestock/migrations/0002_auto_20180523_1111.py
  3. 13
    0
      livestock/models.py

+ 1
- 0
.coveragerc View File

@@ -17,6 +17,7 @@ exclude_lines =

# Don't complain about missing debug-only code:
def __repr__
def __str__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:

+ 30
- 0
livestock/migrations/0002_auto_20180523_1111.py View File

@@ -0,0 +1,30 @@
# Generated by Django 2.0.5 on 2018-05-23 11:11

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('livestock', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Herd',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150, verbose_name='herd')),
],
options={
'verbose_name': 'Herd',
'verbose_name_plural': 'Herds',
},
),
migrations.AddField(
model_name='animal',
name='herd',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='livestock.Herd'),
),
]

+ 13
- 0
livestock/models.py View File

@@ -2,9 +2,22 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _


class Herd(models.Model):
"""Herd"""
name = models.CharField(verbose_name=_('herd'), max_length=150)

class Meta:
verbose_name = _('Herd')
verbose_name_plural = _('Herds')

def __str__(self) -> str:
return self.name


class Animal(models.Model):
"""Animal model."""
id = models.IntegerField(primary_key=True, verbose_name=_('id'))
herd = models.ForeignKey(Herd, blank=True, null=True, on_delete=models.SET_NULL)

class Meta:
verbose_name = _('Animal')

Loading…
Cancel
Save