Commit c78f773d authored by chris's avatar chris

content/models: ForeignKey(unique=True) is usually better served by a...

content/models: ForeignKey(unique=True) is usually better served by a OneToOneField. Migration file. Fix Page save method.
parent e92ed525
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('content', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='agenda',
name='page',
field=models.OneToOneField(to='content.Page'),
),
migrations.AlterField(
model_name='press',
name='page',
field=models.OneToOneField(to='content.Page'),
),
migrations.AlterField(
model_name='reference',
name='page',
field=models.OneToOneField(to='content.Page'),
),
]
......@@ -20,11 +20,9 @@ class Page(models.Model):
class Meta:
ordering = ['weight']
def save(self):
#if not self.id:
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
#self.lnk = "/" + self.folder.slug + "/" + self.slug
super(Page, self).save()
super(Page, self).save(*args, **kwargs)
class Image(models.Model):
page = models.ForeignKey(Page)
......@@ -53,14 +51,14 @@ class Video(models.Model):
return self.title
class Agenda(models.Model):
page = models.ForeignKey(Page, unique=True)
page = models.OneToOneField(Page)
text = RichTextField(blank=True,null=True)
def __unicode__(self):
return "Agenda " + str(self.page)
class Press(models.Model):
page = models.ForeignKey(Page, unique=True)
page = models.OneToOneField(Page)
image = ImageField(upload_to="images",blank=True,null=True)
text = RichTextField(blank=True,null=True)
......@@ -71,7 +69,7 @@ class Press(models.Model):
verbose_name = 'Press review'
class Reference(models.Model):
page = models.ForeignKey(Page, unique=True)
page = models.OneToOneField(Page)
text = RichTextField(blank=True,null=True)
def __unicode__(self):
......
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