Skip to content

Commit

Permalink
new migrations + tinymce admin
Browse files Browse the repository at this point in the history
  • Loading branch information
csmant committed Mar 17, 2017
1 parent df5fbcd commit 3759485
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions csnews/admin.py
@@ -1,7 +1,6 @@
from django.contrib import admin
from csnews.models import Article

from tinymce.widgets import TinyMCE
from csnews.forms import ArticleAdminForm


def show_entry_thumbnail(item):
Expand All @@ -21,6 +20,7 @@ class ArticleAdmin(admin.ModelAdmin):
search_fields = ['title', 'summary']
prepopulated_fields = {'slug': ('title',)}
photologue_image_fields = ('image',)
form = ArticleAdminForm


admin.site.register(Article, ArticleAdmin)
15 changes: 15 additions & 0 deletions csnews/forms.py
@@ -0,0 +1,15 @@
from django import forms
from django.conf import settings
from tinymce.widgets import TinyMCE
from csnews.models import Article

TINYMCE_DEFAULT_CONFIG = getattr(settings, 'TINYMCE_DEFAULT_CONFIG', {})


class ArticleAdminForm(forms.ModelForm):
desk = forms.CharField(widget=TinyMCE(
attrs={'cols': 80, 'rows': 50, }, mce_attrs=TINYMCE_DEFAULT_CONFIG))

class Meta:
model = Article
fields = '__all__'
20 changes: 20 additions & 0 deletions csnews/migrations/0002_article_seo_tags.py
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-17 13:22
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('csnews', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='article',
name='seo_tags',
field=models.CharField(blank=True, max_length=300, verbose_name='seo tags'),
),
]
1 change: 1 addition & 0 deletions csnews/models.py
Expand Up @@ -10,6 +10,7 @@ class Article(models.Model):
summary = models.TextField(_('summary'), blank=True)
body = models.TextField(_('body'))
image = models.ForeignKey(Photo, null=True, blank=True, related_name=_('news_image'))
seo_tags = models.CharField(_('seo tags'), max_length=300, blank=True)

is_public = models.BooleanField(default=True)

Expand Down

0 comments on commit 3759485

Please sign in to comment.