Django, from zero to first page
A short, plain-language guide to what Django is, how to spin it up in a browser without installing anything, and how to build your first data model. A live sandbox is embedded below.
Your private Replit sandbox
Django needs Python and a shell, so the sandbox provider is a browser-based IDE. Replit and Gitpod both boot a Django project in about 30 seconds. Save your Replit URL below and this page will reload your sandbox next time.
If nothing loads here, the sandbox host does not allow being framed by other sites. That is a common, sensible security setting for live admin interfaces — use the "Open in new tab" button above.
Launch the sandbox- Replit templates — browser IDE with Django preset
- Gitpod on the Django repo — full VS Code in the browser
- GitHub Codespaces — built into any Django repo
- PythonAnywhere — free-tier long-lived Python host
How to put it into the sandbox
Django is not a hosted CMS — it is a framework you run. A sandbox for Django means a browser IDE where the Python + Django server runs for you, so you can code and see the live site without installing anything on your machine.
-
1. Open the sandbox provider
Click replit.com/templates and pick the Django template, or open Gitpod with the Django repo. Either gives you an IDE, a terminal, and a live URL.
-
2. Fork the template
On Replit, click Fork template (sign in with GitHub or email if asked). Replit clones the project into your account and boots a container in a few seconds.
-
3. Wait for the environment to build
The first boot runs
pip install -r requirements.txtautomatically. Watch the terminal on the right — when it prints "Starting development server at 0.0.0.0:8000" the site is up. -
4. Open your live URL
A tab appears on the right showing the running Django site. Click the Open in new tab icon to get a full-page URL — that is your sandbox link. Paste it below so this page reloads it next visit.
-
5. Create the admin user
In the Replit shell run
python manage.py createsuperuser. Enter a username, email and password. Now visit/admin/at your live URL and log in — you have a working Django Admin. -
6. Add an app and a model
In the shell run
python manage.py startapp blog. Openblog/models.py, add aPostclass withtitleandbody. Register it inblog/admin.py. Runmakemigrationsthenmigrate. Refresh /admin/ — a new Posts section appears. -
7. Wire up a URL
Create
blog/urls.pymapping''to a view that returnsPost.objects.all(). Include it from the projecturls.pywithpath('blog/', include('blog.urls')). Refresh — your posts render. -
8. Save what you want to keep
Replit keeps your fork for as long as your account exists, so you can come back to it. To take the code with you, click the three dots and export as a ZIP, or connect a GitHub repo and push. Do not put secrets in the code — use Replit Secrets instead.
Step-by-step guide
-
1. What Django is
Django is a free, open-source web framework written in Python. It is not a CMS out of the box — it is a toolkit for building web apps quickly. It ships with an ORM (a Python way to talk to a database), a URL router, a template engine, forms, users and permissions, and a very good auto-generated Admin site that behaves like a CMS. Instagram, Pinterest, Mozilla and NASA have all shipped production sites on it.
Was this useful? -
2. Try Django without installing anything
Two easy paths: Replit gives you a browser IDE with Python and Django pre-installed and a live URL for your app; or Gitpod opens a full VS Code in the browser with Django ready to run. Both are free for small projects and disposable — perfect for a first tour.
Was this useful? -
3. What you need to run it yourself
Python 3.10 or newer, and pip (Python's package manager, ships with Python). That is really it. For a database Django uses SQLite by default (a file, no server), and only needs PostgreSQL or MySQL if you go to production or want features SQLite lacks. Optional but recommended:
venv(built into Python) to isolate project dependencies.Was this useful? -
4. Install Django locally in one minute
Open a terminal, then run
python -m venv .venv,source .venv/bin/activate(or.venv\Scripts\activateon Windows),pip install django,django-admin startproject mysite,cd mysite,python manage.py migrate,python manage.py runserver. Open http://127.0.0.1:8000 and you see the green rocket welcome page.Was this useful? -
5. First run — the Admin site
Create an admin user:
python manage.py createsuperuser. Answer the prompts. Restart the server, open /admin/, and log in. Django's Admin is a full CRUD interface auto-generated from your data models: it looks like a CMS out of the box and is where most Django projects start.Was this useful? -
6. Apps and models — the core idea
A Django project is a collection of "apps" — self-contained features (blog, shop, forum). Create one with
python manage.py startapp blog. Inblog/models.pydeclare a class per table (for examplePost(title, body, published_at)). Then runpython manage.py makemigrationsandpython manage.py migrate. Register the model with the Admin site inblog/admin.pyand it appears in /admin/ as an editable content type — no HTML needed.Was this useful? -
7. URLs, views and templates
Every URL is mapped to a Python function ("view") in a per-app
urls.py. The view fetches data from the ORM and renders a template (an HTML file in atemplates/folder). Django's template language is simple:{{ post.title }},{% for post in posts %}. Global URL wiring lives in the project's rooturls.py.Was this useful? -
8. Users, authentication and permissions
Django ships with a full auth system:
Usermodel, sessions, login/logout views, password reset, and per-model permissions (add, change, delete, view). Just addpath('accounts/', include('django.contrib.auth.urls'))and you get every auth URL for free. Superusers can create staff users and grant them per-app admin rights inside /admin/.Was this useful? -
9. Add features with reusable apps
The Django ecosystem calls plugins "apps". Install with pip: for a REST API use Django REST framework (
pip install djangorestframework); for search use django-haystack; for a full CMS UI use Wagtail or django CMS; for background jobs use Celery or django-q; for forms use django-crispy-forms. Add each toINSTALLED_APPSinsettings.pyand run any migrations it ships with.Was this useful? -
10. Publishing your site
Set
DEBUG = Falsein settings, generate a strongSECRET_KEY, add your domain toALLOWED_HOSTS, switch to PostgreSQL, runpython manage.py collectstatic, then deploy. Easiest hosts: Fly.io, Railway, Render, Heroku, or a VPS with gunicorn + nginx. Set environment variables for the secret key and database URL — never commit them to git.Was this useful?
One-page cheat sheet
Create a project and app
python -m venv .venv
source .venv/bin/activate
pip install django
django-admin startproject mysite
cd mysite
python manage.py startapp blog
python manage.py migrate
python manage.py runserver Data model workflow
# edit blog/models.py, then:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser Deploy checklist
# settings.py
DEBUG = False
ALLOWED_HOSTS = ["example.com"]
# environment
python manage.py collectstatic
python manage.py migrate
gunicorn mysite.wsgi --bind 0.0.0.0:8000 Useful manage.py commands
python manage.py shell # interactive Python + ORM
python manage.py test # run tests
python manage.py dumpdata # export data as JSON
python manage.py loaddata # import data from JSON
XIA LEI