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

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/

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
44 [python] 크롤링한 데이터 DB에 저장하기 file 졸리운_곰 2021.01.29 3215
43 [python] 크롤러 만들어 db에 정보 insert 하기 졸리운_곰 2021.01.29 356
42 Python - mongoDB 다루기 졸리운_곰 2020.12.05 345
41 XML to JSON ( JSON to XML ) 파이썬 스크립트 변환 졸리운_곰 2020.10.04 365
40 [python] 크롤러 만들어 db에 정보 insert 하기 졸리운_곰 2020.10.02 525
39 python 으로 pdf 에서 text 문자열 추출 (뽑아내기) file 졸리운_곰 2020.09.05 1001
38 [파이썬] sqlite3 모듈 사용법 졸리운_곰 2020.05.06 510
37 Python 데이터 시각화 file 졸리운_곰 2020.05.06 587
36 파이썬 SQLite3 사용법 file 졸리운_곰 2020.05.06 450
35 How to create an SQLite3 database in Python 3 졸리운_곰 2020.04.30 40569
34 Python - Linked Lists 졸리운_곰 2020.03.25 439
33 python으로 GUID 만들기 졸리운_곰 2019.02.27 545
32 파이썬으로 구현한 기본적인 블록체인 : A Practical Introduction to Blockchain with Python file 졸리운_곰 2019.02.22 1078
31 파이썬-sql알케미-tutorial, sqlalchemy tutorial file 졸리운_곰 2018.08.27 524
30 node.js python-shell을 활용하여 python 실행 file 졸리운_곰 2018.08.14 689
29 Python, PyV8로 javascript 실행하기 file 졸리운_곰 2018.08.14 623
28 Does Python SciPy need BLAS? 졸리운_곰 2018.05.26 487
27 [파이썬으로 구현한 알고리즘] (7) 트리(Tree) file 졸리운_곰 2018.02.27 1957
26 [파이썬으로 구현한 알고리즘] (6) 쉘 정렬(Shell Sort) file 졸리운_곰 2018.02.27 771
25 [파이썬으로 구현한 알고리즘] (5) 삽입 정렬(Insertion Sort) file 졸리운_곰 2018.02.27 1033
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED