mirror of
https://github.com/lemeow125/Django-NotesApp.git
synced 2024-11-17 06:29:25 +08:00
Hotfix for not being able to POST with changed 12 hour datetime format
This commit is contained in:
parent
df411d2f46
commit
ec74dbdaf5
4 changed files with 45 additions and 1 deletions
Binary file not shown.
21
project/notes/migrations/0010_alter_note_owner.py
Normal file
21
project/notes/migrations/0010_alter_note_owner.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 4.1.7 on 2023-03-04 11:06
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('notes', '0009_alter_note_content'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='note',
|
||||||
|
name='owner',
|
||||||
|
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
21
project/notes/migrations/0011_alter_note_owner.py
Normal file
21
project/notes/migrations/0011_alter_note_owner.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 4.1.7 on 2023-03-04 11:16
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('notes', '0010_alter_note_owner'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='note',
|
||||||
|
name='owner',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,8 +4,10 @@ from .models import Note
|
||||||
|
|
||||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
owner = serializers.ReadOnlyField(source='owner.username')
|
owner = serializers.ReadOnlyField(source='owner.username')
|
||||||
date_created = serializers.DateTimeField(format="%d-%m-%Y %I:%M%p")
|
date_created = serializers.DateTimeField(
|
||||||
|
format="%d-%m-%Y %I:%M%p", read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Note
|
model = Note
|
||||||
fields = ('id', 'title', 'content', 'date_created', 'owner')
|
fields = ('id', 'title', 'content', 'date_created', 'owner')
|
||||||
|
read_only_fields = ('id', 'date_created', 'owner')
|
||||||
|
|
Loading…
Reference in a new issue