Reference Generic date views
classWeekArchiveView[source] : A weekly archive page showing all objects in a given week. Objects with a date in the future are not displayed unless you set allow_future to True.
1413 sections across all versions Narrow to Django 6.0 (current) →
Reference Generic date views
classWeekArchiveView[source] : A weekly archive page showing all objects in a given week. Objects with a date in the future are not displayed unless you set allow_future to True.
Reference Generic date views
classDayArchiveView[source] : A day archive page showing all objects in a given day. Days in the future throw a 404 error, regardless of whether any objects exist for future days, unless you set allow_future to True.
Reference Date-based mixins
classBaseDateListView[source] : 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.
Reference django.contrib.auth User model
classmodels.UserManager : The User model has a custom manager that has the following helper methods (in addition to the methods provided by BaseUserManager):
Reference Geographic Database Functions Measurements
… more resource-intensive). In the following example, the distance from the city of Hobart to every other PointField in the AustraliaCity queryset is calculated: NOTE: Because the distance attribute is a > Distance object, you can easily > express the value …
Reference
… with Raster Fields Spatial Lookups Distance Queries Compatibility Tables GeoDjango Forms API Field arguments Form field classes Form widgets GIS QuerySet API Reference Spatial Lookups Distance Lookups Geographic Database Functions Measurements Relationships Operations Editors Input format Output format Miscellaneous Measurement …
Reference GeoDjango Tutorial Spatial Queries
When doing spatial queries, GeoDjango automatically transforms geometries if they’re in a different coordinate system.
Reference Databases PostgreSQL notesServer-side cursors
Another option is to wrap each QuerySet using server-side cursors in an atomic() block, because it disables autocommit for the duration of the transaction. This way, the server-side cursor will only live for the duration of the transaction.
Reference Database Functions Date functions
classExtract(expression,lookup_name=None,tzinfo=None,**extra)[source] Extracts a component of a date as a number. Takes an expression representing a DateField, DateTimeField, TimeField, or DurationField and a lookup_name, and returns the part of the date referenced by lookup_name as an IntegerField.
Reference Query Expressions Built-in Expressions
As well as being used in operations on single instances as above, F() can be used with update() to perform bulk updates on a QuerySet.
Topic guide
Article.objects.filter(reporter__first_name="John") <QuerySet [<Article: John's second story>, <Article: This is a test>]> Query twice over the related field.
Topic guide Models Model methods
NOTE: Note that the delete() method for an object is not > necessarily called when deleting objects in bulk using a > QuerySet or as a result of a cascading > delete.
Topic guide Making queries
To represent database-table data in Python objects, Django uses an intuitive system: A model class represents a database table, and an instance of that class represents a particular record in the database table.
Topic guide Making queries Related objectsOne-to-many relationships
Subsequent accesses to the foreign key on the same object instance are cached. Example: Note that the select_related() QuerySet method recursively prepopulates the cache of all one-to-many relationships ahead of time. Example:
Topic guide Making queries Related objectsMany-to-many relationships
You would expect it to return the entry e. However, the filter condition, which traverses the many-to-many relationship between Entry and Author, yields an empty QuerySet.
Topic guide Pagination
… you methods for accessing the items for each page: NOTE: Note that you can give Paginator a list/tuple, a Django QuerySet, > or any other object with a count() or __len__() method. When > determining the number of objects contained …
| | | | --- | --- | | - handle() (BaseCommand method) - handle_app_config() (AppCommand method) - handle_label() (LabelCommand method) - handle_no_permission() (AccessMixin method) - handle_raw_input() (FileUploadHandler method) - handler400 (in module django.conf.urls) - handler403 (in module django.conf.urls) - …
| | | | --- | --- | | - m (LineString attribute) - (Point attribute) - mail_admins() (in module django.core.mail) - mail_managers() (in module django.core.mail) - make_aware() (in module django.utils.timezone) - make_list - template filter - make_naive() (in module …
How-to How to write custom lookups
You will need to ensure that this registration happens before you try to create any querysets using it. You could place the implementation in a models.py file, or register the lookup in the ready() method of an AppConfig.
Reference The syndication feed framework
This simple example, taken from a hypothetical police beat news site describes a feed of the latest five news items: To connect a URL to this feed, put an instance of the Feed object in your URLconf.