I have introduced a new django command which i can run from cronjob. This is particulary helpful to get ORM specification.
To Run this django command, do we need the django server should be running ?
No, the django server is a separate process completly independent from your custom command.
If you are using virtualenv (if you aren't yo probably should) keep in mind you must source the virtualenv or use the python interpreter within it in order to get the managemente command properly run.
Related
In our Django project(Django 2.1.5), every time we try to run the project we have to give the '--noreload' command in addition to the runserver command, else the project returns an error as,
ValueError: signal only works in main thread
We are using Django signals to communicate between the apps created in Django and Web-sockets in Threading aysnc-mode to connect between the other services involved in the project. When we try to deploy the project in Jenkins, this becomes a problem and we are using Nginx as the webserver for host the application. Is there any possibility to solve the issue of '--noreload' and run the application normally?
We are not sure if its because of the same problem referred above but we have a problem when trying to migrate the changes in the Models in Django, it always returns
No changes Detected
After a quick internet search, we did the migrations by mentioning the app names and it did work, yet the terminal stays still after the migrating and waits to manually terminate the process.
Is there a possible solution to overcome this? and also we would like to know where we go wrong
I'm trying to run a Django app on Google Cloud Run. The site itself works nicely, can run migrations and collect static assets via a startup script. The one thing I cannot figure out how to do is create a superuser. This requires interactively typing in a password or at least setting it via a django shell. I currently cannot figure out how to do this and it seems like it might not be possible; which would make Cloud Run unusable for Django. Has anyone been able to achieve this or have a sustainable workaround? Thanks!
Instead of Django Shell use the api to create the superuser. Once you have the script make it part of the container build process.
My web server depends on nginx, django, and a lot of python dependencies. I'm wondering if there is a way to create a portable image/script that I can run in a new server and quickly get it up and running.
Is Docker relevant to this?
You should always use git to manage your code. With git you could get your django project in the other server quickly. But just that.
Also you have to migrate your database. Every DB engine have dump options for doing this.
Do not forget to move your static assests. Probably, you've all of them in one directory.
What about your nginx, database installation and configuration? Here is relevant Docker.
With all of this, you should migrate successfully.
I'm using Django 1.4.1 with the gunicorn and nginx on my server with a setup similar to Django-Nginx-Gunicorn.
What I need is a good place to hook into Django, so that I can initialize stuff like signal listeners on startup (so it works with all management commands and server startup).
I am aware that a lot of people use urls.py or the middleware hack (Where to put Django startup code?), but those don't seem to get called when I run python manage.py shell. And at some point down the road a startup signal will be available, but I don't want to fork Django to include it, unless absolutely necessary.
I really like the startup script technique from Entry Point Hook Django Projects and it works correctly when using python manage.py runserver or any other management command. However, gunicorn starts Django without calling the management command and I can't figure out where I would modify my gunicorn startup script to run the startup.py, as shown in the WSGI.py example. Any solutions?
I have multiple django projects running different django versions in their own virtualenv. I want to use sphinx-api-doc command to generate api docs for the django projects. However i dont want to install sphinx directly in the system and would like to install it in a separate virtualenv.
Since only one virtualenv can be activated at a time, i am not able to use sphinx-api-doc. Is there a way to use sphinx-api-doc with sphinx and django in independent virtualenv or is installing sphinx directly in the system the only way to go?
The api documentation for your code can only be generated with proper access to your code, so the anser will be "no, you'll need to have them both in the same virtualenv".
Some extra thoughts:
If your code virtualenv isn't isolated from the system's python packages, you could install sphinx globally, but you probably don't and shouldn't want that.
I'd just add sphinx to your code's virtualenv. I don't think you'll have to worry about extra overhead of a few extra kilobytes.