Access development server - Django - python

I tried to run a friend's Django project on my Ubuntu Virtual Machine but I can't access the development server.
After a:
python manage.py runserver 0:80 --settings=a.settings.dev_a
Here the result :
Performing system checks...
System check identified no issues (0 silenced).
June 19, 2017 - 21:56:31
Django version 1.11, using settings 'a.settings.dev_a'
Starting Channels development server at http://0:80/
Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.

Add 'localhost' to ALLOWED_HOSTS in your "dev_a" file
and then like said #FlipperPA, try a
python manage.py runserver [::]:8000 --settings=a.settings.dev_a

Related

Server stops at http://127.0.0.1:8000/admin/ in python django

Here I am creating my first Django application that is basically a polls app. I have followed these steps:
Created a django app in pycharm.
Wrote two tables in models.py.
Done "python manage.py makemigrations".
It successfully created my migrations.
Done "python manage.py createsuperuser", set its username and
password.
Now doing, "python manage.py runserver", Its opening great.
Issue:
When hitting "http://127.0.0.1:8000/admin/", server just stops. No error and nothing happens. I don't understand that why I am not being able to hit the url.
urls.py
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
Server state while quitting:
C:\Users\Maha Waqar\PycharmProjects\DjangoSites>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
March 09, 2020 - 21:40:44
Django version 3.0.4, using settings 'DjangoSites.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[09/Mar/2020 21:41:20] "GET / HTTP/1.1" 200 16351
C:\Users\Maha Waqar\PycharmProjects\DjangoSites>
My folder hirearchy:
DjangoSites //root folder
->DjangoSites
->mysite //current app I am working in
It's a bug and can be fixed by upgrade to python 3.8.
https://code.djangoproject.com/ticket/31092

Accessing containerized Django app from ECS public IPv4 endpoint

