Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I have to run some benchmarks and see. I am using SQLite and I have heard some people say that it cannot handle concurrent transactions. From what I read it can handle some 50,000 transactions/ sec depending on your disk IO. For a small deli website I take it should be fine, even if the user pl

Re: Model QuerySet used in base.html template

2013-08-25 Thread Kamil Gałuszka
I'm just preferring if something have to be done before template rendering and store that in context variable. Difference to your solution is that variables are just only created before starting template rendering. In your solution you evaluate QuerySet in template rendering time. Sometimes is

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
Hey Kamil, Isn't that overkill though? templatetag was an easy solution but you still do a query on the locations model on each page load. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I simply added an assignment tag instead as follows: @register.assignment_tag def get_locations(): from store.models import Location locations = list(Location.objects.all()) return locations And use it like so in template {% get_locations as all_locations %} then can

Re: Model QuerySet used in base.html template

2013-08-25 Thread Kamil Gałuszka
Hi Radomir, If you have something like that you should use in my opinion template context processor. It's very easy to write one, because it's simple python function. Here you have some context_processor from django core: https://github.com/django/django/blob/master/django/core/context_proces

Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I am actually thinking using some sort of templatetag now instead of passing the query each time since its used in base.html. It can return the exact html string that can be displayed in base.html. Right now I have the " locations = Location.objects.all() " passed to the template in every sing

Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I wanted to add location address in the menu. I have a model called locations so this is easy enough to do. But now I have to add the queryset to every view, because every view has a template that extends base.html. So do I have to add this queryset as such to every view now? locations = Locat