简体   繁体   中英

How can I integrate a wordpress front-end on top of my existing Django web application

I have built a new website using wordpress which looks great and has required blogging functionality.

Our old site was built using Django and looked awful but had required backend functionality built into it thanks to Django. For example on one page it has a drop down box and you select options from it and it returns data, which works fine on the Django website.

I want to integrate this functionality into the wordpress front-end somehow. Is this possible? If so can you suggest how I might do this?

I understand that wordpress is a PHP CMS, and Django is a Python framework so you can't simply click them together. But does anyone have any suggestions on how I might integrate the functionality from my existing Django website inside my wordpress front end.

I have found this question: Wordpress on Django

Which asked how to connect to wordpress from Django. But I would like to connect to Django from wordpress.

In essence I want to replicate some of the Django pages on my wordpress site, utilising the existing Django backend functionality.

Can this be done? Any suggestions as to how?

Thanks.

I will share my experience in creating a hybrid solution and although for me it was two different PHP frameworks the approach could be the same. It's not a ready-to-go solution, but maybe it will help. I will list key points.

  1. To have both Wordpress and django on the same url you have to install them on the same webserver (Apache most likely)
  2. Put django app and Wordpress site in different folders eg localhost/wordpress and localhost/django so that rewrite rules do not interfere.
  3. Write a Wordpress plugin that will store the session in the database (there are tutorials on the web, but the main idea is to implement session save/load functions and use session_set_save_handler() to register them)
  4. Write a Worpdress plugin that will add menu points for all your old backend functions (or just one menu saying "Backend")
  5. Whenever user clicks this menu simply redirect him to the localhost/django/oldfunction
  6. In django app - read the PHPSESSID from cookies, and use it to read additional session data from the database (user_id for instance) and create a session. That way you implement "Single Signon" between two apps.
  7. Adjust css-styles in django so that UI-controls in old app looks similar to the new site. That has to be done manually in most cases. The target is to make an impression this is one app. In my experience it's enough to adjust color-scheme of the UI controls, the rest doesn't matter that much.

This is a complicated approach and it's not fast but it's clean (you have two independent apps) and potentially allows slowly migrating and refactoring the old app functions into new one. The main thing here to have the access to the same database from both apps and to have them hosted on the same webserver.

Have you tried, https://github.com/agiliq/django-wordpress ?

I haven't used it yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM