Invalid syntax when place QuerySet to a new value

2 views
Skip to first unread message

Xuqing Kuang

unread,
Jul 2, 2009, 11:43:21 PM7/2/09
to Django users
Hi, all.

I want to generate a report of my job status in somedays, so I make a
QuerySet like following:

====================================
# Generate query set
jobs = Job.list(request.REQUEST)

#today_jobs = jobs.filter(started_time__gte = date.fromtimestamp
(time.time()))
7days_jobs = jobs.filter(started_time__gte = date.fromtimestamp
(time.time() - 24 * 60 * 60 * 7))
#30days_jobs = jobs.filter(started_time__gte = date.fromtimestamp
(time.time() - 24 * 60 * 60 * 30))
====================================

The issue is when I place the jobs QuerySet to the new value named
7days_jobs, Django will report

('invalid syntax', ('/Users/xkuang/Documents/Projects/DjangoApp/report/
views.py', 157, 18, ' 7days_jobs = jobs.filter
(started_time__gte = date.fromtimestamp(time.time() - 24 * 60 * 60 *
7))\n'))

But after I rename the 7days_jobs to jobs it will works fine, But the
function I need will can not implemented.

Does anybody know are there some solution to resolve it ?

BTW: The another very strange thing is to place the QuerySet like
following will works fine.

====================================
# Get the lastest jobs of need
top_longest_jobs = jobs.order_by('-process_time')[:10]
top_recipes_jobs = jobs.order_by('-recipes_count')[:10]
====================================

I'm very confusing in it ... Please help.

Alex Gaynor

unread,
Jul 2, 2009, 11:46:05 PM7/2/09
to django...@googlegroups.com
In Python a variable cannot start with a number.

Alex

--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

Xuqing Kuang

unread,
Jul 3, 2009, 1:20:23 AM7/3/09
to Django users
Ahhh!!!

Thank you for you resolved my problem !!!



On Jul 3, 11:46 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages