django + TinyMce

212 views
Skip to first unread message

Владислав Иванов

unread,
Aug 20, 2012, 2:36:22 AM8/20/12
to django...@googlegroups.com
Hello! I am a novice. I want to install TinyMce on Django. I tried a lot of lessons posted on the Internet, nothing. 3 days can not adjust. Please tell me a link to a detailed and clear tutorial

Diego pascual lopez

unread,
Aug 20, 2012, 6:59:38 AM8/20/12
to django...@googlegroups.com
Hi, 


Regards.

On Mon, Aug 20, 2012 at 8:36 AM, Владислав Иванов <vlad...@gmail.com> wrote:
Hello! I am a novice. I want to install TinyMce on Django. I tried a lot of lessons posted on the Internet, nothing. 3 days can not adjust. Please tell me a link to a detailed and clear tutorial

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/C6JhwE-x8PgJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Aljoša Mohorović

unread,
Aug 20, 2012, 7:08:07 AM8/20/12
to django...@googlegroups.com

miigaa ..

unread,
Aug 20, 2012, 2:38:55 AM8/20/12
to django...@googlegroups.com

Aljoša Mohorović

unread,
Aug 20, 2012, 7:10:09 AM8/20/12
to django...@googlegroups.com
HTMLField() is probably the easiest way to use django-tinymce:
http://django-tinymce.readthedocs.org/en/latest/usage.html#the-htmlfield-model-field-type

let me know if you have any issues.

Amyth Arora

unread,
Aug 20, 2012, 7:46:38 AM8/20/12
to django...@googlegroups.com
Hey there, i could not really find a detailed step by step tutorial on
setting tinyMCE on django, so i did one for you and for others, you
can check it out here
http://techstricks.com/django-tinymce-tutorial-step-by-step/ and feel
free to ask any question if you face any problems
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>



--
Thanks & Regards
----------------------------

Amyth [Admin - Techstricks]
Email - aroras....@gmail.com, ad...@techstricks.com
Twitter - @a_myth_________
http://techstricks.com/

Владислав Иванов

unread,
Aug 20, 2012, 12:07:40 PM8/20/12
to django...@googlegroups.com
Thank you all. I used a tutorial Amyth, but I still could not run-error 'MediaDefiningClass' object is not iterable. The following are my files, help reshist problem.
admin.py

from dipkurs.models import Disciplina, Raboty, Tipes

from django.contrib import admin

from tinymce.widgets import TinyMCE


class RabotyAdmin(admin.ModelAdmin):

list_display = ('tema', 'predmet', 'tip', 'pub_date')

list_filter = ['predmet']

search_fields = ['tema']


class TinyMCEAdmin(admin.ModelAdmin):

def formfield_for_dbfield(self, db_field, **kwargs):

if db_field.name in ('anounce', 'soderz', 'istochnik'):

return db_field.formfield(widget=TinyMCE(

attrs={'cols': 80, 'rows': 30},

mce_attrs={'external_link_list_url': reverse('tinymce.views.flatpages_link_list')},

))

return super(TinyMCEAdmin, self).formfield_for_dbfield(db_field, **kwargs)



admin.site.register(Raboty, RabotyAdmin)

admin.site.register(TinyMCEAdmin)

admin.site.register(Tipes)

admin.site.register(Disciplina)


models.py

#!/usr/bin/env python

#-*-coding:utf-8-*-

import os.path

from django.db import models

import datetime

from django.utils import timezone


class Disciplina(models.Model):

predmet = models.CharField(max_length=1000)


def __unicode__(self):

return self.predmet


class Meta:

verbose_name_plural = "Дисциплины"



class Tipes(models.Model):

tip = models.CharField(max_length=100)


def __unicode__(self):

return self.tip


class Meta:

verbose_name_plural = "Типы работ"



class Raboty(models.Model):

tema = models.CharField(max_length=300, verbose_name="Тема работы")

tip = models.ForeignKey(Tipes, verbose_name="Тип работы")

pub_date = models.DateTimeField('Дата публикации')

keywords = models.TextField(verbose_name="Ключевые слова")

predmet = models.ForeignKey(Disciplina, verbose_name="Предмет")

anounce = models.TextField(verbose_name="Описание работы")

soderz = models.TextField(verbose_name="Содержание")

istochnik = models.TextField(verbose_name="Список литературы")


class Meta:

verbose_name_plural = "Работы"


def __unicode__(self):

return self.tema


def was_published_recently(self):

return self.datetime.timedelta(days=1)




понедельник, 20 августа 2012 г., 17:46:38 UTC+6 пользователь Amyth написал:

Amyth Arora

unread,
Aug 20, 2012, 5:03:19 PM8/20/12
to django...@googlegroups.com
you are getting the error because you are not register the tinyMCE
correctly, the line that is causing this error is:

admin.site.register(TinyMCEAdmin)

you need to specify a model class as the first argument and then the
ModelAdmin class, for example:

admin.site.register(TinyMCEModel, TinyMCEModelAdmin)

also be sure of the order of the arguments , the first has to be the
Model Class and Second one should be a ModelAdmin class.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/JaEEDUuEWfEJ.

lakesh

unread,
Aug 21, 2012, 12:43:35 AM8/21/12
to django...@googlegroups.com

Kolbe

unread,
Aug 21, 2012, 1:04:49 AM8/21/12
to django...@googlegroups.com
Here's a good reference.

http://www.hackedexistence.com/project/django/video4-tinymce.html


On Monday, August 20, 2012 2:36:22 PM UTC+8, Владислав Иванов wrote:

Владислав Иванов

unread,
Aug 21, 2012, 6:39:20 AM8/21/12
to django...@googlegroups.com
Guys, Thanks!! I have converted my class and I did it!  But displays the text along with the styles for some reason:

<p><span style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: left;">Дипломная работа была выполнена в 2010 г. специалистами Учебного центра Рефермейкер по индивидуальному заказу.</span><br style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: left; padding: 0px; margin: 0px;" /><span style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: left;">Общий объем дипломной работы на тему &laquo;Женская преступность&raquo; &mdash; 78 стр., количество ссылок &mdash; 88.</span></p>

My admin.py (I think I need to put the self, but do not know where

class TinyMCEAdmin(admin.ModelAdmin):

list_display = ('tema', 'predmet', 'tip', 'pub_date')

list_filter = ['predmet']

search_fields = ['tema']


def formfield_for_dbfield(self, db_field, **kwargs):

if db_field.name in ('anounce', 'soderz', 'istochnik'):

return db_field.formfield(widget=TinyMCE(

attrs={'cols': 130, 'rows': 30},


))

return super(TinyMCEAdmin, self).formfield_for_dbfield(db_field, **kwargs)



admin.site.register(Raboty, TinyMCEAdmin)

admin.site.register(Tipes)

admin.site.register(Disciplina)



Reply all
Reply to author
Forward
0 new messages