Thanks Etienne!
By the way, the minus sign in the view was a mistake, I wanted to
write front_page. Anyway, it was just an example, in my case, the view
is called 'portada' = 'front page' in Spanish :-)
Thanks.
On 29 ago, 14:30, Etienne Robillard <[EMAIL PROTECTED]>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Grupo,
>
> I think it would be better not using the minus sign for naming your
> front page function. Also, dont put weird attributes directly in a view,
> but instead use a dictionary in your urls.py (read "Passing extra options to
> view
> functions in url_dispatch.txt).
>
> Here's a quick rewrite for the records:
>
> def myview(request, *args, **kwargs):
> if kwargs['returnHttp']:
> # do stuff here
> ...
>
> Cheers,
>
> Etienne
>
> On Wed, 29 Aug 2007 04:09:42 -0700
>
>
>
> Grupo Django <[EMAIL PROTECTED]> wrote:
>
> > 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.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.5 (FreeBSD)
>
> iEYEARECAAYFAkbVZvUACgkQdXKAffkXj4MQ/ACfT+ZbiErc/hgzo3wnJWvn/za8
> QLkAn3PJ0GeB0E47KRR9phbMgotv6F2t
> =ayKi
> -----END PGP SIGNATURE-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---