· 6 years ago · Jul 16, 2019, 05:58 PM
1#### admin.py ####
2from django.contrib import admin
3from .models import Book
4
5
6
7from django.contrib import admin
8from jalali_date.admin import (
9 ModelAdminJalaliMixin,
10 StackedInlineJalaliMixin,
11 TabularInlineJalaliMixin,
12)
13
14# Register your models here.
15
16
17@admin.register(Book)
18class BookModelAmin(ModelAdminJalaliMixin, admin.ModelAdmin):
19 pass
20
21
22
23
24####settings.py ####
25"""
26Django settings for locallibrary project.
27
28Generated by 'django-admin startproject' using Django 2.1.7.
29
30For more information on this file, see
31https://docs.djangoproject.com/en/2.1/topics/settings/
32
33For the full list of settings and their values, see
34https://docs.djangoproject.com/en/2.1/ref/settings/
35"""
36
37import os
38
39# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
40BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
41
42
43# Quick-start development settings - unsuitable for production
44# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
45
46# SECURITY WARNING: keep the secret key used in production secret!
47SECRET_KEY = 'lo2$o&xxp=92$ko6^pk^aatyoju*g=sj+0*6d-l-i50j9@&-ew'
48
49# SECURITY WARNING: don't run with debug turned on in production!
50DEBUG = True
51
52ALLOWED_HOSTS = []
53
54
55# Application definition
56
57INSTALLED_APPS = [
58 'catalog.apps.CatalogConfig',
59 'django.contrib.admin',
60 'django.contrib.auth',
61 'django.contrib.contenttypes',
62 'django.contrib.sessions',
63 'django.contrib.messages',
64 'django.contrib.staticfiles',
65]
66
67MIDDLEWARE = [
68 'django.middleware.security.SecurityMiddleware',
69 'django.contrib.sessions.middleware.SessionMiddleware',
70 'django.middleware.common.CommonMiddleware',
71 'django.middleware.csrf.CsrfViewMiddleware',
72 'django.contrib.auth.middleware.AuthenticationMiddleware',
73 'django.contrib.messages.middleware.MessageMiddleware',
74 'django.middleware.clickjacking.XFrameOptionsMiddleware',
75]
76
77ROOT_URLCONF = 'locallibrary.urls'
78
79TEMPLATES = [
80 {
81 'BACKEND': 'django.template.backends.django.DjangoTemplates',
82 'DIRS': [],
83 'APP_DIRS': True,
84 'OPTIONS': {
85 'context_processors': [
86 'django.template.context_processors.debug',
87 'django.template.context_processors.request',
88 'django.contrib.auth.context_processors.auth',
89 'django.contrib.messages.context_processors.messages',
90 ],
91 },
92 },
93]
94
95WSGI_APPLICATION = 'locallibrary.wsgi.application'
96
97
98# Database
99# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
100
101DATABASES = {
102 'default': {
103 'ENGINE': 'django.db.backends.sqlite3',
104 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
105 }
106}
107
108
109# Password validation
110# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
111
112AUTH_PASSWORD_VALIDATORS = [
113 [
114 {
115 "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
116 },
117 {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
118 {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
119 {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
120 ]
121]
122
123
124# Internationalization
125# https://docs.djangoproject.com/en/2.1/topics/i18n/
126
127LANGUAGE_CODE = 'en-us'
128
129TIME_ZONE = 'UTC'
130
131USE_I18N = True
132
133USE_L10N = True
134
135USE_TZ = True
136
137
138# Static files (CSS, JavaScript, Images)
139# https://docs.djangoproject.com/en/2.1/howto/static-files/
140
141STATIC_URL = '/static/'
142
143"""
144Django settings for jalali project.
145
146Generated by 'django-admin startproject' using Django 2.2.3.
147
148For more information on this file, see
149https://docs.djangoproject.com/en/2.2/topics/settings/
150
151For the full list of settings and their values, see
152https://docs.djangoproject.com/en/2.2/ref/settings/
153"""
154
155import os
156
157# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
158BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
159
160# Quick-start development settings - unsuitable for production
161# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
162
163
164# Static files (CSS, JavaScript, Images)
165# https://docs.djangoproject.com/en/2.2/howto/static-files/
166
167
168JALALI_DATE_DEFAULTS = {
169 "Strftime": {"date": "%y/%m/%d", "datetime": "%H:%M:%S _ %y/%m/%d"},
170 "Static": {
171 "js": [
172 # loading default jQuery
173 "admin/jquery.ui.datepicker.jalali/scripts/jquery-1.10.2.min.js",
174 # loading datepicker
175 "admin/js/django_jalali.min.js",
176 ],
177 "css": {
178 "all": ["admin/jquery.ui.datepicker.jalali/themes/base/jquery-ui.min.css"]
179 },
180 },
181}