Date-based mixinsLink to this heading
YearMixinLink to this heading
- class YearMixinLink to this definition
A mixin that can be used to retrieve and provide parsing information for a year component of a date.
Cara dan Atribut
- year_formatLink to this definition
Bentuk
strftime()digunakan ketika mengurai tahun. Secara awal, ini adalah'%Y'.
- yearLink to this definition
Pilihan Nilai untuk tahun, sebagai deretan kalimat. Secara awal, disetel ke
None, yang berarti tahun akan ditentukan menggunakan cara lain.
- get_year_format()Link to this definition
Returns the
strftime()format to use when parsing the year. Returnsyear_formatby default.
- get_year()Link to this definition
Mengembalikan tahun untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
Nilai dari atribut
YearMixin.year.Nilai dari argumen
yearditangkap di corak URL.The value of the
yearGETquery argument.
Memunculkan 404 jika spesifikasi tahun tidak sah ditemukan.
- get_next_year(date)Link to this definition
Mengembalikan obyek tanggal mengandung hari pertama dari tahun setelah tanggal disediakan. Fungsi ini dapat juga mengembalikan
Noneatau memunculkan pengecualianHttp404, tergantung pada nilai dariallow_emptydanallow_future.
- get_previous_year(date)Link to this definition
Mengembalikan obyek tanggal mengandung hari pertama dari tahun setelah tanggal disediakan. Fungsi ini dapat juga mengembalikan
Noneatau memunculkan pengecualianHttp404, tergantung pada nilai dariallow_emptydanallow_future.
MonthMixinLink to this heading
- class MonthMixinLink to this definition
A mixin that can be used to retrieve and provide parsing information for a month component of a date.
Cara dan Atribut
- month_formatLink to this definition
The
strftime()format to use when parsing the month. By default, this is'%b'.
- monthLink to this definition
Pilihan Nilai dari bulan, sebagai deretan kalimat. Secara awal, disetel ke
None, yang berarti bulan akan ditentukan menggunakan cara lain.
- get_month_format()Link to this definition
Returns the
strftime()format to use when parsing the month. Returnsmonth_formatby default.
- get_month()Link to this definition
Mengembalikan bulan untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
The value of the
MonthMixin.monthattribute.The value of the
monthargument captured in the URL pattern.The value of the
monthGETquery argument.
Raises a 404 if no valid month specification can be found.
- get_next_month(date)Link to this definition
Returns a date object containing the first day of the month after the date provided. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
- get_previous_month(date)Link to this definition
Returns a date object containing the first day of the month before the date provided. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
DayMixinLink to this heading
- class DayMixinLink to this definition
A mixin that can be used to retrieve and provide parsing information for a day component of a date.
Cara dan Atribut
- day_formatLink to this definition
The
strftime()format to use when parsing the day. By default, this is'%d'.
- dayLink to this definition
Pilihan Nilai dari hari, sebagai deretan kalimat. Secara awal, disetel ke``None``, yang berarti hari akan ditentukan menggunakan cara lain.
- get_day_format()Link to this definition
Returns the
strftime()format to use when parsing the day. Returnsday_formatby default.
- get_day()Link to this definition
Mengembalikan hari untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
The value of the
DayMixin.dayattribute.The value of the
dayargument captured in the URL pattern.The value of the
dayGETquery argument.
Raises a 404 if no valid day specification can be found.
- get_next_day(date)Link to this definition
Returns a date object containing the next valid day after the date provided. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
- get_previous_day(date)Link to this definition
Returns a date object containing the previous valid day. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
WeekMixinLink to this heading
- class WeekMixinLink to this definition
A mixin that can be used to retrieve and provide parsing information for a week component of a date.
Cara dan Atribut
- week_formatLink to this definition
The
strftime()format to use when parsing the week. By default, this is'%U', which means the week starts on Sunday. Set it to'%W'if your week starts on Monday.
- weekLink to this definition
Pilihan Nilai dari minggu, sebagai deretan kalimat. Secara awal, disetel ke``None``, yang berarti minggu akan ditentukan menggunakan cara lain.
- get_week_format()Link to this definition
Returns the
strftime()format to use when parsing the week. Returnsweek_formatby default.
- get_week()Link to this definition
Mengembalikan minggu untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
The value of the
WeekMixin.weekattribute.The value of the
weekargument captured in the URL patternThe value of the
weekGETquery argument.
Raises a 404 if no valid week specification can be found.
- get_next_week(date)Link to this definition
Returns a date object containing the first day of the week after the date provided. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
- get_prev_week(date)Link to this definition
Returns a date object containing the first day of the week before the date provided. This function can also return
Noneor raise anHttp404exception, depending on the values ofallow_emptyandallow_future.
DateMixinLink to this heading
- class DateMixinLink to this definition
A mixin class providing common behavior for all date-based views.
Cara dan Atribut
- date_fieldLink to this definition
The name of the
DateFieldorDateTimeFieldin theQuerySet’s model that the date-based archive should use to determine the list of objects to display on the page.When time zone support is enabled and
date_fieldis aDateTimeField, dates are assumed to be in the current time zone. Otherwise, the queryset could include objects from the previous or the next day in the end user's time zone.
- allow_futureLink to this definition
A boolean specifying whether to include "future" objects on this page, where "future" means objects in which the field specified in
date_fieldis greater than the current date/time. By default, this isFalse.
- get_date_field()Link to this definition
Returns the name of the field that contains the date data that this view will operate on. Returns
date_fieldby default.
- get_allow_future()Link to this definition
Determine whether to include "future" objects on this page, where "future" means objects in which the field specified in
date_fieldis greater than the current date/time. Returnsallow_futureby default.
BaseDateListViewLink to this heading
- class BaseDateListViewLink to this definition
A base class that provides common behavior for all date-based views. There won't normally be a reason to instantiate
BaseDateListView; instantiate one of the subclasses instead.While this view (and its subclasses) are executing,
self.object_listwill contain the list of objects that the view is operating upon, andself.date_listwill contain the list of dates for which data is available.Mixins
Cara dan Atribut
- allow_emptyLink to this definition
A boolean specifying whether to display the page if no objects are available. If this is
Trueand no objects are available, the view will display an empty page instead of raising a 404.This is identical to
django.views.generic.list.MultipleObjectMixin.allow_empty, except for the default value, which isFalse.
- date_list_periodLink to this definition
Optional A string defining the aggregation period for
date_list. It must be one of'year'(default),'month', or'day'.
- get_dated_items()Link to this definition
Returns a 3-tuple containing (
date_list,object_list,extra_context).date_listis the list of dates for which data is available.object_listis the list of objects.extra_contextis a dictionary of context data that will be added to any context data provided by theMultipleObjectMixin.
- get_dated_queryset(**lookup)Link to this definition
Returns a queryset, filtered using the query arguments defined by
lookup. Enforces any restrictions on the queryset, such asallow_emptyandallow_future.
- get_date_list_period()Link to this definition
Returns the aggregation period for
date_list. Returnsdate_list_periodby default.
- get_date_list(queryset, date_type=None, ordering='ASC')Link to this definition
Returns the list of dates of type
date_typefor whichquerysetcontains entries. For example,get_date_list(qs, 'year')will return the list of years for whichqshas entries. Ifdate_typeisn't provided, the result ofget_date_list_period()is used.date_typeandorderingare simply passed toQuerySet.dates().