Commit 7972d7c5 authored by Nicolas Noé's avatar Nicolas Noé
Browse files

Better models.

parent a4756fd8
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-08 12:26
# Generated by Django 1.11.2 on 2017-06-14 13:02
from __future__ import unicode_literals
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
......@@ -14,11 +14,39 @@ class Migration(migrations.Migration):
]
operations = [
migrations.CreateModel(
name='Person',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Specimen',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('specimen_id', models.IntegerField(unique=True)),
('scientific_name', models.CharField(max_length=100)),
('depth', models.IntegerField(blank=True, null=True)),
('comment', models.TextField(blank=True, null=True)),
('identified_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='specimens.Person')),
],
),
migrations.CreateModel(
name='SpecimenLocation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
],
),
migrations.AddField(
model_name='specimen',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='specimens.SpecimenLocation'),
),
migrations.AlterUniqueTogether(
name='person',
unique_together=set([('first_name', 'last_name')]),
),
]
from django.contrib.gis.db import models
class Person(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
class Meta:
unique_together = ("first_name", "last_name")
class SpecimenLocation(models.Model):
name = models.CharField(max_length=100)
class Specimen(models.Model):
specimen_id = models.IntegerField(unique=True) # ID from the lab, not Django's PK
scientific_name = models.CharField(max_length=100)
location = models.PointField()
depth = models.IntegerField(blank=True, null=True)
identified_by = models.ForeignKey(Person)
location = models.ForeignKey(SpecimenLocation)
comment = models.TextField(blank=True, null=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment