Skip to content

Commit 4e2126f

Browse files
[refactor]: added the admin config
- Github Issue: Authored-by: Shubham Bansal <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
1 parent f9856d4 commit 4e2126f

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

myproject/article/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from django.contrib import admin
2+
from .models import Article
23

3-
# Register your models here.
4+
admin.site.register(Article)

myproject/myproject/settings.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import dj_database_url
1515

1616
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
18-
17+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
1918

2019
# Quick-start development settings - unsuitable for production
2120
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
@@ -24,7 +23,7 @@
2423
SECRET_KEY = '=z!)ljo#)g8$am1z4s(!s!+2fj_xz$wys-6vqlk!b!hd6avr@4'
2524

2625
# SECURITY WARNING: don't run with debug turned on in production!
27-
DEBUG = False
26+
DEBUG = True
2827

2928
ALLOWED_HOSTS = ['*']
3029

@@ -77,8 +76,8 @@
7776
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
7877

7978
DATABASES = {
80-
'default': dj_database_url.config(
81-
default='sqlite:////{0}'.format(os.path.join(BASE_DIR, 'db.sqlite3'))
79+
'default': dj_database_url.config(
80+
default='sqlite:////{0}'.format(os.path.join(BASE_DIR, 'db.sqlite3'))
8281
)
8382
}
8483

@@ -115,8 +114,16 @@
115114

116115
USE_TZ = True
117116

118-
119117
# Static files (CSS, JavaScript, Images)
120118
# https://docs.djangoproject.com/en/2.0/howto/static-files/
119+
STATIC_ROOT = os.path.join(BASE_DIR, '.staticfiles')
121120

121+
# URL that handles the static files served from STATIC_ROOT.
122+
# Example: 'http://example.com/static/', 'http://static.example.com/'
123+
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
122124
STATIC_URL = '/static/'
125+
126+
# A list of locations of additional static files
127+
STATICFILES_DIRS = [
128+
os.path.join(BASE_DIR, "static"),
129+
]

myproject/myproject/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from django.urls import path, include
1818
from .routers import router
1919
from django.views.generic import TemplateView
20+
from django.conf.urls.static import static
21+
from django.conf import settings
2022

2123

2224
urlpatterns = [
@@ -25,4 +27,4 @@
2527
path('article', TemplateView.as_view(template_name='index.html')),
2628
path('', TemplateView.as_view(template_name='index.html')),
2729

28-
]
30+
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

0 commit comments

Comments
 (0)