Before now, the main domain was serving a WordPress website but I needed to replace that with a new django application.
I was able to successfully deploy the Django application to cPanel, and the application was served on a subdomain without any problems. But when I edit the application url to point to the main domain, the homepage renders without the static files. Initially, I thought it was a static file issue until I tried to access other pages, but all I keep getting is a 404 page that is being served by the old WordPress. Somehow the old wordpress website is conflicting with the django app.
I'm not sure why the old wordpress is still trying to serve the new django pages except the homepage, even though static files are also missing on the homepage.
I figured out that it was the wordpress installation that was interfering with the Django application, so I renamed the wordpress index.php file, and everything works now. This means that the problem is not with the Django configuration but with the fact that a WordPress website was running on that domain before.
Changing the index.php file name fixed it; I could have deleted all the WordPress files and folders and it would still work, but since I still want to keep the files, renaming the index.php means that WordPress won't be able to load the file.
Related
I have made a flask web application and wanted to host it with netlify. When I try to preview/open my site , page not found error rises.
My site is deployed successfully! I read through other documentations but still the problem was not resolved. I have my index.html also included in my application
Link to my Github repository = https://github.com/PranaySadani/PredictX
Please tell me what I should do to resolve the issue at hand!
Netlify can only serve static web pages, which is not the case when you are using flask (with sign in and sign up functionality with database), you might want to check out other services like Heroku.
A Django-based service that I'm working on allows users to upload media files via REST API or Django admin but does not provide or use any static files (like css styles, js libraries, etc.).
Media files are stored in specific fields in database and use S3 bucket as storage backend so server itself does not directly serve any files at all.
Having such a case is running collectstatic command required every time application is being deployed?
Thought the concept of static and media files in Django application is rather simple I'm still confused about whether configurations for them should be somehow related?
As Django won't serve the staticfiles when the DEBUG is False (through deployment), if you want the css, js and other static files (at least in the admin, in your case), you need to run collectstatic.
So if you want django admin to be like your development environment (with css and images), you need it.
Your Django-based service does not need collectstatic at all.
Question is about django admin - because admin app uses static content css/img/js.
Do you use django admin in production?
If yes - then you need to run collectstatic command it, otherwise admin site will be unstyled or totally broken because of missing js files.
If no - then you collectstatic command has no use for you.
This is a bit embarassing, but I'm a Django noob and I couldn't find a simple solution to this:
I have written a Django app in a local VM that I now want to deploy to a "production" server. App works like a charm locally.
Now my IT colleague has set up the server with Django and that also works fine. I can open it via the Web and I get the usual "Congratulations on your first Django-powered page". I can also log into the admin interface. The project has been created.
This is a very low-key mini project and I'm not too familiar with git, so we've decided to just push files via FTP. (And I want to stick with that if at all possible.) So I uploaded the app folder into the project folder and also adjusted the project's settings.py and urls.py.
However, nothing seems to be happening on the server's end. The welcome page is the same, the app does not show up in the admin interface and the URLs won't be resolved as hoped.
Any suggestions what I should have done / done differently?
You need to restart apache or whatever is running your django project. Your changes to py files are cached when you first load your server config (settings).
Any suggestions what I should have done / done differently?
You should be using git/jenkins/deployment techniques, I know you said you've decided not to use it but you're going to be missing out on important things like being able to keep track of changes and unit testing
I tend to write my API documentation in Markdown and generate a static site with MkDocs. However, the site I'd like to host the documentation on is a Django site. So my question is, and I can't seem to find an answer Googling around, is how would I go about hosting the MkDocs static generated site files at a location like /api/v1/docs and have the static site viewable at that URL?
UPDATE:
I should point out I do serve all static files under Apache and do NOT use runserver or Debug mode to serve static files, that's just crazy. The site is completely built and working along with a REST API.
My question was simply how do I get Django (or should I say Apache) to serve the static site (for my API docs) generated by MkDocs under a certain URL. I understand how to serve media and static files for the site, but not necessarily how to serve what MkDocs generates. It generates a completely static 'site' directory with HTML and assets files in it.
Django is just a framework you need to host your static files and serve them with something like Nginx or Apache etc.
I think you need the alias directive in apache and use that to redirect certain URLs to your static documentation site.
from the docs
urls = [
static(settings.STATIC_URL, document_root=settings.STATIC_ROOT),
("/home","views.home"),
...
]
https://docs.djangoproject.com/en/1.8/howto/static-files/#serving-static-files-during-development
in your request you would change to
static("/api/v0/docs",document_root="/home/docs/")
I transferred my Django project from a Ubuntu server that is currently serving the website. I'm trying to run this project on a localhost MacOSX environment for testing purposes. The command I'm familiar with for Django projects is:
python manage.py runserver
After which when I input 127.0.0.1:8000 into a browser, the project displays.
But my Ubuntu server is not currently running a script in that form, rather in the form of
python manage.py celeryd
My knowledge of how celery interfaces with Django is somewhat limited so this question may be very basic, but I can't find the URL to display the project.
On my Mac server, when I run:
python manage.py celeryd
the script does not error out on me--instead, it appears to be working by displaying this:
However, I don't know how to access the project. When I put 127.0.0.1 in the browser (and many other possible variations using different ports), I get Page Not Found.
Any help is greatly appreciated.
First you need to define 'core' template tag in one of your apps templatetags library say custom_tags.py. Make sure that this app is added to INSTALLED_APPS in settings. Then in your html template add
{% load custom_tags %}
It will fix the error you are getting. For more details please read docs.
You seem confused about what celery is. It is not a webserver, and it won't serve pages for you. It is an offline task manager, useful for performing complex or long running jobs that aren't appropriate to do in the context of a web request.
You'll need an actual web server alongside celery to serve your site itself.