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?

-- 
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.

Reply via email to