We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error 500 when trying to Add Object from Admin Panel (Fresh Install)
(Full Pastebin)
http://pastebin.com/v1FbmBhq

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/objects/objectdb/add/

Django Version: 1.7.4
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
 'django.contrib.sites',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.flatpages',
 'django.contrib.staticfiles',
 'src.server',
 'src.typeclasses',
 'src.players',
 'src.objects',
 'src.comms',
 'src.help',
 'src.scripts',
 'src.web.webclient')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.admindocs.middleware.XViewMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
1.                     response = wrapped_callback(request, _callback_args, *_callback_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in wrapper
2.                 return self.admin_site.admin_view(view)(_args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
3.                     response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
4.         response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in inner
5.             return view(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in add_view
6.         return self.changeform_view(request, None, form_url, extra_context)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapper
7.             return bound_func(_args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapped_view
8.                     response = view_func(request, _args, *_kwargs)
   File "C:\Python27\lib\site-packages\django\utils\decorators.py" in bound_func
9.                 return func.**get**(self, type(self))(_args2, *_kwargs2)
   File "C:\Python27\lib\site-packages\django\db\transaction.py" in inner
10.                 return func(_args, *_kwargs)
    File "C:\Python27\lib\site-packages\django\contrib\admin\options.py" in changeform_view
11.         ModelForm = self.get_form(request, obj)
    File "C:\Users\codyp.PIPECOSRV0\Desktop\evennia-master\evennia\src\objects\admin.py" in get_form
12.                     'fields': admin.util.flatten_fieldsets(self.add_fieldsets),

Exception Type: AttributeError at /admin/objects/objectdb/add/
Exception Value: 'module' object has no attribute 'util'


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/objects/admin.py`
Content:
```
1 #
2 # This sets up how models are displayed
3 # in the web admin interface.
4 #
5 
6 from django import forms
7 from django.conf import settings
8 from django.contrib import admin
9 from src.typeclasses.admin import AttributeInline, TagInline
10 from src.objects.models import ObjectDB
11 
12 
13 class ObjectAttributeInline(AttributeInline):
14     model = ObjectDB.db_attributes.through
15 
16 
17 class ObjectTagInline(TagInline):
18     model = ObjectDB.db_tags.through
19 
20 
21 class ObjectCreateForm(forms.ModelForm):
22     "This form details the look of the fields"
23     class Meta:
24         model = ObjectDB
25         fields = '__all__'
26     db_key = forms.CharField(label="Name/Key",
27                              widget=forms.TextInput(attrs={'size': '78'}),
28                              help_text="Main identifier, like 'apple', 'strong guy', 'Elizabeth' etc. If creating a Character, check so the name is unique among characters!",)
29     db_typeclass_path = forms.CharField(label="Typeclass",
30                                         initial=settings.BASE_OBJECT_TYPECLASS,
31                                         widget=forms.TextInput(attrs={'size': '78'}),
32                                         help_text="This defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass. If you are creating a Character you should use the typeclass defined by settings.BASE_CHARACTER_TYPECLASS or one derived from that.")
33     db_cmdset_storage = forms.CharField(label="CmdSet",
34                                         initial="",
35                                         required=False,
36                                         widget=forms.TextInput(attrs={'size': '78'}),
37                                         help_text="Most non-character objects don't need a cmdset and can leave this field blank.")
38     raw_id_fields = ('db_destination', 'db_location', 'db_home')
39 
40 
41 class ObjectEditForm(ObjectCreateForm):
42     "Form used for editing. Extends the create one with more fields"
43 
44     class Meta:
45         fields = '__all__'
46     db_lock_storage = forms.CharField(label="Locks",
47                                       required=False,
48                                       widget=forms.Textarea(attrs={'cols':'100', 'rows':'2'}),
49                                       help_text="In-game lock definition string. If not given, defaults will be used. This string should be on the form <i>type:lockfunction(args);type2:lockfunction2(args);...")
50 
51 
52 class ObjectDBAdmin(admin.ModelAdmin):
53 
54     inlines = [ObjectTagInline, ObjectAttributeInline]
55     list_display = ('id', 'db_key', 'db_player', 'db_typeclass_path')
56     list_display_links = ('id', 'db_key')
57     ordering = ['db_player', 'db_typeclass_path', 'id']
58     search_fields = ['^db_key', 'db_typeclass_path']
59     raw_id_fields = ('db_destination', 'db_location', 'db_home')
60 
61     save_as = True
62     save_on_top = True
63     list_select_related = True
64     list_filter = ('db_typeclass_path',)
65     #list_filter = ('db_permissions', 'db_typeclass_path')
66 
67     # editing fields setup
68 
69     form = ObjectEditForm
70     fieldsets = (
71         (None, {
72                 'fields': (('db_key','db_typeclass_path'), ('db_lock_storage', ),
73                            ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
74                            )}),
75         )
76     #fieldsets = (
77     #    (None, {
78     #            'fields': (('db_key','db_typeclass_path'), ('db_permissions', 'db_lock_storage'),
79     #                       ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
80     #                       )}),
81     #    )
82 
83     #deactivated temporarily, they cause empty objects to be created in admin
84 
85     # Custom modification to give two different forms wether adding or not.
86     add_form = ObjectCreateForm
87     add_fieldsets = (
88         (None, {
89                 'fields': (('db_key','db_typeclass_path'),
90                            ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'
91                            )}),
92         )
93 
94     #add_fieldsets = (
95     #    (None, {
96     #            'fields': (('db_key','db_typeclass_path'), 'db_permissions',
97     #                       ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'
98     #                       )}),
99     #    )
100     def get_fieldsets(self, request, obj=None):
101         if not obj:
102             return self.add_fieldsets
103         return super(ObjectDBAdmin, self).get_fieldsets(request, obj)
104 
105     def get_form(self, request, obj=None, **kwargs):
106         """
107         Use special form during creation
108         """
109         defaults = {}
110         if obj is None:
111             defaults.update({
112                     'form': self.add_form,
113                     'fields': admin.util.flatten_fieldsets(self.add_fieldsets),
114                     })
115             defaults.update(kwargs)
116         return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)
117 
118     def save_model(self, request, obj, form, change):
119         obj.save()
120         if not change:
121             # adding a new object
122             obj = obj.typeclass
123             obj.basetype_setup()
124             obj.basetype_posthook_setup()
125             obj.at_object_creation()
126         obj.at_init()
127 
128 
129 admin.site.register(ObjectDB, ObjectDBAdmin)
130
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/objects/admin.py b/src/objects/admin.py
--- a/src/objects/admin.py
+++ b/src/objects/admin.py
@@ -6,6 +6,7 @@
 from django import forms
 from django.conf import settings
 from django.contrib import admin
+from django.contrib.admin.utils import flatten_fieldsets
 from src.typeclasses.admin import AttributeInline, TagInline
 from src.objects.models import ObjectDB
 
@@ -62,7 +63,6 @@
     save_on_top = True
     list_select_related = True
     list_filter = ('db_typeclass_path',)
-    #list_filter = ('db_permissions', 'db_typeclass_path')
 
     # editing fields setup
 
@@ -73,16 +73,7 @@
                            ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
                            )}),
         )
-    #fieldsets = (
-    #    (None, {
-    #            'fields': (('db_key','db_typeclass_path'), ('db_permissions', 'db_lock_storage'),
-    #                       ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'
-    #                       )}),
-    #    )
 
-    #deactivated temporarily, they cause empty objects to be created in admin
-
-    # Custom modification to give two different forms wether adding or not.
     add_form = ObjectCreateForm
     add_fieldsets = (
         (None, {
@@ -91,12 +82,6 @@
                            )}),
         )
 
-    #add_fieldsets = (
-    #    (None, {
-    #            'fields': (('db_key','db_typeclass_path'), 'db_permissions',
-    #                       ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'
-    #                       )}),
-    #    )
     def get_fieldsets(self, request, obj=None):
         if not obj:
             return self.add_fieldsets
@@ -109,9 +94,9 @@
         defaults = {}
         if obj is None:
             defaults.update({
-                    'form': self.add_form,
-                    'fields': admin.util.flatten_fieldsets(self.add_fieldsets),
-                    })
+                'form': self.add_form,
+                'fields': flatten_fieldsets(self.add_fieldsets),
+            })
             defaults.update(kwargs)
         return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)

{"golden_diff": "diff --git a/src/objects/admin.py b/src/objects/admin.py\n--- a/src/objects/admin.py\n+++ b/src/objects/admin.py\n@@ -6,6 +6,7 @@\n from django import forms\n from django.conf import settings\n from django.contrib import admin\n+from django.contrib.admin.utils import flatten_fieldsets\n from src.typeclasses.admin import AttributeInline, TagInline\n from src.objects.models import ObjectDB\n \n@@ -62,7 +63,6 @@\n     save_on_top = True\n     list_select_related = True\n     list_filter = ('db_typeclass_path',)\n-    #list_filter = ('db_permissions', 'db_typeclass_path')\n \n     # editing fields setup\n \n@@ -73,16 +73,7 @@\n                            ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'\n                            )}),\n         )\n-    #fieldsets = (\n-    #    (None, {\n-    #            'fields': (('db_key','db_typeclass_path'), ('db_permissions', 'db_lock_storage'),\n-    #                       ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'\n-    #                       )}),\n-    #    )\n \n-    #deactivated temporarily, they cause empty objects to be created in admin\n-\n-    # Custom modification to give two different forms wether adding or not.\n     add_form = ObjectCreateForm\n     add_fieldsets = (\n         (None, {\n@@ -91,12 +82,6 @@\n                            )}),\n         )\n \n-    #add_fieldsets = (\n-    #    (None, {\n-    #            'fields': (('db_key','db_typeclass_path'), 'db_permissions',\n-    #                       ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'\n-    #                       )}),\n-    #    )\n     def get_fieldsets(self, request, obj=None):\n         if not obj:\n             return self.add_fieldsets\n@@ -109,9 +94,9 @@\n         defaults = {}\n         if obj is None:\n             defaults.update({\n-                    'form': self.add_form,\n-                    'fields': admin.util.flatten_fieldsets(self.add_fieldsets),\n-                    })\n+                'form': self.add_form,\n+                'fields': flatten_fieldsets(self.add_fieldsets),\n+            })\n             defaults.update(kwargs)\n         return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)\n", "issue": "Error 500 when trying to Add Object from Admin Panel (Fresh Install)\n(Full Pastebin)\nhttp://pastebin.com/v1FbmBhq\n\nEnvironment:\n\nRequest Method: GET\nRequest URL: http://localhost:8000/admin/objects/objectdb/add/\n\nDjango Version: 1.7.4\nPython Version: 2.7.9\nInstalled Applications:\n('django.contrib.auth',\n 'django.contrib.sites',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.admin',\n 'django.contrib.admindocs',\n 'django.contrib.flatpages',\n 'django.contrib.staticfiles',\n 'src.server',\n 'src.typeclasses',\n 'src.players',\n 'src.objects',\n 'src.comms',\n 'src.help',\n 'src.scripts',\n 'src.web.webclient')\nInstalled Middleware:\n('django.middleware.common.CommonMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'django.middleware.csrf.CsrfViewMiddleware',\n 'django.contrib.admindocs.middleware.XViewMiddleware',\n 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')\n\nTraceback:\nFile \"C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py\" in get_response\n1.                     response = wrapped_callback(request, _callback_args, *_callback_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\contrib\\admin\\options.py\" in wrapper\n2.                 return self.admin_site.admin_view(view)(_args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\utils\\decorators.py\" in _wrapped_view\n3.                     response = view_func(request, _args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\views\\decorators\\cache.py\" in _wrapped_view_func\n4.         response = view_func(request, _args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\contrib\\admin\\sites.py\" in inner\n5.             return view(request, _args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\contrib\\admin\\options.py\" in add_view\n6.         return self.changeform_view(request, None, form_url, extra_context)\n   File \"C:\\Python27\\lib\\site-packages\\django\\utils\\decorators.py\" in _wrapper\n7.             return bound_func(_args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\utils\\decorators.py\" in _wrapped_view\n8.                     response = view_func(request, _args, *_kwargs)\n   File \"C:\\Python27\\lib\\site-packages\\django\\utils\\decorators.py\" in bound_func\n9.                 return func.**get**(self, type(self))(_args2, *_kwargs2)\n   File \"C:\\Python27\\lib\\site-packages\\django\\db\\transaction.py\" in inner\n10.                 return func(_args, *_kwargs)\n    File \"C:\\Python27\\lib\\site-packages\\django\\contrib\\admin\\options.py\" in changeform_view\n11.         ModelForm = self.get_form(request, obj)\n    File \"C:\\Users\\codyp.PIPECOSRV0\\Desktop\\evennia-master\\evennia\\src\\objects\\admin.py\" in get_form\n12.                     'fields': admin.util.flatten_fieldsets(self.add_fieldsets),\n\nException Type: AttributeError at /admin/objects/objectdb/add/\nException Value: 'module' object has no attribute 'util'\n\n", "before_files": [{"content": "#\n# This sets up how models are displayed\n# in the web admin interface.\n#\n\nfrom django import forms\nfrom django.conf import settings\nfrom django.contrib import admin\nfrom src.typeclasses.admin import AttributeInline, TagInline\nfrom src.objects.models import ObjectDB\n\n\nclass ObjectAttributeInline(AttributeInline):\n    model = ObjectDB.db_attributes.through\n\n\nclass ObjectTagInline(TagInline):\n    model = ObjectDB.db_tags.through\n\n\nclass ObjectCreateForm(forms.ModelForm):\n    \"This form details the look of the fields\"\n    class Meta:\n        model = ObjectDB\n        fields = '__all__'\n    db_key = forms.CharField(label=\"Name/Key\",\n                             widget=forms.TextInput(attrs={'size': '78'}),\n                             help_text=\"Main identifier, like 'apple', 'strong guy', 'Elizabeth' etc. If creating a Character, check so the name is unique among characters!\",)\n    db_typeclass_path = forms.CharField(label=\"Typeclass\",\n                                        initial=settings.BASE_OBJECT_TYPECLASS,\n                                        widget=forms.TextInput(attrs={'size': '78'}),\n                                        help_text=\"This defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass. If you are creating a Character you should use the typeclass defined by settings.BASE_CHARACTER_TYPECLASS or one derived from that.\")\n    db_cmdset_storage = forms.CharField(label=\"CmdSet\",\n                                        initial=\"\",\n                                        required=False,\n                                        widget=forms.TextInput(attrs={'size': '78'}),\n                                        help_text=\"Most non-character objects don't need a cmdset and can leave this field blank.\")\n    raw_id_fields = ('db_destination', 'db_location', 'db_home')\n\n\nclass ObjectEditForm(ObjectCreateForm):\n    \"Form used for editing. Extends the create one with more fields\"\n\n    class Meta:\n        fields = '__all__'\n    db_lock_storage = forms.CharField(label=\"Locks\",\n                                      required=False,\n                                      widget=forms.Textarea(attrs={'cols':'100', 'rows':'2'}),\n                                      help_text=\"In-game lock definition string. If not given, defaults will be used. This string should be on the form <i>type:lockfunction(args);type2:lockfunction2(args);...\")\n\n\nclass ObjectDBAdmin(admin.ModelAdmin):\n\n    inlines = [ObjectTagInline, ObjectAttributeInline]\n    list_display = ('id', 'db_key', 'db_player', 'db_typeclass_path')\n    list_display_links = ('id', 'db_key')\n    ordering = ['db_player', 'db_typeclass_path', 'id']\n    search_fields = ['^db_key', 'db_typeclass_path']\n    raw_id_fields = ('db_destination', 'db_location', 'db_home')\n\n    save_as = True\n    save_on_top = True\n    list_select_related = True\n    list_filter = ('db_typeclass_path',)\n    #list_filter = ('db_permissions', 'db_typeclass_path')\n\n    # editing fields setup\n\n    form = ObjectEditForm\n    fieldsets = (\n        (None, {\n                'fields': (('db_key','db_typeclass_path'), ('db_lock_storage', ),\n                           ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'\n                           )}),\n        )\n    #fieldsets = (\n    #    (None, {\n    #            'fields': (('db_key','db_typeclass_path'), ('db_permissions', 'db_lock_storage'),\n    #                       ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'\n    #                       )}),\n    #    )\n\n    #deactivated temporarily, they cause empty objects to be created in admin\n\n    # Custom modification to give two different forms wether adding or not.\n    add_form = ObjectCreateForm\n    add_fieldsets = (\n        (None, {\n                'fields': (('db_key','db_typeclass_path'),\n                           ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'\n                           )}),\n        )\n\n    #add_fieldsets = (\n    #    (None, {\n    #            'fields': (('db_key','db_typeclass_path'), 'db_permissions',\n    #                       ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'\n    #                       )}),\n    #    )\n    def get_fieldsets(self, request, obj=None):\n        if not obj:\n            return self.add_fieldsets\n        return super(ObjectDBAdmin, self).get_fieldsets(request, obj)\n\n    def get_form(self, request, obj=None, **kwargs):\n        \"\"\"\n        Use special form during creation\n        \"\"\"\n        defaults = {}\n        if obj is None:\n            defaults.update({\n                    'form': self.add_form,\n                    'fields': admin.util.flatten_fieldsets(self.add_fieldsets),\n                    })\n            defaults.update(kwargs)\n        return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)\n\n    def save_model(self, request, obj, form, change):\n        obj.save()\n        if not change:\n            # adding a new object\n            obj = obj.typeclass\n            obj.basetype_setup()\n            obj.basetype_posthook_setup()\n            obj.at_object_creation()\n        obj.at_init()\n\n\nadmin.site.register(ObjectDB, ObjectDBAdmin)\n", "path": "src/objects/admin.py"}], "after_files": [{"content": "#\n# This sets up how models are displayed\n# in the web admin interface.\n#\n\nfrom django import forms\nfrom django.conf import settings\nfrom django.contrib import admin\nfrom django.contrib.admin.utils import flatten_fieldsets\nfrom src.typeclasses.admin import AttributeInline, TagInline\nfrom src.objects.models import ObjectDB\n\n\nclass ObjectAttributeInline(AttributeInline):\n    model = ObjectDB.db_attributes.through\n\n\nclass ObjectTagInline(TagInline):\n    model = ObjectDB.db_tags.through\n\n\nclass ObjectCreateForm(forms.ModelForm):\n    \"This form details the look of the fields\"\n    class Meta:\n        model = ObjectDB\n        fields = '__all__'\n    db_key = forms.CharField(label=\"Name/Key\",\n                             widget=forms.TextInput(attrs={'size': '78'}),\n                             help_text=\"Main identifier, like 'apple', 'strong guy', 'Elizabeth' etc. If creating a Character, check so the name is unique among characters!\",)\n    db_typeclass_path = forms.CharField(label=\"Typeclass\",\n                                        initial=settings.BASE_OBJECT_TYPECLASS,\n                                        widget=forms.TextInput(attrs={'size': '78'}),\n                                        help_text=\"This defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass. If you are creating a Character you should use the typeclass defined by settings.BASE_CHARACTER_TYPECLASS or one derived from that.\")\n    db_cmdset_storage = forms.CharField(label=\"CmdSet\",\n                                        initial=\"\",\n                                        required=False,\n                                        widget=forms.TextInput(attrs={'size': '78'}),\n                                        help_text=\"Most non-character objects don't need a cmdset and can leave this field blank.\")\n    raw_id_fields = ('db_destination', 'db_location', 'db_home')\n\n\nclass ObjectEditForm(ObjectCreateForm):\n    \"Form used for editing. Extends the create one with more fields\"\n\n    class Meta:\n        fields = '__all__'\n    db_lock_storage = forms.CharField(label=\"Locks\",\n                                      required=False,\n                                      widget=forms.Textarea(attrs={'cols':'100', 'rows':'2'}),\n                                      help_text=\"In-game lock definition string. If not given, defaults will be used. This string should be on the form <i>type:lockfunction(args);type2:lockfunction2(args);...\")\n\n\nclass ObjectDBAdmin(admin.ModelAdmin):\n\n    inlines = [ObjectTagInline, ObjectAttributeInline]\n    list_display = ('id', 'db_key', 'db_player', 'db_typeclass_path')\n    list_display_links = ('id', 'db_key')\n    ordering = ['db_player', 'db_typeclass_path', 'id']\n    search_fields = ['^db_key', 'db_typeclass_path']\n    raw_id_fields = ('db_destination', 'db_location', 'db_home')\n\n    save_as = True\n    save_on_top = True\n    list_select_related = True\n    list_filter = ('db_typeclass_path',)\n\n    # editing fields setup\n\n    form = ObjectEditForm\n    fieldsets = (\n        (None, {\n                'fields': (('db_key','db_typeclass_path'), ('db_lock_storage', ),\n                           ('db_location', 'db_home'), 'db_destination','db_cmdset_storage'\n                           )}),\n        )\n\n    add_form = ObjectCreateForm\n    add_fieldsets = (\n        (None, {\n                'fields': (('db_key','db_typeclass_path'),\n                           ('db_location', 'db_home'), 'db_destination', 'db_cmdset_storage'\n                           )}),\n        )\n\n    def get_fieldsets(self, request, obj=None):\n        if not obj:\n            return self.add_fieldsets\n        return super(ObjectDBAdmin, self).get_fieldsets(request, obj)\n\n    def get_form(self, request, obj=None, **kwargs):\n        \"\"\"\n        Use special form during creation\n        \"\"\"\n        defaults = {}\n        if obj is None:\n            defaults.update({\n                'form': self.add_form,\n                'fields': flatten_fieldsets(self.add_fieldsets),\n            })\n            defaults.update(kwargs)\n        return super(ObjectDBAdmin, self).get_form(request, obj, **defaults)\n\n    def save_model(self, request, obj, form, change):\n        obj.save()\n        if not change:\n            # adding a new object\n            obj = obj.typeclass\n            obj.basetype_setup()\n            obj.basetype_posthook_setup()\n            obj.at_object_creation()\n        obj.at_init()\n\n\nadmin.site.register(ObjectDB, ObjectDBAdmin)\n", "path": "src/objects/admin.py"}]}