diff --git a/project/accounts/serializers.py b/project/accounts/serializers.py index 060f147..2d990c4 100644 --- a/project/accounts/serializers.py +++ b/project/accounts/serializers.py @@ -5,8 +5,9 @@ from notes.models import Note class CustomUserSerializer(serializers.ModelSerializer): notes = serializers.PrimaryKeyRelatedField( - many=True, queryset=Note.objects.all()) + many=True, allow_null=True, queryset=Note.objects.all()) class Meta: model = User - fields = ['id', 'username', 'notes'] + fields = ['id', 'username', 'notes',] + read_only_fields = ['id', 'notes'] diff --git a/project/db.sqlite3 b/project/db.sqlite3 index 68766b5..7180d3e 100644 Binary files a/project/db.sqlite3 and b/project/db.sqlite3 differ diff --git a/project/notes/migrations/0009_alter_note_content.py b/project/notes/migrations/0009_alter_note_content.py new file mode 100644 index 0000000..b038538 --- /dev/null +++ b/project/notes/migrations/0009_alter_note_content.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-03-03 15:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notes', '0008_alter_note_owner'), + ] + + operations = [ + migrations.AlterField( + model_name='note', + name='content', + field=models.TextField(), + ), + ] diff --git a/project/notes/models.py b/project/notes/models.py index b2363f6..82416b3 100644 --- a/project/notes/models.py +++ b/project/notes/models.py @@ -7,7 +7,7 @@ User = get_user_model() class Note(models.Model): title = models.CharField(max_length=20) - content = models.CharField(max_length=1024) + content = models.TextField() date_created = models.DateTimeField(default=now, editable=False) owner = models.ForeignKey(User, on_delete=models.CASCADE)