Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:33:34+00:00 2026-06-09T03:33:34+00:00

My Proposal model is defined as follows: class Proposal(models.Model): scheduled_time = models.DateTimeField() duration =

  • 0

My Proposal model is defined as follows:

class Proposal(models.Model):
    scheduled_time = models.DateTimeField()
    duration = models.IntegerField() # stores minutes as an integer

    # (extra fields clipped for brevity's sake)

I want to annotate each proposal object, giving it an ‘end’ datetime calculated by scheduled_time + a timedelta representation of duration, e.g. timedelta(minutes=duration). However, F() expressions don’t seem to be valid as an argument to timedelta().

>>> from datetime import timedelta
>>> from django.db.models import F
>>> from schedule.models import Proposal
>>>
>>> proposals = Proposal.objects.all()
>>> annotated = proposals.annotate(
...     end=F('scheduled_time')+timedelta(minutes=F('duration')))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: unsupported type for timedelta minutes component: F
>>>

Is this sort of thing possible using annotate() and F() expressions?

edit: The purpose of the annotation is to be able to filter/exclude on the computed end time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:33:36+00:00Added an answer on June 9, 2026 at 3:33 am

    F()-expressions works only with django (as they return instances of specific objects). You can’t pass them to timedelta or whatever except some of the django queryset methods.

    So you’d better add new field to you model:

    class Proposal(models.Model):
        scheduled_time = models.DateTimeField()
        duration = IntegerField()
        end = models.DateTimeField(default=self.scheduled_time + timedelta(minutes=self.duration))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Proposal model and a Signature model. Proposal has many signatures and
I have a model with a integer field wich will increment on user click,
I have a Client and ProposalRequest model that look like this: class Client <
I've been asked to make dictionaries inside a class thread safe. My first proposal
public interface Proposal { public static final enum STATUS { NEW , START ,
I need to submit a college project proposal for a dbms on airline reservation
I'm trying to come up with a proposal for a client for an interface
What are the security topics that you should always include when writing a proposal
I'm currently trying to decide wether to accept a client's proposal or not. Basically,
The functionality I'm looking for: I have a form that will search my 'Proposal'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.