Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Django
  • Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose
  • Getting Started with Django: Models, Views, Templates, the ORM and the Admin
  • Your First Django Project and App: uv, startproject, startapp and a First View
  • The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built
  • How a Request and a Login Flow Through Django: URLconf, ORM, CSRF, Password Hashes and Sessions
  • Testing a Django Blog with pytest-django: Fixtures, the Test Database and the Client
  • One Blog, Three Frameworks: Routing, Models, Templates and Layout in Django, FastAPI and Flask
  • Building a Blog with an AI Coding Agent: Plan Mode, a Master Prompt and the First Review
  • Handing a Figma Design to an AI Agent: Compare the Files, Then Review the Change
  • Django Models, Migrations and the Admin: From a Post Class to a Real Table
  1. Blog
  2. /
  3. Django
  4. /
  5. Fundamentals

Handing a Figma Design to an AI Agent: Compare the Files, Then Review the Change

Give the downloaded design to the AI agent, then compare the two project trees file by file. In Django it added two fields and a Quill editor, in FastAPI a bcrypt clash broke login until a pin fixed it, and in Flask five pages never got the design while CORS and Swagger arrived uninvited.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Fundamentals

What you will learn

  • Hand a downloaded design to an AI agent with one clear prompt and short follow-ups
  • Compare the project before and after to see which files really changed
  • Read an error log from the last line up and fix a library clash with a pin
  • Review a design change for missed pages, new fields and extras nobody asked for

Before you start

  • A blog built by an AI agent
  • The downloaded design src folder

The blog works, but it looks plain. We have a design for it, downloaded as an src folder in the previous step. Now the agent brings the two together, and we check exactly what it changed.

The Django, FastAPI and Flask tracks each did this once. The method is the same, and the screenshots looked equally good in all three. The file compare told three different stories, and that's the part worth learning.

A redesign is mostly the front of the house

In a restaurant, the kitchen is where the work happens and the dining room is what guests see. A redesign is new tables, new colours, new menus. The cooks keep their recipes. In a web app, the kitchen is the routes, the models and the database. The dining room is the templates and the style files.

What a design change should touch: templates and static files on the visible side. The models, routes or views and the database on the work side should stay the same. Changes that cross into the work side are the ones to review closely: in Django, two new Post fields; in FastAPI, the password code; in Flask, CORS and Swagger. What users see (expected to change) The work side (expected to stay) templates: base.html and the pages static: style files models views or routes database crossed over: review these Django fields, FastAPI passwords, Flask CORS Compare the trees file by file to see which side each change landed on.
A design change should land on the left. Anything on the right needs a closer look.

Handing over the design

First the design's src folder goes into the project (Django called it sample design, FastAPI figma design; in Flask it was dragged into the agent's chat). Then one prompt, in Role, Context, Task and Format:

PartWhat it says (FastAPI and Flask sample)
RoleA FastAPI (or Flask) developer working on our blog.
ContextThe blog as it is, with its Jinja2 templates and style file, plus the design folder with its sample HTML and CSS.
TaskApply the design to every page. It's elegant but short on colour, so add colour to the buttons, add some borders, make it friendlier. Keep everything the blog already does.
FormatA short plan first (Flask: with the list of files it will change), then the changes and the command to run the app.

The Django prompt asked for more: upgrade every page, design login and sign-up, let only the admin write posts from a proper page with a rich text editor, and let signed-up users comment.

Then short, specific follow-ups, one at a time. In Django: sample posts and a test admin, more borders and colour, and an editor that needs no key (the agent had picked TinyMCE, whose cloud version asks for an API key, so it switched to Quill). In FastAPI and Flask: can the whole app start with python main.py? In both, the compare showed main.py hadn't changed, because it already did. A follow-up can turn out to be done already. You check it and move on.

Compare the trees, not the screenshots

The before and after screenshots look like a whole new blog in every track. To see what really happened, the lecture compared the two project trees with a small script, file by file (an md5 per file):

Files before / afterAddedRemovedChangedUnchanged that matters
Django107 / 1128315views.py
FastAPI23 / 230011models, routes/posts.py, base.html
Flask24 / 25106routes, models, and five templates

In every track, the look arrives the same way. base.html, the template every page builds on, links the style file from the static folder. The browser gets the HTML, reads that link line, and asks for the CSS, which the server sends from static. So the design lives in two places: the templates hold the layout, and static holds the colours and styles. In FastAPI, base.html didn't change at all; style.css grew from 351 lines to 611. In Flask, base.html grew from 71 to 109 lines and style.css from 293 to 1076.

Now the part that differs per track.

Django: two new fields and an editor with no key

Eight files were added: three style files in static/css, a new migration, a setup_demo.py script, and three files for an API with a docs page. The old README and two setup guides were removed. Of the fifteen changed files, seven are templates; base.html grew from 74 lines to 153. And views.py didn't change at all. The kitchen kept its recipes.

