A basic CRUD admin interface for Django+MongoEngine, very similar to django.contrib.admin
.
- Author: Derek Payton (http://www.dmpayton.com)
- Version: 0.1a
- License: MIT
Requirements:
- Django (1.2-ish, untested with 1.1)
- MongoEngine (0.4)
- django-mongoforms
Todo:
- Changelist pagination
mongoengine.django.auth.User
password form- Better documentation
- ... Probably lots more
Caution:
I have not yet verified that this works with complicated field types, such as ListField, DictField, EmbeddedDocumentField, etc. I have a feeling these might not work, but who knows?
urls.py
import mongoadmin
from django.conf.urls.defaults import *
mongoadmin.autodiscover('admin')
urlpatterns += patterns('',
## ... your URLs here
url(r'^mongo-admin/', include(mongoadmin.site.urls, namespace='mongoadmin')),
)
yourapp/admin.py
import mongoadmin
from mongoengine.django.auth import User
class UserAdmin(mongoadmin.MongoAdmin):
group = 'Accounts'
list_items = ('username', 'email', 'is_active', 'is_staff')
def get_form(self, *args, **kwargs):
form = super(UserAdmin, self).get_form(*args, **kwargs)
form.fields['username'].required = True
form.fields['email'].required = True
return form
# mongoadmin.site.register(User) # With or without the admin
mongoadmin.site.register(User, UserAdmin)
MongoAdmin.form
Similar to ModelAdmin.form
, but a mongoform. Must inherit
mongoadmin.MongoAdminForm
.
Default: mongoadmin.MongoAdminForm
MongoAdmin.group
Used to visually categorize documents on the admin index.
Default: "Documents"
MongoAdmin.list_items
Similar to ModelAdmin.list_display
. Each item may be an attribute or method
on mongoengine.Document
or mongoadmin.MongoAdmin
.
Default: ['_unicode_']
mongoadmin.verbose_name
Similar to Model._meta.verbose_name
.
Default: ModelAdmin.model._class_name
mongoadmin.verbose_name_plural
Similar to Model._meta.verbose_name_plural
.
Default: MongoAdmin.verbose_name + 's'