Here are the examples of the python api django.utils.timezone.timezone_now taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def save(self, *args, **kwargs):
if not self.pk:
self.created = timezone_now()
else:
# To ensure that we have a creation data always, we add this one
if not self.created:
self.created = timezone_now()
self.modified = timezone_now()
super(CreationModificationDateMixin, self).save(*args, **kwargs)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "quotes/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def small_upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "quotes/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S_small"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def medium_upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "quotes/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S_medium"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def large_upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "locations/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S_large"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "products/%s/%s%s" % (
instance.product.slug,
now.strftime("%Y%m%d%H%M%S"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def small_upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "locations/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S_small"),
filename_ext.lower(),
)
3
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def medium_upload_to(instance, filename):
now = timezone_now()
filename_base, filename_ext = os.path.splitext(filename)
return "locations/%s%s" % (
now.strftime("%Y/%m/%Y%m%d%H%M%S_medium"),
filename_ext.lower(),
)
0
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def upload_to(instance, filename):
now = timezone_now()
base, ext = os.path.splitext(filename)
ext = ext.lower()
return f"quotes/{now:%Y/%m/%Y%m%d%H%M%S}{ext}"
0
View Complete Implementation : models.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def product_photo_upload_to(instance, filename):
now = timezone_now()
slug = instance.product.slug
base, ext = os.path.splitext(filename)
return f"products/{slug}/{now:%Y%m%d%H%M%S}{ext.lower()}"