Django image insertion in Admin - django

I am building a small side project - a simple news site. I want to use the Django Admin for uploading articles and allow access to non-coders so as they can publish articles a la Wordpress or such. I have added some functionality to the admin, first trying out TinyMCE and Dojo rich text editors. However, these do not come with the ability to insert an image into an article from a file (just urls).
I really only want some light text formatting in the text area plus the ability to upload and insert images from the users's harddrive directly into the article. Is there a simple way to achieve this?

If you are already using django-tinymce, you can integrate django-filebrowser with it. See django-tinymce's documentation.
There is also a commercial choice which looks good, but I have never tested it.

Related

How to insert multiple images in the Django blog app?

What I want is similar to the stack overflow posts, I can add images in between the text, just simply copy the image and paste it in my blog while editing. is it possible?
I.ve seen some posts that can add a single image as post cover or add the designated number of images like 'must insert 3 images in a post'. that's not what I want.
Have you heard of the Django content management system (CMS) Wagtail? It really sounds like what you want is a CMS, and Wagtail is, as far as I know, the most popular and fleshed out one for Django. You can read in the Wagtail docs about inserting images in a page (tailored for editors) or using images in templates (tailored for developers).
Do keep in mind though that Wagtail is a whole CMS. If you were aiming for more limited functionality, that doesn't come with a bundle of other CMS niceties, you might want to look elsewhere.

Django model React

I'm trying some Django + React stuff and I'm a bit confused with the particular role of Django model in this scheme.
As I can understand Django model provide smooth way to create some typical forms by users of the site (please correct me). And I can't feel the edge of what should be hardcoded and what I need to store in model.
In case of React (I'm trying to connect react with django through api via djangorestframework) should I create a model for Header? And store bg image with it and my slogans. I feel it's should be purely in frontend. But next section with 3 typical screens (they will be listed horizontally and swap each other). They are just copy of each other with different data (title, bg, fg, text, link), for me it seems closer to model usage. But model initially empty and if I want to get this data from model I firstly need to somehow store this data to model.
So in general my question is what the right cases for using Django models and when it's no needed. And if it possible with applying to my example to better understanding for me )
ofc I searched this info widely but so far can't create clear understanding by myself.
Thanks )
You might actually be in search of a headless CMS.
To combine React and Django and still use a CMS to allow administrating text blocks and images, Django Wagtail's StreamField is a good choice.
https://docs.wagtail.io/en/v2.0/topics/streamfield.html
See for example our company's homepage: https://www.blu-beyond.com. It runs on Django Wagtail, having JS animated text blocks that are administered in the CMS (just jQuery and other JS libs, no React, in this case).
Django Wagtail offers a JSON API, as well, that can be used in React:
https://docs.wagtail.io/en/v2.8/advanced_topics/api/v2/usage.html#fetching-content
It also offers a GraphQL API.

WYSIWYG form for users in Django CMS

Recently I started using Django CMS, it turns out to be a great tool for web developer. But one thing I couldn't have achieved so far is creating a form for users so they could submit some content created with WYSIWYG editor. I thought maybe there's some easy way to add editor available in admin panel (the one you use with creating / modifying Text plugins), doesn't seem like that unfortunately.
Long story short - I'd like to enbable users to use the same WYISWYG editor available from admin panel, without giving them permission to access admin panel. Is it possible? Or do I have to use some additional extension so I could embed similiar editor on my Page(s)?
Maybe you should look into divio/djangocms-text-ckeditor. It offers a HTMLFieldto be parts of models and a TextEditorWidgetto be parts of your app's forms.
So based on the comments I assume, when you say "users", you mean anonymous site visitors that are not registered to the CMS? And you want to display a WYSIWYG form field to them to "submit some content"?
If my assumptions are correct, you just need to create an own plugin or maybe an app.
See http://docs.django-cms.org/en/release-3.4.x/how_to/custom_plugins.html

coldfusion - file content editing

I've got fw1 using the content of the default.cfm page as the editable content region. While this works fine for static content, I'd like to add the ability to edit the content over with fckeditor or some other in-browser WYSIWYG tool.
Is there any tool you could recommend that would make this easy? I don't want to convert to a CMS like mura, just want to login and the ability to edit the contents of about 5 files, with the possibility of creating a timestamped backup of the file.
We have the concept of a dynamic text area on some pages on applications that don't require a full on cms.
This is with ColdBox, but you should be able to implement something similar in fw1.
We have a helper component with a method that allows us to "render dynamic text" with a specific code eg. "helppagetext" in a zone in the page. We then have a very simple CRUD application using CKEditor that saves text blocks against those codes. The CRUD application is protected by a pre-existing login system.
It is pretty simple to implement something like this, especially if you already have a security and login system in place.
Hope that helps.
ColdFusion 8 and above has a built in WSYIWYG editor. It is a part of <cftextarea
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_t_02.html

How to integrate multiple image uploading with UPLOADIFY in django administration?

I met the django-uploadify (multiple file uploading) application, but the only template-use is described in wiki of the project. I need to integrate it with django admin. Any ideas?
#rebus and #Mordi have good suggestions; one of those is probably your best bet. Still...
The current implementation of file uploads in web browsers is single file only. That's a limitation of the HTML standards and the browsers themselves. When you see multiple file upload capability (all at once / select multiple) in some web app, something like Flash or Java is in play. You could potentially use a Flash or Java applet (check out Uploadify - about the easiest to work with you'll find), if you wanted, but you'd have to do some work tying it into Django: namely mapping the output of the applet to the input the Django Admin expects on POST.
Personally I found this package to be painful when I attempted to do this locally. It is 7 years old and not maintained. django-filer is a more modern implementation that has this exact functionality built into the admin panel, it was quick to set up and it seems to be maintained a lot better. And the UI is excellent!
If your really set on using uploadify my attempt was quite painful. When I went to the website to download the uploadify jQuery plugin it was a paid download. After looking a bit I found a fork, and was able to get it going locally, but because the python package is old it required a lot of changes from python 2.7..
To integrate this with your project in the admin will definitely require you to write your own custom admin template. In your admin.py you would have to override the default template and methods, this faq has some insights. In your new template you would include the uploadify jquery script and put the upload file field inside the form where your model fields would be. When you upload files the signal sender in the package will fire, and you would just have to intercept the signal and handle it with your intended logic
Very easy to implement multiple image upload with this project:
https://github.com/tstone/django-uploadify