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.
Related
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
I'm using flask as my backend and Vue.js for my frontend. I created my VueJS project with vue-cli.
The way I have my project setup right now is that my backend is serving my static files. I, npm run build, and output the bundle files to my backend.
Everything works. It's just annoying to build every time.
I would like to re-compile my bundle every time I make changes to Vue. Is this possible? Modify my webpack?
Note: My project/flask is dockerized too.
This is what I was looking for: https://github.com/vuejs/vue-cli/issues/1120 then I found https://www.npmjs.com/package/vue-cli-plugin-build-watch
I have a Django 1.9.8 app that's working most of the times. For some reason, Django stopped service application static files, including those of the build-in admin application.
Running collectstatic only looks for files in my STATICFILES_DIR, as does findstatic.
I do have django.contrib.staticfiles in my INSTALLED_APPS, and yet - Django does not look for its apps' static files.
I'm stumped and don't even know where to look next.
Turns out the problem was fixed by deleting the virtual environment and creating it again (without upgrading anything).
Hope this saves someone some time in the future.
I have a django project under a virtualenv.
I included the django-zurb-foundation 5.3.0 package to use foundation but this version only include static css files.
It's my first time using django and normally i use foundation with sass using bower and grunt.
How can i do to use the sass version of foundation?
What should be the files tree?
UPDATE
i installed django compressor and i got it work on local, it works perfectly, but i cannot get it to work on my production server:
on local env i have a CACHE folder with the css static files in it and the html page call correctly the file from there.
On the prod site instead, it doesnt create the CACHE folder and it doesnt render the path to it and it keeps the path to the scss file.
What am i doing wrong?
It seems like compressor isnt working on the prod server, i'm afraid i'm doing something wrong with django settings.py since i'm new to it.
any help?
I have heard of a few people using django-bower with foundation, personally I have not played with it but its worth looking into if you have not already.
I really can't find a reason to use a third party Django application to do that, using front-end frameworks like foundation or Bootstrap is as simple as compiling the less or sass source files to a css file and include it in your html (<link rel="stylesheet"...).
With Django you can use Bower and Grunt without any problem because they're independent and totally configurable to fill your needs. What I do with bower is to create a .bowerrc file at the same level of the bower.json file with the directory setting pointing to the main static folder, something like:
{
"directory": "my_django_app/static/bower_components"
}
Talking about the django-compressor app all that I can say is I don't recommend to use it in a production environment, it has some performance problems and personally I prefer the static files to be responsibility of the front-end dev instead of the back-end dev. For example you will need to have source maps for your javascript for debugging purposes and I don't remember if it's possible with this plugin.
Instead of using the django-compressor you can use a grunt plugin to to it, I've done one that may help you to do so: https://www.npmjs.org/package/grunt-django-compressor
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.