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 6326403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:05:07+00:00 2026-05-24T17:05:07+00:00

Having a such model, I want to make sure only one Photo for each

  • 0

Having a such model, I want to make sure only one Photo for each album to have a cover. This will be used as InlineModelAdmin to the Album model.

class Photo(models.Model):
    is_cover = models.BooleanField( default=False)
    album = models.ForeignKey('Album')
    image = ImageField(upload_to='uploads')

How can this be achieved ?

  • 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-05-24T17:05:08+00:00Added an answer on May 24, 2026 at 5:05 pm

    Which photo is on the cover of the album should be a property of the album, not the Photo.

    Instead of using a boolean property in your Photos, use a reference to a Photo in your Album.

    Answer to Comment: Assuming that ‘inline model’ means what I assume it to be in my comment, you will probably have to provide your own add form template. Using it, you can still provide the option boxes (instead of check boxes) and then set up the Album correctly in the code that processes the contents of the submitted form.

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

Sidebar

Related Questions

I want a table which can only have one record. My current solution is:
Hey guys I'm having such a hard time of it today. I have a
I'm having trouble getting PEX to automatically cover methods calling Linq extension methods, such
Greetings Having an ImageField object in my Foo model as such: class Foo(models.Model): name
I have a method that will provide an array of model object. Some of
I have my entities such as Customer, Order etc. defined in my Domain Model.
I have a model with an enum property (in this case, related to Export
Having such class can I instatiate it in place? abstract class Mammal { public
Is there such a thing as having the most prefered design pattern for building
I having issue that content assistant / intellisense is working in methods such as

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.