I tried Django, so I summarized what I did for myself
Conducted with reference to here https://docs.djangoproject.com/ja/3.1/intro/tutorial01/
Create a project with the following command
django-admin startproject mysite
python manage.py runserver
When specifying a command, is it a set up to python manage.py
?
python manage.py startapp polls
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
I wonder if it feels like importing packages around http and handling requests with a function called index.
polls / urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.index, name='index'),
]
mysite / urls.py
# from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include, url
urlpatterns = [
url('admin/', admin.site.urls),
url('polls/', include('polls.urls')),
]
For some reason I couldn't do it according to the site I referred to, so I'd like to find out later. For some reason it doesn't work unless I use a function called url instead of path ... There seems to be a version problem ...: thinking:
I feel that I haven't been able to specify the version of python used by Django on docker ...
root@38153a1081ae:/code# python --version
Python 3.8.5
root@38153a1081ae:/code# python -m django --version
1.11.29
root@38153a1081ae:/code#
For the time being, I found the problematic part, so let's review the docker side or Django settings ...
Recommended Posts