from __future__ import unicode_literals
from django.db import models
from django.utils import timezone
class Test(models.Model):
name = models.CharField(max_length=10, editable=False)
dateregister = models.DateTimeField(auto_now=False, auto_now_add=False, null=True, blank=True, editable=False)
def __str__(self): # __unicode__ on Python 2
return self.name
from .models import Test
from datetime import datetime
from django.shortcuts import render, get_object_or_404
def test(request):
test = Test.objects.order_by('name')
return render(request, 'test/test.html', {'test': test})
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03de09e4-1a70-4bf3-a669-dce6a22f24d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello Stephen,
from .models import Test
from datetime import datetime
from django.shortcuts import render, get_object_or_404
def test(request):
test = Test.objects.order_by('name')
date2016 = Test.objects.filter(dateregister__contains='2016').count() ??????
return render(request, 'test/test.html', {'test': test})
{% for test in test %}
<td>{{ test.name }}</td>
<td>{{ test.dateregister }}</td>
{% endfor %}
{% test.date2016 %}
????
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f7f13063-3c98-4373-b238-b7ab9fb5e0d0%40googlegroups.com.