I created an app called marketing app which customizes messages to be written 
on top of website page. My problem is that these messages are not showing when 
everything is configured and I don't know why is that might be the template 
because {{ marketing_message.message}} is only not showing

This is the model of the Marketing App

class MarketingMessage(models.Model):
    message = models.CharField(max_length=120)
    active = models.BooleanField(default=False)
    featured = models.BooleanField(default=False)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    start_date = models.DateTimeField(
        auto_now_add=False, auto_now=False, null=True, blank=True)
    end = models.DateTimeField(
        auto_now_add=False, auto_now=False, null=True, blank=True)

    def __str__(self):
        return str(self.message[:12])

this is the views for the core app:

class HomeView(ListView):
    model = Item
    paginate_by = 10
    template_name = "home.html"

    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)
        context['marketing_message'] = MarketingMessage.objects.all()

this is the template:
{% if marketing_message %}
    <div class="alert alert-light" style="padding-top:80px; 
margin-bottom:-24px">
        <a href="#" class="close" data-dismiss="alert">×</a>
        <div class="container" style="text-align:center">
        <strong>Marketing Message ! : </strong> {{ marketing_message.message}}
        </div>   
    </div>
{% endif  %}

This is the admin.py of marketing

from django.contrib import admin
from .models import MarketingMessage
# Register your models here.


class MarketingMessageAdmin(admin.ModelAdmin):
    class Meta:
        model = MarketingMessage


admin.site.register(MarketingMessage, MarketingMessageAdmin)


        return context

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a68d848e-6373-41ef-a614-e4333e974e5c%40googlegroups.com.

Reply via email to