# Django as backend in a MongoDB-Angular app

**URL:** <https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931>\
**Category:** Using the ORM\
**Created:** [December 10, 2021, 9:46am UTC](https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931 "2021-12-10T09:46:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HjoshM](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hjoshm/32/6625_2.png) [@HjoshM](https://forum.djangoproject.com/u/HjoshM)\
**Post date:** [December 10, 2021, 9:46am UTC](https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931/1 "2021-12-10T09:46:18Z")

</div>

I am asking this question here because I believe one or some of my Django settings might be wrong…

Having read through a lot of posts on the following error, I have understood that if you connect to your MongoDB database via `pymongo`, you should remove the **DATABASES** section in your `settings.py` file:

**settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.**

I have removed it, but I still get this error. Nonetheless, I have tried the suggestions in related posts, to no avail…

In my `settings.py` file, I have my database connection:

```
DB_NAME = 'mongodb+srv://User2021:TestMe@cluster0.j9jz1.mongodb.net/test'

```

In my `views.py` file, I have written a simple method, just to start off:

```
@csrf_exempt
def consumers(request):
    print("consumers")
    data = ConsumerModel.objects.all()
    if request.method == 'GET':
        serializer = ConsumerModelSerializer(data, many=True)
        return JsonResponse(serializer.data, safe=False)

```

When I enter the `http://localhost:8000/consumers/`, I just wanna see that the python print statement writes consumers.

What am I missing?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 12, 2021, 8:48pm UTC](https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931/2 "2021-12-12T20:48:08Z")

</div>

PyMongo does _not_ **replace** a relational database with MongoDB. It is simply a facility allowing you to _access_ a MongoDB in addition to your regular database. You still need your databases settings.

---

<div class="post-metadata">

**Author:** ![var1285](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/var1285/32/12295_2.png) [@var1285](https://forum.djangoproject.com/u/var1285)\
**Post date:** [March 2, 2023, 9:38am UTC](https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931/3 "2023-03-02T09:38:55Z")

</div>

It seems that you are using Django with MongoDB and trying to connect to MongoDB through the PyMongo driver. The error message you are getting suggests that the DATABASES setting in your settings.py file is not configured correctly.

However, since you are not using a traditional relational database, you do not need to use the DATABASES setting in your settings.py file. Instead, you can remove the DATABASES setting

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 2, 2023, 1:18pm UTC](https://forum.djangoproject.com/t/django-as-backend-in-a-mongodb-angular-app/10931/4 "2023-03-02T13:18:11Z")

</div>

> [@var1285](#):
>
> However, since you are not using a traditional relational database, you do not need to use the DATABASES setting in your settings.py file. Instead, you can remove the DATABASES setting

This is not an accurate statement. Django **requires** that there be a DATABASES setting and that it **must** contain a `'default'` entry. See: [`DATABASES`](https://docs.djangoproject.com/en/4.1/ref/settings/#databases)