One change did reach the kitchen. The design's cards show a category and a summary, so Post got two new fields in blog/models.py:

    CATEGORY_CHOICES = (
        ('Design', 'Design'),
        ('Development', 'Development'),
        ('Culture', 'Culture'),
        ('Technology', 'Technology'),
        ('Business', 'Business'),
        ('Other', 'Other'),
    )

    excerpt = models.TextField(max_length=500, blank=True, help_text='Brief summary of the post')
    category = models.CharField(max_length=20, choices=CATEGORY_CHOICES, default='Other')

A new field means a new migration, 0004_post_category_post_excerpt. The read time on every card comes from a small helper:

    def get_read_time(self):
        """Calculate estimated read time based on word count (avg 200 words/min)"""
        word_count = len(self.content.split())
        read_time = max(1, round(word_count / 200))
        return f"{read_time} min read"

The form follows the model (title, excerpt, category, content, status), and the card falls back to the first 25 words of the content when there's no excerpt. One field travels all the way from the form to the model, the table and the card.

For the editor, post_form.html loads Quill from a CDN and keeps a hidden textarea named content. Quill's text-change event copies its HTML into that textarea, and submit copies it once more, so Django saves it like any other field. Because it's a CDN, the write page needs an internet connection to load the editor.

Review points:

  • The prompt said only the admin writes posts, but a plain user who signed up could write one too. The write page still checks that you're logged in, not that you're the admin.
  • TinyMCE is gone from the code, but django-tinymce is still in the requirements.
  • After create_sample_posts, the shell count showed 6 posts, 6 with an excerpt, and categories ['Other']. The setup script sets categories; the command never does.
  • manage.py now starts the server when you run it with no command. Nobody asked for that.

FastAPI: a login crash fixed with a pin

Eleven files changed: style.css, six templates, app/main.py, the password code in app/auth.py, the register route and requirements.txt. The templates changed their words, not their forms: login.html now says Welcome back, with placeholders and a Sign in button, but the same fields with the same names, so the login route reads them as before. app/main.py grew from 31 to 45 lines because the FastAPI(...) call got a description, a version, a contact and a license for the docs page.

Then the interesting part. Logging in as the admin gave an internal server error. The full log went to the agent, and the lecture rebuilt the same crash in a clean folder with passlib 1.7.4 and the newest bcrypt, 5.0.0. The end of the traceback:

  File ".\v_latest\Lib\site-packages\passlib\handlers\bcrypt.py", line 421, in _finalize_backend_mixin
    if detect_wrap_bug(IDENT_2A):
       ~~~~~~~~~~~~~~~^^^^^^^^^^
  File ".\v_latest\Lib\site-packages\passlib\handlers\bcrypt.py", line 380, in detect_wrap_bug
    if verify(secret, bug_hash):
       ~~~~~~^^^^^^^^^^^^^^^^^^
  File ".\v_latest\Lib\site-packages\passlib\utils\handlers.py", line 792, in verify
    return consteq(self._calc_checksum(secret), chk)
                   ~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File ".\v_latest\Lib\site-packages\passlib\handlers\bcrypt.py", line 655, in _calc_checksum
    hash = _bcrypt.hashpw(secret, config)
ValueError: password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])

The last line blames the password, but the admin's test password is short. Read the lines above it: the error starts inside passlib's detect_wrap_bug, where passlib tests bcrypt with a long password of its own while setting it up. The newer bcrypt refuses that test. It's a clash between two library versions.

passlib 1.7.4 is the newest passlib on PyPI (uploaded 2020-10-08), so there's nothing to upgrade to. The fix is to pin bcrypt to a version passlib works with. With bcrypt==4.0.1, the same check runs and prints:

bcrypt 4.0.1
hash prefix $2b$12$

2b is the bcrypt format and 12 is the cost. In requirements.txt the pin now sits right under the library that needs it:

passlib[bcrypt]==1.7.4
bcrypt==4.0.1

One honest detail: the first blog already listed the same pin at the bottom of the file, so in the compare this file only moved one line. A pin helps only once you install from the file again. And these passwords are hashed, not encrypted: at login the blog hashes what you type and compares the two. Nothing is ever decrypted.

The agent also changed the password code. Both functions in app/auth.py now cut the password to 72 bytes:

def verify_password(plain_password: str, hashed_password: str) -> bool:
    # Truncate password to 72 bytes (bcrypt limit)
    truncated_password = plain_password.encode('utf-8')[:72].decode('utf-8', errors='ignore')
    return pwd_context.verify(truncated_password, hashed_password)

and the register route got two checks:

    # Validate password length
    if len(password) < 6:
        return templates.TemplateResponse(
            request=request,
            name="register.html",
            context={"error": "Password must be at least 6 characters long", "user": None}
        )

    if len(password.encode('utf-8')) > 72:
        return templates.TemplateResponse(
            request=request,
            name="register.html",
            context={"error": "Password is too long (max 72 bytes)", "user": None}
        )

