Reputation: 2790
I'm starting Django and have been following the Djangogirls blog then I try to do my own blog. But I met a problem. A blog is used to display Posts but all posts don't have the same architecture. Some user want to put more picture or code sample. For example my admin page look like:
But I suppose all the users don't want to respect this architecture.
I want my users to be able to upload images or adding code sample inside the text area. But I didn't find any resources which explain me how to do it. If you could give me some inspiration source it would be great.
Upvotes: 3
Views: 2354
Reputation: 764
A lightweight option would be to use Markdown instead of a raw text field.
This project : https://github.com/jamesturk/django-markupfield provides a field that you can choose to parse with Markdown or other parsers. This way, you can add code samples (with ```
, like in StackOverflow).
Note : the code blocks aren't colored.
You can also include images with ![my alt text](http://example.com/image.png)
, though you have to upload them somewhere on the internet.
For uploading images directly through the Django admin page, you may use an ImageField
Upvotes: 1
Reputation: 11615
I think you make be looking for a rich text editor if I understand your question correctly.
There are two rich text editors that are (seemingly) the most popular tinymce and ckeditor.
Here's a link to a few answers that may be of use to you for the admin part:
django-ckeditor-to-django-admin and django-admin-tinymce-integration
Both of which can turn your text area into rich text editors with the ability to insert code, images, even math etcetera.
You stated in your question:
I want my users to be able to upload images or adding code sample inside the text area.
Which seems to fit the above options (or another editor).
Upvotes: 6