There are alternatives of django-timezones?

Found module datetied to time zones.


The author of the well thought out it (for the functionality it suits me), but it looks like in practice and not used. Because it is full of errors, including no support for mysql, and it alone can generate hundreds of queries per page.


There are of course different ppl were, but substantially the situation, none of them correct.


So the question is, is there another common means of working with dates tied to time zones for Django?
October 14th 19 at 10:40
2 answers
October 14th 19 at 10:42
View it here: Django and timezones
Thank you, the article is of course in the subject. What is described in the second part in fact is the django-timezones in its infancy. And by the way, the code in again it will not work with mysql because driver does not allow any non-null datetime with tzinfo. - Erik_Muller76 commented on October 14th 19 at 10:45
October 14th 19 at 10:44
use django-timezones like this:
class City(models.Model):
 name = models.CharField(u City', max_length=30)
 timezone = TimeZoneField(u 'timezone')

 def now(self):
 return datetime.now(self.timezone).replace(tzinfo=None)

And then, knowing the current time in the city, you need to carry out any calculations — instead of just datetime.now() to use something like self.city.now().

All the extra bells and whistles of django-timezones seem not very useful not figured out how to use them can — there the devil is in the details, as usual. Additional calculations can be performed using the standard datetime or (and) third-party dateutil.
On the contrary I found very useful the possibility to set the time zone lookup in the database.

class City(models.Model):
 timezone = TimeZoneField(u 'timezone')
 created = LocalizedDateTimeField(auto_now_add=True, timezone=u 'timezone')

class Restaurant(models.Model):
 city = models.ForeignKey(City)
 created = LocalizedDateTimeField(auto_now_add=True, timezone=u city__timezone')

class Dish(models.Model):
 restaurant = models.ForeignKey(Restaurant)
 created = LocalizedDateTimeField(auto_now_add=True, timezone=u restaurant__city__timezone')


Only query this creates a lot of, what I actually intend to fight. - Erik_Muller76 commented on October 14th 19 at 10:47

Find more questions by tags time zonesDjangoPython