私のアプリの一部は、ニュースフィードの上部にステータスを表示することで構成されています。ここで私は自分のステータスポストはに対応したかを示すの方法ですモデル外国のテーブルで参照されている行を除くdjangoクエリセット
class Status(models.Model):
user = models.ForeignKey(User)
description = models.CharField(max_length = 600, blank = False)
created_at = models.DateTimeField(auto_now_add = True, editable = False)
image = models.ImageField(upload_to = 'images/statuspics/%Y/%m/%d', blank = True, null = True)
utility = models.ForeignKey(Utility)
numlikes = models.IntegerField(default = 0)
class Meta:
ordering = ["-created_at"]
# Change plural form
verbose_name_plural = "statuses"
私は、その後の応答を持って、それを発表ステータスを持っています。
class Response(models.Model):
post = models.ForeignKey(Post, null = True, blank = True)
status = models.ForeignKey(Status, null = True, blank = True)
status_level = models.IntegerField(
blank = True,
choices = STATUS_CHOICES,
default = 1)
created_at = models.DateTimeField(auto_now_add = True, editable = False)
基本的には、対応するレスポンスのないステータスのみが表示されます。私は私のビューでexclude()を使用する必要があると思うが、私は完全にこの場合に適切に使用する方法はわかりません。
あなたは間違いなくこのようにしてはいけません...新しい...これまで! – crash843