3
で汎用ビューを指定するときにログインしているユーザー探査する、私はこのようになりますモデルがあります:ジャンゴ:urlpatterns
from django.db import models
from django.contrib.auth.models import User
class Application(models.Model):
STATUS_CHOICES = (
(u'IP',u'In Progress'),
(u'C',u'Completed'))
status = models.CharField(max_length=2 ,choices=STATUS_CHOICES, default='IP')
title = models.CharField(max_length = 512)
description = models.CharField(max_length = 5120)
principle_investigator = models.ForeignKey(User, related_name='pi')
をそして、私は現在ログインしているユーザー向けのアプリケーションを一覧表示し、一般的なリストビューを使用したいです、 'IP'のステータスを持っています
私は私のurlパターンを書き始めて、私がquerysetプロパティで現在ログインしているユーザーを参照する必要があることに気づきました....これは可能ですか、モデルクエリを処理する標準カスタムビューを記述しますか?
url(r'^application/pending/$', ListView.as_view(
queryset=Application.objects.filter(status='IP'))),
すごく簡単な解決策です。乾杯! – Ctrlspc