0
0
Djangoframework~20 mins

Development server and runserver in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Django Development Server Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you run python manage.py runserver in a Django project?

When you execute python manage.py runserver inside a Django project folder, what is the expected behavior?

AIt deletes all migrations and resets the database.
BIt compiles all Python files into bytecode and exits without starting any server.
CIt deploys the Django app to a production web server automatically.
DIt starts a lightweight web server that listens on port 8000 by default and serves your Django app.
Attempts:
2 left
💡 Hint

Think about what a development server is used for in Django.

📝 Syntax
intermediate
2:00remaining
Which command correctly starts the Django development server on port 8080?

You want to run the Django development server on port 8080 instead of the default 8000. Which command will do this?

Apython manage.py runserver 8080
Bpython manage.py runserver --port=8080
Cpython manage.py runserver -p 8080
Dpython manage.py runserver port=8080
Attempts:
2 left
💡 Hint

Check the official Django command syntax for specifying the port.

🔧 Debug
advanced
2:00remaining
What error occurs if you run python manage.py runserver outside a Django project folder?

You open a terminal in a folder that is not a Django project and run python manage.py runserver. What error will you see?

AFileNotFoundError: manage.py file not found
BModuleNotFoundError: No module named 'manage'
Cdjango.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured.
DCommandError: Unknown command 'runserver'
Attempts:
2 left
💡 Hint

Think about what Django needs to find to run the server.

state_output
advanced
2:00remaining
What is the output when you run python manage.py runserver 0.0.0.0:8000?

You want your Django development server to be accessible on all network interfaces on port 8000. What output will you see in the terminal after running python manage.py runserver 0.0.0.0:8000?

AStarting development server at http://localhost:8000/
BStarting development server at http://127.0.0.1:8000/
CStarting development server at http://0.0.0.0:8000/
DError: Invalid IP address 0.0.0.0
Attempts:
2 left
💡 Hint

0.0.0.0 means listen on all interfaces.

🧠 Conceptual
expert
2:00remaining
Why should you NOT use Django's development server (runserver) in production?

Django's runserver is great for development. Why is it not recommended for production use?

ABecause it only works on Windows and not on Linux servers.
BBecause it is single-threaded and not optimized for handling multiple users or security in production.
CBecause it requires a graphical interface to run.
DBecause it automatically deletes the database after each request.
Attempts:
2 left
💡 Hint

Think about what a production server needs compared to a development server.