Where are the Django and python files? - django

I'm new to Django and Python, I'm coming from Laravel.
I'm working on a Windows machine.
My Laravel project has tons of folders (vendor etc.) and is >100 MB my Django project is <50kB.
In the end, I want to upload my Django project to a webserver.
But I'm curious where the Djangofiles on my computer are located, and how deployment works. (what are the essential parts/files compared to Laravel (Project Folder + DATABASE) which I've to transfer)
Is the Django Framework similar to a Javascript file, which I can put I my project folder or get via linking?

The place you move your Django project folder to on your server is where your Django files is located. Django files might be small in size, however, to run your Django application you will need to install +100MB packages from PIP.
The essential part of Django is your project directory and your requirements.txt file in which all python package required to run your application will be listed in it.
Django is not similar to a Javascript file, Django is a complete web development framework similar to Laravel framework, you may refer to this Head-to-Head comparison between Django and Laravel: Here
For more details on deployment you may refer to the following tutorials:
Hosting Django with Nginx: Nginx + Django
Hosting Django with Apache: Apache + Django

Related

Can PyInstaller (or other tools) create an executable file from Django project for production environment?

I want to create an executable file from our Django project. Currently we use Daphne as ASGI server hosting both HTTP and web-socket.
I found following link but it seems that PyInstaller is only for Django dev env, not for production.
https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django
Am I correct? Is there any other tool allow me to create standalone file for production environment.
Many thanks!

Multiple Django apps with each having a react frontend

I have a Django aplication (+REST framework) with pluggable Django apps (which are discovered using distutils' entry points, and can be developed independetly from each other, and installed via pip). This works well so far.
The main app should provide a basic index.html which dynamically loads React components, and each app should be possible to add React components as plugins, which are combined on the frontend then.
But: How the heck am I supposed to place my client directories into each app, so that they are found for collecting all the static files?
Should I put a react app into /my-app1/client and /my-app2/client?
my-application/
core-app/
client/
react files etc
static/
models.py
...
plugin-app1/
client/
react files etc
static/
models.py
...
And tell Webpack/brunch/whatever to compile all the css/js etc files into /my-app1/static, followed by ./manage.py collectstatic then?
Is there a better approach to collect distributed react "plugin" in dfferent Django apps into one static directory?
Can brunch.io do this? Webpack? Another? Own script?
It would be nice to have something like brunch watch - to have hot-updated all changed files instantly. This works for one directory, but not for a distributed net of plugin directories, right?
Or is this completely thought wrong? Please help.

Deploying Django App on Heroku using Windows

I want to deploy my django app on heroku , which I have built on Windows machine.
Can I deploy the same application using heroku toolbelt for windows.
Or I have to setup all the things on a unix machine.
And one more thing the application uses Python 3 and Django 1.8
Will that be any problem.
There aren't any special process listed in the docs for windows usersYou should actually deploy from a unix environment, you have to create your Procfile, requirements.txt and make some changes to your settings.py file, it's easy and straight forward.
A step by step guide can be found here https://devcenter.heroku.com/articles/getting-started-with-django
Some problems you may encouter:
Internal Server Error heroku/django
Django migrations fail in heroku
Also make sure you add your migrations and cache folders to your .gitignore file.

Django restframework bootstrap static files

I have a regular django site, with djangorestframework (v2.3.14) serving restful api under "/api". On local box everything works fine (mac / mavericks), on remote box (Ubuntu 12) the API browser comes up but all the bootstrap stuff is missing (the page looks like it's out of 1992 prototype instead of pretty bootstrap theme i see locally).
All the pip dependencies have been upgraded and are identical. Locally running site through PyCharm, remotely it is running on WSGI.
What can I check to see what the issue is and resolve it??
I suppose that under PyCharm on your local machine you are running the development server, which serves static files directly from your apps and projects internal locations.
After every deployment into production (your WSGI server) you need to collect all static files to a single place, your STATIC_ROOT. This is a job for the django management command collectstatic, see Django docs here.
The command may look like this:
# Executing collectstatic (organize static files)
python /path/to/your/project/manage.py collectstatic --noinput
For further details you may also read Django cannot find static files. Need a second pair of eyes, I'm going crazy.
If this question doesn't help, you can quicly fix it making a link under your proyect's static folder
ln -s /your_env_folder/lib/pythonX.X/site-packages/rest_framework/static/rest_framework rest_framework

How do I install an open source django-application?

I want to install an existing django app, djangopeople.net. The code is at http://github.com/simonw/djangopeople.net.
I installed django and I understand how to create a new django project.
But how do you deploy an existing app? I know how this works in Rails or Symfony, but I don't really get the django concept here.
Where do I put the files? Which scripts do I run?
Thanks for the steps.
Why is this any different from deploying your own applications? Just put them somewhere in your PYTHONPATH and set up mod_wsgi or whatever to serve them.