Passing a rendered Django page into a Wordpress frame - django

I have a client who has an already-completed wordpress site, and they want to add osqa.net into the site. I'm the Django dev on the project, and I'm a little behind on my wordpress.
Is there a way to embed another web application's content into a wordpress page's content?
Should I just be doing this with an iframe? I would have to pass parameters from the wordpress url into the iframe url.
edit: Ideally anything in the url after /questions (like parameters and paths) would be passed onto a django application. The django application would render a response, wordpress would take that response and include it in it's page. Are there wordpress plugins that already exist like this?

You'd need to hack OSQA to hide extraneous HTML and return only the pieces you want to include. That seems like a lot of effort for minimal benefits. I'd use an iframe.

Related

Redirecting old urls to new urls in Django

After publishing site in Django, I changed my slugs and now old pages show as errors in Google search. Is there a way to automatically redirect them without having to write an individual redirect for each page?
There are a few things you need to do to make sure that your website gets crawled properly.
In regards to the redirection, you can use django.http.HttpResponsePermanentRedirect to perform the redirection. Just keep the view, and when a user navigates to this view, redirect them to the proper URL.
You should also create a sitemap, which lists out all of the URLs for your website. You can then submit this sitemap to google using their webmaster tool if you have not already done so. This will inform their crawler of all the pages that they need to crawl without worrying on them missing some information

django redirect to subdomain with exact same url

I have a Django website accessible at codewithbishal.com. This is basically a django blog website and all the blog articles are accessible at codewithbishal.com/example/<path>
But now I want to completely restructure the website{such that it is accessible at blog.codewithbishal.com/<path>} and I do no want to lose the current SEO therefore I want to configure django redirect such that when someone launches codewithbishal.com/example/<path> through google search search result or directly through link, they are redirected to blog.codewithbishal.com/<path> instead of a 404 page and eventually google will start showing the new links instead of old once.
Update: Should I configure redirect through apache .htaccess?
You can use the Django redirects app. Just click the link and find the guide.

How to change hashbang url to history API

I'm using ember1.0-rc3, i want to change hashbang urls into normal url format (ie, www.site.com/admin#/page1 to www.site.com/admin/page1).In order to make this change,i use location: "history" in app router.
But when i reload a page or bookmark a page doesn't works, it redirects to home page only.I want the options reload and bookmark in my app, without changing redirect urls in .htaccess file.Is there any way for it?Thanks in advance
In order to use HTML5 history with a single page app like ember, your server must be have the behavior of rendering your main index.html file for any URL. The Ember router has the logic to look at the URL when it loads and go to the correct route.

Django URL conf and Backbone.js Router

I have a backbone.js single-page app that is all set up with the router (well, actually a Backbone.Marionette app with a Backbone.Marionette AppRouter, but nevertheless). However, the backend is based in Django, where I do not have the URL conf directing to views for all URLs that are already in the backbone.js routes.
Based on the existing URLs in the Django URL conf, Backbone.js will serve the backbone routes regardless of what is listed in the Django conf - it seems something, anything just needs to be there.
Do I need to have proper Django views in order to offer a fallback for older browsers/SEO?
What are the best practices to coordinate the Django URL conf and the Backbone.js Router?
I've found a post that addresses this issue quite well:
http://duganchen.ca/single-page-web-app-architecture-done-right/
Briefly, my reasoning for including a fallback is for non-javascript browsers and SEO reasons. At the time of this post, non-javascript browsers account for ~1.4% (less than 2% from everything I've read) of users, making SEO The major consideration. Again, SEO may not be relevant for everyone reading this post, in which case, this can be skipped.
I found Thomas Davis' tutorial using phantom.js quite helpful. http://backbonetutorials.com/seo-for-single-page-apps/
However, another issue that I needed to account for was the history API, which has been neglected by all but the latest IE browsers. Given my client's users, about 15% of which are using IE <= 9, this was also a problem.
In the end, I also needed to use history.js. All in all, this was a lot of work to update an otherwise very simple website. However, I learned a lot from this ordeal.
In my opinion if your backbone app is truly a single page then you don't need any django views whatsoever. You can serve your index.html as a static file (in production, not even by django) and then let backbone's router take care of your url configuration, as you're doing already. You can use backbone's history and navigate to fake urls, add urls parameters etc, for resources in your app.

Integrate existing blog code into Django-CMS?

If I already have a blog app done with Django and I want to use it with my new Django CMS site, is it okay to simply drop it into my new Django CMS project as a decoupled app and match anything /blog/ to the blog app as apposed to a Django CMS plugin? I guess what I need to know is when is it best to write my Django app as a plugin vs an entire app?
Thx
JeffC
Yes, but you don't just drop it into the urls.py, instead you can write an AppHook to tie your blog's URL scheme to a particular page in your CMS.
Plugins on the other hand are useful if you want to inserts particular aspects of you app into other page's placeholders - for example to show your latest 3 posts on the frontpage.
You might also want to include your blog's paths in a breadcrumb or menu on your site - in that case you need to write a custom Menu too.
Finally, it might also be useful to make use of django cms's placeholders in you blog model. His would allow you to post a variety of content via plugins.