Django- Set created & updated date/time in your models

In Django, many of us have question how to create date time in database automatically, When a new data is inserted or Existing Data is Updated.

So, Now we can use to have the date a record was added, or most recently updated. Django makes this really easy.

class Blogs(models.Model):
    title = models.CharField(max_length=100)
    added = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

Sitemap in Python Django

Sitemap in Python Django

# For Sitemap
from django.views.generic import TemplateView
urlpatterns = [


    #include testapp app url
    url(r'', include('testapp.urls')),

    url(r'^sitemap\.xml$', TemplateView.as_view(template_name='sitemap.xml', content_type='text/xml')),

**  keep the sitemap.xml file in app/templates/sitemap.xml