Commits

Simon Meers committed c0b95be

Avoid error about registering abstract models

Comments (0)

Files changed (1)

genericadmin/admin.py

 from genericadmin.views import generic_lookup
 
 class Lookup(models.Model):
-  """
-  A `fake` model that gets registered so that we can create a custom admin
-  url without having to override the default AdminSite.
-  """
-  class Meta:
-    abstract = True
+    """
+    A `fake` model that gets registered so that we can create a custom admin
+    url without having to override the default AdminSite.
+    """
+    pass
 
 class GenericAdminModelAdmin(admin.ModelAdmin):
-  model = Lookup
-  
-  def has_add_permission(self, request):
-    return False
-  
-  def has_change_permission(self, request):
-    return False
-  
-  def has_delete_permission(self, request):
-    return False
-  
-  def get_urls(self):
-    base_urls = super(GenericAdminModelAdmin, self).get_urls()
-    custom_urls = patterns('',
-      url(r'^obj/$', self.admin_site.admin_view(generic_lookup), name='admin_genericadmin_obj_lookup'),
-    )
-    return custom_urls + base_urls
+    model = Lookup
 
-admin.site.register(Lookup, GenericAdminModelAdmin)
+    def has_add_permission(self, request):
+        return False
+
+    def has_change_permission(self, request):
+        return False
+
+    def has_delete_permission(self, request):
+        return False
+
+    def get_urls(self):
+        base_urls = super(GenericAdminModelAdmin, self).get_urls()
+        custom_urls = patterns(
+            '',
+            url(r'^obj/$',
+                self.admin_site.admin_view(generic_lookup),
+                name='admin_genericadmin_obj_lookup'),
+            )
+        return custom_urls + base_urls
+
+admin.site.register(Lookup, GenericAdminModelAdmin)