Catatan
All the date formatting attributes in these mixins use
strftime()
format characters. Do not try to use the format
characters from the now
template tag as they are not compatible.
YearMixin
¶YearMixin
[sumber]¶A mixin that can be used to retrieve and provide parsing information for a year component of a date.
Cara dan Atribut
year_format
¶Bentuk strftime()
digunakan ketika mengurai tahun. Secara awal, ini adalah '%Y'
.
year
¶Pilihan Nilai untuk tahun, sebagai deretan kalimat. Secara awal, disetel ke None
, yang berarti tahun akan ditentukan menggunakan cara lain.
get_year_format
()[sumber]¶Returns the strftime()
format to use when parsing the
year. Returns year_format
by default.
get_year
()[sumber]¶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 year
ditangkap di corak URL.
year
GET
query argument.Memunculkan 404 jika spesifikasi tahun tidak sah ditemukan.
get_next_year
(date)[sumber]¶Mengembalikan obyek tanggal mengandung hari pertama dari tahun setelah tanggal disediakan. Fungsi ini dapat juga mengembalikan None
atau memunculkan pengecualian Http404
, tergantung pada nilai dari allow_empty
dan allow_future
.
get_previous_year
(date)[sumber]¶Mengembalikan obyek tanggal mengandung hari pertama dari tahun setelah tanggal disediakan. Fungsi ini dapat juga mengembalikan None
atau memunculkan pengecualian Http404
, tergantung pada nilai dari allow_empty
dan allow_future
.
MonthMixin
¶MonthMixin
[sumber]¶A mixin that can be used to retrieve and provide parsing information for a month component of a date.
Cara dan Atribut
month_format
¶The strftime()
format to use when parsing the month. By
default, this is '%b'
.
month
¶Pilihan Nilai dari bulan, sebagai deretan kalimat. Secara awal, disetel ke None
, yang berarti bulan akan ditentukan menggunakan cara lain.
get_month_format
()[sumber]¶Returns the strftime()
format to use when parsing the
month. Returns month_format
by default.
get_month
()[sumber]¶Mengembalikan bulan untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
MonthMixin.month
attribute.month
argument captured in the URL pattern.month
GET
query argument.Raises a 404 if no valid month specification can be found.
get_next_month
(date)[sumber]¶Returns a date object containing the first day of the month after the
date provided. This function can also return None
or raise an
Http404
exception, depending on the values of
allow_empty
and
allow_future
.
get_previous_month
(date)[sumber]¶Returns a date object containing the first day of the month before the
date provided. This function can also return None
or raise an
Http404
exception, depending on the values of
allow_empty
and
allow_future
.
DayMixin
¶DayMixin
[sumber]¶A mixin that can be used to retrieve and provide parsing information for a day component of a date.
Cara dan Atribut
day_format
¶The strftime()
format to use when parsing the day. By
default, this is '%d'
.
day
¶Pilihan Nilai dari hari, sebagai deretan kalimat. Secara awal, disetel ke``None``, yang berarti hari akan ditentukan menggunakan cara lain.
get_day_format
()[sumber]¶Returns the strftime()
format to use when parsing the day.
Returns day_format
by default.
get_day
()[sumber]¶Mengembalikan hari untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
DayMixin.day
attribute.day
argument captured in the URL pattern.day
GET
query argument.Raises a 404 if no valid day specification can be found.
get_next_day
(date)[sumber]¶Returns a date object containing the next valid day after the date
provided. This function can also return None
or raise an
Http404
exception, depending on the values of
allow_empty
and
allow_future
.
get_previous_day
(date)[sumber]¶Returns a date object containing the previous valid day. This function
can also return None
or raise an Http404
exception, depending on the values of
allow_empty
and
allow_future
.
WeekMixin
¶WeekMixin
[sumber]¶A mixin that can be used to retrieve and provide parsing information for a week component of a date.
Cara dan Atribut
week_format
¶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.
week
¶Pilihan Nilai dari minggu, sebagai deretan kalimat. Secara awal, disetel ke``None``, yang berarti minggu akan ditentukan menggunakan cara lain.
get_week_format
()[sumber]¶Returns the strftime()
format to use when parsing the
week. Returns week_format
by default.
get_week
()[sumber]¶Mengembalikan minggu untuk dimana tampilan ini akan menampilkan data, sebagai deretan kalimat. Coba sumber berikut, dalam urutan:
WeekMixin.week
attribute.week
argument captured in the URL patternweek
GET
query argument.Raises a 404 if no valid week specification can be found.
get_next_week
(date)[sumber]¶Returns a date object containing the first day of the week after the
date provided. This function can also return None
or raise an
Http404
exception, depending on the values of
allow_empty
and
allow_future
.
get_prev_week
(date)¶Returns a date object containing the first day of the week before the
date provided. This function can also return None
or raise an
Http404
exception, depending on the values of
allow_empty
and
allow_future
.
DateMixin
¶DateMixin
[sumber]¶A mixin class providing common behavior for all date-based views.
Cara dan Atribut
date_field
¶The name of the DateField
or DateTimeField
in the
QuerySet
’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_field
is a DateTimeField
, 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.
Peringatan
In this situation, if you have implemented per-user time zone
selection, the same URL may show a different set of objects,
depending on the end user’s time zone. To avoid this, you should
use a DateField
as the date_field
attribute.
allow_future
¶A boolean specifying whether to include “future” objects on this page,
where “future” means objects in which the field specified in
date_field
is greater than the current date/time. By default, this
is False
.
get_date_field
()[sumber]¶Returns the name of the field that contains the date data that this
view will operate on. Returns date_field
by default.
get_allow_future
()[sumber]¶Determine whether to include “future” objects on this page, where
“future” means objects in which the field specified in date_field
is greater than the current date/time. Returns
allow_future
by default.
BaseDateListView
¶BaseDateListView
[sumber]¶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_list
will contain the list of objects that the view is operating upon, and
self.date_list
will contain the list of dates for which data is
available.
Mixins
Cara dan Atribut
allow_empty
¶A boolean specifying whether to display the page if no objects are
available. If this is True
and 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 is False
.
date_list_period
¶Optional A string defining the aggregation period for
date_list
. It must be one of 'year'
(default), 'month'
, or
'day'
.
get_dated_items
()[sumber]¶Returns a 3-tuple containing (date_list
, object_list
,
extra_context
).
date_list
is the list of dates for which data is available.
object_list
is the list of objects. extra_context
is a
dictionary of context data that will be added to any context data
provided by the
MultipleObjectMixin
.
get_dated_queryset
(**lookup)[sumber]¶Returns a queryset, filtered using the query arguments defined by
lookup
. Enforces any restrictions on the queryset, such as
allow_empty
and allow_future
.
get_date_list_period
()[sumber]¶Returns the aggregation period for date_list
. Returns
date_list_period
by default.
get_date_list
(queryset, date_type=None, ordering='ASC')[sumber]¶Returns the list of dates of type date_type
for which queryset
contains entries. For example, get_date_list(qs, 'year')
will
return the list of years for which qs
has entries. If
date_type
isn’t provided, the result of
get_date_list_period()
is used. date_type
and ordering
are simply passed to
QuerySet.dates()
.
Agt 01, 2016