DEV Community

Bret
Bret

Posted on

Do you create a Model or View first? In DJANGO?

What order do you take,
To create a page.html to show up?
Is it a View, Model, ect? What?

Top comments (5)

Collapse
 
greeder59 profile image
Gordon Reeder

It's been a while since I dabbled with dJango. But IIRC:
Models are your interface to the database and not really necessary for a "Hello World" type of page.
What I would do is create a single stub view. It would look for a context variable and use that to create or modify a text string.
Then I would create the URLS and they all call the stub.
So, short answer Views and URLS first. Models next (completely the opposite of how the django tutorial presents it.

Collapse
 
jerome profile image
Marc Jerome • Edited

I'm assuming this page.html requires models since you are using django.
My own way doing it is, I create a model first then views then urls.

But there are other methodologies justified by the philosophy of some programmer/s.
Some codes in the Test Driven Development (TDD) approach, Behavior Driven Development (BDD), to name a few.

If you are interested in these, I think you can pick a good book at Amazon.

Collapse
 
yoanbello profile image
yoanbello

First create the URL, next create the view and if You need a model then you create that

Collapse
 
yobretyo profile image
Bret

I’ve created urls, for a httprequest, it worked when I had a “

home page<\h1>”,

But when I tried to have a home.html page render.... it doesn’t show

Collapse
 
yobretyo profile image
Bret

My manage.py is at the bottom and I don’t have a duplicate name of a folder. I made a folder first and then ran the commands