On Wed, 2009-03-18 at 11:24 -0700, Jesse wrote:
> In the view.py I have  (def Bypub) that sends data to a template and
> paginates it.  I have a second (def TextFile) that uses the same data
> to send to a CSV file.  I would like to combine the two (def Bypub and
> def TextFile) together into def Bypub, but I'm not sure how to write
> the statements to combine two responses.

What problem are you trying to solve here? You already have two views
where the common stuff is in a separate function (the bit you've marked
as retrieving the data in a list) and the distinct stuff is in the
separate views. That ideal.

If the problem is that you want one URL to be able to access both
formats, then simplest is to create a third view that works out which of
the current two views to call and then passes onto them:

        def dispatch_view(request,...):
           # ... work out which to call somehow... 
        
           if output_format == 'csv':
              return TextFile(request)
           else:
              return Bypub(request)

Is that what you're trying to do?

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to