case insensitive "in" query
I have two lists of values and I need to filter a queryset to only rows in which a column's value is in one of these lists. The data is not case consistent, so if I were comparing the column to a single value I would use the "iexact" lookup type. Since I'm comparing to a list of values I'm using the "in" lookup type, but there's no way to make that case insensitive that I know of. The way I'm doing this is by looping through the list I want to exclude and doing an "iexact" lookup on each of those values. It feels like a really crappy way to do it, but I don't know of anything better. Is there an alternative? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: two column unique index?
Thanks Malcom, I don't know why I thought it didn't work last night. I guess I shouldn't try to figure out new stuff in the 13th working hour of the day. On Apr 24, 12:49 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-04-23 at 22:19 -0700, Tim Saylor wrote: > > I have two columns in my database that must be, as a pair, unique > > throughout all the rows. Googling tells me I want a two column unique > > index. From the docs it looks like unique_together is what I want, > > but that looks like it makes the two columns unique from each other > > within the row. Is there a way to do what I want? Thanks! > > It sounds like you want 'unique_together'. That specifies tuples of > columns that are unique as a tuple amongst all the rows in the table. So > if > > unique_together = [('first', 'second', 'third')] > > Then for each tuple formed from the attributes ('first', 'second', > 'third'), there can only be one occurrence in the table. > > There is no default way in Django's ORM notation to say that 'first' > must be unique amongst itself and amongst the 'second' values, etc. That > would require adding a constraint using raw SQL. > > Regards, > Malcolm > > -- > Borrow from a pessimist - they don't expect it > back.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
two column unique index?
I have two columns in my database that must be, as a pair, unique throughout all the rows. Googling tells me I want a two column unique index. From the docs it looks like unique_together is what I want, but that looks like it makes the two columns unique from each other within the row. Is there a way to do what I want? Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
attributes on a many to many relationship
In a many to many relationship, is it possible to include additional attributes besides the foreign keys in the relationship table? For example, if "Users" and "Events" have a many to many relationship, is it possible to include an attribute for "registration status", which applies to the relationship of the user and the event, but to neither individually? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---