Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use date based generic view in django?
    primarykey
    data
    text
    <p>I want to display objects based on the datetime information they have. My model looks like this:</p> <p><strong>models.py</strong></p> <pre><code>class Person(models.Model): name = models.CharField(max_length=50) class Registration(models.Model): name = models.ForeignKey(Person) reg_id = models.IntegerField() reg_date = models.DateTimeField(db_index=True) reg_type = models.CharField(max_length=50) description = models.CharField(max_length-200) </code></pre> <p><strong>urls.py</strong></p> <pre><code>from app.models import Registration from dajngo.views.generic.date_based import archive_day queryset = registration.objects.all() urlpatterns = patterns('', url(r'^$', 'ui.views.index'), url(r'^registrations/(?P&lt;person_name&gt;)\w+)/(?P&lt;year&gt;\d{4})/(?P&lt;month&gt;\d{2})/(?P&lt;day&gt;\d{2})/$', archive_day, {'year': year, 'month': month, 'day': day, 'queryset': queryset, 'date_field': reg_date}) ) ) </code></pre> <p><strong>My Intent:</strong></p> <p>I want to display all the registrations in a person's name, in a particular day. Yes, one person can have more than one registration.</p> <p><strong>I know I am wrong:</strong></p> <p>I read the docs, but it isn't much handy for a newbie like me. And while I figured out that their are these required parameters and some optional which need to be sent as a <code>key: value</code> pair. But what I don't seem to understand is that how can I <code>reference</code> the <code>year</code>, <code>month</code>, <code>day</code>, <code>reg_time</code> into the <code>key: value</code> pair of the dictionary. I mean to say, that obviously it wont recognize what <code>year</code> is right? So from where can I get the reference? Do I sound confused? I really am. Some help in clearing it will be much appreciated.</p> <p><strong>Update:</strong></p> <p>There's one thing I realize. The <code>date</code> is really going to be wrapped inside the <code>request</code>. Because the user is going to request that <code>URL</code> right? So probably I need to extract the values of <code>year</code> <code>month</code> and <code>day</code> from the request body.So how can this be done?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload