H a n d s o n, p r o j e c t b a s e d


S t y l i n g a n d d e p l oy i n g a n a p p


Download 4.21 Mb.
Pdf ko'rish
bet342/344
Sana31.01.2024
Hajmi4.21 Mb.
#1818553
1   ...   336   337   338   339   340   341   342   343   344
Bog'liq
Python Crash Course, 2nd Edition

20
S t y l i n g a n d d e p l oy i n g a n a p p
Learning Log is fully functional now, but it 
has no styling and runs only on your local 
machine. In this chapter, you’ll style the pro­
ject in a simple but professional manner and 
then deploy it to a live server so anyone in the world 
can make an account and use it.
For the styling we’ll use the Bootstrap library, a collection of tools for 
styling web applications so they look professional on all modern devices, 
from a large flat­screen monitor to a smartphone. To do this, we’ll use the 
django­bootstrap4 app, which will also give you practice using apps made 
by other Django developers.
We’ll deploy Learning Log using Heroku, a site that lets you push your 
project to one of its servers, making it available to anyone with an internet 
connection. We’ll also start using a version control system called Git to 
track changes to the project. 
When you’re finished with Learning Log, you’ll be able to develop 
simple web applications, make them look good, and deploy them to a live 
server. You’ll also be able to use more advanced learning resources as you 
develop your skills.


438
Chapter 20
Styling Learning Log
We’ve purposely ignored styling until now to focus on Learning Log’s func­
tionality first. This is a good way to approach development, because an app 
is useful only if it works. Of course, once it’s working, appearance is critical 
so people will want to use it.
In this section, I’ll introduce the django­bootstrap4 app and show you 
how to integrate it into a project to make it ready for live deployment.
The django-bootstrap4 App
We’ll use django­bootstrap4 to integrate Bootstrap into our project. This 
app downloads the required Bootstrap files, places them in an appropriate 
location in your project, and makes the styling directives available in your 
project’s templates.
To install django­bootstrap4, issue the following command in an active 
virtual environment:
(ll_env)learning_log$ pip install django-bootstrap4
--snip--
Successfully installed django-bootstrap4-0.0.7
Next, we need to add the following code to include django­bootstrap4 
in 
INSTALLED_APPS
in settings.py:
--snip--
INSTALLED_APPS = [
# My apps.
'learning_logs',
'users',
# Third party apps.
'bootstrap4',
# Default django apps.
'django.contrib.admin',
--snip--
Start a new section called Third party apps for apps created by other 
developers and add 
'bootstrap4'
to this section. Make sure you place 
this section after 
# My apps
but before the section containing Django’s 
default apps.

Download 4.21 Mb.

Do'stlaringiz bilan baham:
1   ...   336   337   338   339   340   341   342   343   344




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling