Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django resources #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Python/Django/BOOTSTRAP-INTEGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Django-Bootstrap Integration

This document covers steps to integrate bootstrap in django.
This is to help new comers to easily integrate bootstrap in Django module including Django Admin.

### Integration Steps

- [Download Bootstrap](https://github.com/twbs/bootstrap/releases/download/v5.0.0-beta3/bootstrap-5.0.0-beta3-dist.zip) from here and extract the downloaded folder and you will get two folder named css and js.

- Now create a folder name static in your created app and paste the above extracted folder in it.

- Again create a folder named template inside the app and make file index.html and copy the given code to it
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
{% load staticfiles %}
<link href="{% static 'css/bootstrap.min.css' %}" >
<script src="{% static 'bootstrap.min.js' %}"></script>
</head>
<body>
</body>
</html>
```

- Now copy the below code in your setting.py
```
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'app_name/static')
]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
```
Note: app_name will contain your application name.

- After that run command ```python manage.py collectstatic``` to collect all your static file under assests directory.

- Congratulation! you have integrated bootstrap in your django project. Now you only have to extends index.html in your templates to use bootstrap.

### Additional Step for Django Admin

- Integration with admin is almost same but in place of creating index.html follow the below instructions.

- Create a folder named admin inside your template folder.
- Create a file name base_site.html and paste the below code
```
{% extends 'admin/base_site.html' %}

{% load static %}

{% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<script src="{% static 'bootstrap.min.js' %}"></script>
{% endblock %}
```

- Now extend base_site.html in order to use bootstrap in your templates.
26 changes: 26 additions & 0 deletions Python/Django/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Django

This document covers the resources needed to learn Django.
They are designed in a way that a newcomer can easily know where to look for resources and links.

### Prerequisites

- Basic knowledge of Web technologies: HTML, CSS, and JavaScript.
- [Python](https://docs.python.org/3.9/tutorial/index.html)

### Getting Started

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Checkout this [What is Django?](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Introduction) to know more about this amazing technology.


Also have a look at:-
[What is MVT?](https://medium.com/@jaychaturvedi18/a-brief-introduction-to-django-mvt-framework-8ef46cc321ab)

### Where Should I Start?

You can start from the official website [tutorial](https://docs.djangoproject.com/en/3.2/). It's a great learning curve which covers all the basics of Django.


### Video Tutorials

- You can also checkout [this](https://www.youtube.com/watch?v=OTmQOjsl0eg).