Last active
January 17, 2019 16:02
-
-
Save trAve3113r/67eb618f1760fbf7c8d36e11b72d4b09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # views | |
| # https://django.readthedocs.io/en/2.1.x/topics/class-based-views/index.html | |
| # https://django.readthedocs.io/en/2.1.x/ref/class-based-views/index.html | |
| #urls.py | |
| from django.urls import include,path, re_path | |
| from django.views.generic import TemplateView | |
| from . import views | |
| urlpatterns = [ | |
| path('contact/', include('contact.urls')), | |
| path('index/',TemplateView.as_view(template_name='example.html')), | |
| path('articles/', ListView.as_view()), | |
| # use old-style regex url patterns | |
| re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive), | |
| re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive), | |
| re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>[\w-]+)/$', views.article_detail), | |
| ] | |
| # include() 'contact' app urls | |
| # contact/urls.py file | |
| from django.urls import path | |
| from . import views | |
| app_name = 'contact' | |
| urlpatterns = [ | |
| path('', views.IndexView.as_view(), name='index'), | |
| path('<int:pk>/', views.DetailView.as_view(), name='detail'), | |
| #... | |
| ] | |
| # settings.py file :: | |
| # SEE: https://django.readthedocs.io/en/2.1.x/ref/settings.html | |
| MIDDLEWARE = [ | |
| 'django.middleware.security.SecurityMiddleware', | |
| 'django.contrib.sessions.middleware.SessionMiddleware', | |
| 'django.middleware.common.CommonMiddleware', | |
| 'django.middleware.csrf.CsrfViewMiddleware', | |
| 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
| 'django.contrib.messages.middleware.MessageMiddleware', | |
| 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
| ] | |
| ADMINS = [] | |
| CACHES = {} | |
| BACKEND = {} | |
| # Example | |
| DATABASES = { | |
| 'default': { | |
| 'ENGINE': 'django.db.backends.postgresql', | |
| 'NAME': 'mydatabase', | |
| 'USER': 'mydatabaseuser', | |
| 'PASSWORD': 'mypassword', | |
| 'HOST': '127.0.0.1', | |
| 'PORT': '5432', | |
| } | |
| } | |
| SERIALIZATION_MODULES = {'key':'value'} | |
| TIME_ZONE = 'Nairobi/Kenya' | |
| USE_TZ=True | |
| STATICFILES_DIRS = [] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment