Skip to content

Commit fd6f8c2

Browse files
committed
Leaning Django by doing
Includes:- 1. codemy_myclub_1 2. socialbook 3. trydjango3
1 parent dd165b6 commit fd6f8c2

File tree

1,387 files changed

+187429
-1017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,387 files changed

+187429
-1017
lines changed

codemy_event/events/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def home(request, year=datetime.date.today().year, month=datetime.date.today().month) :
1515
cal = HTMLCalendar().formatmonth(year, month)
1616
curr_yr = datetime.date.today().year
17-
return render(request, 'events/index.html',
17+
return render(request, 'events/base.html',
1818
{'name' : request.user, 'year' : year, 'month' : month, 'cal' : cal,
1919
'time' : datetime.time().strftime('%I:%M %p'), 'curr_yr' : curr_yr,
2020
'events' : Event.objects.filter(date__year=year,date__month=month)})
@@ -24,7 +24,7 @@ def cal(request, year, month) :
2424
# month_number = int(list(calendar.month_name).index(month.title()))
2525
cal = HTMLCalendar().formatmonth(year, month)
2626
curr_yr = datetime.date.today().year
27-
return render(request, 'events/index.html',
27+
return render(request, 'events/base.html',
2828
{'name' : request.user, 'year' : year, 'month' : month, 'cal' : cal,
2929
'time' : datetime.time().strftime('%I:%M %p'), 'curr_yr' : curr_yr})
3030

File renamed without changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for codemy_myclub_1 project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codemy_myclub_1.settings')
15+
16+
application = get_asgi_application()
Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
Django settings for mysite_3 project.
2+
Django settings for codemy_myclub_1 project.
33
4-
Generated by 'django-admin startproject' using Django 3.1.5.
4+
Generated by 'django-admin startproject' using Django 3.2.5.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/3.1/topics/settings/
7+
https://docs.djangoproject.com/en/3.2/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/3.1/ref/settings/
10+
https://docs.djangoproject.com/en/3.2/ref/settings/
1111
"""
1212

1313
from pathlib import Path
@@ -17,10 +17,10 @@
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'i=qxvd1z6@*iwqcu*rto1b#$*8yo4bf&s(n&k6)o(xm3_ng=^)'
23+
SECRET_KEY = 'django-insecure-lq!rnr$6*%%$32uh%u5b^ox44z)i+7rdv(7vihysy0%7mlnzco'
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
@@ -37,8 +37,7 @@
3737
'django.contrib.sessions',
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
40-
'main.apps.MainConfig',
41-
'tinymce',
40+
'event.apps.EventConfig',
4241
]
4342

4443
MIDDLEWARE = [
@@ -51,29 +50,29 @@
5150
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5251
]
5352

54-
ROOT_URLCONF = 'mysite_3.urls'
53+
ROOT_URLCONF = 'codemy_myclub_1.urls'
5554

5655
TEMPLATES = [
5756
{
58-
'BACKEND': 'django.templates.backends.django.DjangoTemplates',
57+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
5958
'DIRS': [],
6059
'APP_DIRS': True,
6160
'OPTIONS': {
6261
'context_processors': [
63-
'django.templates.context_processors.debug',
64-
'django.templates.context_processors.request',
62+
'django.template.context_processors.debug',
63+
'django.template.context_processors.request',
6564
'django.contrib.auth.context_processors.auth',
6665
'django.contrib.messages.context_processors.messages',
6766
],
6867
},
6968
},
7069
]
7170

72-
WSGI_APPLICATION = 'mysite_3.wsgi.application'
71+
WSGI_APPLICATION = 'codemy_myclub_1.wsgi.application'
7372

7473

7574
# Database
76-
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
75+
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
7776

7877
DATABASES = {
7978
'default': {
@@ -84,7 +83,7 @@
8483

8584

8685
# Password validation
87-
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
86+
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
8887

8988
AUTH_PASSWORD_VALIDATORS = [
9089
{
@@ -103,7 +102,7 @@
103102

104103

105104
# Internationalization
106-
# https://docs.djangoproject.com/en/3.1/topics/i18n/
105+
# https://docs.djangoproject.com/en/3.2/topics/i18n/
107106

108107
LANGUAGE_CODE = 'en-us'
109108

@@ -116,38 +115,12 @@
116115
USE_TZ = True
117116

118117

119-
# Static files (css, JavaScript, images)
120-
# https://docs.djangoproject.com/en/3.1/howto/static-files/
118+
# Static files (CSS, JavaScript, Images)
119+
# https://docs.djangoproject.com/en/3.2/howto/static-files/
121120

122121
STATIC_URL = '/static/'
123122

124-
TINYMCE_DEFAULT_CONFIG = {
125-
'height': 360,
126-
'width': 1120,
127-
'cleanup_on_startup': True,
128-
'custom_undo_redo_levels': 20,
129-
'selector': 'textarea',
130-
'theme': 'modern',
131-
'plugins': '''
132-
textcolor save link image media preview codesample contextmenu
133-
table code lists fullscreen insertdatetime nonbreaking
134-
contextmenu directionality searchreplace wordcount visualblocks
135-
visualchars code fullscreen autolink lists charmap print hr
136-
anchor pagebreak
137-
''',
138-
'toolbar1': '''
139-
fullscreen preview bold italic underline | fontselect,
140-
fontsizeselect | forecolor backcolor | alignleft alignright |
141-
aligncenter alignjustify | indent outdent | bullist numlist table |
142-
| link image media | codesample |
143-
''',
144-
'toolbar2': '''
145-
visualblocks visualchars |
146-
charmap hr pagebreak nonbreaking anchor | code |
147-
''',
148-
'contextmenu': 'formats | link image',
149-
'menubar': True,
150-
'statusbar': True,
151-
}
123+
# Default primary key field type
124+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
152125

153-
# LOGIN_REDIRECT_URL='main:homepage'
126+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

sentdex3/mysite_3/urls.py renamed to codemy_myclub_1/codemy_myclub_1/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""mysite_3 URL Configuration
1+
"""codemy_myclub_1 URL Configuration
22
33
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/3.1/topics/http/urls/
4+
https://docs.djangoproject.com/en/3.2/topics/http/urls/
55
Examples:
66
Function views
77
1. Add an import: from my_app import views
@@ -18,5 +18,5 @@
1818

1919
urlpatterns = [
2020
path('admin/', admin.site.urls),
21-
path('', include('main.url')),
21+
path('', include('event.url')),
2222
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for codemy_myclub_1 project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'codemy_myclub_1.settings')
15+
16+
application = get_wsgi_application()
File renamed without changes.

codemy_myclub_1/event/admin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.contrib import admin
2+
from .models import Events,Venue,MyClubMember
3+
# admin.site.register(Events)
4+
# admin.site.register(Venue)
5+
admin.site.register(MyClubMember)
6+
7+
8+
@admin.register(Venue)
9+
class VenueAdmin(admin.ModelAdmin):
10+
list_display = ('name' , 'phone' , 'email')
11+
ordering = ['name']
12+
search_fields = ['name']
13+
14+
15+
@admin.register(Events)
16+
class EventAdmin(admin.ModelAdmin):
17+
list_display = ('name' , 'event_date' , 'venue' , 'manager')
18+
list_filter = ['venue' , 'manager']
19+
ordering = ['event_date']
20+
search_fields = ['name']

codemy_myclub_1/event/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class EventConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'event'

codemy_myclub_1/event/forms.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django import forms
2+
from django.forms import ModelForm
3+
from .models import Venue, Events
4+
5+
6+
class DateInput(forms.DateInput):
7+
input_type = 'date'
8+
9+
10+
class VenueForm(ModelForm):
11+
class Meta:
12+
model = Venue
13+
fields = '__all__'
14+
15+
16+
class EventsForm(ModelForm):
17+
class Meta:
18+
model = Events
19+
fields = '__all__'
20+
widgets = {'event_date' : DateInput()}

0 commit comments

Comments
 (0)