I have a simple blog app that has a blog home and the details. I am using slug for detail URLs and prepopulating the slug field with the post title. everything works fine local but after I deployed the app online, when I click the post to go to its' blog detail it won't find the page.
this is my post models:
class PostManager(models.Manager):
def get_queryset(self):
return PostQuerySet(self.model, using=self._db)
def search(self, query=None):
return self.get_queryset().search(query=query)
class Post(models.Model):
objects = PostManager()
title = models.CharField(max_length=150)
paragraph = models.TextField(blank=True)
published = jmodels.jDateField()
tags = TaggableManager()
slug = models.SlugField(max_length=200, unique=True, allow_unicode=True)
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(Post, self).save(*args, **kwargs)
this is my urls:
path('maghaalaat/', views.MaghaleMain.as_view(), name="blog-page"),
path('maghaalaat/tags/<slug:tag_slug>/', views.MaghaleTags.as_view(), name="tagged"),
re_path(r'maghaalaat/(?P<the_slug>[-\w]+)/', views.MaghaleDetail.as_view(), name='post-detail'),
this is my views:
class MaghaleMain(ListView):
model = MaghaalaatPost
template_name = 'Blog/Blog-elmi.html'
queryset = MaghaalaatPost.objects.all()
context_object_name = 'posts'
ordering = ['-published']
paginate_by = 3
def get_context_data(self, **kwargs):
context = super(MaghaleMain, self).get_context_data(**kwargs)
context['tags'] = MaghaalaatPost.tags.all()
return context
class MaghaleTags(ListView):
model = MaghaalaatPost
template_name = 'Blog/Blog-elmi.html'
context_object_name = 'posts'
def get_queryset(self):
return MaghaalaatPost.objects.filter(tags__slug=self.kwargs.get('tag_slug'))
def get_context_data(self, **kwargs):
context = super(MaghaleTags, self).get_context_data(**kwargs)
context['tags'] = MaghaalaatPost.tags.all()
return context
class MaghaleDetail(DetailView):
model = MaghaalaatPost
template_name = 'Blog/Blog-elmi-detail.html'
context_object_name = 'maghaale'
slug_url_kwarg = 'the_slug'
slug_field = 'slug'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["related_items"] = self.object.tags.similar_objects()[:3]
return context
this is the error I get(I changed the debug to true in order to see the errors):
please help me I don't know what am I doing wrong and why I only have this issue online