Django plus PHP [ID:152] (3/5)
in series: PyCon-Tech: The Python behind PyCon
video tutorial by Doug Napoleone, added 03/07
Our authors tell us that feedback from you is a big motivator. Please take a few moments to let them know what you think of their work.
We dive into the source code behind the PyCon web site and how we integrate the PHP based PMWiki with Django using a custom Template Loader.
The loader allows for loading PHP source from any other template loader, including django flatpages (stored in database). Included is a demonstration of integrating django into a WordPress site.
Information on accessing the source code can be found on the PyCon-Tech wiki page.
Uploaded on 18th February 2007, running time 24 minutes.
Got any questions?
Get answers in the ShowMeDo Learners Google Group.
Video statistics:
- Video's rank shown in the most popular listing
- Video plays: 865 (since July 30th)
- Plays in last week: 4
- Published: Sometime before 1st March 2007 (in other words - we don't remember!)
Thank-yous, questions and comments
If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?
You may also want to see our ShowMeDo Google Group to speak to our active users and authors.
All comments excluding tick-boxed quick-comments
Very useful. Did you publish the source code as well?
Hi Doug, really nice work. I'm going to watch it again to understand the details better.
I have intergated django app into mediawiki once using apache server side includes - It was real pain the the butt to get it right!
Your solution looks great, the only concern that may be left is working with dynamic content - where both php and django stuff is dynamic. May be asking for some tweaks in caching?
Thanks for your effort creating and publishing the screencast.
Cheers,
Evgeny.
That was a great presentation of how PHP can be pushed through Django.
This is a big issue for my company right now, I am trying to convince everyone that python/django is the way forward, but they insist there is too much investment in PHP.
This is my "magic bullet"
Thanks :)
thanks all.
The PHP source is loaded from the same template lookup as any django template.
So you just need to ass the directory containing the PHP files to your TEMPALTE_DIRS in your settings file (no need to copy anything). This is the key to getting it to work actually as your PHP may be loading other PHP modules and it should be doing so in the standard way.
As for the URL hierarchy, that all comes down to how you have your server configured. Your Django code needs to be under a different set of URL's and your server needs to properly dispatch to the proper service. You can do just about anything you want to do, thus my vague statement. For apache just set up your rules and rewrite rules properly to have the urls you want served up as php, going to php, and the django urls going to django. You have to do that no matter what. The template loader trick is just to help you have one set of master PHP page templates used by both your PHP code and by django.
The PHP source is loaded from the same template lookup as any django template.
So you just need to ass the directory containing the PHP files to your TEMPALTE_DIRS in your settings file (no need to copy anything). This is the key to getting it to work actually as your PHP may be loading other PHP modules and it should be doing so in the standard way.
As for the URL hierarchy, that all comes down to how you have your server configured. Your Django code needs to be under a different set of URL's and your server needs to properly dispatch to the proper service. You can do just about anything you want to do, thus my vague statement. For apache just set up your rules and rewrite rules properly to have the urls you want served up as php, going to php, and the django urls going to django. You have to do that no matter what. The template loader trick is just to help you have one set of master PHP page templates used by both your PHP code and by django.
I didn't quite follow where do the PHP source come from - from the WordPress/PmWiki folder on the disk or does it have to be copied over to the Django project/application? Also, how do the URL hierarchies of the PHP and Django applications play along?
Wow!!! Good job. Could I take some of yours triks to build my own site?
