A Python full stack developer builds both sides of a web application: the back end that stores data and runs the logic, and the front end that users see. This guide covers the web half of that journey: choosing between Django and Flask, the front-end basics you need, REST APIs and JSON, Django models, queries, templates, forms, login and REST Framework, calling other APIs, scraping responsibly, and putting your app online. It ends with the questions interviewers ask about Python web projects.
If you are new to the language itself, start with our Python for Beginners guide first.
Contents
- 1. The Python full stack roadmap
- 2. Django vs Flask: which to learn first
- 3. HTML, CSS and JavaScript for Python developers
- 4. REST APIs and JSON
- 5. HTTP status codes
- 6. Django models and migrations
- 7. Django ORM queries
- 8. Django templates and inheritance
- 9. Django forms and validation
- 10. Django authentication
- 11. Django REST Framework: your first API
- 12. Building a REST API with Flask
- 13. Calling APIs with requests
- 14. Web scraping with BeautifulSoup, responsibly
- 15. Deploying a Python web app with Nginx
- 16. Python web interview questions
1. The Python full stack roadmap
The skill list can look endless, so learn it in an order where each step builds on the last:
- Core Python: variables, loops, functions, lists, dictionaries, files, exceptions and modules, practised with small daily programs.
- Object-oriented Python: classes, inheritance and decorators, which Django and Flask use everywhere.
- SQL and a database: SELECT, JOIN, GROUP BY and keys on MySQL or PostgreSQL. Interviewers ask SQL even for developer roles; see our SQL guide.
- A web framework: pages, forms, login and models in Django or Flask.
- REST APIs and JSON: return JSON with the right status codes, then try Django REST Framework.
- Front-end basics: HTML, CSS and JavaScript, then fetch data from your own API.
- Tools: Git, virtual environments, logging and a debugger.
- Deployment: put one project online; a live link beats a screenshot on a resume.
- Projects and interviews: two or three complete projects on GitHub with clear READMEs, and practice explaining how a request travels from the browser to the database.
Most freshers need several months of steady work; consistency matters more than speed. For project ideas, see 5 Python full stack project ideas for freshers.
2. Django vs Flask: which to learn first
Django comes with a database layer (ORM), login system, admin panel and form handling built in, and suits larger projects and teams that want one clear structure. Flask is small and flexible: you add only what you need, which suits small apps, APIs and learners who want to see how each piece connects. Both map web addresses to Python functions, use templates, connect to databases and include a development server.
Many courses teach Django first, because its built-in features cover what most job projects need. If you want to understand routing and requests before the framework does the work, spend a week or two on Flask, then move to Django. Knowing both makes you a stronger developer.
3. HTML, CSS and JavaScript for Python developers
- HTML gives a page its structure: headings, paragraphs, forms, buttons and links. In Django you write HTML in templates and fill in data from Python.
- CSS controls how the page looks: colours, spacing and a layout that works on a phone as well as a laptop.
- JavaScript runs in the browser to make pages interactive, such as checking a form before it is sent or loading data without a refresh.
You do not need to become a designer: learn enough HTML to build clear forms, enough CSS for a clean responsive layout, and enough JavaScript to handle forms and call an API.
4. REST APIs and JSON
A REST API lets two programs talk over the web. One sends a request to an address with a method; the other replies with data, usually JSON.
- Endpoint: the address, such as
/students/12. - Method: GET reads, POST creates, PUT updates and DELETE removes.
- Response: a status code plus the data.
JSON is text holding keys and values, such as {"name": "Asha", "marks": 82}. Python reads it into a dictionary with json.loads() (or json.load() for a file) and turns a dictionary back into JSON with json.dumps(). Common mistakes: forgetting the response is text until parsed, assuming a key is always present, and ignoring error codes such as 404 or 500. Once you can read an API, the next step is to build one in Flask or Django.
5. HTTP status codes
- 200 OK: the request worked.
- 201 Created: a new item was saved, usually after a POST.
- 400 Bad Request: the data sent was wrong or incomplete.
- 401 / 403: not signed in (401) or not allowed (403).
- 404 Not Found: the address or record does not exist.
- 500 Internal Server Error: the server code failed; check the logs.
When a call fails, look at the status code first, then the response body: a 400 points to the data you sent, a 500 to the server code.
6. Django models and migrations
In Django you describe data as Python classes called models, and migrations turn them into tables:
class Course(models.Model):
title = models.CharField(max_length=120)
duration_months = models.PositiveIntegerField()
created_at = models.DateTimeField(auto_now_add=True)Each attribute becomes a column, and the field type also drives validation in forms and the admin. Run python manage.py makemigrations to write a migration describing your change, then python manage.py migrate to apply it. Treat migration files as version control for your database and commit them to Git.
Use ForeignKey for one-to-many links, such as course = models.ForeignKey(Course, on_delete=models.CASCADE) on an Enrollment, and think about the on_delete rule rather than copying CASCADE everywhere. Use a many-to-many field when both sides can have many, such as courses and tags. Common problems: adding a required field to a table with existing rows (give a default or make it nullable first), editing migrations already applied elsewhere, and forgetting to register a model in admin.py.
7. Django ORM queries
Course.objects.all(): every row.Course.objects.get(id=5): exactly one row; raises an error if none or several match.Course.objects.filter(duration_months=5)and.exclude(is_active=False): matching or non-matching rows.
These return a lazy QuerySet: no query runs until you loop, slice or count. Double underscores add conditions: title__icontains="data", fee__gte=10000, start_date__year=2026, id__in=[1, 2, 3], and they follow relationships too: Enquiry.objects.filter(course__title__icontains="python").
Course.objects.filter(is_active=True).order_by("-created_at")[:10] gives the ten newest active courses. Use .count() and .exists() instead of len(). To avoid N+1 queries on list pages, use select_related() for foreign keys and prefetch_related() for collections. annotate(num_enquiries=Count("enquiry")) is the ORM version of GROUP BY. Print str(queryset.query) or use Django Debug Toolbar to see the SQL.
8. Django templates and inheritance
Views decide what data to show; templates decide how it looks. Pass data with render(request, "courses/list.html", {"courses": courses}), then display it with {{ course.title }} and filters such as {{ created_at|date:"d M Y" }}. Tags handle logic: {% for %} with {% empty %}, {% if user.is_authenticated %}, and {% url "course-detail" course.id %} so links never break when paths change.
Template inheritance saves copying headers and footers: put the shared layout in base.html with an empty {% block content %}{% endblock %}, then start every page with {% extends "base.html" %} and fill only that block. Load CSS with {% load static %} and run collectstatic in production. Django escapes variables automatically to block script injection, so never use the safe filter on user input, and keep heavy logic in views and models.
9. Django forms and validation
A Form handles input not tied to a table, such as a search box; a ModelForm builds fields and validation from a model, and form.save() writes the row:
class EnquiryForm(forms.ModelForm):
class Meta:
model = Enquiry
fields = ["name", "phone", "course"]
def clean_phone(self):
phone = self.cleaned_data["phone"].strip()
if not phone.isdigit() or len(phone) != 10:
raise forms.ValidationError("Enter a 10-digit phone number.")
return phoneIn the view, build the form from request.POST, call is_valid(), then save and redirect on success (the POST-redirect-GET pattern stops duplicate submissions on refresh) or re-display the errors. Override clean() for rules involving two fields. Include {% csrf_token %} in every POST form, read from cleaned_data rather than request.POST, and remember that browser checks can be bypassed: server-side validation is what protects your data.
10. Django authentication
Never build password handling yourself. Django provides a User model with securely hashed passwords, ready-made login, logout and password reset views, the @login_required decorator and request.user in every view and template.
- Include
path("accounts/", include("django.contrib.auth.urls")), createregistration/login.html, and setLOGIN_REDIRECT_URL. In recent versions logout must be a POST, so use a small form with a button. - For signup,
UserCreationFormdoes most of the work; save the user and log them in withlogin(request, user). - Protect function views with
@login_requiredand class-based views withLoginRequiredMixin, then add separate checks so users can only access their own records.
Authentication is who the user is; authorisation is what they may do. Use Django’s password validators, keep DEBUG = False and the secret key out of your code in production, and plan a custom user model at the very start if you need extra profile fields.
11. Django REST Framework: your first API
Install with pip install djangorestframework and add "rest_framework" to INSTALLED_APPS. A serializer converts models to JSON and validates incoming JSON, like an API version of a ModelForm:
class CourseSerializer(serializers.ModelSerializer):
class Meta:
model = Course
fields = ["id", "title", "duration_months"]
class CourseList(generics.ListCreateAPIView):
queryset = Course.objects.all()
serializer_class = CourseSerializerListCreateAPIView handles GET (list) and POST (create); RetrieveUpdateDestroyAPIView handles a single item. Map it with path("api/courses/", CourseList.as_view()) and open the URL: DRF shows a browsable page for testing. It returns 200, 201, 400 and 404 correctly, so do not override them without reason. Before calling it done, set permissions (IsAuthenticatedOrReadOnly is a sensible start), turn on pagination, and write tests with APITestCase.
12. Building a REST API with Flask
from flask import Flask, jsonify, request
app = Flask(__name__)
courses = [{"id": 1, "title": "Python Full Stack"}]
@app.get("/api/courses/<int:course_id>")
def get_course(course_id):
for c in courses:
if c["id"] == course_id:
return jsonify(c)
return jsonify({"error": "Course not found"}), 404
@app.post("/api/courses")
def create_course():
data = request.get_json(silent=True) or {}
title = str(data.get("title", "")).strip()
if not title:
return jsonify({"error": "title is required"}), 400
course = {"id": len(courses) + 1, "title": title}
courses.append(course)
return jsonify(course), 201Run it with flask --app app run --debug. Returning a tuple sets the status code. To make it real, replace the list with a database via SQLAlchemy, split routes into Blueprints, test with Flask’s test client, and deploy with Gunicorn behind Nginx, never the debug server.
13. Calling APIs with requests
import requests
response = requests.get("https://api.example.com/courses",
params={"city": "Bengaluru"}, timeout=10)
response.raise_for_status()
courses = response.json()
requests.post("https://api.example.com/enquiries",
json={"name": "Asha", "course": "Python Full Stack"}, timeout=10)params builds the query string safely, timeout stops your program waiting forever (always set it), raise_for_status() turns 4xx and 5xx responses into errors, and json= encodes data and sets the right header. Catch requests.exceptions.Timeout and HTTPError separately. Send API keys in headers such as Authorization: Bearer ..., keeping them in environment variables. Reuse a requests.Session() for many calls, back off when an API returns 429, and log status codes rather than whole responses containing private data.
14. Web scraping with BeautifulSoup, responsibly
Scraping reads information from web pages with a program. Check the site’s robots.txt and terms first; if automated collection is not allowed, do not scrape, and look for an official API instead.
import requests
from bs4 import BeautifulSoup
r = requests.get("https://example.com/courses", timeout=10,
headers={"User-Agent": "course-research/1.0"})
r.raise_for_status()
soup = BeautifulSoup(r.text, "html.parser")
titles = [h2.get_text(strip=True) for h2 in soup.select("h2.course-title")]Be polite: wait between requests, cache pages instead of downloading them twice, and stop if the site returns errors or asks you to slow down. Save results to CSV and check for missing values and duplicates. Personal data such as names and phone numbers has privacy rules, copying large amounts of copyrighted content can be a legal problem, and scrapers need maintenance because pages change.
15. Deploying a Python web app with Nginx
Before deploying, put the code in Git with secrets kept out, list packages in requirements.txt, and test with production-like settings. Then:
- Choose a host: a small cloud server or a platform service.
- Copy the code and install packages in a virtual environment.
- Set environment variables for secrets and the database address.
- Run the app with a production server such as Gunicorn, never the development server.
- Put Nginx in front as a reverse proxy, check the logs and open the app in a browser.
Nginx receives requests on ports 80 and 443, forwards them to your app’s internal port, serves static files quickly and handles HTTPS:
server {
listen 80;
server_name example.com;
location /static/ { alias /var/www/app/static/; }
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Always run sudo nginx -t before sudo systemctl reload nginx, and add free HTTPS with Let’s Encrypt and Certbot. Common errors: 502 Bad Gateway (the app is not running on the proxied port), 404 for static files (wrong alias path) and 413 (raise client_max_body_size for uploads). The classic mistakes are leaving debug mode on, putting the database password in code and forgetting to update requirements.txt.
16. Python web interview questions
- What is a Django model, view and template? A model describes stored data; a view receives a request and returns a response (a rendered template or JSON); a template displays the data.
- select_related vs prefetch_related? select_related joins single-valued relationships in one query; prefetch_related loads related collections separately and links them.
- Why does a list page run too many queries? Reading related fields row by row creates an N+1 pattern; load relationships in batches.
- What does a migration record? A schema change or data operation, applied consistently to every database.
- What is CSRF protection? It stops another site making state-changing requests with a user’s session; include the token in your POST forms.
- GET vs POST in a form? GET retrieves information and puts values in the URL; POST is for actions that change data.
- What is the POST-redirect-GET pattern? Redirect after a successful POST so refreshing does not resubmit the form.
- Why validate on the server if React already checks? Browser checks can be bypassed; validate types, ranges and permissions before writing data.
- What is a fixture? Serialised data Django can load, such as demo categories; keep private production data out of it.
- How do you test a Django app? Test creating, editing and deleting records, invalid form data that should save nothing, and the same requests as a second user to confirm ownership checks.
- What belongs in a project README? Prerequisites, setup, how to run migrations and tests, and one example of what the app does.
For many more questions, see the Python Full Stack questions and answers, and for a guided first project, follow your first Django CRUD project.
Learn Python Full Stack with ScholarLogic
This order is the basis of the Python Full Stack course in Bangalore at ScholarLogic, BTM Layout, with Django, REST APIs, front-end basics and deployment practised through projects at every stage. Book a free demo class and a counsellor will share the fee and the next batch dates. To book, call 78923 93639.

ScholarLogic Student Project Videos: Python Full Stack Apps Built in BTM Layout - ScholarLogic
[…] build something similar, start with our Python Full Stack with Django guide, 5 Python full stack project ideas and your first Django CRUD […]