Review points:

  • Register turns long passwords away, but login quietly cuts them. Registering with exactly 72 bytes and logging in with those 72 bytes plus extra text worked. The cut was already there before (bcrypt only reads 72 bytes); the agent made it visible but didn't close it.
  • The cut in auth.py doesn't fix the crash. The pin did. Ask why the cut is there.
  • A visitor on the write page sees a raw JSON line, {"detail":"Not authenticated"}, instead of the login page.
  • The findings from the first review are still there: admin chosen by email and the unused token code (see the first review).

Flask: pages the design missed, and extras nobody asked for

Six files changed. Four are the look: style.css, base.html, index.html (81 lines to 195, now with a featured article on top) and post_detail.html (95 to 189). The data didn't change: same view, same posts, same variables.

Now look at what didn't change. login.html, register.html and the three admin templates are the exact same files as before. Each still starts with:

{% extends "base.html" %}

So they pick up the new header and footer from base.html, and nothing else. The login page has the new header on top, and in the middle the same plain card with the default blue button. The screenshots hide this. The compare doesn't.

The first run also stopped with errors. The full log went to the agent, which fixed it. That's fine, but don't paste and pray: read the last line, see which file it names, and when the fix comes back, check that the diff touched that file and nothing unexpected.

The other two changed files aren't about the look at all. app/__init__.py grew from 34 to 53 lines:

from flask_swagger_ui import get_swaggerui_blueprint
from flask_cors import CORS

# Swagger UI configuration
SWAGGER_URL = '/api/docs'
API_URL = '/static/swagger.json'


def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)

    # Enable CORS for all routes
    CORS(app)
    ...
    # Register Swagger UI blueprint
    swaggerui_blueprint = get_swaggerui_blueprint(
        SWAGGER_URL,
        API_URL,
        config={
            'app_name': "Flask Blog API"
        }
    )
    app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL)

The new static/swagger.json is 548 lines, written by hand, listing ten of the blog's routes, and flask-cors and flask-swagger-ui came into the requirements. /api/docs went from 404 to 200. We asked for a design and got these as well. The track looks at CORS properly in Inside a Flask Blog.

Running it, every answer matched the first blog: 200 for the home page and a post, 302 to login for a visitor on the dashboard, 403 for a plain user on the dashboard and the write page. Review points:

  • Name the five missed pages (login, register, dashboard, create post, edit post) and ask for the same look there.
  • Line 23 of index.html shows the post's word count as "min read", so a card can say 194 min read. A real reading time divides by a reading speed.
  • CORS for every route and a hand-written docs file that has to be kept in step with the routes. Keep them only if the blog needs them.
  • SimpleMDE still loads from a link that says latest. Pin a version.

Common mistakes

  • Judging the change by screenshots. In Flask, five pages looked redesigned and weren't.
  • Trusting the last line of a traceback. "Password too long" was really a version clash, found by reading the lines above it.
  • Keeping extras without asking. New packages, new routes and new behaviour (an API, CORS, a manage.py that starts the server) all came from a design prompt.
  • Long follow-ups. Small, clear follow-ups, one at a time, give you small diffs you can read.

Quick recap

TrackWhere the look landedWhat crossed into the work side
Django7 templates, 3 new style filesexcerpt and category with migration 0004, Quill editor, sample data, an API
FastAPIstyle.css and 6 templatesthe bcrypt pin, a 72-byte cut and new register checks, richer docs metadata
Flaskstyle.css, base.html, 2 page templatesCORS for every route, Swagger UI with a hand-written swagger.json

Try it yourself

Pick your track and write one follow-up prompt: give Django's sample posts proper categories, make FastAPI's login turn away passwords over 72 bytes the way register does, or bring the design to Flask's five missed pages by name. Then read the diff before you keep it.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Django · 9 of 10

Previous
Building a Blog with an AI Coding Agent: Plan Mode, a Master Prompt and the First Review
Next post
Django Models, Migrations and the Admin: From a Post Class to a Real Table

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose

One small project lists two blog posts three times: as a Django view, a Flask route and a FastAPI endpoint. See each shape with its real output, what each framework includes, and a three-question way to choose.

Getting Started with Django: Models, Views, Templates, the ORM and the Admin

A tiny Django menu app with one model, one view, one URL, one template and the admin. What each file does, how one request travels through them, and the real output of a run.

Your First Django Project and App: uv, startproject, startapp and a First View

Set up a Django project called blogproject with uv, add an app called blog, write one view that returns Hello blog, give it the empty path and run the server. Every command with its real output.

The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built

A tour of a finished Django blog: manage.py, the project package, the blog app with its models, views, templates, forms and admin, a custom command, the REST API and Swagger docs, plus the review points check --deploy found.

On this page

  • A redesign is mostly the front of the house
  • Handing over the design
  • Compare the trees, not the screenshots
  • Django: two new fields and an editor with no key
  • FastAPI: a login crash fixed with a pin
  • Flask: pages the design missed, and extras nobody asked for
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.