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

  • Home
  • SEARCH
  • 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 8432735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:12:31+00:00 2026-06-10T06:12:31+00:00

I was building a django model that has two fields, only one of them

  • 0

I was building a django model that has two fields, only one of them is required.

class course_data(models.Model):
    link = models.CharField(max_length = 500, null = True, blank = True)
    uploaded_file = models.FileField(upload_to='course_files', null = True, blank = True)
    name = models.CharField(max_length = 200, null = True, blank = True)
    description = models.TextField(null = True, blank = True)    
    applies_to = models.ManyToManyField('course') 

I want the entry to be valid only if the “link” field is provided or if the ‘uploaded_file’ field is provided or both. I can’t make both parameters optional since they can be both left blank. Any suggestions?

  • 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-10T06:12:32+00:00Added an answer on June 10, 2026 at 6:12 am

    You can use a ModelForm and override its clean method to get the behaviour you want. If you want to use the admin, you can add the custom behaviour with a ModelAdmin

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a small web project using Django that has one model ( Image
I'm building a django app that has an image gallery, and the client insists
I'm building a blog, with models Post and Image like so: class Post(models.Model): title
I'm building a site in django that interfaces with a large program written in
I'm building a site with django that lets users move content around between a
Help! I have two objects that i have created using different techniques in django;
I am building a django app that requires some currency entries. I am trying
Currently I have three models in Django that create a circular reference: A User
My Django model has a field within which I want to have reference logic.
I'm building an application in Django that needs to integrate advertising into the site.

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.