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.
This commit is contained in:
		
							parent
							
								
									843b24c63a
								
							
						
					
					
						commit
						457e5739f7
					
				
					 4 changed files with 52 additions and 2 deletions
				
			
		
							
								
								
									
										31
									
								
								www/conservancy/apps/staff/migrations/0001_initial.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								www/conservancy/apps/staff/migrations/0001_initial.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| # -*- 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', | ||||
|             }, | ||||
|         ), | ||||
|     ] | ||||
|  | @ -0,0 +1,20 @@ | |||
| # -*- 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), | ||||
|         ), | ||||
|     ] | ||||
							
								
								
									
										0
									
								
								www/conservancy/apps/staff/migrations/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								www/conservancy/apps/staff/migrations/__init__.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue