Friday, June 29, 2012

Re: Avoiding code repetition in views

@grimmus

I have a file called shared.py, and In it, i have created a dict template_dict { } which has stuff that all the views share. I import it into views.py and any app that will use that dict. I can then add more items or alter existing ones via template_dict.update().


On Fri, Jun 29, 2012 at 9:01 AM, kenneth gonsalves <lawgon@thenilgiris.com> wrote:
On Fri, 2012-06-29 at 01:07 +0200, Christophe Pettus wrote:
> > I hope i have been clear
>
> I'm going to take a guess and surmise that you have a lot of different
> view functions, each one of which needs to pass a list of gigs into
> the context for the template and then render that page, and you're
> trying to avoid repeating the code that builds the list of gigs.  Is
> that correct?
>
> You might look at whether you really need all those separate view
> functions, or if they can be rolled together.  You might also look at
> using class-based Views in 1.4 as a way to factor out the
> gig-list-building code in a reasonable way.

or use templatetags
--
regards
Kenneth Gonsalves

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment