How to Access URL of Localhost Django Project - Page Not Found - python

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.

Related

Problem in deploying Django website on Cyber Panel

I have deployed the Django website on openlite server and cyberpanel. According to the documentation of the cyberpanel, there is no requirement to run the server manually. The default page of cyberpanel will be removed automatically once the Django website will be there. But in my case, that default page is still there. As this is not working, I tried it by executing the following command:
python manage.py runserver example.com:8000
After this, the website is working only on port 8000 i.e. "https://example.com:8000", but not on "https://example.com".
I have tried configuring all the settings in settings.py like setting the allowed host to ["*"] and also configuring the configurations of vhost in cyberpanel but still it is not working.
Can anyone help please ?

Django: Push app from local server to production server via FTP

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

Download and setup a Angular/Django site from server to localhost?

Hi I am new to Django and have been googling for a whole day without any success.
Basically there is a live/working website built with AngularJS, Django and PostgreSQL (Ubuntu 14.04) and I am trying to download all the files and clone the site into my localhost (Ubuntu 14.04).
After I downloaded the folder and finished install the required packages on my localhost, I run:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
The server runs without reporting any errors.
However, some of the links are directed to a 404 page, such as this:
http://127.0.0.1:8000/city/chicago
Whereas in the live site, it would direct to the correct working page.
Can someone tell me what may have gone wrong in the process?
Thanks.
Try editing the settings.py file set the DEBUG value to True. Instead of a 404 you should get a full debug of the actual request and see what exactly is missing (I suspect missing data as #NightShadeQueen pointed).
Also you might have a look at django debug toolbar which prints the executed sql queries as well and run them against your local database to see what exactly they return.

Deployment issues of Django CMS Project on Ubuntu Server

I'm a rookie to Django and Django CMS but definitely enjoying the framework thus far.
I have a question regarding deploying a Django CMS project on Ubuntu Server. When we deploy it on the Ubuntu desktop version, the project works just fine without any issues, but on the server, we run into trouble with the CMS admin interface. Although the content of the sidebar is functional, it does not collapse anymore and once we select an option from the CMS toolbar, the modal window that pops up is unresponsive.
Initially i thought there was an issue with my project, but then we just installed a basic django CMS project on the server itself, without any other apps, and the issue still persisted. I am using Django 1.7.3, Django CMS 3.0.9, and Ubuntu Server 14.04. I am unable to determine what the issue is and no errors are thrown. Tried searching the web for this issue, but we couldn't find any similar issues.
UPDATE:
So i was able to narrow down the problem here to some extent. Found out that the problem was with the browser. A few versions of chrome were giving me these issues. IE and Firefox were working just fine.
UPDATE 2:
As #mkoistinen suggested, this problem had been occuring on devices with touch-screens and mouse capabilities. Please look at this issue.
I run Django and CMS, etc. on Ubuntu servers all day long, so there is not an issue with the OS for sure.
Having said this, running Django locally can be very different than running it in a production environment. Locally, runserver takes care of a lot of things you have to address yourself on a server under the WSGI implementation of your choice.
It sounds like you have WSGI configured well enough to get Django to respond, but you may be having trouble with your STATIC and MEDIA paths. Definitely check the settings for these items.
Another thing to look at is, did you run python manage.py collectstatic on the server? If not, the static files from your packages will not have been copied into your STATIC_ROOT, which could easily lead to the condition you describe above.
If your client is both touch- and mouse-capable, please note that this is an issue that is fixed in 3.0.10.

Django deployment final step

I have a Django project with 1 app that is working locally and I am trying to make it work on the server but I imagine I am still missing something...
The steps I have followed are:
1) create a virtualnev
2) Install django and the libraries I need
3) copy my local project to the server, keeping the same directory structure
4) create the file passenger_wsgi.py (python passenger_wsgi.py did not return any error)
After this do I need to do anything like python manage.py runserver? Or with this I should be already able to see the site through mydomain/my project/ my app (when I do ot just get an error 404)?
I have read the django book and followed the tutorial, but this part is not well described anywhere...
Thanks in advance for any help!
Deployment is explained in the documentation.
You need to actually serve your application with some kind of HTTP server and something to run your python code. Some of the possible combinations are:
nginx with uWSGI
Any web server as reverse proxy with gunicorn
Apache with mod_wsgi
Your hosting service may or may not give you the choice or even the possibilty to do this.
There is a list of Django friendly hosters in the Django wiki.
Well firstly you might want to go through the previously asked questions.
When you are deploying using passenger you do not need to run manage.py runserver , etc. The passenger_wsgi file should take care of it.
You might want to check this link out, in the first answer also contains link to Dreamhost which details quite extensively on how to achieve the same.
Visit Deploying Django app using passenger
From my personal experience I found Nginx and uwsgi setup to be much more easier to handle and work and debug in the logs, but this is subjective to your needs and platform you may have.

Categories

Resources