diff --git a/Blogger/Blogger/__init__.py b/Blogger/Blogger/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Blogger/Blogger/asgi.py b/Blogger/Blogger/asgi.py new file mode 100644 index 0000000..52ba7b4 --- /dev/null +++ b/Blogger/Blogger/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for Blogger project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Blogger.settings') + +application = get_asgi_application() diff --git a/Blogger/Blogger/settings.py b/Blogger/Blogger/settings.py new file mode 100644 index 0000000..7a445d4 --- /dev/null +++ b/Blogger/Blogger/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for Blogger project. + +Generated by 'django-admin startproject' using Django 6.0.4. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/6.0/ref/settings/ +""" + +from pathlib import Path +import os + + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-b^mn--!(*ktv09tbwvvg!f%@@hh!xelhd$&+xyya2$2znl)xic' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'blog', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'Blogger.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'Blogger.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/6.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/6.0/howto/static-files/ + +STATIC_URL = 'static/' + + +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') \ No newline at end of file diff --git a/Blogger/Blogger/urls.py b/Blogger/Blogger/urls.py new file mode 100644 index 0000000..bbbc7b3 --- /dev/null +++ b/Blogger/Blogger/urls.py @@ -0,0 +1,25 @@ +""" +URL configuration for Blogger project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/6.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import include, path +from django.conf.urls.static import static +from . import settings + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('blog.urls')), +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/Blogger/Blogger/wsgi.py b/Blogger/Blogger/wsgi.py new file mode 100644 index 0000000..03bf872 --- /dev/null +++ b/Blogger/Blogger/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for Blogger project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Blogger.settings') + +application = get_wsgi_application() diff --git a/Blogger/blog/__init__.py b/Blogger/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Blogger/blog/admin.py b/Blogger/blog/admin.py new file mode 100644 index 0000000..d1b807a --- /dev/null +++ b/Blogger/blog/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin +# Register your models here. + diff --git a/Blogger/blog/apps.py b/Blogger/blog/apps.py new file mode 100644 index 0000000..7930587 --- /dev/null +++ b/Blogger/blog/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BlogConfig(AppConfig): + name = 'blog' diff --git a/Blogger/blog/migrations/0001_initial.py b/Blogger/blog/migrations/0001_initial.py new file mode 100644 index 0000000..5f8e42e --- /dev/null +++ b/Blogger/blog/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 6.0.4 on 2026-04-14 22:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Post', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=2048)), + ('content', models.TextField()), + ('is_published', models.BooleanField(default=True)), + ('published_at', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/Blogger/blog/migrations/0002_post_image.py b/Blogger/blog/migrations/0002_post_image.py new file mode 100644 index 0000000..05b948c --- /dev/null +++ b/Blogger/blog/migrations/0002_post_image.py @@ -0,0 +1,18 @@ +# Generated by Django 6.0.4 on 2026-04-15 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='image', + field=models.ImageField(default='images/default.jpg', upload_to='images/'), + ), + ] diff --git a/Blogger/blog/migrations/__init__.py b/Blogger/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Blogger/blog/models.py b/Blogger/blog/models.py new file mode 100644 index 0000000..ce5b1d9 --- /dev/null +++ b/Blogger/blog/models.py @@ -0,0 +1,14 @@ +from django.db import models + +# Create your models here. + +class Post(models.Model): + title = models.CharField(max_length=2048) + content = models.TextField() + is_published = models.BooleanField(default=True) + published_at = models.DateTimeField(auto_now_add=True) + image = models.ImageField(upload_to="images/", default="images/default.jpg") + + def __str__(self): + return self.title + \ No newline at end of file diff --git a/Blogger/blog/static/css/style.css b/Blogger/blog/static/css/style.css new file mode 100644 index 0000000..539b5cb --- /dev/null +++ b/Blogger/blog/static/css/style.css @@ -0,0 +1,164 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: 'Segoe UI', Tahoma, sans-serif; + background: #ffffff; + color: #000000; + +} + +.navbar { + background: #000000; + color: white; + padding: 15px 40px; + display: flex; + justify-content: space-between; + align-items: center; +} + +.navbar a { + color: white; + text-decoration: none; + margin-left: 20px; + font-weight: bold; + padding: 15px 20px; +} + +.container { + width: 90%; + max-width: 900px; + margin: 40px auto; +} + +.post-card { + background: white; + padding: 20px; + border-radius: 12px; + margin-bottom: 20px; + box-shadow: 0 5px 15px rgba(0,0,0,0.05); +} + +.post-card h3 { + margin-bottom: 10px; + color: #000000; +} + +.post-card p { + margin-bottom: 10px; + line-height: 1.6; +} + +.post-card small { + color: gray; +} + +.form-container { + background: white; + padding: 25px; + border-radius: 12px; + box-shadow: 0 5px 15px rgba(0,0,0,0.05); +} + +.form-container input, +.form-container textarea { + width: 100%; + padding: 10px; + margin-bottom: 15px; + border: 1px solid #ddd; + border-radius: 8px; +} + +button { + background: #000000; + color: white; + border: none; + padding: 10px 20px; + border-radius: 8px; + cursor: pointer; +} + +button:hover { + background: #ffffff; + color: #000000; + border: 1px solid #000000; +} + +input[type="checkbox"] { + margin-right: 10px; + display: flex; + align-items: center; + +} + +img { + width: 100%; + height: auto; + border-radius: 8px; + margin-bottom: 15px; +} + +.form-control { + margin-bottom: 15px; + padding: 10px; + border: 1px solid #ddd; + border-radius: 8px; + +} + +.btn-secondary { + display: inline-block; + margin-top: 15px; + background: #000000; + color: white; + border: none; + padding: 10px 20px; + border-radius: 8px; + cursor: pointer; + +} + +a.btn-secondary { + text-decoration: none; + color: white; +} + +.btn-secondary:hover { + background: #ffffff; + color: #000000; + border: 1px solid #000000; +} + +.btn-danger { + display: inline-block; + margin-top: 15px; + background: #ff4d4d; + color: white; + border: none; + padding: 10px 20px; + border-radius: 8px; + cursor: pointer; + +} + +a.btn-danger { + text-decoration: none; + color: white; +} + +.btn-danger:hover { + background: #ff9999; + color: white; + border: 1px solid #ff4d4d; + +} + +small { + display: block; + margin: 15px 0; + color: gray; + gap: 2rem; +} \ No newline at end of file diff --git a/Blogger/blog/static/images/logo.png b/Blogger/blog/static/images/logo.png new file mode 100644 index 0000000..1db772e Binary files /dev/null and b/Blogger/blog/static/images/logo.png differ diff --git a/Blogger/blog/templates/blog/add_post.html b/Blogger/blog/templates/blog/add_post.html new file mode 100644 index 0000000..0f4f1f3 --- /dev/null +++ b/Blogger/blog/templates/blog/add_post.html @@ -0,0 +1,23 @@ +{% extends 'blog/base.html' %} + +{% load static %} + +{% block title %}Add New Post{% endblock %} + +{% block content %} + +
{{ post.content }}
+ {{ post.published_at }} +{{ post.content }}
+