I use django_filters to filter the date greater than datetime
for example
http://127.0.0.1:8000/movies/?datetimefilter=2014-11-18
But the 2014-11-18 I save is utc time,
So actually the time in my timezone maybe is 2014-11-19
How can I let the timezone convert from utc to Asia/Taipei in my views.py??
Please teach me,Thank you very much
my views.py
class MovieFilter(django_filters.FilterSet):
datetimefilter = django_filters.DateTimeFilter(name="datetime",lookup_type="gte")
class Meta:
model = Movie
fields = ['datetimefilter']
If you simply want to change the timezone of your project, you can set
TIME_ZONE = 'Asia/Taipei'in yoursettings.py.If you want to covert the input date from UTC to another timezone (Asia/Taipei), this would do the trick:
First of all, do
pip install pytzThen, you can do something like:
For detailed documentation, see django.utils.timezone