Changeset - 457e5739f717
[Not reviewed]
0 1 3
Ben Sturmfels (bsturmfels) - 5 months ago 2021-11-29 03:31:26
ben@sturm.com.au
Add unique constraint to Staff.username.

Previously had some duplicates for "pono" which were causing
MultipleObjectsReturned errors. A username is generally considered to be unique.
4 files changed with 52 insertions and 2 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/staff/migrations/0001_initial.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.10.7 on 2021-11-28 21:12
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    initial = True
 

	
 
    dependencies = [
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='Person',
 
            fields=[
 
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 
                ('username', models.CharField(max_length=20)),
 
                ('formal_name', models.CharField(max_length=200)),
 
                ('casual_name', models.CharField(max_length=200)),
 
                ('currently_employed', models.BooleanField(default=True)),
 
                ('date_created', models.DateTimeField(auto_now_add=True)),
 
                ('date_last_modified', models.DateTimeField(auto_now=True)),
 
            ],
 
            options={
 
                'verbose_name_plural': 'people',
 
            },
 
        ),
 
    ]
www/conservancy/apps/staff/migrations/0002_auto_20211128_2112.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.10.7 on 2021-11-28 21:12
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

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

	
 
    operations = [
 
        migrations.AlterField(
 
            model_name='person',
 
            name='username',
 
            field=models.CharField(max_length=20, unique=True),
 
        ),
 
    ]
www/conservancy/apps/staff/migrations/__init__.py
Show inline comments
 
new file 100644
www/conservancy/apps/staff/models.py
Show inline comments
...
 
@@ -7,7 +7,7 @@ class Person(models.Model):
 
    Referenced from other models (blog, events, etc)
 
    """
 

	
 
    username = models.CharField(max_length=20)
 
    username = models.CharField(max_length=20, unique=True)
 
    formal_name = models.CharField(max_length=200)
 
    casual_name = models.CharField(max_length=200)
 
#    title = models.CharField(max_length=200, blank=True)
...
 
@@ -28,4 +28,3 @@ class Person(models.Model):
 

	
 
    def biography_url(self):
 
        return u"/about/#%s" % self.username
 

	
0 comments (0 inline, 0 general)