2018~/Django 개인 공부 정리
django 어드민(admin) 페이지 처음 확인하기
반원_SemiCircle
2019. 9. 4. 00:03
1. admin프로젝트 폴더-앱에 urls.py를 보면 기본적으로 admin 페이지에 대한 url conf를 확인할 수 있다.
"""fc_community URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
django.contrib의 admin 파일을 참조하고, url 패턴은 'admin/' 뒤에 여러 문자조합으로 나오면 이것은 'admin.site.urls' 파일 내부에 정의되어 있음을 나타내는 코드이다.
2. 서버를 실행시킨다.
python manage.py runserver
(venv) PS C:\Storage\DjangoStudy01\fc_community> python .\manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): fuser.
Run 'python manage.py migrate' to apply them.
September 03, 2019 - 23:55:22
Django version 2.2.5, using settings 'fc_community.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
3. 현재 admin에 접속가능한 username과 password를 안 만들어줬다.
서버를 종료하고 superuser를 생성하자.
(venv) PS C:\Storage\DjangoStudy01\fc_community> python .\manage.py createsuperuser
You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): fuser.
Run 'python manage.py migrate' to apply them.
Username (leave blank to use 'park'): soorte
Email address: soorte214@gmail.com
Password:
Password (again):
Superuser created successfully.
다시 서버실행하고 admin에 로그인 해보자.