First Django Challenge

I tried Django, so I summarized what I did for myself

Reference site

Conducted with reference to here https://docs.djangoproject.com/ja/3.1/intro/tutorial01/

Creating a project

Create a project with the following command

django-admin startproject mysite

File to be created

Server startup

python manage.py runserver

When specifying a command, is it a set up to python manage.py?

Creating a project

python manage.py startapp polls

Create view

Edit views.py

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.

Routing definition

Create polls / urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
    url('', views.index, name='index'),
]

Edit 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

First Django Challenge
First Django development
Django
Django Girls Tutorial Summary First Half
Django admin screen customization first step
Start Django for the first time
django update
Django note 4
Django memorandum
django search
First Flask
Django Summary
Django test
First draft
Django # 2 (template)
Django Note 5
Django hands-on
Touch django
django notes
Django Summary
Django basics
Django Shoho
First python-review-
Django defaults
Django + Docker
First gdb
Create your first app with Django startproject
Challenge AtCoder
Django Glossary
Django search
Install Django
Django: References
Django Note 1
Django note 3
Django note 2
Django startup
Django notes
Django NullCharField
What is a dog? Challenge Django templates! Volume