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

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/

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED