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

+2-2
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

+16
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()
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

+3-3
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
]
+16
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()

codemy_myclub_1/event/admin.py

+20
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

+6
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

+20
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()}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 3.2.5 on 2023-02-09 14:34
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Events',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('name', models.CharField(max_length=50)),
19+
('event_date', models.DateTimeField()),
20+
('venue', models.CharField(max_length=50)),
21+
('manager', models.CharField(max_length=50)),
22+
('description', models.TextField(blank=True)),
23+
],
24+
),
25+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 3.2.5 on 2023-02-09 15:14
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('event', '0001_initial'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='MyClubMember',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('fname', models.CharField(max_length=50)),
19+
('lname', models.CharField(max_length=50)),
20+
('email', models.EmailField(blank=True, max_length=254)),
21+
],
22+
),
23+
migrations.CreateModel(
24+
name='Venue',
25+
fields=[
26+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
27+
('name', models.CharField(max_length=50)),
28+
('address', models.TextField(blank=True)),
29+
('phone', models.CharField(max_length=50)),
30+
('web', models.URLField(blank=True)),
31+
('email', models.EmailField(blank=True, max_length=254)),
32+
],
33+
),
34+
migrations.AddField(
35+
model_name='events',
36+
name='attendees',
37+
field=models.ManyToManyField(blank=True, to='event.MyClubMember'),
38+
),
39+
migrations.AlterField(
40+
model_name='events',
41+
name='venue',
42+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='event.venue'),
43+
),
44+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.2.5 on 2023-02-09 15:24
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('event', '0002_auto_20230209_2044'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='myclubmember',
15+
name='lname',
16+
field=models.CharField(blank=True, max_length=50),
17+
),
18+
migrations.AlterField(
19+
model_name='venue',
20+
name='phone',
21+
field=models.CharField(blank=True, max_length=50),
22+
),
23+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 3.2.5 on 2023-02-10 10:27
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
('event', '0003_auto_20230209_2054'),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name='events',
18+
name='manager',
19+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
20+
),
21+
]

0 commit comments

Comments
 (0)