ANDing together results from ManyToMany Field not working

2009-06-22 Thread IanR
I have a model with a ManyToManyField. I want to return all the instances where this M2M field has specific instances of the table that the M2M field points at. For example. Model.objects.filter(m2mfield__id=1,m2mfield__id=2), so in theory this would return results in which the objects with pri

Best Convension for dealing with variables needed in every view.

2009-03-29 Thread IanR
I'm currently converting my website from PHP to Django. I've always loved python and all my backend code is in python. I figured that it might as well make the jump. So far so good, as everything has been very strait forward and a joy. It's definitely making web development fun again. I'm try

Re: Best Convension for dealing with variables needed in every view.

2009-03-29 Thread IanR
essor is made how would I add it to this list? Something like settings.TEMPLATE_CONTEXT_PROCESSORS.append(my_processor) On Mar 29, 7:19 pm, David Zhou wrote: > On Sun, Mar 29, 2009 at 7:14 PM, IanR wrote: > > I'm trying to stay a close to the suggested Django conventions as > >

How would you code a template to do this (template logic)

2009-03-30 Thread IanR
I have a grid of 51 items that I want to display in 6 columns.. Column 1-5 contain 9 elements, Column 6 contains 6 elements. This is done by creating 6 div's that are float-left and only 50px wide. So what I would do is just count in a for loop and when I hit the row limit just output a "" and i

Reverse DB lookup returns too many instances

2009-06-17 Thread IanR
I've recreated this behavior with the following examples. (using 1.0) #models.py class Building(models.Model): name = models.CharField(max_length=10) floors = models.IntegerField() class Unit(models.Model): unit_number = models.IntegerField() bedrooms = models.IntegerField() building

Reverse lookups and chaining filters doesn't work

2009-06-19 Thread IanR
Anyone have any ideas? q2 and q3 should return the same results. >>> from testing.models import Building >>> from testing.models import Unit >>> b1 = Building(name="Bld 1") >>> b1.save() >>> u1 = Unit(building=b1,bedrooms=1,bathrooms=1) >>> u1.save() >>> u2 = Unit(building=b1,bedrooms=2,bathroo

Re: Reverse lookups and chaining filters doesn't work

2009-06-19 Thread IanR
Seems to work fine if I build the query using Q's and then only use filter one. On Jun 19, 11:33 am, IanR wrote: > Anyone have any ideas? > > q2 and q3 should return the same results. > > >>> from testing.models import Building > >>> from testing.models