diff --git a/LibCasaAdministration/settings.py b/LibCasaAdministration/settings.py index 2ed38c0..f44121d 100644 --- a/LibCasaAdministration/settings.py +++ b/LibCasaAdministration/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'forum.apps.ForumConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', diff --git a/forum/__init__.py b/forum/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/forum/admin.py b/forum/admin.py new file mode 100644 index 0000000..fbef64a --- /dev/null +++ b/forum/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin + +from .models import Post, Replie, Profile + +admin.site.register(Post) +admin.site.register(Replie) +admin.site.register(Profile) \ No newline at end of file diff --git a/forum/apps.py b/forum/apps.py new file mode 100644 index 0000000..f0cb8de --- /dev/null +++ b/forum/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ForumConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'forum' diff --git a/forum/migrations/0001_initial.py b/forum/migrations/0001_initial.py new file mode 100644 index 0000000..bf5e545 --- /dev/null +++ b/forum/migrations/0001_initial.py @@ -0,0 +1,47 @@ +# Generated by Django 4.0.4 on 2022-06-20 15:45 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Post', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('post_content', models.CharField(max_length=5000)), + ('timestamp', models.DateTimeField(default=django.utils.timezone.now)), + ('image', models.ImageField(default='', upload_to='images')), + ('user1', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Reply', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('reply_content', models.CharField(max_length=5000)), + ('timestamp', models.DateTimeField(default=django.utils.timezone.now)), + ('image', models.ImageField(default='', upload_to='images')), + ('post', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='forum.post')), + ('user', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image', models.ImageField(default='default/user.png', upload_to='images')), + ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/forum/migrations/__init__.py b/forum/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/forum/models.py b/forum/models.py new file mode 100644 index 0000000..8a1273a --- /dev/null +++ b/forum/models.py @@ -0,0 +1,25 @@ +from django.db import models + +from django.db import models +from django.contrib.auth.models import User +from django.utils.timezone import now + +# Create your models here. +class Profile(models.Model): + user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) + image = models.ImageField(upload_to="images",default="default/user.png") + +class Post(models.Model): + user1 = models.ForeignKey(User, on_delete=models.CASCADE, default=1) + post_id = models.AutoField + post_content = models.CharField(max_length=5000) + timestamp= models.DateTimeField(default=now) + image = models.ImageField(upload_to="images",default="") + +class Reply(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE, default=1) + reply_id = models.AutoField + reply_content = models.CharField(max_length=5000) + post = models.ForeignKey(Post, on_delete=models.CASCADE, default='') + timestamp= models.DateTimeField(default=now) + image = models.ImageField(upload_to="images",default="") \ No newline at end of file diff --git a/forum/templates/basic.html b/forum/templates/basic.html new file mode 100644 index 0000000..9e63f8a --- /dev/null +++ b/forum/templates/basic.html @@ -0,0 +1,44 @@ +
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
+It uses utility classes for typography and spacing to space content out within the larger container.
+ +{{post.post_content}}
+