We're using an older version of Django (1.1.1) and are preparing to upgrade to the latest version (currently 1.2) soon.
None of my searches have brought up the topic of migrating database tables (auth_user, etc.) across Django versions. Using syncdb only works for creating new tables but has no effect on existing tables.
I'm under the impression that the upgrade is not simply linking to a new version of the Django files but that we also need to manage the migration of our database since we rely on some built-in Django apps (django.contrib.auth, django.contrib.sites, etc.). We're planning to use South to manage the database migration.
Is this something handled internally by Django? Am I trying to solve a problem that doesn't exist?
There are no changes to the django.contrib.auth or django.contrib.sites models between 1.1.1 and 1.2.5 so you won't need to do any database migration.
Related
I am looking for a solution to work with Postgres and MongoDB simultaneously in my Django project.
I have large data which I would like to store in MongoDB and Postgres for user management, billing, and other things to manage.
I have tried to use a library ```pip install djongo`` djongo, which is outdated, and not able to find any solution. Please guide me with an authentic solution! Thanks
First of all, To install a newer version of Django you can use pip install Django==<version>, But you need to see compatibility with the Python version you're running on your system and virtual environment.
e.g. For Python 3.x, I'm using a bit older Django version 2.2.21.
Second, Django does not support MongoDB natively, But MongoDB team themselves provides a library called pymongo which you can install, but with pymongo you'll have to write more of a native mongodb queries. They do not have any Django ORM.
But there's another library called mongoengine which is actually built on top of pymongo and is very handy and close to the ORM Django provides for relational databases.
Thirdly, About Postgres you can easily set up any relational database with Django as it provides native support for relational databases. Both the database are completely independent of each other, So there should not be any problem with the setup.
I, myself use Postgres and MongoDB together in my projects, Never faced a single problem. Although, sometimes it's a little challenging to build things for NoSQL databases in Django which Django already provides for relational databases but yeah a little extra code as overriding Django base classes to provide support for mongodb always works.
I am working with Django 3.1 edition. As a Database, my choice is to go with any NoSQL database like MongoDB. I have tried two ways to connect MongoDB with Django 3.1. First One is using Djongo and the Second one is using Mongo Engine. But both the cases, I am unable to work with Django 3.1. In the case of Django, it's not supporting Django 3.1 but it switching me to Django 3.0.5, and in the case of mongo engine it's not supporting Django 3.1. Is there any third way to connect MongoDB with Django 3.1. Note that I have to use Django 3.1 only
These are the docs I was following in Djongo and Mongo Engine.
https://pypi.org/project/djongo/
https://django-mongodb-engine.readthedocs.io/en/latest/topics/setup.html
Your best bet is going to be Djongo:
https://github.com/nesdis/djongo/
However, Djongo's master branch currently supports up to Django 3.0.5. If you really need Django 3.1 support:
Clone the Djongo repository
Change this line to have an upper bounds of <3.2 instead of <=3.0.5: https://github.com/nesdis/djongo/blob/de5191ccbd9dd2255627e6d1cb6a58cd591c2353/setup.py#L86
pip install -e . from the cloned directory into your venv.
Then see if it works, and what needs fixing. If you fix things in Djongo, you can send Pull Requests to the project for 3.1 support.
Please note, this is a fairly risky dependency to put into a project. You'll be locked to using versions of Django that Djongo supports going forward, and won't be able to upgrade until Djongo does. I've had to do this in some of my projects with third-party SQL Server support, and it can be frustrating. I wouldn't recommend it if you aren't comfortable getting involved with the project you're relying on, and contributing. That said... good luck!
This question is already asked on StackOverflow,
The asked questions date back to 2013, Its 2015 now and Django has grown up fast.
What is the situation of using mongodb with Django 1.8 as of 2015?
Does Django support Monogodb out of the box (with db adapters)? or another distribution like django-nonrel should be used?
I don't think Django provides out of the box support for MongoDB. It is more tailored for relational databases.
One solution could be using MongoEngine.
MongoEngine is an Object-Document Mapper, written in Python for
working with MongoDB.
You need to just configure MongoEngine with Django and then it should work comfortably.
just my thoughts and somewhat subjective and opinionated but I would say it does not work very well. I quickly disbanded the idea of trying to run Django with MongoDB, since it's auth system is heavily reliant upon a relational database to work.
There are apparently ways around this, but ultimately I decided for my project it was not worth the effort just to use MongoDB.
Does Django support Monogodb out of the box (with db adapters)?
No, it does not. If you can find a django compatible engine for mongodb, then it will work perfectly.
The good news is there is such an engine, called django-mongodb-engine; the bad news is that it relies on django-nonrel which is not updated against the latest stable version of django.
So, if you must - you can use MongoDB at the expense of not having some updated django features available to you (and more importantly, any security patches).
If you want to supplement your main database with mongodb - that is, mongodb will not be your primary database, then the process is a lot easier.
So, in summary:
django 1.8 provides no out-of-the-box support for mongodb (or other non-relational databases) as the primary data store.
support is available using the third party django-nonrel package, which is behind the current django production version.
I came across a new package that does support the latest django on MongoDB: djongo
As stated above, mongoengine does not support all contrib apps of django. Especially the auth app doesn' work on mongoengine
Djongo claims to compile SQL queries into mongodb queries. So its is essentially version agnostic and works for all versions of Django.
Disclosure: I have contributed to this package by making minor bug fixes.
I know that its been three years but for those who are wondering about MongoDB and Django now should know that the situation has not changed. Mongoengine as described earlier is a good enough tool but still there are limitations. For instance when i integrated mongodb with django using mongoengine i was not able the use elastic search with my application. Furthermore with mongoDB you loose you loose Django admin and authentications functionalities. So, MongoDB with Django is still a risky choice
After reading some older posts about Django South's features, I began wondering why there wasn't a similar tool built in to Django itself. Then I was curious if maybe something had been added these last few years.
Has something been added?
Are there any alternatives to South, or is it the accepted way of handling migrations and such?
The same thought django core developers had. Since Django 1.7, migrations is a built-in feature:
Django now has built-in support for schema migrations. It allows
models to be updated, changed, and deleted by creating migration files
that represent the model changes and which can be run on any
development, staging or production database.
Note that 1.7 is not a stable version at the moment.
I am really new to the world of App Engine development and I want to start with a test project on Django and GAE. I've done some research and found out that there are two major ways to use Django in my app on GAE.
Django-nonrel + djangoappengine
use_library() to load Django from SDK
Please tell about pros and cons of each way.
Is there anything better than django-nonrel if i will decide to distribute Django code with my project?
It's not a matter of two different ways to use Django - it's two different versions of Django. App Engine comes bundled with versions 0.96, 1.0 and 1.1 of Django, unmodified from the mainline release. Django-nonrel is a branch of Django, which adds support for App Engine for the database backend.
If you're writing a new app, and you want to use Django for the whole app, including the models, you should use Django-nonrel.
When using django-nonrel you can use all Django features (including admin, auth, models, queries). I don't have a complete list of django modules which are either not working or partly not working in app engine.
If you use the Django version via use_library you have to be careful with app engine's limitations (use their model api, their auth via google accounts and so on).