Skip to content
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

PageExtension Not Working #6657

Open
mhavci opened this issue Mar 22, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@mhavci
Copy link

commented Mar 22, 2019

Not migration table

Where am I doing wrong?

models.py

`
from django.db import models
from cms.extensions import PageExtension
from cms.extensions.extension_pool import extension_pool

@extension_pool.register
class Person(PageExtension):

name = models.CharField(max_length=100 , null=True)
username_on_slack = models.CharField(max_length=100, blank=True, null=True)
email = models.EmailField(blank=True, null=True)


def __unicode__(self):
    return self.name

def __str__(self):
    return self.name  

`

admin.py

`
from django.contrib import admin
from .models import Person

from cms.extensions import PageExtensionAdmin

class PersonAdmin(PageExtensionAdmin):
pass

admin.site.register(Person, PersonAdmin)

`

cms_toolbars.py

`
from cms.toolbar_pool import toolbar_pool
from cms.extensions.toolbar import ExtensionToolbar
from django.utils.translation import ugettext_lazy as _
from .models import SideBarExtension

@toolbar_pool.register
class SideBarExtensionToolbar(ExtensionToolbar):

model = SideBarExtension

def populate(self):

    current_page_menu = self._setup_extension_toolbar()
 
    if current_page_menu:
     
        page_extension, url = self.get_page_extension_admin()
        if url:
         
            current_page_menu.add_modal_item(
                    _('Sidebar'),
                    url=url,
                    disabled=not self.toolbar.edit_mode
            )

`

migrations

`

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

class Migration(migrations.Migration):

initial = True

dependencies = [
    ('cms', '0022_auto_20180620_1551'),
]

operations = [
    migrations.CreateModel(
        name='Person',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('name', models.CharField(default='SOME STRING', max_length=100, null=True)),
            ('username_on_slack', models.CharField(blank=True, default='SOME STRING', max_length=100, null=True)),
            ('email', models.EmailField(blank=True, default='SOME STRING', max_length=254, null=True)),
            ('extended_object', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='cms.Page')),
            ('public_extension', models.OneToOneField(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='draft_extension', to='core.Person')),
        ],
        options={
            'verbose_name_plural': 'people',
            'ordering': ['name'],
        },
    ),
]

`
python manage.py makemigrations
python manage.py migrate

Environment

  • Python version: 3.7
  • Django version: 2.1
  • django CMS version: 3.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.