Giter VIP home page Giter VIP logo

mongodb-engine's Introduction

Django MongoDB Engine, the MongoDB backend for Django

Documentation on http://django-mongodb-engine.readthedocs.org/

Use Django's ORM (including Aggregations, Atomic Updates, Embedded Objects, Map/Reduce and GridFS), admin site, authentication, site, session and caching frameworks with MongoDB.

master branch:https://secure.travis-ci.org/django-nonrel/mongodb-engine.png?branch=master

Contributing

You are highly encouraged to participate in the development, simply use GitHub's fork/pull request system. If you don't like GitHub (for some reason) you're welcome to send regular patches to the mailing list.

Web site:http://www.django-nonrel.org/
Mailing list:http://groups.google.com/group/django-non-relational
Bug tracker:https://github.com/django-nonrel/mongodb-engine/issues/
PyPI:http://pypi.python.org/pypi/django-mongodb-engine/
License:2-clause BSD
Keywords:django, mongodb, orm, nosql, database, python

mongodb-engine's People

Contributors

aburgel avatar alir3z4 avatar anemitz avatar bhomnick avatar bikeshedder avatar bpedman avatar charettes avatar dconlon avatar dduong42 avatar dillongreen avatar emperorcezar avatar endyman avatar flaper87 avatar jonashaag avatar key avatar mgmtech avatar r4fek avatar rozza avatar silas avatar smacker avatar theikkila avatar wrwrwr 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  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

mongodb-engine's Issues

AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead)

Im seeing strange error when using django admin to add models with foreign keys to regular database.

My models.py :-

from django.db import models
from django.contrib.auth.models import User
class Author(models.Model):
    user = models.ForeignKey(User, unique=True, related_name='profile')
    name = models.CharField(max_length=50)
    shortdisc = models.TextField(help_text="Short disc with content")
    longdisc = models.TextField(help_text="Long disc for author page")

The issue here is when saving a new Author object from the django admin, it gives the following err-

AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead)

Adding a new author works as expected from the shell, but not the admin.

Note: The user model is in regular SQL database (tried both sqlite and mysql) and the Author model is in mongodb .

Mondodb-engine : latest master
Django : 1.3 beta 1

The error happens in the latest master. There was no problems when until 3 or 4 days ago. Maybe one of the commits on 2011-02-12 broke it.

Suppress _id index creation

Get rid of annoying index creation messages on seach syncdb because indices on _id don't actually create a collection so Django tries to re-create those indices every time.

GEO querying just don't work

class Point(models.Model):
    lat = models.FloatField()
    lon = models.FloatField()

class Section(models.Model):
    name = models.CharField( max_length = 255)
    tags = ListField()
    loc = EmbeddedModelField(Point)

    objects = MongoDBManager()

and test code is

here = {'lat':24.975048, 'lon':121.327136}
where = Section.objects.raw_query({'loc' : {'$near' : here}})
print where

OperationFailure: database error: can't find special index: 2d for: { loc: { $near: { l

Better README

  • list of Django features that can be used
  • list of extra features django-mongodb-engine provides
  • link to docs page
  • etc

Release 0.3.1 to PyPI

The 0.3-maintenance branch contains a few bug fixes. We should release a 0.3.1 (already created a v0.3.1 tag).

Allow failover for read-only/slave_okay connections

PyMongo doesn't allow using replica set connections with slave_okay, and this creates problems in some cases: if read-only connections are being used for load balancing and one of the underlying secondaries goes down, the corresponding database connection will fail.

Right now, I see 2 possible ways to solve this:

  1. connect to the replica set without slave_okay, get the host list, and then use the first available one, looking at them in the order specified in the URI/host list; this means we have to parse mongodb:// URIs, and the user is responsible for writing and maintaining one separate URI for each read-only config with different host order (can become hard to maintain for larger replica sets)
  2. introduce something like PREFERRED_HOST, to allow using the same URI and doing the tweaks in the options

I tend to like the second option more, although it introduces a new option, but I'd like some feedback before I take any of these roads

sql_indexes_for_model uses field.name, should use field.attname

django-nonrel's ForeignKey maps model fieldnames like "user" to DB names like "user_id", but the indexes for them that mongodb-engine creates will use the original name ("user").

This means the indexes don't work (and will cause incomprehensible crashes in the presence of "unique" contstraints, because of null values in the indexes).

Changing creation.sql L#48 from this:

collection.ensure_index([(field.name, direction)], unique=field.unique)

to this:

collection.ensure_index([(field.attname, direction)], unique=field.unique)

seems to fix this, creating indexes on *_id for foreignkey fields, and base names for other types.

Feature list

on the home page.

Lets start adding some here:

  • Existing projects don't need to be modified
  • Full django integration

GridFsStorage -> GridFSStorage

consistency ftw!

edit: Hm. Two successive uppercased "S" aren't that beautiful, either. But PEP8 says we should keep abbreviations uppercase. Hm.

some PEP 8 love needed

There are some things in need of PEP 8 love :-)

