I want to use mongodb as my primary database with django, but when I make DATABASE dict in settings.py file, create a model and run migrations it throws error.
I want to use my mongodb(connection string) and use mongo-db atlas.
models.py:
class Department(models.Model):
dptId = models.AutoField(primary_key=True)
name = models.CharField(max_length=100)
superior = models.CharField(max_length=100)
empQty = models.IntegerField()
def __str__(self):
return self.name
When I try to makemigrations it throws this error:
ERROR:
File “C:\Users\Axix Technologies\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\dummy\base.py”, line 20, in complain
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
How do rate this approach, would it be good and worth applying, If I have to use mongodb with django, but point to be noted I am not allowed to use any other database.
The DATABASES setting must configure a default database;
[emphasis added]
First reaction. Bull. (Personally, I have no patience with organizations that supposedly put restrictions in like this.) Policies and procedures are subservient to business requirements. If you are required to use Django, then someone needs to understand that you have been given contradictory requirements.
Or, Don’t use Django. Use Flask or some other framework. Django is very closely tied to the relational model.
Or, use SQLite. Technically, it’s a file, not a database engine, and may be sufficient.
Actually, I’ve told to design this product on django with postgresql, I completed it, but there were some limitations, because this product has 2 parts 1 will be hosted and the other one will be locally on the client’s pc, they want to use 1 database, which could link both these parts.
So, now tell me how can I handle this. If I use sqlite3, or any other sql database.
Or, any other hint or information, which could help me sync the data on cloud and locally. And also save the data on mongodb(as our own backup) .
Now you’re getting into areas of system architecture and design that fall well-outside what can be reasonably discussed in a forum such as this.
It would be irresponsible of me to offer ideas and suggestions without a much more detailed understanding of the system being proposed and that’s not really an appropriate topic here.
I suggest you find a firm with expertise in hybrid / distributed systems and hire them for your design. It would be money well-spent.