I have a dockerized django app that is stored in ECR. When I set-up a new ECS cluster (using Fargate), this image loads correctly and I can see the logs in Cloudwatch:
20:12:21 Operations to perform:
20:12:21 Apply all migrations: admin, auth, contenttypes, sessions
20:12:21 Running migrations:
20:12:21 No migrations to apply.
20:12:23 No changes detected
20:12:25 Watching for file changes with StatReloader
20:12:25 Performing system checks...
20:12:25 System check identified no issues (0 silenced).
20:12:26 June 22, 2019 - 20:12:26
20:12:26 Django version 2.2.2, using settings 'config.settings'
20:12:26 Starting development server at http://127.0.0.1:8000/
20:12:26 Quit the server with CONTROL-C.
but when I got to the public ipv4 listed under the task network details, and go to :8000 in my browser, nothing loads and I dont see any requests going to the server in the container in cloud watch.
I'm wondering if the issue is related to using:
python manage.py runserver 0.0.0.0:8000 in my container set-up or alternatively, a setting in the security group, etc.
But i've allowed inbound traffic to 127.0.0.1 & 0.0.0.0 port 8000 inside the settings there already.
I'm somewhat at a loss as I've looked around at a variety of documentation and I seem to have my configuration set similarly.
You need to map your host port to container port if your container is running in bridge mod Something like docker run -p <port>:8000.to view it on browser as public_ip:port Similar configuration you have to do in fargate.
Check if in AWS Control panel for Fargate this particular container definition have correct port mapping.
In your case, you need to map to port: 8000 as your app is listening on that port. Also, you need to create that app in a container is listening to 0.0.0.0, not 127.0.0.1 ( At least from log port I can see you bind it to 127.0.0.1

Running python3 manage.py runserver but not seeing any requests

I activated my virtual environment with source env/bin/activate, and then started my server with python3 manage.py runserver 0.0.0.0:80.
I have made sure I have the following in my settings.py:
ALLOWED_HOSTS = ['xx.xx.xx.xxx', 'mywebsite.org']
I start the server and it outputs :
System check identified no issues (0 silenced).
January 28, 2019 - 21:40:33
Django version 2.0.7, using settings 'app.settings'
Starting development server at http://0.0.0.0:80/
Quit the server with CONTROL-C.
But, I visit "mywebsite.org" and it outputs
> Index of /
> Name Last modified Size Description cgi-bin
> 2018-08-23 07:26 -
The homepage of my website normally appears when I visit "http://127.0.0.1:8000/", so how can I get that to appear?
I'm using a Mac

How to allow others to connect to my Django website?

Now that I have created a website, I wish the users can connect to my website within a local network. However my website now can only be accessible from the localhost (my pc), the others are not able to connect to my website when typing my ip address for example xxx.xxx.xxx.xxx:8000 on their browser. I launch the service on my localhost using # python manage.py runserver. May I know if there is a way/command to allow the others to connect to my website?
Note: I have tried # python manage.py runserver 0.0.0.0:8000 as well, which allow all incoming, but it didn't work.
In settings.py write
ALLOWED_HOSTS = ['*'] and run python manage.py runserver 0.0.0.0:8000
Note: you can use any port instead of 8000
There are steps to resolve this problem are:
1. Use http://<your ip address> than https
2. Then in settings.py write
ALLOWED_HOSTS = ['*']
3. Finally ran the server with:
python manage.py runserver 0.0.0.0:8000

How can I debug Openstack Dashboard?

I'm running the Openstack Cloud System. I installed and deployed the kilo version on the server successful, but this is only the default version of Openstack. So that, I want to have some modifies on this openstack source and add more features to it.
I started to change something with the Openstack Dashboard. However, there are some problems happened. Therefore, I have debugged this django web application. All everything I have configured is the same as the official tutorials on the openstack website (http://docs.openstack.org).
So, I have search on my server and find out 2 places that have the sources:
The first one is /usr/share/openstack-dashboard/
The second one is /usr/lib/python2.7/dist-packages/horizon/
And the config file is /etc/openstack-dashboard/local_settings.py
I set the option Debug = True in local_settings.py file.
On the server I typed these commands:
cd /usr/share/openstack-dashboard/
python manage.py runserver
Here is the output:
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
Performing system checks...
System check identified no issues (0 silenced).
August 05, 2015 - 09:28:50
Django version 1.7.6, using settings 'openstack_dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But in the browser, it shows the error:
And then, on the console, it shows:
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2015 10:21:29] "GET / HTTP/1.1" 302 0
Not Found: /horizon/auth/login/
[05/Aug/2015 10:21:29] "GET /horizon/auth/login/?next=/ HTTP/1.1" 404 4237
Not Found: /favicon.ico
[05/Aug/2015 10:21:29] "GET /favicon.ico HTTP/1.1" 404 4206
Please help me to get out of this problems. And how can to debug Openstack Django Website properly.Thank you very much !
As you run server by runserver command you should go to the root url like
127.0.0.1:8000/
not
127.0.0.1:8000/horizon
The difference is in running method.
When you installed openstack_dashboard there is apache config that listen to address http://host/horizon look in to /etc/apache2/conf/sites-available/
The directories
/usr/lib/python2.7/dist-packages/horizon/
Is like the framework for all dashboards
/usr/share/openstack-dashboard/
Is the default dashboard for openstack
/etc/openstack-dashboard/local_settings.py
The config file for dashboard. Here you can apply changes for default dash, for example attach your project that modifies or extends default dash
So, your problem will be solved if you follow that link http://127.0.0.1:8000/
For debugging use
pdb or ide with integrated debugger
Follow this link.
http://docs.openstack.org/developer/horizon/quickstart.html
Once this is done, add pdb statements to your code that you wish to debug.Go into the horizon folder and run the following command
./run_tests.sh --runserver 127.0.0.1:port_number
Instead of local host you can put in the IP address where horizon is running
I have written the OpenStack documentation for debugging dashboards using PyCharm.
(It is good for any Openstack Dashboard including Horizon)
http://docs.openstack.org/developer/mistral/developer/troubleshooting.html

Categories