Hello, I'd like to know if there is some way for reutilizing a view.

In my case, I have an application to show some data, but I want to
show the same data in the front page, among other data from other
models.
Well, I have figured out this method:

def myview(request, returnHTTP=True):
    t = loader.get_template('template.html')
    ...
    c = RequestContext(request,{ 'data':data })
    if returnHTTP:
        return HttpResponse(t.render(c))
    else:
        return data

and in the view of the front page:

def front-page(request):
    from someApp.views import myview
    data = myview(request,False)


Is this ok? Perhaps there is a better way of doing it with django.
Thank you very much.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to