Code Monkey home page Code Monkey logo

django-mongonaut's Introduction

django-mongonaut

Info

An introspective interface for Django and MongoDB.

Version

0.2.21

Maintainer

Jazzband (jazzband.co)

Build Status

Code Climate

Jazzband

This Project is Being Moved to Jazzband

In late 2015 @garrypolley and I agreed to move this project to the @jazzband organization. Since we've both been off MongoDB for several years, maintaining this project ourselves no longer makes sense. By handing this to Jazzband, we are:

  1. Putting the project in a place where it will be maintained and extended.
  2. Removes the time and effort needed to continue to accept and manage pull requests for a project we no longer wish to maintain but has a somewhat active user base.

About

django-mongonaut is an introspective interface for working with MongoDB via mongoengine. Rather then attempt to staple this functionality into Django's Admin interface, django-mongonaut takes the approach of rolling a new framework from scratch.

By writing it from scratch I get to avoid trying to staple ORM functionality on top of MongoDB, a NoSQL key/value binary-tree store.

Features

Installation

Made as easy as possible, setup is actually easier than django.contrib.admin. Furthermore, the only dependencies are mongoengine and pymongo. Eventually django-mongonaut will be able to support installations without mongoengine.

Get MongoDB:

Download the right version per http://www.mongodb.org/downloads

Get Django Mongonaut (and mongoengine + pymongo):

pip install -U django-mongonaut

Install the dependency in your settings.py:

INSTALLED_APPS = (
...
    'mongonaut',
...
)

You will need the following also set up:

  • django.contrib.sessions
  • django.contrib.messages

Note

No need for autodiscovery() with django-mongonaut!

Add the mongonaut urls.py file to your urlconf file:

python

from djanog import urls

urlpatterns = [

... url.path('mongonaut/', urls.include('mongonaut.urls')), ...

]

Configuration

django-mongonaut will let you duplicate much of what django.contrib.admin gives you, but in a way more suited for MongoDB. Still being implemented, but already works better than any other MongoDB solution for Django. A simple example:

# myapp/mongoadmin.py

# Import the MongoAdmin base class
from mongonaut.sites import MongoAdmin

# Import your custom models
from blog.models import Post

# Instantiate the MongoAdmin class
# Then attach the mongoadmin to your model
Post.mongoadmin = MongoAdmin()

Documentation

All the documentation for this project is hosted at https://django-mongonaut.readthedocs.io.

Dependencies

  • mongoengine >=0.5.2
  • pymongo (comes with mongoengine)
  • sphinx (optional - for documentation generation)

Code of Conduct

This project follows the Jazzband.co Code of Conduct.

django-mongonaut's People

Contributors

anushajp avatar anushaprasanth avatar audreyfeldroy avatar bryanveloso avatar chrisgilmerproj avatar garrypolley avatar haard avatar igorpejic avatar j1z0 avatar jaormx avatar jazzband-bot avatar jezdez avatar kaflesudip avatar marsam avatar pedroma avatar pydanny avatar rdil avatar swaroopch avatar wolph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-mongonaut's Issues

0.4.0

  • Indexes
  • templates refactor
  • inclusion of static media

ImageField not supported

I would like to be able to upload an image on an ImageField. Currently a textbox just shows "<ImageGridFsProxy: None>". Ideally an thumbnail would be shown when an image exists.

request.user.is_active == false

When I do:

class FooAdmin(MongoAdmin):
        def has_view_permission(self, request):
                return request.user.is_authenticated and request.user.is_active

The "request.user.is_authenticated" is true. But the "request.user.is_active" is false, which prevents me from accessing the admin site.
Why my user is not active and how can I fix that, pydanny?
Thanks.

Any plans on upgrading for django 1.8.x?

For Django 1.7, mongonaut works fine, however for 1.8.x it is not working specifically edit part. I noticed the dictionary field "_data" for the document only has key-value pair of "id" and all the other fields are missing.

UnicodeEncodeError in mongonaut_tags

In mongonaut_tags.py there are two similar lines:

(1) return mark_safe("""<a href="{0}">{1}</a>""".format(value, value))
(2) return mark_safe("""<a href="{0}">{1}</a>""".format(url, value.__unicode__()))

Is there a reason for using .__unicode__() in (2)? (It gives me me UnicodeEncodeError on a string that includes unicode characters. Removing .__unicode__() seems to help.)

Cheers

NoReverseMatch

