<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Digamber Jha</title>
    <description>The latest articles on DEV Community by Digamber Jha (@kumardigamberjha).</description>
    <link>https://dev.to/kumardigamberjha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F851996%2F8f669f6b-b274-4162-afb9-efd5792037f8.png</url>
      <title>DEV Community: Digamber Jha</title>
      <link>https://dev.to/kumardigamberjha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kumardigamberjha"/>
    <language>en</language>
    <item>
      <title>How to add Rich Text Editor Field in Django?</title>
      <dc:creator>Digamber Jha</dc:creator>
      <pubDate>Fri, 22 Apr 2022 21:27:04 +0000</pubDate>
      <link>https://dev.to/kumardigamberjha/how-to-add-rich-text-editor-field-in-django-5ahg</link>
      <guid>https://dev.to/kumardigamberjha/how-to-add-rich-text-editor-field-in-django-5ahg</guid>
      <description>&lt;p&gt;Sometimes we need a field to get data other than a paragraph or heading tag that field is called the text area field. This field is used to get the long text as input from the user. Or we can say that we use the text area field as an alternative to the input field to get the long input from the user. The Syntax of the text area filed is:  &lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax:
&lt;/h2&gt;

&lt;blockquote&gt;

&lt;/blockquote&gt;

&lt;p&gt;But the text area field is quite simple and we can’t get the option to format the text or change the layout of the text and add images to the text area field. So, we use Rich Text Editors for design purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rich Text Editor:
&lt;/h2&gt;

&lt;p&gt;The rich-text editor is based on an open-source application called CKEditor. For more information on the CKEditor, you may also refer to the following website.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://ckeditor.com/docs/"&gt;https://ckeditor.com/docs/&lt;/a&gt;   &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We will use the rich text editor field as the Rich Text field in Django Model. It is an external Package, so we need to download it before implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to download Rich Text Editor for Django:
&lt;/h2&gt;

&lt;p&gt;For downloading we need to install the following package using the pip command. After Installing we have to add it to the installed app which will placed in project’s folder.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;pip install django-ckeditor&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The above commands will install the package of the latest Django on your local machine. And ck-editor packages and its built-in files into our local machine.&lt;/p&gt;

&lt;p&gt;After installation add it to the Installed app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Settings.py:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
    'website',
    'ckeditor',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, we are able it to just import and use the Rich Text Editor Field in Django.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Models.py:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models
from ckeditor.fields import RichTextField
class Blogs(models.Model):
    title = models.CharField(max_length=200)
    desc = RichTextField()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we need to do &lt;em&gt;makemigrations&lt;/em&gt; and &lt;em&gt;migrate&lt;/em&gt; to apply the changes at the database.&lt;br&gt;
And done!&lt;br&gt;
You have successfully installed Rich Text Editor Field in Django.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Other Blogs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://coding-india.herokuapp.com/blogs/readblog/3/"&gt;A Step-By-Step Tutorial For Coding Your First HTML Document&lt;/a&gt;&lt;br&gt;
&lt;a href="https://coding-india.herokuapp.com/blogs/readblog/10/"&gt;Complete CSS Grid Tutorial | Learn CSS by practicing it&lt;/a&gt;&lt;br&gt;
&lt;a href="https://coding-india.herokuapp.com/blogs/readblog/11/"&gt;How to deploy django on heroku server?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://coding-india.herokuapp.com/blogs/readblog/5/"&gt;What is virtual environment and how to use it in python?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://coding-india.herokuapp.com/blogs/readblog/12/"&gt;What are the file structure of django projects and apps and how to create django project and apps&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
