Skip to content

Commit abeedf9

Browse files
committed
fix field clashes with in Django 1.9
Set cmsplugin_ptr and set related_name to avoid field name clashes. see django-cms/django-cms#5030
1 parent 8ab022a commit abeedf9

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.2 on 2016-03-04 04:10
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('djangocms_file', '0003_remove_related_name_for_cmsplugin_ptr'),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name='file',
18+
name='cmsplugin_ptr',
19+
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='djangocms_file_file', serialize=False, to='cms.CMSPlugin'),
20+
),
21+
]

djangocms_file/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ class File(CMSPlugin):
3939
The icon search is currently performed within get_icon_url; this is
4040
probably a performance concern.
4141
"""
42-
# Set cmsplugin_ptr and remove related_name to avoid field name clashes
43-
# with any other plugin that has a field called "file".
42+
# Add an app namespace to related_name to avoid field name clashes
43+
# with any other plugins that have a field with the same name as the
44+
# lowercase of the class name of this model.
4445
# https://github.com/divio/django-cms/issues/5030
4546
cmsplugin_ptr = models.OneToOneField(
46-
CMSPlugin, related_name='+', parent_link=True)
47+
CMSPlugin, related_name='djangocms_file_file', parent_link=True)
4748

4849
file = models.FileField(_("file"), upload_to=get_plugin_media_path)
4950
title = models.CharField(

0 commit comments

Comments
 (0)