diff --git a/django-boilerplate/TechConnect/TechConnect/__pycache__/settings.cpython-311.pyc b/django-boilerplate/TechConnect/TechConnect/__pycache__/settings.cpython-311.pyc index 0b3a27fe..eac33ecf 100644 Binary files a/django-boilerplate/TechConnect/TechConnect/__pycache__/settings.cpython-311.pyc and b/django-boilerplate/TechConnect/TechConnect/__pycache__/settings.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/TechConnect/__pycache__/urls.cpython-311.pyc b/django-boilerplate/TechConnect/TechConnect/__pycache__/urls.cpython-311.pyc index eb852c98..e7242178 100644 Binary files a/django-boilerplate/TechConnect/TechConnect/__pycache__/urls.cpython-311.pyc and b/django-boilerplate/TechConnect/TechConnect/__pycache__/urls.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/TechConnect/settings.py b/django-boilerplate/TechConnect/TechConnect/settings.py index 8902d946..e1115438 100644 --- a/django-boilerplate/TechConnect/TechConnect/settings.py +++ b/django-boilerplate/TechConnect/TechConnect/settings.py @@ -38,6 +38,7 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'blog_form', + 'chapter', ] MIDDLEWARE = [ diff --git a/django-boilerplate/TechConnect/TechConnect/urls.py b/django-boilerplate/TechConnect/TechConnect/urls.py index dc3f7b9d..723adec8 100644 --- a/django-boilerplate/TechConnect/TechConnect/urls.py +++ b/django-boilerplate/TechConnect/TechConnect/urls.py @@ -19,5 +19,6 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('blog/', include('blog_form.urls', namespace='blog')) + path('blog/', include('blog_form.urls', namespace='blog')), + path('chapter/', include('chapter.urls', namespace='chapter')), ] diff --git a/django-boilerplate/TechConnect/chapter/__init__.py b/django-boilerplate/TechConnect/chapter/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/__init__.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 00000000..d1a40410 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/__init__.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/admin.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/admin.cpython-311.pyc new file mode 100644 index 00000000..0997e1a2 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/admin.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/apps.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/apps.cpython-311.pyc new file mode 100644 index 00000000..d6d3acaa Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/apps.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/forms.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/forms.cpython-311.pyc new file mode 100644 index 00000000..c68c1a03 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/forms.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/models.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/models.cpython-311.pyc new file mode 100644 index 00000000..029af5e9 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/models.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/urls.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/urls.cpython-311.pyc new file mode 100644 index 00000000..fe816a53 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/urls.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/__pycache__/views.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/__pycache__/views.cpython-311.pyc new file mode 100644 index 00000000..a6a39a79 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/__pycache__/views.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/admin.py b/django-boilerplate/TechConnect/chapter/admin.py new file mode 100644 index 00000000..58a6ff39 --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from .models import BlogPost + +class BlogPostAdmin(admin.ModelAdmin): + list_display = ('title', 'author', 'published_date') + search_fields = ('title', 'author') + list_filter = ('published_date',) + +admin.site.register(BlogPost, BlogPostAdmin) \ No newline at end of file diff --git a/django-boilerplate/TechConnect/chapter/apps.py b/django-boilerplate/TechConnect/chapter/apps.py new file mode 100644 index 00000000..a9292503 --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ChapterConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'chapter' diff --git a/django-boilerplate/TechConnect/chapter/forms.py b/django-boilerplate/TechConnect/chapter/forms.py new file mode 100644 index 00000000..b561417c --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/forms.py @@ -0,0 +1,7 @@ +from django import forms +from .models import BlogPost + +class BlogPostForm(forms.ModelForm): + class Meta: + model = BlogPost + fields = ['title', 'content', 'author'] diff --git a/django-boilerplate/TechConnect/chapter/migrations/0001_initial.py b/django-boilerplate/TechConnect/chapter/migrations/0001_initial.py new file mode 100644 index 00000000..2f2a2afb --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.2 on 2023-07-15 19:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='BlogPost', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('content', models.TextField()), + ('author', models.CharField(max_length=100)), + ('published_date', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/django-boilerplate/TechConnect/chapter/migrations/__init__.py b/django-boilerplate/TechConnect/chapter/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/django-boilerplate/TechConnect/chapter/migrations/__pycache__/0001_initial.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 00000000..0d9513dc Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/migrations/__pycache__/__init__.cpython-311.pyc b/django-boilerplate/TechConnect/chapter/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 00000000..91919886 Binary files /dev/null and b/django-boilerplate/TechConnect/chapter/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/django-boilerplate/TechConnect/chapter/models.py b/django-boilerplate/TechConnect/chapter/models.py new file mode 100644 index 00000000..a7c4d7a6 --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/models.py @@ -0,0 +1,10 @@ +from django.db import models + +class BlogPost(models.Model): + title = models.CharField(max_length=200) + content = models.TextField() + author = models.CharField(max_length=100) + published_date = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.title diff --git a/django-boilerplate/TechConnect/chapter/tests.py b/django-boilerplate/TechConnect/chapter/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django-boilerplate/TechConnect/chapter/urls.py b/django-boilerplate/TechConnect/chapter/urls.py new file mode 100644 index 00000000..97b6a4db --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from . import views + +app_name = 'chapter' + +urlpatterns = [ + path('blog/publish/', views.blog_publish, name='blog_publish') + +] \ No newline at end of file diff --git a/django-boilerplate/TechConnect/chapter/views.py b/django-boilerplate/TechConnect/chapter/views.py new file mode 100644 index 00000000..01965787 --- /dev/null +++ b/django-boilerplate/TechConnect/chapter/views.py @@ -0,0 +1,16 @@ +from django.shortcuts import render, redirect +from .forms import BlogPostForm +from django.contrib import messages + +def blog_publish(request): + if request.method == 'POST': + form = BlogPostForm(request.POST) + if form.is_valid(): + form.save() + messages.success(request, 'Your blog is submitted successfully') + return redirect('blog_published') + else: + form = BlogPostForm() + + return render({'form': form}) + diff --git a/django-boilerplate/TechConnect/db.sqlite3 b/django-boilerplate/TechConnect/db.sqlite3 index 7161b9ee..c4909ff4 100644 Binary files a/django-boilerplate/TechConnect/db.sqlite3 and b/django-boilerplate/TechConnect/db.sqlite3 differ