8000 Fil 190: Adding Generic Foreign Key to Placeholder model by anirbanlahiri-fidelity · Pull Request #6452 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Fil 190: Adding Generic Foreign Key to Placeholder model #6452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
FIL-190: Added Generic Foreign Key to Placeholder model
  • Loading branch information
Anirban Lahiri committed Jul 20, 2018
commit 67cd0fed1debaba9839c6fe1a0ec429611219914
27 changes: 27 additions & 0 deletions cms/migrations/0022_auto_20180719_1638.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 0023 instead of 22 and move the others (>=0023) one number up

# Generated by Django 1.11.14 on 2018-07-19 16:38
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('cms', '0021_auto_20180507_1432'),
]

operations = [
migrations.AddField(
model_name='placeholder',
name='content_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='placeholder',
name='object_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
]
6 changes: 6 additions & 0 deletions cms/models/placeholdermodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _, force_text
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType

from cms.cache.placeholder import clear_placeholder_cache
from cms.exceptions import LanguageError
Expand Down Expand Up @@ -38,6 +40,10 @@ class Placeholder(models.Model):
cache_placeholder = True
is_static = False
is_editable = True
content_type = models.ForeignKey(ContentType, blank=True, null=True, on_delete=models.SET_NULL)
object_id = models.PositiveIntegerField(blank=True, null=True)
content_object = GenericForeignKey('content_type', 'object_id')


class Meta:
app_label = 'cms'
Expand Down
0