Browse Source

added show on page

master
Domagoj Zecevic 2 years ago
parent
commit
bd1628bbda
  1. 6
      blog/admin.py
  2. 18
      blog/migrations/0007_post_show_on_page.py
  3. 23
      blog/migrations/0008_index_post_show_on_page_sexy_posts_show_on_page.py
  4. 3
      blog/models.py
  5. 6
      blog/templates/blog/index.html
  6. 11
      blog/templates/blog/post_list.html
  7. 11
      blog/templates/blog/sexy_list.html
  8. BIN
      db.sqlite3

6
blog/admin.py

@ -2,13 +2,13 @@ from django.contrib import admin
from .models import Post, Index_Post, Sexy_Posts
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'short_description', 'pub_date')
list_display = ('title', 'short_description', 'pub_date', 'show_on_page')
class IndexPostAdmin(admin.ModelAdmin):
list_display = ('title', 'content', 'pub_date')
list_display = ('title', 'content', 'pub_date', 'show_on_page')
class SexyPost(admin.ModelAdmin):
list_display = ('title', 'short_description', 'pub_date')
list_display = ('title', 'short_description', 'pub_date', 'show_on_page')
admin.site.register(Post, PostAdmin)
admin.site.register(Index_Post, IndexPostAdmin)

18
blog/migrations/0007_post_show_on_page.py

@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-01-27 23:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0006_sexy_posts'),
]
operations = [
migrations.AddField(
model_name='post',
name='show_on_page',
field=models.BooleanField(default=False),
),
]

23
blog/migrations/0008_index_post_show_on_page_sexy_posts_show_on_page.py

@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2024-01-27 23:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0007_post_show_on_page'),
]
operations = [
migrations.AddField(
model_name='index_post',
name='show_on_page',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='sexy_posts',
name='show_on_page',
field=models.BooleanField(default=False),
),
]

3
blog/models.py

@ -5,6 +5,7 @@ class Post(models.Model):
content = models.TextField()
short_description = models.TextField(max_length=300, blank=True, null=True)
pub_date = models.DateTimeField('date published')
show_on_page = models.BooleanField(default=False)
def __str__(self):
return self.title
@ -13,6 +14,7 @@ class Index_Post(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
pub_date = models.DateTimeField('date published')
show_on_page = models.BooleanField(default=False)
def __str__(self):
return self.title
@ -22,6 +24,7 @@ class Sexy_Posts(models.Model):
content = models.TextField()
short_description = models.TextField(max_length=300, blank=True, null=True)
pub_date = models.DateTimeField('date published')
show_on_page = models.BooleanField(default=False)
def __str__(self):
return self.title

6
blog/templates/blog/index.html

@ -85,11 +85,15 @@
<div class="detail-box">
<div class="heading_container">
<h2>
{% if post.show_on_page %}
{{ post.title }}
{% endif %}
</h2>
</div>
<p>
{{ post.content|linebreaksbr }}
{% if post.show_on_page %}
{{ post.content|linebreaksbr }}
{% endif %}
</p>
</div>
</div>

11
blog/templates/blog/post_list.html

@ -85,14 +85,19 @@
<div class="detail-box">
<div class="heading_container">
<h2>
{% if post.show_on_page %} as
{{ post.title }}
{% endif %}
</h2>
</div>
<p>
{{ post.short_description|linebreaksbr }}
{% if post.show_on_page %}
{{ post.short_description|linebreaksbr }}
{% endif %}
</p>
<a href="{% url 'blog:post_detail' post.id %}">
Read More
{% if post.show_on_page %}
<a href="{% url 'blog:post_detail' post.id %}"> Read More
{% endif %}
</a>
</div>
</div>

11
blog/templates/blog/sexy_list.html

@ -85,14 +85,19 @@
<div class="detail-box">
<div class="heading_container">
<h2>
{% if post.show_on_page %}
{{ post.title }}
{% endif %}
</h2>
</div>
<p>
{{ post.short_description|linebreaksbr }}
{% if post.show_on_page %}
{{ post.short_description|linebreaksbr }}
{% endif %}
</p>
<a href="{{ post.id }}">
Read More
{% if post.show_on_page %}
<a href="{{ post.id }}"> Read More
{% endif %}
</a>
</div>
</div>

BIN
db.sqlite3

Binary file not shown.
Loading…
Cancel
Save