diff --git a/Web_Development/djangotweet/.gitignore b/Web_Development/djangotweet/.gitignore new file mode 100644 index 0000000000..bdaab25d58 --- /dev/null +++ b/Web_Development/djangotweet/.gitignore @@ -0,0 +1 @@ +env/ diff --git a/Web_Development/djangotweet/requirements.txt b/Web_Development/djangotweet/requirements.txt new file mode 100644 index 0000000000..013038c896 --- /dev/null +++ b/Web_Development/djangotweet/requirements.txt @@ -0,0 +1,4 @@ +asgiref==3.8.1 +Django==5.1.2 +sqlparse==0.5.1 +tzdata==2024.2 diff --git a/Web_Development/djangotweet/tweethead/db.sqlite3 b/Web_Development/djangotweet/tweethead/db.sqlite3 new file mode 100644 index 0000000000..430a085a2a Binary files /dev/null and b/Web_Development/djangotweet/tweethead/db.sqlite3 differ diff --git a/Web_Development/djangotweet/tweethead/manage.py b/Web_Development/djangotweet/tweethead/manage.py new file mode 100644 index 0000000000..37806ea6c8 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tweethead.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Web_Development/djangotweet/tweethead/media/photos/bloreclimate.jpeg b/Web_Development/djangotweet/tweethead/media/photos/bloreclimate.jpeg new file mode 100644 index 0000000000..e245f9b3a2 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/media/photos/bloreclimate.jpeg differ diff --git a/Web_Development/djangotweet/tweethead/media/photos/modi.png b/Web_Development/djangotweet/tweethead/media/photos/modi.png new file mode 100644 index 0000000000..27d285b1e9 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/media/photos/modi.png differ diff --git a/Web_Development/djangotweet/tweethead/media/photos/modi_NAECpv1.png b/Web_Development/djangotweet/tweethead/media/photos/modi_NAECpv1.png new file mode 100644 index 0000000000..27d285b1e9 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/media/photos/modi_NAECpv1.png differ diff --git a/Web_Development/djangotweet/tweethead/media/photos/motive.webp b/Web_Development/djangotweet/tweethead/media/photos/motive.webp new file mode 100644 index 0000000000..d8eaa93c95 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/media/photos/motive.webp differ diff --git a/Web_Development/djangotweet/tweethead/requirements.txt b/Web_Development/djangotweet/tweethead/requirements.txt new file mode 100644 index 0000000000..37b55bc05c --- /dev/null +++ b/Web_Development/djangotweet/tweethead/requirements.txt @@ -0,0 +1,5 @@ +asgiref==3.8.1 +Django==5.1.2 +pillow==11.0.0 +sqlparse==0.5.1 +tzdata==2024.2 diff --git a/Web_Development/djangotweet/tweethead/templates/layout.html b/Web_Development/djangotweet/tweethead/templates/layout.html new file mode 100644 index 0000000000..551fad9bbb --- /dev/null +++ b/Web_Development/djangotweet/tweethead/templates/layout.html @@ -0,0 +1,83 @@ +{% load static %} + + + + + + + + + + + {% block title %} + + Chai and django + + {% endblock %} + + + + + + + + + + +
+ {% block container %} + + + {% endblock %} + + +
+ + + \ No newline at end of file diff --git a/Web_Development/djangotweet/tweethead/templates/registration/logged_out.html b/Web_Development/djangotweet/tweethead/templates/registration/logged_out.html new file mode 100644 index 0000000000..cbaaf242b7 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/templates/registration/logged_out.html @@ -0,0 +1,7 @@ +{% extends "layout.html" %} + +{% block container %} +

Logged out

+ +

You have been logged outLogin here

+{% endblock %} diff --git a/Web_Development/djangotweet/tweethead/templates/registration/login.html b/Web_Development/djangotweet/tweethead/templates/registration/login.html new file mode 100644 index 0000000000..57b2ab2af3 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/templates/registration/login.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} + +{% block container %} +

Login form

+
+ {% csrf_token %} + {{ form.as_p }} + +
+

Don't have an account? Register here

+{% endblock %} diff --git a/Web_Development/djangotweet/tweethead/templates/registration/register.html b/Web_Development/djangotweet/tweethead/templates/registration/register.html new file mode 100644 index 0000000000..e0fc1e2123 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/templates/registration/register.html @@ -0,0 +1,11 @@ +{% extends "layout.html" %} + +{% block container %} +

Register form form

+
+ {% csrf_token %} + {{ form.as_p }} + +
+ +{% endblock %} diff --git a/Web_Development/djangotweet/tweethead/tweet/__init__.py b/Web_Development/djangotweet/tweethead/tweet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/__init__.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000..77bdfb92e9 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/__init__.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/admin.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000000..e2d6fc5adb Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/admin.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/apps.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000000..4dcfea8366 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/apps.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/forms.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/forms.cpython-312.pyc new file mode 100644 index 0000000000..2227843f06 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/forms.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/models.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000000..f6f9938a36 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/models.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/urls.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000..9e0b2db206 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/urls.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/__pycache__/views.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000000..772f4e9bd5 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/__pycache__/views.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/admin.py b/Web_Development/djangotweet/tweethead/tweet/admin.py new file mode 100644 index 0000000000..0e8fca3b43 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from .models import Tweet + +# Register your models here. + +admin.site.register(Tweet) diff --git a/Web_Development/djangotweet/tweethead/tweet/apps.py b/Web_Development/djangotweet/tweethead/tweet/apps.py new file mode 100644 index 0000000000..0cc1ecae74 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class TweetConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'tweet' diff --git a/Web_Development/djangotweet/tweethead/tweet/forms.py b/Web_Development/djangotweet/tweethead/tweet/forms.py new file mode 100644 index 0000000000..28bf143429 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/forms.py @@ -0,0 +1,16 @@ +from django import forms +from .models import Tweet +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.models import User + +class TweetForm(forms.ModelForm): + class Meta: + model = Tweet + fields = ['text','photo'] + + +class UserRegistrationForm(UserCreationForm): + email=forms.EmailField() + class Meta: + model = User + fields = ('username','email','password1','password2') diff --git a/Web_Development/djangotweet/tweethead/tweet/migrations/0001_initial.py b/Web_Development/djangotweet/tweethead/tweet/migrations/0001_initial.py new file mode 100644 index 0000000000..6dbbc94014 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 5.1.2 on 2024-10-17 06:04 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Tweet', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(max_length=240)), + ('photo', models.ImageField(blank=True, null=True, upload_to='photos/')), + ('created_at', models.DateField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/Web_Development/djangotweet/tweethead/tweet/migrations/__init__.py b/Web_Development/djangotweet/tweethead/tweet/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/0001_initial.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000000..4b7cccb29c Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/__init__.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000..d71dd09f4e Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweet/models.py b/Web_Development/djangotweet/tweethead/tweet/models.py new file mode 100644 index 0000000000..5d598e1518 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/models.py @@ -0,0 +1,23 @@ +from django.db import models +from django.contrib.auth.models import User + +# Create your models here. + + +class Tweet(models.Model): + + user=models.ForeignKey(User,on_delete=models.CASCADE) + text=models.TextField(max_length=240) + photo=models.ImageField(upload_to = 'photos/', blank=True, null=True) + created_at=models.DateField(auto_now_add=True) + updated_at=models.DateTimeField(auto_now=True) + + + def __str__(self): + return f'{self.user.username} - {self.text[:10]}' + + + + + + diff --git a/Web_Development/djangotweet/tweethead/tweet/templates/index.html b/Web_Development/djangotweet/tweethead/tweet/templates/index.html new file mode 100644 index 0000000000..abe58f50d6 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/templates/index.html @@ -0,0 +1,17 @@ +{% extends "layout.html" %} + +{% block title %} + + +Chai aur tweet + +{% endblock %} + +{% block container %} + + +

+Welcome to this django project + +

+{% endblock %} \ No newline at end of file diff --git a/Web_Development/djangotweet/tweethead/tweet/templates/tweet_confirm_delete.html b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_confirm_delete.html new file mode 100644 index 0000000000..b57117f7f6 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_confirm_delete.html @@ -0,0 +1,26 @@ +{% extends "layout.html" %} + +{% block title %} + + +Chai aur tweet + +{% endblock %} + +{% block container %} + + +

+Are you sure you want to delete this tweet? + +

+ +
+ {% csrf_token %} + + Cancel +
+ + + +{% endblock %} \ No newline at end of file diff --git a/Web_Development/djangotweet/tweethead/tweet/templates/tweet_form.html b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_form.html new file mode 100644 index 0000000000..7132968dff --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_form.html @@ -0,0 +1,27 @@ +{% extends "layout.html" %} + +{% block title %} + Chai aur tweet +{% endblock %} + +{% block container %} +

+ Welcome to this Django project +

+ +

+ {% if form.instance.pk %} + Edit Tweet + {% else %} + Create Tweet + {% endif %} +

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+ + Back to tweet list +{% endblock %} diff --git a/Web_Development/djangotweet/tweethead/tweet/templates/tweet_list.html b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_list.html new file mode 100644 index 0000000000..11ccbcac6d --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/templates/tweet_list.html @@ -0,0 +1,40 @@ +{% extends "layout.html" %} + +{% block title %} + + +Chai aur tweet + +{% endblock %} + +{% block container %} + + +

+Welcome to this django project +

+ +Create a tweet + +
+ {%for tweet in tweets%} +
+ ... +
+
{{tweet.user.username}}
+

{{tweet.text}}

+ + {% if tweet.user == user %} + Edit + Delete + {% endif %} +
+
+ + {% endfor %} + + +
+ + +{% endblock %} \ No newline at end of file diff --git a/Web_Development/djangotweet/tweethead/tweet/tests.py b/Web_Development/djangotweet/tweethead/tweet/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Web_Development/djangotweet/tweethead/tweet/urls.py b/Web_Development/djangotweet/tweethead/tweet/urls.py new file mode 100644 index 0000000000..14ec287acb --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/urls.py @@ -0,0 +1,14 @@ + +from django.urls import path +from . import views + + +urlpatterns = [ + + + path('',views.tweet_list,name='tweet_list'), + path('create/',views.tweet_create,name='tweet_create'), + path('/edit/',views.tweet_edit,name='tweet_edit'), + path('/delete/',views.tweet_delete,name='tweet_delete'), + path('register/',views.register,name='register'), +] diff --git a/Web_Development/djangotweet/tweethead/tweet/views.py b/Web_Development/djangotweet/tweethead/tweet/views.py new file mode 100644 index 0000000000..c10a32794a --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweet/views.py @@ -0,0 +1,76 @@ +from django.shortcuts import render +from .models import Tweet +from .forms import TweetForm, UserRegistrationForm +from django.shortcuts import get_object_or_404, redirect +from django.contrib.auth.decorators import login_required +from django.contrib.auth import login,authenticate +from django.shortcuts import redirect +from django.contrib.auth.forms import AuthenticationForm +# Create your views here. + + +def index(request): + return render(request,'index.html') + + +def tweet_list(request): + tweets = Tweet.objects.all().order_by('-created_at') + return render(request,'tweet_list.html',{'tweets':tweets}) + + +@login_required +def tweet_create(request): + if request.method == "POST": + form = TweetForm(request.POST, request.FILES) + if form.is_valid(): + tweet = form.save(commit=False) + tweet.user = request.user + tweet.save() + return redirect('tweet_list') + else: + form = TweetForm() # This needs to be outside the if block to ensure it's always initialized. + + return render(request, 'tweet_form.html', {'form': form}) + + + +@login_required +def tweet_edit(request,tweet_id): + tweet=get_object_or_404(Tweet,pk=tweet_id,user=request.user) + if request.method=='POST': + form=TweetForm(request.POST,request.FILES,instance=tweet) + if form.is_valid(): + tweet=form.save(commit=False) + tweet.user=request.user + tweet.save() + return redirect('tweet_list') + + else: + form=TweetForm(instance=tweet) + return render(request,'tweet_form.html',{'form':form}) + + + +@login_required +def tweet_delete(request,tweet_id): + tweet=get_object_or_404(Tweet,pk=tweet_id,user=request.user) + if request.method=='POST': + tweet.delete() + return redirect('tweet_list') + return render(request,'tweet_confirm_delete.html',{'tweet':tweet}) + + + +def register(request): + if request.method == 'POST': + form = UserRegistrationForm(request.POST) + if form.is_valid(): + user = form.save(commit=False) + user.set_password(form.cleaned_data['password1']) + user.save() + login(request,user) + return redirect('tweet_list') + else: + form = UserRegistrationForm() + + return render(request, 'registration/register.html', {'form': form}) diff --git a/Web_Development/djangotweet/tweethead/tweethead/__init__.py b/Web_Development/djangotweet/tweethead/tweethead/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Web_Development/djangotweet/tweethead/tweethead/__pycache__/__init__.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000..4fc644f27d Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/__init__.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweethead/__pycache__/settings.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000000..d7558e22f4 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/settings.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweethead/__pycache__/urls.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000..9b2e064a28 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/urls.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweethead/__pycache__/wsgi.cpython-312.pyc b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/wsgi.cpython-312.pyc new file mode 100644 index 0000000000..644d401be3 Binary files /dev/null and b/Web_Development/djangotweet/tweethead/tweethead/__pycache__/wsgi.cpython-312.pyc differ diff --git a/Web_Development/djangotweet/tweethead/tweethead/asgi.py b/Web_Development/djangotweet/tweethead/tweethead/asgi.py new file mode 100644 index 0000000000..29f8164d3a --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweethead/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for tweethead 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/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tweethead.settings') + +application = get_asgi_application() diff --git a/Web_Development/djangotweet/tweethead/tweethead/settings.py b/Web_Development/djangotweet/tweethead/tweethead/settings.py new file mode 100644 index 0000000000..e76a6b061b --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweethead/settings.py @@ -0,0 +1,138 @@ +""" +Django settings for tweethead project. + +Generated by 'django-admin startproject' using Django 5.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/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/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-iubq17ueoyjw$u543v@qsmx_g2^41^&^k#8&%zf@@w=uesq%%=' + +# 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', + 'tweet', +] + +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 = 'tweethead.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR,'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'tweethead.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/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/5.1/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/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + +STATIC_URL = '/static/' +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] + +LOGIN_URL = '/accounts/login/' + +LOGIN_REDIRECT_URL = '/tweet/' +LOGOUT_REDIRECT_URL = '/tweet/' + diff --git a/Web_Development/djangotweet/tweethead/tweethead/urls.py b/Web_Development/djangotweet/tweethead/tweethead/urls.py new file mode 100644 index 0000000000..e14ebab7c5 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweethead/urls.py @@ -0,0 +1,27 @@ +""" +URL configuration for tweethead project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/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 path,include +from django.conf import settings +from django.conf.urls.static import static +from django.contrib.auth.urls import views as auth_views + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('tweet.urls')), + path('accounts/', include('django.contrib.auth.urls')), +]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/Web_Development/djangotweet/tweethead/tweethead/wsgi.py b/Web_Development/djangotweet/tweethead/tweethead/wsgi.py new file mode 100644 index 0000000000..e79e063912 --- /dev/null +++ b/Web_Development/djangotweet/tweethead/tweethead/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for tweethead 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/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tweethead.settings') + +application = get_wsgi_application()