Date-based generic views do not provide pagination by default but Django is very extensible. It provides a Paginator that takes care of pagination. Since date based views usually order by descending order ie from latest entry to the oldest, I used a queryset to order the items (on a field called 'date_pub') and then pass this queryset to the paginator which takes care of the pagination.
Dada una fecha_origen, incrementa N dias a partir de esa fecha ignorando sábados y domingos.
Increments a date by n days without counting weekends. Just working days.
This widget uses: [DHTML Calendar Widget](http://www.dynarch.com/projects/calendar/).
It is very simple implementation but may be easily extended/changed/refined.
1. Necessary files:
First download calendar package and extract it to your MEDIA folder (MEDIA/calendar/...)
You'll also need a small gif that will be shown as a button that allows user to display calendar. By default this 'gif' is searched at '[MEDIA]images/calbutton.gif' but you may change this path in the code (calbtn variable). You need to download or create callbutton.gif image by yourself (it is not included).
2. Include css and js files in your page (as shown in the comment in the code).
3. In form code assign a widget to a field as usual (see newforms documentation for more details).
4. It is possible to change date format by specifying different value for 'dformat' attribute of widget class.
If you get javascript errors while trying to open calendar try to use english translation file (calendar-en.js). I've found that some translations, eg. Polish, are broken by default. In this case you should override your language translation with english one and translate it by yourself (it is easy).
Form fields use the dateutil module [http://labix.org/python-dateutil](http://labix.org/python-dateutil) to parse natural-language input for date and datetime fields.
The callback function will replace all date and datetime fields automatically for form_for_model and form_for_instance. **Note**: by replacing the 'form_class' keyword argument instead of just returning the field itself you preserve the 'required' status of the field.
This is tag similar to *timesince* and *timeuntil*, which work great until you starting giving timesince dates in the future or timeuntil dates in the past. Timedelta tag will humanize output correctly for both future and past dates using *now* as a default reference date (or a specified reference date as argument)
now = Apr 27 2007
futuredate = May 5 2007
pastdate = Jan 5 2007
{{ futuredate|timedelta }} will output "in 1 week, 1 day"
{{ pastdate|timedelta }} will output "3 months, 2 weeks ago"
This is a reasonably straight forward port of functionality provided by the `django.utils.dateformat` module into a method extending JavaScript's Date object. Its intended use is to allow client-side dynamic content to share the same date & time string formatting as Django template markup. By using this in conjunction with a context processor (to pass a format string to all templates) you can switch formats for both server-generated & client-generated dates across a complete site with a single setting.
The function supports *almost* the entire format -- as listed by the Django documentation for the [now template tag](http://www.djangoproject.com/documentation/templates/#now) -- with the exception of "I" & "T".
As a 'dumb' illustration, the following template tag usage:
It is {% now "jS F Y H:i" %}
...could equate to the following:
It is <script type="text/javascript">var now = new Date(); document.write(now.strfdate('jS F Y H:i'));</script>
It's not extensively tested (I only wrote it over the weekend), but seems to be working okay. Feel free to leave any corrections or suggestions in the comments, and I'll try to keep this entry updated if I make any fixes or changes.
Sometimes you'll have a list of ORM objects that aren't in a QuerySet, but you still want to sort them by date. For instance, you have a list of shows with a date_time attribute. Maybe you used a list comprehension to filter them...who knows. Regardless, you have a list (not a QuerySet) of Django objects.