Wordpress on Django

2019-03-17 06:29发布

问题:

Can wordpress blog be installed on Django.If so please let me know the links for this.

Are there any versions of word press easily installable on Django plug and play APP.

回答1:

No.

Django is a Python framework, Wordpress is a PHP CMS.

It's like asking if you can plug a Ford motor on a white poney.

However, you can install both on the same machine, and make them share data. But it requires a professional knowledge of the topic and time.



回答2:

It doesn't really make sense to install a WordPress site into a Django project. However, you can integrate your WordPress site's database tables into your Django app(s) by writing a Django Model class for each WordPress table.

Django provides a tool, inspectdb, that you can use to build a models.py from existing WordPress (or other) database tables, like so:

manage.py inspectdb > models.py

Once you have these models, which basically represent your WordPress site, you can proceed coding in Django as usual, using Django's database-abstraction API to access the WordPress tables as needed by your app.

Hope that helps.



回答3:

I'm building a site this weekend which has some nonstandard UI, in addition to the WordPress functionality. I'm still coming up to speed on WordPress, but I know Django pretty well. If WordPress doesn't let me do what I want easily, I'll probably resort to driving WordPress from Python. So I did some poking around.

I noticed a module called django-wordpress on github tonight, which claims to provide models and views for reading a WordPress database: https://github.com/sunlightlabs/django-wordpress

I also noticed what appears to be a migration tool from WordPress to Django: http://code.google.com/p/django-wordpress-admin/

Hope this helps.



回答4:

Quick and dirty solution if you just want to add a wordpress blog to an existing django website and have the same overall look/feel (this was my use case and I have a feeling it's the most common use case).

Worked for me and I'm happy with the results: collaborate.io/blog

This is what I did:

  1. Setup a wordpress blog at url yourwebsite.com/hidden_blog
  2. Install Toolbox wordpress theme (vanilla theme that you can easily modify by editing css files)
  3. Configure django url yourwebsite.com/blog to serve html that has the wordpress blog as an iframe containing yourwebsite.com/hidden_blog
  4. Tweak wordpress Toolbox css to get same fonts
  5. Setup jquery-iframe-auto-height to automatically modify height of iframe

There are some idiosyncracies due to the iframe, but nothing serious so far. Might also cause some SEO issues down the road but much quicker than building your own CMS/blogging app in django.



回答5:

You can also have a try on django-wordpress app.

In fact it does the works what @byrandie tells: inspect the database, and create the model.

For more, it creates pip packages so you can easily add it into you project.

pip install the-real-django-wordpress