I'm using Django with google app engine. I'm using the google furnished django app engine helper project.
I'm attempting to create a Django modelformset like this:
#MyModel inherits from BaseModel
MyFormSet = modelformset_factory(models.MyModel)
However, it's failing with this error:
'ModelOptions' object has no attribute 'fields'
Apparently modelformset_factory() is expecting MyModel to implement a 'fields' accessor.
Anybody successfully used a modelformset with GAE datastore? Or is this a fundamental incompatibility between Django and GAE?
It is a fundamental incompatibility between Django and GAE, because they do not share the same interface for their models. The django helper does not include a patch for the modelformsets, but django-nonrel probably does, or will eventually.
Since the google team does not spend much time on the django helper any more, you are probably better off looking at django-nonrel http://www.allbuttonspressed.com/projects/django-nonrel unless you want to patch the helper yourself.
Related
I am starting developing a website, I want to use Django and Arangodb, but Django's built-in databases backend does not support arango.
django documentation refers to this in database section:
You can use a database backend that doesn’t ship with Django by setting ENGINE to a fully-qualified path (i.e. mypackage.backends.whatever).
but I could not find anything that bridges between Django and Arango. there is this repo in GitHub https://github.com/pablotcarreira/django-arangodb but this does not support new features of Django and Arango.
I would like any thread to lead me to solve this problem.
Navigate this projects:
https://github.com/pablotcarreira/django-arangodb
Build API for Django with Foxx or use ArangoDB Python driver?
You must first create an app for the database, for example dbms, and then implement all the required items such as crud in a .py file yourself and use the query class in the view you want and return it such as list ,dict or ... .
Note ! In the __init __ file, be sure to create an object from the created class
I am using a Django installation with MongoEngine to get MongoDB to work as my project's backend.
I've got the implementation to work but am stuck with Django Rest Framework's authentication system. Was just reading the API guide for their authentication chapter and was trying out their TokenAuthentication.
Tokens are created using
t = Token.objects.create(user=..)
and it expects a Django User instance. Since I am using MongoEngine, my database entry in the settings.py file is set to Dummy.
So how do I create a user instance that can be used by Token class.
I tried creating users using MongoEngine's mongoengine.django.auth but the Token class isn't accepting this object.
The resulting error is:
ValueError: Cannot assign "<User: gaurav>": "Token.user" must be a "User" instance.
Please let me know how I can get this to work.
Unfortunately you have to write it for yourself. As a reference you can use a gist I just created: https://gist.github.com/RockingRolli/79ceab04adb72c106cd6
I solved the issue a few weeks ago and it works. The code basically is inheriting the TokenAuthentication and adds Mongoengine specific behaviour.
There are also Django user features provided by Mongoengine: http://docs.mongoengine.org/en/latest/django.html#custom-user-model - IIRC you also need them for MongoTokenAuthentication.
All in all using Django (+Rest Framework) with Mongoengine can be tricky at some point and currently it looks like these issues will not be resolved soon.
I'm plugging some framework agnostic code of mine into Django instead of Pyramid. It uses SQLAlchemy and has a customized session factory object for getting db sessions. In pyramid, I instantiate this at server start up in the main app method and attach it to the registry so that all other parts of my app can get at it. I'd like to know what the "correct" way of instantiating and making available a shared factory is in Django. Is there somewhere canonical for putting something like that so that Django users will find it easily and the code will be readable to people used to Django patterns?
thanks
I place my SQLAlchemy/SQLSoup connections at models.py, because it is related to persistence (and to the "model" layer of Model-View-Whatever).
You can even replace the Django ORM with SQLAlchemy if you are not using applications relying on the first like django.contrib.admin or django.contrib.auth.
I have been leaning Django so I could use the Django admin form in my GAE application. I have just read that GAE doesn't support the django models so i am thinking that it also does not support the admin form.
So the question is does GAE support any other 'forms' or 'reports' environment or do you have to do everything with html
If you're using CloudSQL, django models are supported, and you'll be fine.
If you're using the HRD, getting the admin pages to work would be more difficult.
django models are not supported. The app engine SDK comes with django-style forms that work with the GAE db.Model fields.
Alternatively, you can use django-nonrel which includes a translation layer that allows django models to be used with GAE. The translation layer has various limitations, most prominently, many-to-many relations aren't support. This breaks the Django permissions module which is used by the admin. I've seen some attempts documented to get around this, but I'm not sure how successful people have been.
I am impressed with django.Am am currenty a java developer.I want to make some cool websites for myself but i want to host it in some third pary environmet.
Now the question is can i host the django application on appengine?If yes , how??
Are there any site built using django which are already hosted on appengine?
Django-nonrel is the best and "official" way to run django on appengine. You can run django apps unmodified on AppEngine (as long as there are no complex joins or ManyToMany relationships)
You also now have access to the full django admin which really is the best part of django.
http://code.google.com/appengine/articles/django.html
http://www.allbuttonspressed.com/projects/django-nonrel
http://code.google.com/appengine/articles/django.html
http://www.42topics.com/dumps/django/docs.html
http://thomas.broxrost.com/2008/04/08/django-on-google-app-engine/
Yes, its quite possible. The only difference is, instead of using django's models and database api you simply need to use appengine's datastore api and models. Look at the above links for reference
Appengine comes with built in Django, if you look under your (google_appengine/lib/django_1_3) lib dir you will see a few versions. You can define what version you want to be used in your app.yaml
It isn't a full release of Django and if you do want to have full admin functionality of Django you might have to use something like nonrel but personally I would say its not necessary and you stand to gain more by getting to understand the underlying nosql structure of appengine, in particular the NDB model is very useful