Upate school class definion to not require a user when creating one
This commit is contained in:
parent
4d2b354bc0
commit
75ba289100
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 2.0.6 on 2019-09-04 14:10
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0007_usersetting'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='schoolclass',
|
||||||
|
name='users',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='school_classes', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -57,7 +57,7 @@ class User(AbstractUser):
|
||||||
class SchoolClass(models.Model):
|
class SchoolClass(models.Model):
|
||||||
name = models.CharField(max_length=100, blank=False, null=False, unique=True)
|
name = models.CharField(max_length=100, blank=False, null=False, unique=True)
|
||||||
is_deleted = models.BooleanField(blank=False, null=False, default=False)
|
is_deleted = models.BooleanField(blank=False, null=False, default=False)
|
||||||
users = models.ManyToManyField(get_user_model(), related_name='school_classes')
|
users = models.ManyToManyField(get_user_model(), related_name='school_classes', blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'SchoolClass {}-{}'.format(self.id, self.name)
|
return 'SchoolClass {}-{}'.format(self.id, self.name)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue