上一篇:《时光荏苒》
1.
python manage.py migrate
2.
from django.contrib import admin from . import models admin.site.register(models.Article)
3.
from django.urls import path from . import views urlpatterns = [ path('articles/<int:year>/', views.year_archive), path('articles/<int:year>/<int:month>/', views.month_archive), path('articles/<int:year>/<int:month>/<int:pk>/', views.article_detail), ]
4.
{{ somevariable|cut:"0" }} django.template.Library.filter() register.filter('cut', cut) register.filter('lower', lower) @register.filter(name='cut') def cut(value, arg): return value.replace(arg, '') @register.filter def lower(value): return value.lower()
5.
print(django.get_version()) python -m django --version django-admin startproject mysite
6.
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ] ------------------------------------------------------- from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ]
7.
7.
7.
7.
7.
7.
7.
7.
7.
7.
7.