Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLogesh Jayaraman
445 PointsRun server
(a) what is the difference of providing manage.py runserver vs manage.py runserver 0.0.0.0:8000? (b) Can i change the port? (c) Usually if we look at .net web application usually we host it in iis server or iis express to run the web app. But in django when we use the runserver we are able to access the webpage? (d) How does it works in backend what is the server used? (e) What is the architecture behind it? (f) Do the comments generated during the server are saved some where as log files? (g) How does the prod deployment works?
5 Answers
Chris Freeman
Treehouse Moderator 68,454 Points(a) what is the difference of providing manage.py runserver vs manage.py runserver 0.0.0.0:8000?
manage.py runserver
will default to using the IP Address 127.0.0.1 and port address 8000. A different port number or a different IP address and port number can be specified in the form ipaddr:port
.
For more help on runserver
type: python manage.py runserver --help
or see Django docs
(b) Can i change the port?
Yes, the port can be specified on the command line: python manage.py runserver 8080
(c) Usually if we look at .net web application usually we host it in iis server or iis express to run the web app. But in django when we use the runserver we are able to access the webpage?
The runserver
command launches a lightweight non-production server for debug use. The runserver and the base http server code can be found in the GitHub Django repo
(d) How does it works in backend what is the server used?
The server is a lightweight python-based server provided with Django.
(e) What is the architecture behind it?
The Django basehttp server is based on the Python library module wsgiref simple_server which is based on the Python library HTTP module server
(f) Do the comments generated during the server are saved some where as log files?
The server output is directed to STDERR and STDOUT on the console running the server.
(g) How does the prod deployment works?
Runserver is not used for production. Instead a combination of Nginx or Apache Webserver and uWSGI or gunicorn Webserver Gateway Interface are used to handle web requests and feed them to the Django wsgi.py application interface which runs the project application.
Logesh Jayaraman
445 Pointsthanks for the clarification chris.
Do we need modify any code or settings for prod migration?
Chris Freeman
Treehouse Moderator 68,454 PointsUsually a project will have a different settings.py file for development vs production. The database settings, value of DEBUG, other secret key values will likely be different. There is no one solution for deploying a Django site to production. Places to learn are:
- Django docs on how to deployment
- Deploying to Digital Ocean
- Deploying using AWS elastic beanstalk
- Deploying on Heroku
- Two Scoops of Django, Chapter 31: Deploying Django Projects. A book on organizing Django projects for development and production
Logesh Jayaraman
445 PointsThanks for your response chris. How does django works behind the scene. What i am trying to understand is how the memory is allocated to run the process or also about the synchronous, Threading details .
Chris Freeman
Treehouse Moderator 68,454 PointsThat's digging into the core of Django and is beyond this forum. I suggest posting on the Django IRC channel for more information: irc://irc.freenode.net/django
Logesh Jayaraman
445 PointsThanks Chris for all your responses. Is it possible to consume API through web services using djnago
Chris Freeman
Treehouse Moderator 68,454 PointsDjango can be set up as an API.
- http://www.pydanny.com/choosing-an-api-framework-for-django.html
- googling "Django API" will show lots of solutions and tutorials
Logesh Jayaraman
445 PointsAlso what are the different types of views?
Chris Freeman
Treehouse Moderator 68,454 PointsDjango views types fall into two catagories: