Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapter issue#9 #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions django-boilerplate/TechConnect/TechConnect/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'blog_form',
'chapter',
]

MIDDLEWARE = [
Expand Down
3 changes: 2 additions & 1 deletion django-boilerplate/TechConnect/TechConnect/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions django-boilerplate/TechConnect/chapter/admin.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions django-boilerplate/TechConnect/chapter/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ChapterConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'chapter'
7 changes: 7 additions & 0 deletions django-boilerplate/TechConnect/chapter/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import forms
from .models import BlogPost

class BlogPostForm(forms.ModelForm):
class Meta:
model = BlogPost
fields = ['title', 'content', 'author']
24 changes: 24 additions & 0 deletions django-boilerplate/TechConnect/chapter/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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)),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions django-boilerplate/TechConnect/chapter/models.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions django-boilerplate/TechConnect/chapter/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions django-boilerplate/TechConnect/chapter/urls.py
Original file line number Diff line number Diff line change
@@ -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')

]
16 changes: 16 additions & 0 deletions django-boilerplate/TechConnect/chapter/views.py
Original file line number Diff line number Diff line change
@@ -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})

Binary file modified django-boilerplate/TechConnect/db.sqlite3
Binary file not shown.