views:

190

answers:

1

hello

I used : SplitDateTimeWidget to split DateTime field ,

appointment = forms.DateTimeField(widget=forms.SplitDateTimeWidget)

In the template side i manage to use datePicker and TimePicker for each field , using jQuery .

When i try to filter the entries regarding to today date as in this code :

d = datetime.date.today()
entries = Entry.objects.filter(appointment__year=d.year ,appointment__month=d.month ,appointment__day=d.day )

It shows the entries of yesterday 17 aug :( which is really weird !

I Tried to split the Date and Time in the model , i got the same result as well !

Any idea how to fix this ?!

+2  A: 

Fix your timezone settings, in settings.py TIME_ZONE

Default: 'America/Chicago'

Some excerpts of useful info from the docs:

A string representing the time zone for this installation. See available choices.

(...)

Note that this is the time zone to which Django will convert all dates/times -- not necessarily the timezone of the server.

(...)

Django cannot reliably use alternate time zones in a Windows environment. If you're running Django on Windows, this variable must be set to match the system timezone.

nosklo
Thank you , Already figured the issue and fixed it , am using Django on Ubuntu , BSD and ArchLinux mostly .. don't like to deal with windows as dev environment .... BTW any solution to change the time zone regarding the visitor or current user ?!Regards
Hamza
@Hamza: One generally uses a template filter to do that. See here http://djangosnippets.org/snippets/183/ for an example of filter you can use. Please mark answer as accepted so your question can have a correct answer
nosklo