Do You Ever Wish You Had a Crystal Ball When Writing a Blog?

Sep 15, 2017 posted by Rishabh Khare under Python

Imagine a “crystal ball” in the world of Python: not only would companies improve the way blogs would be written, but they would have a model upon which to base future blogs. Although there is no crystal ball, it is possible to improve the quality of development in Python with the right module at your disposal.

Tackling the Challenges with Our Module

Admindjango CKEditor Blogs is a simple application developed on Django to create web-based blogs. Only authorized Django users can maintain blogs on the application. Blogs are a series of posts that are time-stamped and are typically viewed by date.

Currently, there is no proper documentation for installing CKEditor plugin which can replace Textarea field within the CKEditor field. Due to a number of settings present in the configuration files, we contributed a module to the development community along with some enhanced features. Some of the key features of the module are: 

  • CKEditor
  • SEO Fields
  • Peer review
  • Approval

Setting up the Application

With this contribution, the developer does not have to spend time on doing research related to CKEditor installation. They can follow the following steps:

  1. Add "blog" to your INSTALLED_APPS setting:

INSTALLED_APPS = [

... 'blog', 'ckeditor', 'ckeditor_uploader';

]

  1. Add the following lines to your settings.py:

MEDIA_ROOT = os.path.join(BASE_DIR, "uploads") MEDIA_URL = "/uploads/"

CKEDITOR_UPLOAD_SLUGIFY_FILENAME = False CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' CKEDITOR_IMAGE_BACKEND = "pillow" CKEDITOR_UPLOAD_SLUGIFY_FILENAME = True CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_CONFIGS = {

'default': {

'skin': 'moono', 'toolbar': 'full', 'height': 100, 'allowedContent': True,

},

}

STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/'

  1. Add the following lines in url.py file
    1. from django.conf.urls import url, include
    2. from django.conf import settings
    3. from django.views.static import serve
    4. from django.conf.urls.static import static
    5. from django.core.urlresolvers import reverse

and the following url in urlpatterns:

url(r'^ckeditor/', include('ckeditor_uploader.urls')),

and at the end of urlpatterns:

'+ static(settings.MEDIA_URL,' document_root=settings.MEDIA_ROOT)'

urlpatterns += [

url(r'^media/(?P<path>.*)$', serve, {

'document_root': settings.MEDIA_ROOT,

}),

]

  1. Once the settings are done, run "python manage.py makemigrations" to build files before creating blogs models
  2. Run "python manage.py migrate" to migrate blogs models and sync them with the database
  3. Start the development server and go to http://127.0.0.1:8000/admin/ to create a blog (enable the Admin app).
  4. Visit http://127.0.0.1:8000/blog/ to add a new blog.

How to Seamlessly Write a Blog in Python and Django?

 

     7. Click on the “+Add” symbol, located to the right of the above screen to start writing a blog. 

Django Administration

 

Category

Share this: