Commit f99ce702 authored by Jersey Dayao's avatar Jersey Dayao 🏀

feat: added Reply model and additional fields in current Post model in forum app

parent f6998759
from django.contrib import admin
from .models import Post
from .models import Post, Reply
# Register your models here.
admin.site.register(Post)
admin.site.register(Reply)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-07 17:14
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_auto_20220407_0505'),
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='post',
name='author',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reply_body', models.CharField(max_length=10000)),
('pub_date', models.DateTimeField(verbose_name='date published')),
('author', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser')),
('reply_post', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.post')),
],
),
]
from django.db import models
from homepage.models import WidgetUser
# Create your models here.
......@@ -6,6 +7,16 @@ class Post(models.Model):
post_title = models.CharField(max_length=100)
post_body = models.CharField(max_length=10000)
pub_date = models.DateTimeField('date published')
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, default=None, null=True)
def __str__(self):
return self.post_title
class Reply(models.Model):
reply_body = models.CharField(max_length=10000)
pub_date = models.DateTimeField('date published')
reply_post = models.ForeignKey(Post, on_delete=models.CASCADE, default=None, null=True)
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, default=None, null=True)
def __str__(self):
return 'Reply to: {}' .format(self.reply_post)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment