| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- crawler
- basics
- Classes
- .gitignore
- Methods
- JSON
- directories
- forks
- DATABASE
- ansible
- MySQL
- noob
- GIT
- pandas
- workbench
- SCV
- Linux
- Filecoin
- MyAnimeList
- Blockchain
- Jupyter Notebook
- Django
- cached
- python
- commands
- API
- project
- Anime
- github
- strings
- Today
- Total
제니 블로그
Setting up the Django project 본문
Since we have our project folders ready, it's time to set it up.
This includes adding urlpatterns in urls.py, and altering the settings.py and view.py files.
The most basic setup is the urlpatterns named index in our root folder from our app folder.
urlpatterns = [
path('', views.index, name='index')
]
This sets up the first pattern matches the root URL ('') and maps it to the index view function.
After that, in our views.py file, we add the index function from the urls.py file.
# Create your views here.
def index(request):
return render(request, 'index.html')
This loads the index.html template, and views.py file is a critical part of a Django web application, responsible for processing user requests and returning responses that render HTML content, JSON data, or other types of responses.
Now that our app folders are all configured, it's time to configure the main project files.
In the urls.py file, we add the pattern, the name of the App name.
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path('', include('sentimental_A.urls'))
]
And finally, we have to set up the settings.py file, scrolling down on INSTALLED APPS and adding the app name.
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"sentimental_A"
]
We are now finished setting up the basics of the project.
'Project' 카테고리의 다른 글
| Starting a Django project (0) | 2023.03.20 |
|---|---|
| Inserting Data into the database (0) | 2023.03.07 |
| Making a Database Schema (0) | 2023.03.01 |
| Text Preprocessing (0) | 2023.02.25 |
| Getting the Data from API (0) | 2023.02.21 |