파이썬 장고와 워드프레스 연동의 간단한 방법 :

Simple django wordpress integration with Django WordPress API library

Nowadays, WordPress is the most known CMS in the web. For creating and managing static content with no complex logic behind, it is a good point to start. The problem is when you need to start managing users, custom data and relate them through some degree of complexity; WordPress is not the tool to do it in the best way.

There is when Django appears, it is an awesome framework to create and personalize your website according to your needs without almost any limitations, using the thousands of Django libraries available in the web. The problem is that Django is not designed to be a CMS, so if you need it as one, it could be harder to implement than to just use WordPress. There are some Django libraries that allow to use WordPress from Django, but they are hard to intregrate and the resulting applications are hard to maintain. The other problem is that a lot of websites are already implemented in WordPress so it could be traumatic to migrate it to a Django application.

In order to make things easier, I am going to introduce you to Django WordPress Api library, DWA to his friends. It takes advantage of WP REST API v1 to connect in an easy way a WordPress blog with your Django application; allowing you to customize your Django app without giving up the tools that WordPress as a CMS presents to you. In fact, Swapps’ blog page has been created using Django, but this post has been created in WordPress and is being displayed here using this library.

How to use DWA

Let’s start with the configuration. The first thing is that you need to install WP REST API v1 plugin inside your WordPress site and enable it.
Then you need to install Django WordPress Api library inside your django application

pip install django-wordpress-api

After that, add wordpress_api inside the installed apps

INSTALLED_APPS += ('wordpress_api',)

Also, if you are using DWA Views (explained later) you need to add the wordpress_api urls in your application urls

url(r'^blog/', include('wordpress_api.urls')),

Finally, you need to set up the DWA required settings; WP_URL and BLOG_POSTS_PER_PAGE.

WP_URL = http://your-wordpress-app.com/
BLOG_POSTS_PER_PAGE = number-of-blogs-to-display-per-page

and that’s it.

DWA has two ways to be used, using its views or using its client. The views allow to retrieve and display the blog, retrieve posts details, retrieve posts by tags or by categories and search by keywords; the same as in a simple WordPress blog. This views alone will allow you to display a basic blog, as the one you are reading right now. You can see more information about it inside the documentation.

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

On the other hand, if you need something more complex you could use the wordpress_api client. It allows you to retrieve other kinds of post, beyond the “post” type, order them by another field more than “date” and use all the filters that WP API v1 allows. This could give you more control and customization inside your Django blog if your app requires it. This process is very simple, the wordpress_api client bases itself in just one main method: get_posts. You just need to provide this method with your requirements and you are ready to go. For example, the following method call will return all the ‘analysis’ type posts written by me that are in the second page, ordered by title; considering each page with the number of blogs per page defined in the settings.

wp_posts = get_posts(wp_filter={'author': 'jariza'},
                     page_number=2, orderby='title',
                     custom_type='analysis')

In conclusion, Django WordPress Api allows you to integrate your WordPress blog with your Django application using the most transparent way: an API. This way, you will be able to take advantage of all the CMS potential that WordPress provides and all the customization, personalization and simplicity that makes Django one of the best web framework out there.

The one little disadvantage is that you need to have two applications living: the WordPress one and the Django one. For already existing WordPress applications, there is no problem at all; you may simply integrate it with your django site. On the other side, if you are starting from scratch it may be harder to have two living sites; but it is easier to implement and to manage. Keep in mind that your CMS will be isolated from your actual site so you will not have to worry about bugs or misbehaviors produced by code dependencies.

If you need more information, you may always read the Django WordPress Api documentation directly.

 

[출처] https://swapps.com/blog/simple-django-wordpress-integration-with-django-wordpress-api-library/

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
46 [python][Django] [개념] Django는 Web Server가 아니라구요!! file 졸리운_곰 2023.03.11 464
45 [python][Django] [Django] Django Rest Framework에서 request 로깅하기 졸리운_곰 2023.03.11 381
44 [python][Django] Django REST Framework 졸리운_곰 2023.03.10 486
43 [python][Django] Django의 기본 개념 file 졸리운_곰 2023.03.10 473
42 Django 장고 텍스트에디터 사용하기(CKeditor) file 졸리운_곰 2020.11.22 933
41 Django Traffic Monitor + 트래픽 초과 알림 file 졸리운_곰 2020.11.22 511
40 공공 데이터 XML 크롤링을 통해 Django HTML에 띄워보기 file 졸리운_곰 2020.05.05 536
» 파이썬 장고와 워드프레스 연동의 간단한 방법 : Simple django wordpress integration with Django WordPress API library 졸리운_곰 2019.10.28 1200
38 Django의 세션을 이용한 단계별 페이지 만들기 file 졸리운_곰 2019.02.02 880
37 Django 템플릿 (Template) 졸리운_곰 2019.02.02 606
36 python django 기본 file 졸리운_곰 2018.09.02 1097
35 PyCharm과 함께 DJango와 RestFramework를 활용한 웹 사이트 구축하기 file 졸리운_곰 2018.05.22 563
34 Installing Python and Django on WampServer file 졸리운_곰 2018.02.18 740
33 python django 개요 다이어그램 file 졸리운_곰 2018.02.10 937
32 웹서버 중에서 Django를 선택한 이유 졸리운_곰 2017.08.22 1306
31 Django App 생성 file 졸리운_곰 2017.03.06 472
30 Django - 설치 및 Hello World 웹 서비스 만들기 졸리운_곰 2017.03.05 549
29 Learning Django and AngularJS 졸리운_곰 2017.02.06 1694
28 [Django 17] Django 디버깅 file 졸리운_곰 2017.01.28 1185
27 [Django 16] Django - Site Deployment 졸리운_곰 2017.01.28 598
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED