├── account ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-310.pyc │ ├── settings.cpython-310.pyc │ ├── urls.cpython-310.pyc │ └── wsgi.cpython-310.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── accountdata ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-310.pyc │ ├── admin.cpython-310.pyc │ ├── apps.cpython-310.pyc │ ├── models.cpython-310.pyc │ └── views.cpython-310.pyc ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_student_student_image.py │ ├── 0003_student_email.py │ ├── 0004_auto_20220405_0333.py │ ├── 0005_auto_20220406_0259.py │ ├── 0006_delete_blog.py │ ├── 0007_blog.py │ ├── 0008_rename_content1_blog_content.py │ ├── 0009_blogcomment.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-310.pyc │ │ ├── 0002_student_student_image.cpython-310.pyc │ │ ├── 0003_student_email.cpython-310.pyc │ │ ├── 0004_auto_20220405_0333.cpython-310.pyc │ │ ├── 0005_auto_20220406_0259.cpython-310.pyc │ │ ├── 0006_auto_20220406_0323.cpython-310.pyc │ │ ├── 0006_auto_20220406_0335.cpython-310.pyc │ │ ├── 0006_delete_blog.cpython-310.pyc │ │ ├── 0007_auto_20220406_0327.cpython-310.pyc │ │ ├── 0007_blog.cpython-310.pyc │ │ ├── 0008_auto_20220406_0328.cpython-310.pyc │ │ ├── 0008_rename_content1_blog_content.cpython-310.pyc │ │ ├── 0009_auto_20220406_0330.cpython-310.pyc │ │ ├── 0009_blogcomment.cpython-310.pyc │ │ ├── 0010_auto_20220406_0332.cpython-310.pyc │ │ └── __init__.cpython-310.pyc ├── models.py ├── templatetag │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ ├── extra.cpython-310.pyc │ │ └── extras.cpython-310.pyc │ └── extras.py ├── tests.py └── views.py ├── db.sqlite3 ├── manage.py ├── media └── img │ ├── f6806bfc76499939bbce9efa6360bcce.jpg │ ├── images.png │ └── img2.png └── tamplates ├── addblog.html ├── base.html ├── blogpost.html ├── index.html ├── login.html └── signin.html /account/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/account/__init__.py -------------------------------------------------------------------------------- /account/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/account/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /account/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/account/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /account/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/account/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /account/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/account/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /account/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for account 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', 'account.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /account/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for account project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.2.8. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.2/ref/settings/ 11 | """ 12 | 13 | from django.contrib.messages import constants as messages 14 | from pathlib import Path 15 | import os 16 | 17 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 18 | BASE_DIR = Path(__file__).resolve().parent.parent 19 | 20 | 21 | # Quick-start development settings - unsuitable for production 22 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 23 | 24 | # SECURITY WARNING: keep the secret key used in production secret! 25 | SECRET_KEY = 'django-insecure-ri%f+c#^m-irch2t#gye3g^x1rq(*ohh=g#4w2+#gg*!!)s7j#' 26 | 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = True 29 | 30 | ALLOWED_HOSTS = [] 31 | 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'accountdata.templatetag.extras', 37 | 'django.contrib.admin', 38 | 'django.contrib.auth', 39 | 'django.contrib.contenttypes', 40 | 'django.contrib.sessions', 41 | 'django.contrib.messages', 42 | 'django.contrib.staticfiles', 43 | 'accountdata.apps.AccountdataConfig', 44 | 'django.contrib.humanize', 45 | 46 | ] 47 | 48 | MIDDLEWARE = [ 49 | 'django.middleware.security.SecurityMiddleware', 50 | 'django.contrib.sessions.middleware.SessionMiddleware', 51 | 'django.middleware.common.CommonMiddleware', 52 | 'django.middleware.csrf.CsrfViewMiddleware', 53 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 54 | 'django.contrib.messages.middleware.MessageMiddleware', 55 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 56 | ] 57 | 58 | ROOT_URLCONF = 'account.urls' 59 | 60 | TEMPLATES = [ 61 | { 62 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 63 | 'DIRS': ['tamplates'], 64 | 'APP_DIRS': True, 65 | 'OPTIONS': { 66 | 'context_processors': [ 67 | 'django.template.context_processors.debug', 68 | 'django.template.context_processors.request', 69 | 'django.contrib.auth.context_processors.auth', 70 | 'django.contrib.messages.context_processors.messages', 71 | ], 72 | }, 73 | }, 74 | ] 75 | 76 | WSGI_APPLICATION = 'account.wsgi.application' 77 | 78 | 79 | # Database 80 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases 81 | 82 | DATABASES = { 83 | 'default': { 84 | 'ENGINE': 'django.db.backends.sqlite3', 85 | 'NAME': BASE_DIR / 'db.sqlite3', 86 | } 87 | } 88 | 89 | 90 | # Password validation 91 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 92 | 93 | AUTH_PASSWORD_VALIDATORS = [ 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 102 | }, 103 | { 104 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 105 | }, 106 | ] 107 | 108 | 109 | # Internationalization 110 | # https://docs.djangoproject.com/en/3.2/topics/i18n/ 111 | 112 | LANGUAGE_CODE = 'en-us' 113 | 114 | TIME_ZONE = 'UTC' 115 | 116 | USE_I18N = True 117 | 118 | USE_L10N = True 119 | 120 | USE_TZ = True 121 | 122 | 123 | # Static files (CSS, JavaScript, Images) 124 | # https://docs.djangoproject.com/en/3.2/howto/static-files/ 125 | 126 | 127 | STATIC_URL = '/static/' 128 | MEDIA_ROOT= os.path.join(BASE_DIR, "media") 129 | MEDIA_URL="/media/" 130 | # Default primary key field type 131 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field 132 | 133 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 134 | 135 | 136 | 137 | 138 | MESSAGE_TAGS ={ 139 | messages.SUCCESS: 'msg', 140 | messages.ERROR: 'danger' 141 | } 142 | -------------------------------------------------------------------------------- /account/urls.py: -------------------------------------------------------------------------------- 1 | """account URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | from accountdata import views 19 | from django.conf import settings 20 | from django.conf.urls.static import static 21 | 22 | 23 | urlpatterns = [ 24 | path('admin/', admin.site.urls), 25 | path('',views.blogs , name='blogs'), 26 | path('addblog',views.addblog , name='addblog'), 27 | # path('blogs',views.blogs , name='blogs'), 28 | path('blogcomment',views.blogcomment , name='blogcomment'), 29 | path('signin',views.signin , name='signin'), 30 | path('login',views.userlogin , name='login'), 31 | path('logout',views.userlogout , name='logiut'), 32 | path('blog/',views.blogpost , name='blogpost'), 33 | 34 | ]+ static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) 35 | -------------------------------------------------------------------------------- /account/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for account 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', 'account.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /accountdata/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__init__.py -------------------------------------------------------------------------------- /accountdata/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Blog,Blogcomment 3 | # Register your models here. 4 | admin.site.register((Blog,Blogcomment)) -------------------------------------------------------------------------------- /accountdata/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountdataConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'accountdata' 7 | -------------------------------------------------------------------------------- /accountdata/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-03-24 17:42 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='student', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('first_name', models.CharField(error_messages={'required': 'Enter First Name First'}, max_length=15)), 19 | ('last_name', models.CharField(max_length=15)), 20 | ('father_name', models.CharField(max_length=30)), 21 | ('phone_number', models.IntegerField()), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /accountdata/migrations/0002_student_student_image.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-03-24 18:43 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='student', 15 | name='student_image', 16 | field=models.ImageField(default=0, upload_to='stuimage'), 17 | preserve_default=False, 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /accountdata/migrations/0003_student_email.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-03-24 18:48 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0002_student_student_image'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='student', 15 | name='email', 16 | field=models.EmailField(default=0, max_length=254), 17 | preserve_default=False, 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /accountdata/migrations/0004_auto_20220405_0333.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-04 22:33 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0003_student_email'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Blog', 15 | fields=[ 16 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('title', models.CharField(error_messages={'required': 'Enter First Name First'}, max_length=15)), 18 | ('heading', models.CharField(max_length=15)), 19 | ('content', models.CharField(max_length=30)), 20 | ], 21 | ), 22 | migrations.DeleteModel( 23 | name='student', 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /accountdata/migrations/0005_auto_20220406_0259.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-05 21:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0004_auto_20220405_0333'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RemoveField( 14 | model_name='blog', 15 | name='content', 16 | ), 17 | migrations.RemoveField( 18 | model_name='blog', 19 | name='heading', 20 | ), 21 | migrations.AddField( 22 | model_name='blog', 23 | name='content1', 24 | field=models.CharField(default=0, max_length=3000), 25 | preserve_default=False, 26 | ), 27 | migrations.AddField( 28 | model_name='blog', 29 | name='content2', 30 | field=models.CharField(default=0, max_length=3000), 31 | preserve_default=False, 32 | ), 33 | migrations.AddField( 34 | model_name='blog', 35 | name='heading1', 36 | field=models.CharField(default=0, max_length=50), 37 | preserve_default=False, 38 | ), 39 | migrations.AddField( 40 | model_name='blog', 41 | name='heading2', 42 | field=models.CharField(default=0, max_length=50), 43 | preserve_default=False, 44 | ), 45 | migrations.AlterField( 46 | model_name='blog', 47 | name='title', 48 | field=models.CharField(error_messages={'required': 'Enter First Name First'}, max_length=30), 49 | ), 50 | ] 51 | -------------------------------------------------------------------------------- /accountdata/migrations/0006_delete_blog.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-05 22:37 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0005_auto_20220406_0259'), 10 | ] 11 | 12 | operations = [ 13 | migrations.DeleteModel( 14 | name='Blog', 15 | ), 16 | ] 17 | -------------------------------------------------------------------------------- /accountdata/migrations/0007_blog.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-05 22:38 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ('accountdata', '0006_delete_blog'), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Blog', 17 | fields=[ 18 | ('sno', models.AutoField(primary_key=True, serialize=False)), 19 | ('title', models.CharField(error_messages={'required': 'Enter First Name First'}, max_length=30)), 20 | ('writter', models.CharField(max_length=50)), 21 | ('slug', models.CharField(max_length=130)), 22 | ('time', models.DateTimeField(auto_now_add=True)), 23 | ('content1', models.TextField()), 24 | ], 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /accountdata/migrations/0008_rename_content1_blog_content.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-05 22:41 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('accountdata', '0007_blog'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RenameField( 14 | model_name='blog', 15 | old_name='content1', 16 | new_name='content', 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /accountdata/migrations/0009_blogcomment.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.8 on 2022-04-06 20:33 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | import django.utils.timezone 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 13 | ('accountdata', '0008_rename_content1_blog_content'), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Blogcomment', 19 | fields=[ 20 | ('sno', models.AutoField(primary_key=True, serialize=False)), 21 | ('comment', models.TextField()), 22 | ('time', models.DateTimeField(default=django.utils.timezone.now)), 23 | ('blog', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accountdata.blog')), 24 | ('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='accountdata.blogcomment')), 25 | ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 26 | ], 27 | ), 28 | ] 29 | -------------------------------------------------------------------------------- /accountdata/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__init__.py -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0002_student_student_image.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0002_student_student_image.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0003_student_email.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0003_student_email.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0004_auto_20220405_0333.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0004_auto_20220405_0333.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0005_auto_20220406_0259.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0005_auto_20220406_0259.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0006_auto_20220406_0323.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0006_auto_20220406_0323.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0006_auto_20220406_0335.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0006_auto_20220406_0335.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0006_delete_blog.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0006_delete_blog.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0007_auto_20220406_0327.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0007_auto_20220406_0327.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0007_blog.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0007_blog.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0008_auto_20220406_0328.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0008_auto_20220406_0328.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0008_rename_content1_blog_content.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0008_rename_content1_blog_content.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0009_auto_20220406_0330.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0009_auto_20220406_0330.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0009_blogcomment.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0009_blogcomment.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/0010_auto_20220406_0332.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/0010_auto_20220406_0332.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/models.py: -------------------------------------------------------------------------------- 1 | from distutils.command.upload import upload 2 | import email 3 | from email.policy import default 4 | from pyexpat import model 5 | from django.db import models 6 | from django.contrib.auth.models import User 7 | from django.utils.timezone import now 8 | # Create your models here. 9 | 10 | 11 | class Blog(models.Model): 12 | sno = models.AutoField(primary_key=True) 13 | title = models.CharField(max_length=30,error_messages={'required':'Enter First Name First'}) 14 | writter = models.CharField(max_length=50) 15 | slug=models.CharField(max_length=130) 16 | time = models.DateTimeField(auto_now_add=True) 17 | content = models.TextField() 18 | # img = models.ImageField() 19 | 20 | def __str__(self): 21 | return self.title 22 | 23 | class Blogcomment(models.Model): 24 | 25 | sno = models.AutoField(primary_key=True) 26 | comment = models.TextField() 27 | user = models.ForeignKey(User , on_delete=models.CASCADE) 28 | blog = models.ForeignKey(Blog , on_delete=models.CASCADE) 29 | parent = models.ForeignKey('self', on_delete=models.CASCADE , null=True) 30 | time = models.DateTimeField(default=now) 31 | 32 | # img = models.ImageField() 33 | 34 | def __str__(self): 35 | return self.comment[0:13] + "..." + "by" + " " + self.user.username 36 | 37 | -------------------------------------------------------------------------------- /accountdata/templatetag/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/templatetag/__init__.py -------------------------------------------------------------------------------- /accountdata/templatetag/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/templatetag/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/templatetag/__pycache__/extra.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/templatetag/__pycache__/extra.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/templatetag/__pycache__/extras.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/accountdata/templatetag/__pycache__/extras.cpython-310.pyc -------------------------------------------------------------------------------- /accountdata/templatetag/extras.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register=template.Library() 4 | 5 | @register.filter(name='get_val') 6 | def get_val(dict, key): 7 | return dict.get(key) 8 | -------------------------------------------------------------------------------- /accountdata/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /accountdata/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib import messages 2 | from django.http import HttpResponse 3 | from django.shortcuts import render,redirect 4 | from django.http import HttpResponse 5 | from django.contrib.auth.models import User 6 | from django.contrib.auth import authenticate, login, logout 7 | from . models import Blog,Blogcomment 8 | 9 | 10 | # Create your views here. 11 | 12 | 13 | 14 | 15 | 16 | def signin(request): 17 | 18 | if request.method=="POST": 19 | fname = request.POST.get('fname') 20 | lname = request.POST.get('lname') 21 | uname = request.POST.get('uname') 22 | email = request.POST.get('email') 23 | pass1 = request.POST.get('pass1') 24 | pass2 = request.POST.get('pass2') 25 | if not fname.isalpha(): 26 | messages.error(request,"Please Remove Symbles Or Numbers Of First Name") 27 | dic={} 28 | # return redirect('signin',dic) 29 | 30 | if not lname.isalpha(): 31 | messages.error(request,"Please Remove Symbles Or Numbers Of Last Name") 32 | dic={} 33 | # return redirect('signin',dic) 34 | 35 | if not uname.isalnum(): 36 | messages.error(request,"User Name Is Must Be Alpha Numaric") 37 | dic={} 38 | # return redirect('signin',dic) 39 | 40 | if len(uname) < 8 : 41 | messages.error(request,"User Name Is Must Be 8 Character") 42 | dic={} 43 | # return redirect('signin',dic) 44 | 45 | if len(pass1) < 8: 46 | messages.error(request,"Password IsTo Small Please Create 8 Character Password") 47 | dic={} 48 | # return redirect('signin',dic) 49 | 50 | 51 | if pass1 != pass2: 52 | messages.error(request,"Passwords Is Not Same") 53 | dic={} 54 | # return redirect('signin',dic) 55 | 56 | 57 | user = User.objects.create_user(uname,email,pass1) 58 | user.save() 59 | user=authenticate(username= uname, password= pass1) 60 | if user is not None: 61 | login(request, user) 62 | messages.success(request,"You Logedin You Account Is Created") 63 | return redirect('blogs') 64 | # login(request,user) 65 | messages.success(request,"You Account Is Created") 66 | dic={} 67 | # return redirect('signin',dic) 68 | 69 | 70 | dic={} 71 | return render(request,'signin.html',dic) 72 | 73 | 74 | 75 | def userlogin(request): 76 | user = request.user 77 | if user.is_authenticated: 78 | return redirect('blogs') 79 | else: 80 | if request.method == "POST": 81 | # Get the post parameters 82 | loginusername = request.POST['loginuname'] 83 | loginpassword = request.POST['loginpass'] 84 | 85 | user=authenticate(username= loginusername, password= loginpassword) 86 | if user is not None: 87 | login(request, user) 88 | messages.success(request, "Successfully Logged In") 89 | return redirect('blogs') 90 | 91 | else: 92 | messages.error(request, "Invalid credentials! Please try again") 93 | # return redirect("home") 94 | 95 | return render(request,'login.html') 96 | return render(request,'login.html') 97 | 98 | 99 | 100 | 101 | def userlogout(request): 102 | logout(request) 103 | messages.success(request, "Successfully logged out") 104 | 105 | return redirect('blogs') 106 | 107 | 108 | 109 | def addblog(request): 110 | user = request.user 111 | if user.is_authenticated: 112 | if request.method == "POST": 113 | title = request.POST.get('blogtitle') 114 | bwritter = f"{user.first_name} {user.last_name}" 115 | text = request.POST.get('blogcontent') 116 | 117 | blog = Blog(title=title,writter=bwritter,slug=title,content=text) 118 | blog.save() 119 | messages.success(request,"YOUR BLOG HAS BEEN SAVE") 120 | 121 | return redirect('blogs') 122 | 123 | 124 | 125 | return render(request,'addblog.html') 126 | return redirect('blogs') 127 | 128 | 129 | 130 | def blogs(request): 131 | 132 | b = Blog.objects.all() 133 | dic={'blog':b} 134 | 135 | return render(request,'index.html',dic) 136 | 137 | def blogpost(request , slug): 138 | 139 | # b = Blog.objects.all() 140 | blog=Blog.objects.filter(slug=slug).first() 141 | comments= Blogcomment.objects.filter(blog=blog,parent=None) 142 | # replies= Blogcomment.objects.filter(blog=blog).exclude(parent=None) 143 | # replydic={} 144 | # for reply in replies: 145 | # if reply.parent.sno not in replydic.keys(): 146 | # replydic[reply.parent.sno]=[reply] 147 | # else: 148 | # replydic[reply.parent.sno].append(reply) 149 | 150 | # for comment in comments: 151 | # getval = get_val(replydic,comment.sno) 152 | 153 | dic={"blog":blog,'comments':comments,'user': request.user} 154 | 155 | return render(request,'blogpost.html',dic) 156 | 157 | def blogcomment(request): 158 | if request.method == "POST": 159 | comment=request.POST.get('comment') 160 | user=request.user 161 | blogsno =request.POST.get('blogsno') 162 | blog= Blog.objects.get(sno=blogsno) 163 | parentsno=request.POST.get('commentsno') 164 | if parentsno==None: 165 | comment=Blogcomment(comment= comment, user=user, blog=blog) 166 | comment.save() 167 | messages.success(request, "Your comment has been posted successfully") 168 | else: 169 | parent= Blogcomment.objects.get(sno=parentsno) 170 | comment=Blogcomment(comment= comment, user=user, blog=blog,parent=parent) 171 | comment.save() 172 | messages.success(request, "Your replay has been posted successfully") 173 | 174 | 175 | 176 | return redirect(f"blog/{blog.slug}") -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/db.sqlite3 -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'account.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /media/img/f6806bfc76499939bbce9efa6360bcce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/media/img/f6806bfc76499939bbce9efa6360bcce.jpg -------------------------------------------------------------------------------- /media/img/images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/media/img/images.png -------------------------------------------------------------------------------- /media/img/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdul-Basit-Ansari/Django-User-Blogs/73b0ed573bdab75fae60818f05c2cd164f73ff88/media/img/img2.png -------------------------------------------------------------------------------- /tamplates/addblog.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block title %} Add Blog | Ab-Blogs {% endblock title %} {% block body %} 2 | 41 | 42 | 43 |
44 | {% csrf_token %} 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | {% endblock body %} -------------------------------------------------------------------------------- /tamplates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {% block title %}{% endblock title %} 10 | 11 | 12 | 13 | 88 | 89 | 112 | {% if messages %} {% for message in messages %} 113 |
114 | 122 | 123 |
124 | {% endfor %} {% endif %} 125 | 126 | 127 | 128 | 135 | 136 | {% block body %} {% endblock body%} 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /tamplates/blogpost.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block title %} {{blog.title}} | Ab-Blogs {% endblock title %} {% block body %} {% load humanize %} 2 | 115 | 116 | 117 |
118 |

{{blog.title}}

119 |

{{blog.time}} by {{blog.writter}}

120 | 121 |

{{blog.content}}

122 |
123 |
124 | 125 |
126 | {% csrf_token %} {% if user.is_authenticated %} 127 | 128 | 129 | {% else %} 130 | 131 | {% endif %} 132 | 133 |
134 | 135 |

Comments ({{comments.count}})

136 | {% for comment in comments %} 137 | 138 | 139 |
140 | noimg 141 | {{comment.user.username|title}} 142 |
143 |

{{comment.time | naturaltime}}

144 |

{{comment.comment}}

145 |
146 | 160 | {% endif %} 161 | 162 | {% endfor %} {% endblock body %} -------------------------------------------------------------------------------- /tamplates/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block title %} Blogs | Ab-Blogs{% endblock title %} {% block body %} {% for b in blog %} 2 | 45 | 46 |
47 |
48 |

{{b.title}}

49 |
50 |
51 |
52 |

Writer : {{b.writter}}

53 | 54 |
55 |
56 |
57 |

{{b.content | truncatechars:150}}

58 |
59 | 60 |
61 | 62 | 63 | {% endfor %} {% endblock body %} -------------------------------------------------------------------------------- /tamplates/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block title %} Login | Ab-Blogs {% endblock title %} {% block body %} 2 | 40 | 41 | 42 | 43 |
44 |

Log In

45 |
46 | {% csrf_token %} 47 | 48 |
49 | 50 |
51 | 52 |
53 |
54 | 55 | 56 | {% endblock body %} -------------------------------------------------------------------------------- /tamplates/signin.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} {% block title %} Signin | Ab-Blogs {% endblock title %} {% block body %} 2 | 3 | 4 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
74 |

Signin Your Accocunt

75 |
76 | {% csrf_token %} 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 | 87 | 88 |
89 | 90 | 96 | 97 | 98 | 99 | 100 | {% endblock body%} --------------------------------------------------------------------------------