Applying ckeditor to a textarea - django

I am trying to add the (inline) CKEditor 5 to an existing django project.
From what I understand the inline version does not work with textarea elements but rather with div's. However the django forms do not have div widgets. I'm not entirely sure what is the best way to proceed from here. I can make the editable div show up using the steps in the documentation. But how do I associate it with a form and / or pass the text on to my views?

Rather than doing this manually with django, there's already a package you can import to your project: https://github.com/django-ckeditor/django-ckeditor.
You can see other WYSIWYG editor django integrations at https://djangopackages.org/grids/g/wysiwyg/

Related

Is it possible to completely override Django's auto admin theme?

I want to use one of the many bootstrap responsive themes to override Django's auto admin style. I've only donde the tutorial but I'm not sure if messing with the CSS will break the tool. Is it possible?
Django documents have a section on overriding admin templates.
There is someone also has port twitter bootstrap for Django admin. You should take a look at django-admin-bootstrap. Works on Django 1.7+.

Create custom django widget for timefield with now option

I have models with datetimefields and timefields. When the user interacts with these fields in a form they often just need to enter the current time. I need a now link almost exactly like what shows up in the django admin, so the user can just click it and the current time gets put in the field.
I tried looking through the django source but it seems to utilize some frontend javascript which I'm not very familiar with. Is there a simple way to make a widget that can be easily used in a timefield and datetimefield?
So this is not on the admin panel? As in on the site? Then this is not really a question to be posed to Django, I suggest tagging javascript. If you are unfamiliar with javascript, then tag jquery, they have things for this.
In case you're lazy, here's a start:
Here
jQuery premade
Javascript methods
Sorry, but this is more of a UI issue than a Django issue. Hope I helped, though.

What are some Apps or add ons that get used to customize Django Admin

Im looking for a list or just suggestions on some Django Admin must haves or things that people tend to use.
I'm particularly interested in adding a Wysiwyg or Markdown Editor to the the TextAreas in the Django Admin.
Any suggestions?
There are a number of apps that add wysiwyg editors to Django's admin, such as django-wysiwyg. There are also a couple of articles on this subject in Django's wiki. Some other django apps that are great for admin customization are django-admin-tools and grappelli. Beyond being a general ovehaul of the user interface, grappelli also includes support for the inclusion of a wysiwig editor. And as always, the Django docs are usually a good first stop.
Personanlly, I'm particularly fond of grappelli, it's been used to great effect on a number of Django projects, including mezzanine and a few of my own! Here's a preview of the facelift it gives Django's admin:
Have you take a look at this list ?
I use the django-adimin-tools myself, it lets you create custom menus and custom dashboard as well as custom css. Here is what it looks like pretty much out of the box. Items are draggable. More on that here.
I also used django-admin-bootstrapped which uses twitter bootstrap to make the admin look nicer. more information on it here.
Grapelli is probably the most popular though and I have been using it in my Mezzanine apps but haven't yet tried it in a vanilla Django app as of yet.

Use django text plugin for model fields in custom plugin

Hi this is a long shot i think but here goes.....
Basically i have a few custom plugins and apps being used in my django /django-cms site. I have set tinymce up which is working fairly ok however what im wondering is it possible to use the built in text plugin for the TextField model fields in my custom plugins and apps?
so in effect the info text field for my main content plugin would actually render in the admin site as the text plugin
Like i said i think this is a long shot...
You cannot use single-plugins on models, however you can define PlaceholderFields on your custom models to put cms plugins in. So you can define a PlaceholderField, put a TextPlugin inside that placeholder and do whatever you want.
For more information, read the official documentation about this http://docs.django-cms.org/en/2.1.3/extending_cms/placeholders.html
I also had this requirement (formatted text on a django-cms plugin configuration) and ended up with the following workaround:
I installed django-tinymce and changed my TextField to an HTMLField in the CMS plugin configuration model. This will render a tinymce text editor in the plugin configuration form. You can then use the input from the HTMLField in your plugin template with the ...|safe filter.

Django form to enter/save html to database

I'm in my first week of Django development and am working on an admin page that will let me write some quick html using TinyMCE and then save it to the database. I don't need to display this web page on the site or add it to urls.py, etc. The html snippet will be loaded from the database and used in a view function.
I've read in "Practical Django Projects" how to integrate TinyMCE, so my question is more concerned with the best approach for the form itself. Specifically:
1. Is there a built-in form like flatpage that works well for this? I only need one field in the form for the html.
2. How do I save the form's text after it's entered?
I created a model with a JSONField to save the html in, but I'm not clear on what to do next. Thanks.
here is the documentation for Django Flatpages App, maybe you serve.
I ended up using the ModelAdmin class to get what I wanted. I created a new model in models.py and then used ModelAdmin to enable an admin-editable form for the model's data.
Hope this helps someone.