簡體   English   中英

在這種情況下,如何修復 django 中的 UnicodeDecode 錯誤?

[英]How to fix UnicodeDecode error in django in this scenario?

I want to order the model objects in descending order, how am I supposed to go about doing that using the field number in my model class.

這是我的views.py:

class SeasonDetailView(DetailView):
  
    model = CartoonSeason
    template_name = "episode_list.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["episodes"] = Episode.objects.filter(season=self.object)
        return context



class EpisodeDetailView(DetailView):
  
    model = Episode
    template_name = "episode.html"

這是我的models.py:

class Episode(models.Model):
    season = models.ForeignKey(CartoonSeason, on_delete=models.CASCADE)
    number = models.IntegerField()
    cover  = models.URLField(max_length=300, blank=True, null=True)
    name = models.CharField(max_length=200, blank=True, null=True)
    description = models.TextField(blank=True, null=False)
    link = models.URLField(max_length=300, blank=True, null=True)
    published = models.DateField(auto_now_add=True, blank=True, null=True)
class Episode(models.Model):
    season = models.ForeignKey(CartoonSeason,on_delete=models.CASCADE)
    number = models.IntegerField()
    cover  = models.URLField(max_length=300, blank=True, null=True)
    name = models.CharField(max_length=200, blank=True, null=True)
    description = models.TextField(blank=True, null=False)
    link = models.URLField(max_length=300, blank=True, null=True)
    published = models.DateField(auto_now_add=True, 
    blank=True,null=True)


    class Meta:
        verbose_name = _("Episode")
        verbose_name_plural = _("Episodes")
        ordering = ["season"]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM