[Python] Introduce UIKit3 to your Django project

Introduction

CSS framework for Django projects We will introduce ** UIKit3 **.

UIKit3 UIKit is one of the CSS frameworks. Although it is a little inferior to Bootstrap and Foundation in terms of name recognition It is a popular framework with a simple design.

The class name is unified so that it starts with ʻuk-`, It is also a good point that friction with other CSS is unlikely to occur.

Download UIKit

Download from here.

Unzip the zip file and This time, we will use the following 3 files.

uikit-3.5.6/  ├ css/  │ └ uikit.min.css  └ lib/    └ uikit-icons.min.js    └ uikit.min.js

Create static directory

Create a static directory directly under the project directory and Store the file as shown below.

[projectname]/  ├ [projectname]/  ├ static/  │ └ css/  │ │ └ uikit.min.css  │ └ js/  │   └ uikit.min.css  │   └ uikit.min.css  └ manage.py

Modify settings.py

Define the information for the'static' directory in [projectname] /settings.py.

settings.py


STATICFILES_DIRS = (
	os.path.join(BASE_DIR, 'static'),
)

Read static

Point1:

{% load static %} Use the load tag to enable the use of static tags.

Point2:

{% static '[css or js]/[filenama]' %} You can use the> static tag to define a static file path as a relative path.

Point3:

ʻLoad UIKit` <link href="{% static 'css/uikit.min.css' %}" rel="stylesheet"> <script src="{% static 'js/uikit.min.js' %}"> <script src="{% static 'js/uikit-icons.min.js' %}">

Official documentation: https://getuikit.com/docs/introduction#html-markup

Try to display the Dropdown list. I wanted a margin because I wanted to take a screenshot of the screen, so I also tried using ʻuk-margin-top`.

uikit-sample.html


{% load static %}

<!DOCTYPE html>
<html lang="ja">
<head>
    <title>TEST</title>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="{% static 'css/uikit.min.css' %}" rel="stylesheet">
    <script src="{% static 'js/uikit.min.js' %}"></script>
    <script src="{% static 'js/uikit-icons.min.js' %}"></script>
</head>
<body>
    <h1 class="uk-margin-top uk-margin-left">UIKit sample</h1>

    <div class="uk-button-group uk-margin-left">
        <button class="uk-button uk-button-default">Dropdown</button>
        <div class="uk-inline">
            <button class="uk-button uk-button-default" type="button"><span uk-icon="icon:  triangle-down"></span></button>
            <div uk-dropdown="mode: click; boundary: ! .uk-button-group; boundary-align: true;">
                <ul class="uk-nav uk-dropdown-nav">
                    <li class="uk-active"><a href="#">Active</a></li>
                    <li><a href="#">Item</a></li>
                    <li class="uk-nav-header">Header</li>
                    <li><a href="#">Item</a></li>
                    <li><a href="#">Item</a></li>
                    <li class="uk-nav-divider"></li>
                    <li><a href="#">Item</a></li>
                </ul>
            </div>
        </div>
    </div>

</body>
</html>

It was displayed safely. It's simple and nice! uikit-dropdown.png

in conclusion

I had the opportunity to introduce UIKit, so I summarized it.

I haven't mastered UIkit yet, but as mentioned above It is very easy to use that the class name is unified with ʻuk-`.

Recommended Posts

[Python] Introduce UIKit3 to your Django project
Convert Scratch project to Python
Deploy django project to heroku
Steps to create a Django project
Register your Django application in your project
Introduction to Python Django (2) Mac Edition
Migrate Django applications running on Python 2.7 to Python 3.5
[Django] Want to customize your admin page?
Want to add type hints to your Python decorator?
Updated to Python 2.7.9
Project cannot be created with Python3.5 (Windows) + django1.7.1
Python Django Tutorial (5)
Python Django Tutorial (2)
Python Django Tutorial (8)
Python Django Tutorial (6)
Django Project Baseline
Python Django Tutorial (7)
Python Django Tutorial (1)
[Python] Do your best to speed up SQLAlchemy
Python Django tutorial tutorial
Python Django Tutorial (3)
Python Django Tutorial (4)
A story about trying to introduce Linter in the middle of a Python (Flask) project
Memo to create your own Box with Pepper's Python
[Python] [Django] How to use ChoiceField and how to add options
When I tried to introduce python3 to atom, I got stuck
Python beginners try adding basic auth to Django admin
[Introduction to Udemy Python 3 + Application] 66. Creating your own exceptions
Introduce pipe operators and function synthesis to Python (provisional)
Try to improve your own intro quiz in Python
(Python) Try to develop a web application using Django
[Python beginner] If __name__ == Move your hand to understand'__main__'.
How to build a Django (python) environment on docker
Steps from installing Python 3 to creating a Django app
Single sign-on to your Django application with AWS SSO
[Road to intermediate Python] Define in in your own class
How to use Django on Google App Engine / Python
To myself as a Django beginner (1) --Create a project app--
Use Django features from batch scripts outside your Django project
How to reference static files in a Django project
Django 1.11 started with Python3.6
Python Django tutorial summary
Django python web framework
How to install Python
Django project environment construction
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Introduce serverspec to Linux
Rewrite Python2 code to Python3 (2to3)
Django Python shift table
How to install python
Introduction to Python language
Introduction to OpenCV (python)-(2)
Django --start project without start project
unable to import django
Introducing Python 2.7 to CentOS 6.6
[Django] Rename the project
Connect python to mysql
update django version 1.11.1 to 2.2
Start a Django project
Introduce elpy to emacs