On Sunday, January 9, 2011 6:40:17 PM UTC, Shantp wrote: > > I am using a Manager on a model based on a Boolean field to filter the > objects displayed on the site while showing all objects in the admin > unfiltered. The idea is that user's are submitting Locations but I do > not want them to show on the site until they have been verified as a > valid location based on my criteria. > > models.py > > class LocationManager(models.GeoManager): > def get_query_set(self): > return super(LocationManager, > self).get_query_set().filter(verified=True) > > class Location(models.Model): > verified = models.BooleanField(default=False) > objects = LocationManager() > admin_objects = models.Manager() > > admin.py > > class LocationAdmin(admin.OSMGeoAdmin): > def queryset(self, request): > qs = self.model.admin_objects.get_query_set() > return qs > > admin.site.register(Location, LocationAdmin) > > In the admin, when I go into a record and check the verified Boolean > to True and press save, I get an IntegrityError: > > duplicate key value violates unique constraint > "localshare_location_pkey" > traceback: http://dpaste.com/299829/ > > This worked on another project when default was True and I filtered > for False. I am using Postgres. Does anyone know why this is not > working or have suggestions for a better way to achieve this?
This doesn't have anything to do with filtering on the boolean. As you state, this happens when you *save* - integrity errors are raised by the database when you try and update a row with data that violates one or more constraints. In your case, you seem to have a unique constraint in the Location model - did you previously have a unique=True on the boolean field? If so, you'll need to remove it from the db manually. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. 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.

