I'm migrating my project to Magic Removal. I couldn't find how to do
the equivalent of the limit_choices_to = {'name__ne' : 'John'} in Magic
Removal.
Rudolph
The Wiki documentation at
http://code.djangoproject.com/wiki/RemovingTheMagic#Changedtemplatenamesingenericviews
says that 'ne is no longer a valid lookup type'
I had a look around and in the MR version of the file
db/backends/mysql/base.py we have this;
OPERATOR_MAPPING = {
'exact': '= %s',
'iexact': 'LIKE %s',
'contains': 'LIKE BINARY %s',
'icontains': 'LIKE %s',
'gt': '> %s',
'gte': '>= %s',
'lt': '< %s',
'lte': '<= %s',
'startswith': 'LIKE BINARY %s',
'endswith': 'LIKE BINARY %s',
'istartswith': 'LIKE %s',
'iendswith': 'LIKE %s',
}
Whereas in the 0.91 release (at the location core/db/backends/mysql.py)
we have this;
OPERATOR_MAPPING = {
'exact': '= %s',
'iexact': 'LIKE %s',
'contains': 'LIKE BINARY %s',
'icontains': 'LIKE %s',
'ne': '!= %s',
'gt': '> %s',
'gte': '>= %s',
'lt': '< %s',
'lte': '<= %s',
'startswith': 'LIKE BINARY %s',
'endswith': 'LIKE BINARY %s',
'istartswith': 'LIKE %s',
'iendswith': 'LIKE %s',
}
I guess you could add the line into your own MR installation, but there
might be some side-effects (I did it as a test and got repeated entries
- I've since edited it out)
Anyone know the proper way of doing this?
Cheers,
Tone
Magic-removal replaced the "__ne" and friends with the much-clearer
"exclude()" lookup filter::
People.objects.exclude(firstname="Jacob")
Is the same as trunk's::
people.get_list(name__ne="Jacob")
Jacob
I noticed the cleaner syntax (really nice!), but I wonder how this
applies to "limit_choices_to".
Rudolph
(ie __exclude doesn't work)
Cheers,
Tone
Rudolph
Yeah. Please file a ticket. This is a bug.
Joseph
I'm afraid I can't patch this myself (yet), so I'll just be patient.
Rudolph