sa@sub:~/0/mongodb/mongodb-engine/django_mongodb_engine$ alias acsn; acsn pep8; pep8 *py
alias acsn='apt-cache search --names-only'
pep8 - Python PEP 8 code style checker
aggregations.py:29:1: E302 expected 2 blank lines, found 1
aggregations.py:46:41: E203 whitespace before ':'
aggregations.py:48:21: E221 multiple spaces before operator
aggregations.py:57:80: E501 line too long (91 characters)
base.py:16:29: E202 whitespace before ')'
base.py:137:73: W291 trailing whitespace
compiler.py:63:32: W602 deprecated form of raising exception
compiler.py:142:20: E111 indentation is not a multiple of four
compiler.py:176:25: E301 expected 1 blank line, found 0
compiler.py:224:15: E261 at least two spaces before inline comment
creation.py:91:17: E701 multiple statements on one line (colon)
fields.py:42:5: E303 too many blank lines (2)
utils.py:68:10: E222 multiple spaces after operator
widgets.py:13:16: W601 .has_key() is deprecated, use 'in'
widgets.py:14:25: E225 missing whitespace around operator
widgets.py:15:23: E201 whitespace after '('
widgets.py:50:45: E231 missing whitespace after ','
sa@sub:~/0/mongodb/mongodb-engine/django_mongodb_engine$ 

unable to get mongodb-engine on a fresh install (Ubuntu 10.10)

django-admin.py shell
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in
management.execute_from_command_line()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/init.py", line 429, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 209, in execute
translation.activate('en-us')
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/init.py", line 66, in activate
return real_activate(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 55, in _curried
return curried_func((args+moreargs), *_dict(kwargs, **morekwargs))
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/init.py", line 36, in delayed_loader
return getattr(trans, real_name)(_args, *_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 193, in activate
_active[currentThread()] = translation(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/init.py", line 1, in
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/helpers.py", line 1, in
from django import forms
File "/usr/local/lib/python2.6/dist-packages/django/forms/init.py", line 17, in
from models import *
File "/usr/local/lib/python2.6/dist-packages/django/forms/models.py", line 6, in
from django.db import connections
File "/usr/local/lib/python2.6/dist-packages/django/db/init.py", line 75, in
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/local/lib/python2.6/dist-packages/django/db/utils.py", line 92, in getitem
conn = backend.DatabaseWrapper(db, alias)
File "/usr/local/lib/python2.6/dist-packages/django_mongodb_engine-0.1.1-py2.6.egg/django_mongodb_engine/mongodb/base.py", line 38, in init
self.features = DatabaseFeatures(self)
TypeError: object.new() takes no parameters
root@mobxchange:/usr/local/src/mobxchange# vi /usr/local/lib/python2.6/dist-packages/django_mongodb_engine-0.1.1-py2.6.egg/django_mongodb_engine/mongodb/base.py

Incorrect indexes added on syncdb

I am not exactly sure which piece is responsible for this, django-nonrel or the mongodb backend (probably the latter)...but when I do a syncdb which creates the indexes it is creating indexes on the wrong fields for foreign keys

So if I have a model like:

class MyModel(models.Model):
    myfk = models.ForeignKey(OtherModel)

When I run syncdb it will create an index on myfk, except that when the model instance is saved, the field name is myfk_id, not myfk. In most situations this doesn't cause problems...but it bubbled up in another situation where the index was also unique.

I have a user profile object for my users. This has a OneToOneField to the User object. When I ran syncdb a while ago it created an index on the field 'user'. I was just trying to add a new user profile (and user) and it appeared in the admin UI that everything worked...except when I look at the user profiles list it did not exist...took a whole bunch of digging since the error was hidden (because I hadn't enabled safe inserts I guess), but here is the error that was returned:

{u'code': 11000, u'ok': 1.0, u'err': u'E11000 duplicate key error index: global.shared_userprofile.$user_1 dup key: { : null }', u'n': 0}

Once I removed the index on 'user' it worked just fine.

The actual problem was that it also added a {unique:true} on the index since it was a OneToOneField. Since user is null on the first user profile, the next one fails since user is null on the new profile as well.

InvalidId

When I tried to enable the admin site I get:

AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead). Please make sure your SITE_ID contains a valid ObjectId string.

Can't use Django's default admin sue to session id problem

when i access localhost:8000/admin gives me the error 'MultipleObjectsReturned at /admin/ get() returned more than one Session -- it returned 2! Lookup parameters were {'session_key': 'ee5a8be487352e42a89f962ee4ab22a6', 'expire_date__gt': datetime.datetime(2011, 7, 8, 5, 38, 36, 645053)}'

if access the mongodb and delete one of the rows in the collection django_session it works, but after awhile gives me the same error because it was created another document in the collection django_session

even in the browser i deleted the cookie that stored the session id then i was able to run the page smoothly. then when i refresh or click on the link i get the multiple object returned error.

is this a problem with the mongodb-engine for django that tries to add session ids for every page refresh

_decode_child returns converts all values

When using _decode_child to decode the where node childs values from normal django fields get converted to their types. If we want to pass a A() query or any other query to a unicode field we'll get a unicoded A value.

name on PyPI

Currently the package name on PyPI is django_mongodb_engine rather than django-mongodb-engine. It's just cosmetic but it looks odd so I suggest changing it i.e. set

setup(
    name='django-mongodb-engine',
    [... ]

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.