Opened 5 years ago

Closed 5 years ago

#30202 closed Cleanup/optimization (invalid)

Add a documentation example for DateRangeField

Reported by: Malik A. Rumi Owned by: nobody
Component: Documentation Version: 2.1
Severity: Normal Keywords: Date, DateRange, DateRangeField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am requesting that the documentation of this feature be enhanced. Specifically, that it be given a concrete example of usage in a class / model definition. I don't think people like me should be left to guess through trial, error and repeated migrations to figure out how this is supposed to work. To make matters worse, when I was googling just now to find an answer somewhere else, not in the docs, I came cross this -> https://stackoverflow.com/questions/39400086/setting-django-daterangefield-parameters, which is me asking the same damn question 2 and a half years ago - and no, there is still no answer posted there, either.

Are we explicitly subclassing class psycopg2.extras.DateRange(lower=None, upper=None, bounds='[)', empty=False)
in our models? Where? What is the syntax for that? What about blank=True and/or null=True? Where do they go. if they go here at all? etc.

I ask because of this error I got:

daterange = models.DateRangeField(start_date, end_date,
AttributeError: module 'django.db.models' has no attribute 'DateRangeField'

This gets an error that 'psycopg2' is undefined, even though it is imported at the top of the file.

daterange = psycopg2.extras.DateRangeField(start_date, end_date,
blank=True, null=True)

Change History (1)

comment:1 by Tim Graham, 5 years ago

Resolution: invalid
Status: newclosed
Summary: DateRangeFieldAdd a documentation example for DateRangeField

From the top of the page you linked: "All of these fields are available from the django.contrib.postgres.fields module." It seems you're passing positional arguments (start_date, end_date) that you've made up. The field takes the normal model field options and nothing extra (thus there's nothing special to document). Please use TicketClosingReasons/UseSupportChannels to get help in the future.

Note: See TracTickets for help on using tickets.
Back to Top