Skip to content
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
1 change: 1 addition & 0 deletions COMMANDS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pip install django-cors-headers
pip install psycopg2
pip install gunicorn
pip install python-dotenv
pip install djoser



Expand Down
12 changes: 11 additions & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'djoser',
'corsheaders',
'blog.apps.BlogConfig',
'account.apps.AccountConfig',
Expand Down Expand Up @@ -148,7 +150,7 @@
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
# 'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
Expand All @@ -158,6 +160,14 @@
]
}

DJOSER = {
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'USERNAME_RESET_CONFIRM_URL': '#/username/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': False,
'SERIALIZERS': {},
}

SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=5),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
Expand Down
22 changes: 22 additions & 0 deletions backend/blog/migrations/0011_article_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.0.6 on 2024-06-14 16:10

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blog', '0010_alter_article_options_remove_article_user'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name='article',
name='user',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='user_article', to=settings.AUTH_USER_MODEL, verbose_name='User'),
preserve_default=False,
),
]
2 changes: 1 addition & 1 deletion backend/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Meta:
verbose_name_plural = 'Articles'
ordering = ['-created_at']

# user = ForeignKey(User, verbose_name='User', on_delete=PROTECT, related_name='user_article')
user = ForeignKey(User, verbose_name='User', on_delete=PROTECT, related_name='user_article')
title = CharField(max_length=75, verbose_name='Title', unique=True)
image = ImageField(upload_to=get_blog_image_path, verbose_name='Image', blank=True)
content = TextField(verbose_name='Content')
Expand Down
16 changes: 16 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
asgiref==3.8.1
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.8
defusedxml==0.8.0rc2
Django==5.0.6
django-cors-headers==4.3.1
django-templated-mail==1.1.1
djangorestframework==3.15.1
djangorestframework-simplejwt==5.3.1
djoser==2.2.3
gunicorn==22.0.0
idna==3.7
oauthlib==3.2.2
packaging==24.1
pillow==10.3.0
psycopg2==2.9.9
pycparser==2.22
PyJWT==2.8.0
python-dotenv==1.0.1
python3-openid==3.2.0
requests==2.32.3
requests-oauthlib==2.0.0
social-auth-app-django==5.4.1
social-auth-core==4.5.4
sqlparse==0.5.0
typing_extensions==4.12.1
urllib3==2.2.1