Reputation: 69
What is the best/efficient way of creating a mobile app out of a Django site. I understand that perhaps using React to and connect to a DJANGO API, but assuming I don't know React, can I somehow convert DJANGO site into a Phone App?
Upvotes: 2
Views: 7135
Reputation: 11
Personally, I have not transitioned a webapp to a webapp + mobileapp, but I think I can give some context on what the fundamental problem is.
It's important to understand the difference between a full stack framework like django and the alternative, which is a seperation of frontend and backend.
In native django, when an url gets visited, it searches for a fitting view function, which then handles all the logic. Critically, the view function returns a render function that builds the html site.
With a frontend / backend seperation on the other hand, the backend handles all the logic, but instead of returning the html site, it just returns data. This is what allows for more flexibility, because this data can get displayed by any kind of frontend, whether that's a website or an app.
So, in order to transition a django webapp, you must split the fullstack logic into a backend and frontend. In djangos case, the view function must return data, instead of a html render function. This is done by using django rest. With this backend, you can build out your html pages as well as your apps.
Upvotes: 1
Reputation: 3350
Yes you can conwert your Django Project to App: Here you can see a Talk from Russell Keith-Magee, he was many years in Djangoproject,
https://2022.djangocon.us/talks/how-to-turn-your-website-into-an-app-and/
and here the tool:
or:
https://github.com/beeware/beeware
Upvotes: 1
Reputation: 439
Short answer - You shouldn't because there are better ways to build mobile apps with Django as your backend.
Long answer - You could use webview in android to wrap your web application. Depending on you app, you might need to use some native code to build any of your floating action buttons, bottom navigation, toolbars etc while keeping the rest of your Django app wrapped in the webview. The downside is that your app will lack real performance gains or full native features that you’d be able to utilise.
You could also convert it to a Progressive Web App which will be your django app given some super powers to be able to provide content when a user is offline on both desktop and mobile. Check out Django PWA for this.
Upvotes: 2