Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Give different template for normal page and ajax raw page
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Xiaotian Tan  
View profile  
 More options Aug 19 2012, 11:22 pm
From: Xiaotian Tan <xiaotian....@butterfly.com.au>
Date: Sun, 19 Aug 2012 20:22:04 -0700 (PDT)
Local: Sun, Aug 19 2012 11:22 pm
Subject: Give different template for normal page and ajax raw page

Hi, I am trying to create a custom content type which support ajax.

The same url should give two template files, one is for normal html page, another is just raw page. I knew I can use request.is_ajax() to verify if the request is an Ajax call or not, but how can I set different template for it?

Do I have to create urls.py to make it happen or use page processors? Could any pro to guild me about this please?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ken Bolton  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 12:04 pm
From: Ken Bolton <kenbol...@gmail.com>
Date: Mon, 20 Aug 2012 12:04:06 -0400
Local: Mon, Aug 20 2012 12:04 pm
Subject: Re: [mezzanine-users] Give different template for normal page and ajax raw page
I was thinking about this recently. A mezzanine site that is about to
launch came to me with the front-end pre-built to use ajax for the
entire UX, which gave the project what I considered a very bad "smell"
of premature optimization. Now that the architecture and UX is built
to work on browsers without javascript, I have considered how best to
approach applying that ajax UX (if we really want it) to the existing
codebase. The idea that keeps floating to the top is to add an
request.is_ajax() conditional to mezzanine.pages.views.page and return
the page data as json.

Anyone else have similarly subversive thoughts?

ken

On Sun, Aug 19, 2012 at 11:22 PM, Xiaotian Tan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Schott  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 1:13 pm
From: Brian Schott <brian.sch...@nimbisservices.com>
Date: Mon, 20 Aug 2012 13:13:45 -0400
Local: Mon, Aug 20 2012 1:13 pm
Subject: Re: [mezzanine-users] Give different template for normal page and ajax raw page
We've been using djaxice for all of our ajax support, but these are in our custom apps.
http://www.dajaxproject.com

Is it bad form to return .json when the page is requesting .html?  Not familiar with how request.is_ajax() is used, but sounds like a reasonable approach to just serialize the page object into json conditionally.

-------------------------------------------------
Brian Schott, CTO
Nimbis Services, Inc.
brian.sch...@nimbisservices.com
ph: 443-274-6064  fx: 443-274-6060

On Aug 20, 2012, at 12:04 PM, Ken Bolton <kenbol...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen McDonald  
View profile   Translate to Translated (View Original)
 More options Aug 21 2012, 4:36 pm
From: Stephen McDonald <st...@jupo.org>
Date: Wed, 22 Aug 2012 06:36:38 +1000
Local: Tues, Aug 21 2012 4:36 pm
Subject: Re: [mezzanine-users] Give different template for normal page and ajax raw page

I can see a couple of optional one-size-fits-all approaches.

In either case, based on middleware checking request.is_ajax is True:

- context data passed to template gets converted to JSON data and returned
as the response.
- list of template names to search for gets prepended with a
<template-name>-ajax.html for each template.

In my own projects I'd want the latter. Many people would want the former.
I suppose we could create two middleware classes, one for each, that aren't
enabled by default.

What do you guys think?

--
Stephen McDonald
http://jupo.org

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »