issues with django-ckeditor : acts like regular TextField - django

I am trying to use the django-ckeditor in my models / forms.
However, the RichTextField or CKEditorWidget seem to work like regular
text field. This happens both on the admin site and in my own forms.
I followed the installation guide as explained here :
https://github.com/shaunsephton/django-ckeditor
I feel like there is some step I did wrong or something else I forgot
to install, because there are no error message.
Thanks for helping.

Did you remember to attach the JS to your forms as discussed? Do you see any errors at the JS console?

Related

Django Banners in Admin

Hi I am looking for advice on setting up side banners on my Django app that can be edited through the admin panel, in a similar way to Wordpress where I can just insert the link into the primary sidebar. I have searched the net extensively and still can't find anything to point me in the right direction. I checked Django-ads but the documentation is a little hard to follow, so I am wondering if anyone has any suggestions for a simpler solution.
I would like the following functionality
- Create custom banner from admin panel
- Ability to resize
- Preferably ability to add multiple different types/sizes
I understand that this question is a little vague / no example, but if anyone has done something similar I would greatly appreciate a nudge in the right direction.
Thanks in advance
You can add "description" key onto fieldsets attribute inside admin.py of your app, like:
from django.contrib import admin
class AdminClass(admin.ModelAdmin):
fieldsets = ((None,{"fields":<fields_list>,"description":"Your banner"},))
To decorate with html styles, also you can:
from django.utils.html import format_html
...,"description":format_html("<html_tags style='[styles]'>Your Banner</html_tags>")},)))
And register
admin.site.register(YourModel,AdminClass)

Adding non-CMS (Django) page to Wagtail menu

I may not be understanding something obvious, but I'm struggling to add a (top-level) menu item to my Wagtail based menu that hooks to a page rendered by an included app that doesn't know about Wagtail. Ideally, it is just a normal Django TemplateView with standard urlconf, though I may need to add some custom code.
If I use the custom URL in the menu editor, I get a not found from Wagtails core.serve. I've looked at snippets, wagtail hooks, RoutablePageMixin, and the custom URL in the menu editor and none seem like it accomplishes what I'm trying to do.
It may well be that I'm simply misunderstanding the docs, but is there a simple example of someone doing this? The closest I've found so far is https://www.caktusgroup.com/blog/2016/02/15/wagtail-2-steps-adding-pages-outside-cms/. I've also searched https://docs.wagtail.io/en/v2.4/advanced_topics/third_party_tutorials.html to now avail. Any guidance appreciated.
Thx,
--Don
Hope this is useful, but it seems that my problem was not the mixing of Wagtail and non-Wagtail items - it was in my URLConf - Wagtail.core.serve occurred before the Django url I was trying to reach and was trying to respond. Once I reordered the URLConf appropriately, I am getting the view as I wanted.
Sigh...

django-tinymce modern theme

I'm having issues getting the modern theme to work with django-tinymce. Both the simple and the advanced themes render correctly, but when I switch to the modern theme nothing renders and I get a 404 error for /static/tiny_mce/themes/modern/editor_template.js in the console
I am attempting to do all of this in the django admin. The error is coming from /static/tiny_mce/tiny_mce.js which is interesting because I don't have anything installed in that directory. I'm using /static/js/tinymce as my TINYMCE_JS_ROOT in settings.py. When switching between simple and advanced theme, everything works correctly.
I've tried to copy a version of editor_template.js in the exact location it's looking, but I still get the 404. It's like it wipes out /static/tiny_mce if it exists and replaces it with something, but I can't figure out how/where it's getting that from.
I'm using an install of TinyMCE 4.1.3 from http://www.tinymce.com/download/download.php and django 1.6.5
I've been struggling with TinyMCE recently, as well. I'm using TinyMCE v4 and Django 1.6. I went down the django-tinymce/django-flatpages-tinymce route because I had these working on another project. Some how it wasn't working for this new project. I did some research and decided to just go straight TinyMCE, no Django applications (eg, no django-tinymce or django-flatpages-tinymce).
This method cuts down on all configuration in Django, and it can be completely handled within the tinymce.init call. I found this much easier than dealing with Django's settings files, overriding models, etc. Just simply find the template you want TinyMCE to spice up and add the init call there.
The example here for full featured example really helped me:
http://www.tinymce.com/tryit/full.php
This use the modern theme...
I simply added this to whichever change_form.html template for whatever model I was needing the rich editor. For instance for flatpages:
admin/flatpages/flatpage/change_form.html
Or custom model in app:
admin/custom_app/model_name/change_form.html
I know this is exactly an answer to your question, but I think it's worth thinking about and might help you ultimately get what you need.
Also, I should note, it looks like only modern theme is available for TinyMCE v4:
http://www.tinymce.com/wiki.php/Tutorial:Migration_guide_from_3.x

django on apache - admin page links are VISIBLE but not CLICKABLE

I have just deployed a django site, and upon changing the value my DEBUG variable to 'False' causes my admin page links to change from active links to simple text.
An attempt to go directly to what I know should be the URL causes a 'TemplateDoesNotExist'.
I am sure it's not a permissions issue with Apache, I feel it is something to do with my admin configuration though I have no idea what.
I figured it out. Here is a reference for anyone else who might find themselves with this problem.
I was using what must be a deprecated method of defining my Admin models - I put them all in models.py, instead of creating a separate admin.py file for each application.
When learning django, there are plenty of tutorials floating around that recommend or give examples that use this method. Apparently this is no longer a good idea (at least not as of Django 1.4). It could probably be wrangled into working with some template hacking, but it is is probably cleaner and definitely simpler to just follow the latest conventions and create the admin.py file.
I thought I was saving time by just cramming it all into one file "for now" but without some of the magical debug-only template loading, this solution failed.
Hope this saves someone some frustration!
I know this question's been already solved.
But in my case, coming from django 1.7 to a server that runs django 1.6, I had to add
admin.auto_discover()
to my urls.py.
Well, I had added this line to the end of urls.py and django admin was all characters !
Moving it to top up the file, above definition of urlpatterns, fixed the issue.
Hope this helps :)

Django Markdown or WYSIWYG editor

I have user generated context that extends multiple paragraphs. I'd like to enable the user to create paragraphs, possibly change font-weight, but nothing too huge.
I've seen a tutorial which uses the Python-Markdown module. Would anyone recommend this or should I just go with a WYSIWYG plugin? I've seen plugins for the admin but have not yet seen it applied to a general Django template.
Thanks
Brendan
I have used django tiny-mce with tinymce in my comment app and is working. Defining plugins for this WYSIWYG editor is easy and comes only to specifying name of plugin in settings.py and JS file.
MarkItUp! editor can help http://markitup.jaysalvat.com/
It have many rich features, includes django model class MarkupField(models.TextField), JS-settingynized editor's toolbar, etc.