Creating a base project
This episode covers :-
1) How to prepare a general base project.
- Setup :-
Terminal
cp -fr 14-Models 15-Base-Project
cd 15-Models
source ../venv/bin/activate
- Adding a description field :-
Open myapp models.py file:
myapp/models.py
├── 15-Base-Project
│ ├── myapp
│ │ ├── models.py # < here
Add the description field:
myapp/models.py
from django.db import models
class Flower(models.Model):
title = models.CharField(max_length=255, default='')
description = models.TextField(default='') # < here
Run migrations:
Terminal
python manage.py makemigrations
python manage.py migrate
Visit http://127.0.0.1:8000/admin/ and add descriptions for the flowers. You can find mock data in here: https://samuli.to/Lorem.
- Adding masonry like columns :-
- Adding a footer :-
- We now have a decent base project to work with. We use this for some of the chapters as a starting point. You might want to use this as a base for your own experiments.
- Bootstrap offers some helpful classes like card-columns that accomplish quite a bit with very little markup.
- Template filters allow you to manipulate template output like truncate strings or format dates.


No comments:
Post a Comment
If you have any doubts. Please let me know.