how can i convert django app to desktop app - python

I have a Django app up and running on DigitalOcean with Nginx and PostgreSQL. But some clients want an offline version of the app so that their data remains on their systems and they don't have to connect to the internet. One solution is to write the whole app from scratch but that would take time and cost.
I was thinking of a solution where I can convert the Django app into a desktop app with minimal changes i.e. replace CDNs with files and remove functionality that requires internet. But I don't know how can I do this.
I was thinking of electron, i,e, elctron will spawn a child process which will start django's server and then the electron will load 127.0.0.1:8000 in a webview.
But how can I package this app into an executable because it would need python installed and configured on the user's system. Or does python itself has any library that can convert the Django app into a desktop app?
Below is the file structure of my Django project
project_folder/
app_1/
app_2/
app_3/
configurations/
templates/
__init__.py
asgi.py
settings.py
urls.py
wsgi.py
media/
staticfiles/
manage.py
Any help would be appreciated.

Related

Containerize Django Fullstack application with Reactjs frontend served as a django app with webpack and babel

I'm building a fullstack Django app with react js , webpack and babel. My django backend is serving my react frontend as an app via port 8000 with webpack bundling my reactjs. I want to be able to containerize my app so that i will have independent services that ie frontend as container, backend as a container and probably postgresql as a container.
Now the major challenge i'm facing is how best can i separate these two main service frontend and backend considering that my Django backend is serving my frontend reactjs app via port 8000. I dont want to use create react app to serve my frontend at its own port 3000, i want to go the webpack and babel route, where i create a frontend app in Django that will host my react js app and its static files.
Ultimately my folder structure looks something similar to this
-django-app
-fontend-app
-src-react
-components
-actions
-reducers
App.js
-static
-templates
index.html
urls.py
-another-app
-django-app
settings.py
Dockerfile
manage.py
package.json
webpack.config.js
.babelrc
Also consider a solution that will be able to make the application scalable ie, providing scaling functionality for the frontend app and backend app services repsectively.
If you're looking to separate/decouple your frontend and backend, I would recommend using something like webpack dev server to serve the frontend in development. For the backend, you should just be able to copy your Django app into a Docker image based on the official Python Docker image.
That will solve development, then for staging/production you can use any cloud offering to serve the backend (I like to use Google Cloud Run), and any static content host for serving the frontend (I like to use Netlify for this). This will allow your application components to automatically scale independently.

Python Django App Design change on deploy to server

I recently uploaded my Django App to the server (Digital Ocean). The functionality is okay as in my local project on my computer, but the design (css style) of the Admin Interface has changed drastically in a lot of elements of the change_list and change_form templates. I‘ve checked and made sure that the templates of my local Django and Suit files are the same as they of the server, but it is still not the same design.
Does anyone has experience with that?
In deployment server just collect your static files from static folder by running command python manage.py collectstatic which will create a staticfiles folder in your Main project app in the project directory. May be this will help. Try it out.

Django project to domain, vps

I have VPS-server (CentOS 6.8)
I installed Python 3.5.2 and Django 1.10.1 on virtual enviroment
I connected my domain to VPS-server
Now:
django-project:
(venv) /home/django_user/djtest/venv/django_project/django_project
domain:
/var/www/www-root/data/www/mydomain.com
I tried set BASE_DIR in settings.py to '/var/www/www-root/data/www/mydomain.com' but not working
How I can to connect django-project to domain?
Project is still empty, just created
Django project can't be served like this, you need some web-server application like gunicorn or apache too.
Just like you use ./manage.py runserver you need some application to execute your django project corresponsing to command theses application are Gunicorn, ApacheWSGI server and others.
There will be a file wsgi.py that would have created when you created the project it's web server gateway interface it will interact with the above mentioned web-servers and server your django based website.

Google App Engine & Polymer | Configuration

I'm developing a web application on Google App Engine using Python, I understand how to use basically the app.yaml and manage the different files; now I'd like to upgrade my application and use Polymer. The root folder has this configuration:
/MyApp
/assets
/css
/img
/js
/bower_components
/templates
app.yaml
bower.json
index.yaml
main.py
I'm having a problem with the bower_components, inside that folder Bower put all the polymer elements that I need in different folders and file inside them, for example:
/bower_components
/core-menu
/core-menu.html
/core-scaffold
/core-scaffold.html
How have I to configure my app yaml? I've tried in different ways to say at mylocalhost & appengine about this folder but every time I try to run my project, I can't see no changes respect to a simple html file. Sometimes, using FireBug i can see the platform js is taken from GAE but I don't know how to rightly link this elements to works fine.
There isn't really anything to configure here. These are all static files, exactly the same as the files you have under /assets: so you should point to them in the same way you do with the assets paths.

Run multiple Flask apps on the same domain

I want to run several Flask apps such that...
mydomain.com is running one app in one directory.
mydomain.com/app1 is running another app in another directory.
mydomain.com/app2 is running a third app in a third directory.
I want to specifically avoid having to have a URL structure like app1.mydomain.com
Is this possible under Apache?

Categories