2016-09-15 5 views
0

私はDjango v1.9で作業しているDjango初心者で、DjangoGirlチュートリアルを学び、複製しようとしています。私は "テンプレート内のダイナミックデータ"と "Djangoテンプレート"で立ち往生しています。Djangoフィールドエラー

from django.shortcuts import render 
from .models import Post 
from django.utils import timezone 

# Create your views here. 



def post_list(request): 

    posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') 
    return render(request, 'blog/post_list.html', {'posts':posts}) 

エラー

Exception Value:  
Cannot resolve keyword 'published_date' into the field. Choices are: author, author_id, creat_date, id, publish_Data, text, title 

を示す与えられた「view.py」私は、可能なすべてのものを試してみましたが、親切に助けて...働いていません。

+0

あなたのフィールドはモデルで間違ったものと呼ばれています:あなたは 'publish_Data'という名前を付けました。したがって、ビュー内で同じ名前を使用する必要があります。 –

答えて

1
from django.shortcuts import render 
from .models import Post 
from django.utils import timezone 

def post_list(request): 

    posts = Post.objects.filter(publish_Data__lte=timezone.now()).order_by('publish_Data') 
    return render(request, 'blog/post_list.html', {'posts':posts}) 
+0

thaaaaanksそれが働いた – jax

関連する問題