Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A basic CRUD admin interface for Django+MongoEngine, very similar to `django.contrib.admin`

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.mkd

MongoAdmin

A basic CRUD admin interface for Django+MongoEngine, very similar to django.contrib.admin.

Requirements:

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?

Example:

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)

Documentation

mongoadmin.MongoAdmin

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'


Something went wrong with that request. Please try again.