Skip to main content

r/django



Advertisement: 🔴 ⚪ 🔵 Score up to 70% OFF during our FOURTH OF JULY CLEARANCE 🔴 ⚪ 🔵 Save on furniture, decor, and more through July 6!
🔴 ⚪ 🔵 Score up to 70% OFF during our FOURTH OF JULY CLEARANCE 🔴 ⚪ 🔵 Save on furniture, decor, and more through July 6!
  • Thaxton Solid Wood Single Coffee Table Steelside™
  • Beaumont Oval Coffee Table with Lower Tray Shelf, White & Natural Wood Finish, Metal Frame Wade Logan®
  • Caidyn Solid Wood Single Coffee Table Loon Peak®
  • Padmore Modern Coffee Table Birch Lane™
  • Labana 51" Modern Oval Coffee Table, Sintered Stone Top, Gold legs, drawer Everly Quinn
  • Aurian Single Coffee Table Ophelia & Co.


You don't need React to be reactive — djust 1.0 brings server-driven reactivity to Django, in pure Python
You don't need React to be reactive — djust 1.0 brings server-driven reactivity to Django, in pure Python
r/django - You don't need React to be reactive — djust 1.0 brings server-driven reactivity to Django, in pure Python

UniqueConstraints
UniqueConstraints

Is there a short hand for creating UniqueConstraints to all fields in a model?

Update: A couple of people have asked why I'm trying to do this. I'm creating a website for people to use to teach a card game to people. In doing so, I want them to be able to create a room where the hands can have certain features that can be saved. There are about 10 features that they can have for each hand and they may have more the one set since there are four hands. For example, the person in first position may have 5 hearts, 1 club and 3 spades. The person in second position may have 5 spades and 4 clubs.

My plan is to have a manytomany that links to hand features. Because many of these hand features could potentially be reused multiple times I'd prefer not to have duplicates. My model is below. If the way I'm planning on doing this is wrong I'm definitely open to constructive suggestions.

class RoomModel(models.Model):
    room_name = models.CharField(default='No Room Name', unique=True)
    hand_features = models.ManyToManyField(HandFeatures, related_name='room_hand_features')


class HandFeatures(models.Model):
    applies_North=models.BooleanField(default=False)
    applies_South=models.BooleanField(default=False)
    applies_East=models.BooleanField(default=False)
    applies_West=models.BooleanField(default=False)
    alternate=models.BooleanField(default=False)
    min_HCP=models.IntegerField(default=0)
    max_HCP=models.IntegerField(default=40)
    partner_min_HCP=models.IntegerField(default=0)
    partner_max_HCP=models.IntegerField(default=40)    
    five_card_major=models.BooleanField(default=False)
    partner_with_support=models.BooleanField(default=False)