Can Django be used to combine both webapp and moblie api? - django

I want to use django framework to write a web site with static/dynamic pages (I will not be using angular/react - i.e. SPA technology) but I also want the web app to serve as the backend for a mobile app.
What's the best practice here? Can Django alone be used for it?
Will I need to use Django REST framework?
If you could recommend some specific modules to keep the app as simple as possible and avoid DRY code. That'd be great.
Thanks.

You have the right pointers in your question already.
Use django-rest-framework to create a rest service, create your web app in django to consume that service, create a mobile app to consume the same rest service.
In general, once you have a rest service, you can build anything on top of it. Just consume the service from whichever platform you want to build for.
I hope that helps.

Related

How to deploy a Django backend and Flutter frontend web app

I've been working on a web application that uses Django REST Framework and Django channels in the backend and has a Flutter frontend. It works successfully when tested locally, but my question was how would I deploy this:
What server is most appropriate for this application? (it should be free as this is just a personal project I've been testing)
Do I need to deploy the frontend and backend separately?
Are there any online resources I can refer to, to help me in this process?
Any help is appreciated :)
If you want to use it only for your personal use you could use https://www.heroku.com/free to host you backend.
You could use this guide
Yes, you should deploy them seperately.
Since in your specific case the django application is only used to hold the data, provide a REST API and sockets.

How create application backend in django and create a api so that other developers can use that as well

I just started learning Django and wanted to make an application with API (probably REST) endpoints so that other developers can use it as well (like GitHub API), and I could connect it to my react app and android app. I want my backend to be on a different server and do not want to build my react app integrated with Django backend using the REST Framework.
Can anyone just give me the general idea of what I need to do?
P.S. Sorry in advance if my question sounds silly, I am still new to backend.
Creating a Django REST API should be your first step. This is pretty simple if you already have a Django app running, and will allow your React app or Android app to connect and access data.
Authentication is a step beyond. You may want to look into implementing authentication on the server you will be hosting your back end on. You can also read through this article for some guidance on implementing auth on the DRF side.
Best of luck!
First off all you can start from this.
https://www.django-rest-framework.org/tutorial/quickstart/

Could the directus app be used in a django stack as a CMS

I am developing a web application in django and react but would like to use directus as a cms. I already have a mysql database and RESTful api set up and working so I was wondering if I could use the directus application as an application within django to manage and update content?
if not what would be the correct way to connect directus to my application? or should I stick with a cms built for integration into django projects?
There is no SDK for django/python yet but you can still use the standard way of HTTP requests instead.
In the docs, you can learn more about how to authenticate and how to make requests or update data.
Docs: https://docs.directus.io/api/reference.html#authentication

Combining a project made in Django with a RESTful API using Django-Rest-Framework

We have a project that was developed by using Django, and we want to develop a mobile application out of one part of that project(not entirely the whole project).
From my own understanding, RESTful APIs are used to be the backend of mobile applications. So we want to build this API as an app inside the django project using Django-RESTful-Framework.
So my question is, is it okay to build an API inside an already made Django Project?
Because the RESTful API will need models of that project. For now, we already have a problem of accessing the api endpoint from the mobile app because the django project we developed was using sessions and it responses with 403 forbidden.
ABSOLUTELY! DRF is an awesome package, and if you need to power a mobile app through an API off the same models, this is the way to go. Of course it is an opinion thing, but I think that DRF's strength is that it is easy to get up and running with, but allows some really in depth control when needed.
If you are getting a 403, it is tough to say why without seeing any code. Take a look at this: http://www.django-rest-framework.org/api-guide/authentication/

Django and Drupal

Since Django is a web development framework and Drupal is a CMS.
Is it possible to use them both together instead of a preferred database on Django like apache?
Maybe that question isn't clear enough.
Is it possible to use Django and Drupal simultaneously on the server side to provide a better web development solution?
You can use Drupal and Django side-by-side on the same server for different portions of your web site, but they will be entirely separate systems. They cannot interact in any meaningful fashion (except possibly a Django app making web API calls to Drupal, if Drupal has a web API).
Django is a Python-based web development framework. Drupal is a CMS (and framework, through its module system) written in PHP. They really can't use each other.
Communication between Drupal and any other system is possible and very common, especially using their Services module, and by calling other SOAP (and other) web services.
You can, if you want, to make both Django and Drupal work on the same server, and to call "localhost" for the services you are using, both ways. For Drupal, it is irrelevant where the actual server sits.
If you have a certain Django application you want to integrate with Drupal just write down what it is, and accordingly you will be able to get more help...
Regards,
Shushu