List of models show up find, but when I try to add an entry I get:

Error during template rendering

In template /usr/local/lib/python2.7/site-packages/mongonaut/templates/mongonaut/document_list.html, error at line 48

Reverse for 'document_detail' with arguments '(u'mplayers', u'Player', u'DDDD7E9F-E2BD-59E9-AED7-476D45E147A8b.device')' and keyword arguments '{}' not found. 1 pattern(s) tried: ['padmin/(?P<app_label>[-\w]+)/(?P<document_name>[-\w]+)/(?P[\w]+)/$']

What could be the problem?

TypeError: get_form() got an unexpected keyword argument 'form_class' with Django 1.8.2

I have installed the latest version of Mongonaut with Django 1.8.2. While I am able to login and view the data from my Mongo DB, I get the following error whenever I try to Add or Edit any data:

TypeError: get_form() got an unexpected keyword argument 'form_class'

This is the traceback. Any help would be appreciated!

Traceback (most recent call last):
File "/home/abc/workspace/3m/ve/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "/home/abc/workspace/3m/ve/local/lib/python2.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, _args, *_kwargs)
File "/home/abc/workspace/3m/ve/local/lib/python2.7/site-packages/django/views/generic/base.py", line 89, in dispatch
return handler(request, _args, *_kwargs)
File "/home/abc/workspace/3m/ve/local/lib/python2.7/site-packages/django/views/generic/edit.py", line 206, in get
form = self.get_form()
File "/home/abc/workspace/3m/ve/local/lib/python2.7/site-packages/django/views/generic/edit.py", line 36, in get_form_with_form_class
return get_form(self, form_class=form_class)
TypeError: get_form() got an unexpected keyword argument 'form_class'

selective viewing/editing of fields

One of my collections has a couple of string fields along with a list field that contains a few thousand elements. When I open them for editing in mongonaut, it takes too long to load the list 2 -3 minutes when I don't even want to edit it.
Desirable features would be:

  • ability to select the fields to be shown in the admin
  • changing the widget used for showing a field in the admin

Install requires mongoengine 0.5.2

It is now install_requires=['mongoengine==0.5.2'], in setup.py.

Does it mean that mongonaut is incompatible with mongoengine 0.6.x versions?

If it does compatible it is better to address minimal required mongoengine version.

Now pip install mongonaut forces the last mongoengine version to be uninstalled and installs mongoengine 0.5.2.

'import as' with models file does not work

# myapp/models.py
import mongoengine as me
class DemoModel(me.Document):
    title = me.StringField()

# Snippet1
# myapp/mongoadmin.py
from myapp import models as mm
class DemoModelAdmin(MongoAdmin):
    search_fields= ('title',)
    list_fields = ('title',)

mm.DemoModel.mongoadmin = DemoModelAdmin()

# Snippet2
# myapp/mongoadmin.py
from myapp.models import DemoModel
class DemoModelAdmin(MongoAdmin):
    search_fields= ('title',)
    list_fields = ('title',)

DemoModel.mongoadmin = DemoModelAdmin()

Snippet1 where I import the model specifically, the way it is shown in the documentation works flawlessly. However, if I want to use an alias for the model using the 'from x import y as z' feature, nothing shows up on the http://localhost:8000/mongonaut/ listing.

Index controls

Simple index controls

  • add
  • delete

Compound index controls

  • add
  • delete

Search

Simple Mongo search based off supplied fields.

Style and JS Missing when user has invalid permissions

Sorry I haven't written a patch and submitted for this, but I wanted to write it up. If you are not logged in and you try to access the admin list view for a particular document you get a page that has no style or javascript. I tracked this down to this line in get_context_data():

https://github.com/pydanny/django-mongonaut/blob/master/mongonaut/views.py#L117

Basically, I'm pretty sure that get_context_data() cannot return anything except a dictionary. Raising an HttpResponseForbidden isn't respected by the view and so you get the rendered page with no real context data. If you don't get to this I might later this week.

Thanks for this project, keep up the good work.

Allow dotted names in urlconf

Hello.
It seems like a little bug: if my application app_name includes a dot, e.g. forum.mongo_forum then the default mongonaut's urlconf can not handle the url: it can not reverse for 'document_list' with keyword arguments like 'app_name': 'forum.mongo_forum'.
The mongo_forum application is installed right into my project and accessed with an project name prefix.

