Reputation: 197
I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this?
To clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!
Upvotes: 1
Views: 564
Reputation: 5249
What you're looking for is probably coverd by post_date__year=year
and post_date__month=month
in django.
Nevertheless all this seems a little bit werid for get
parameters. Do you have any constraint at database level that forbids you from putting there two posts with the same title in the same month of given year?
Upvotes: 1