jax
jax

Reputation: 4197

Django field Error

I am a Django beginner working on Django v1.9 and trying to learn and replicate DjangoGirl tutorial. I have stuck at "Dynamic data in templates" and "Django templates".

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})

the given "view.py" showing error

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

I have tried each and everything possible but it's not working... kindly help.

Upvotes: 0

Views: 95

Answers (1)

sebb
sebb

Reputation: 1966

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})

Upvotes: 1

Related Questions