To fix that you can add dot-symbol to mongonaut's urlconf:
(?P<app_label>[.-\w]+)
for all of your url patterns (document
{list, detail, detail_edit_form, detail_add_form}, etc).

Thanks.

readonly_fields not supported in custom MongoAdmin

I've created a custom MongoAdmin, and I need some of the fields to be pre-populated with values and read-only; however, setting this up in my custom MongoAdmin class does nothing. To be honest, either proper documentation or a code change to get this working would be excellent.

Switch to using dispatch for get_mongoadmin et all

Right now it's in the View.get_context_data() methods or other places and is a bit hairy. This ought to be done against the View.dispatch() method as that is the correct location. This includes:

  • Determining self.app_label and self.document_name and self.document_type
  • Checking if the requesting user has permission

Permission Error

Hi,
I just saw this project and i am very excited about it. But i am unable to make it work until now.

Here is my pip freeze command output:

Django==1.6.2
pymongo==2.3
mongoengine==0.8.7
django-mongonaut==0.2.19

I think that everything is OK here.

I have a custom user model and here is my terminal output

>>> from project.profiles.models import *
>>> u = UserProfile.objects.get(email="[email protected]")
>>> u.is_authenticated()
True
>>> u.is_staff
True
>>> u.is_superuser
True

So my logged-in user has all necessary permissions (Regarding the documentation.)

My Model:

class FBUser(Document):
    app_id = StringField(required=False)
    facebook_id = StringField(required=True)
    facebook_ids = ListField(StringField())

    meta = {'collection': 'friends_of_friends_network'}

My admin file (appname/mongoadmin.py)

FBUser.mongoadmin = MongoAdmin()

When i type http://ubuntu.local:8000/mongonaut/
What i get is a 403 response:
You do not have permissions to access this content.

I read the documentation 5 times, checked the source but unable to find any clue. Do you have any ideas?

Thank you.

Add Continuous Integration + Test Harness

django-mongonaut should be on travis-ci and should have a working test harness so we can start writing tests. This will make it easier to maintain and allow us to quickly test against multiple versions of Python and Django.

Whoever gets this working will have my gratitude. I will shout your skills the heavens (or at least Twitter).

MongoEngine's Django User Auth Model Not Supported

Due to a limitation in MongoEngine, User objects stored in MongoEngine don't have a user_permissions field, which makes it impossible to log into mongonaut when using MongoEngine's user model replacement:

INSTALLED_APPS = (
    ...
    'django.contrib.auth',
    'mongoengine.django.mongo_auth',
    ...
)

AUTH_USER_MODEL = 'mongo_auth.MongoUser'

Admittedly, this is a bug in MongoEngine, but it'd be awesome to see a workaround in the meantime in mongonaut to enable users to log in until this is fixed upstream.

A patch for this would consist of simply replacing the use of the permissions API with a check to user.is_staff and user.is_active.

Default Tests

Currently there are not much in the way of tests for this application. It would be good to create some unit tests to make sure functionality does not get broken with code updates.

Things I'd like to test:

  • Posting to each type for Field (Happy Path)
  • Posting blank and invalid data to each Field (Special cases)
  • Results passed to context look like they should when using detail view

Inclusion of static media

Right now it's pulled off hosting sites. In some ways this is awesome in that we always run the latest/greatest, but in other ways it kind of sucks because it doesn't work if disconnected.

Any ideas anyone?

"You do not have permissions to access this content." but... how to log in?

OK, this may sound noobish but I'm puzzled for two hours straight now, and kindly request help :)

/mongonaut/ url throws 403 accompanied with "You do not have permissions to access this content.". Yet I have no idea how to log in. Here are my files layouts:

# settings.py
from mongoengine import connect
connect('dbname')
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.dummy'
    }
}

AUTHENTICATION_BACKENDS = (
    'mongoengine.django.auth.MongoEngineBackend',
)
AUTH_USER_MODEL = 'mongo_auth.MongoUser'
MONGOENGINE_USER_DOCUMENT = 'mongoengine.django.auth.User'
SESSION_ENGINE = 'mongoengine.django.sessions'
SESSION_SERIALIZER = 'mongoengine.django.sessions.BSONSerializer'

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'mongoengine.django.mongo_auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mongonaut',
)

# my full urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
    url(r'^mongonaut/', include('mongonaut.urls')),
)

I have nothing more, no mongoengine models yet, just want to log in for starters :]
manage.py createsuperuser works ok!

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.