class Team(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() events: fields.ManyToManyRelation[Event] minrelation_through: fields.ManyToManyRelation["MinRelation"] alias = fields.IntegerField(null=True) def __str__(self): return self.name
class Event(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() tournament_id = fields.IntegerField() # Here we make link to events.Team, not models.Team participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField( "events.Team", related_name="events", through="event_team") def __str__(self): return self.name class Meta: app_label = "events"
class CommentModel(Model): class Meta: db_table = "comments" table_description = "Test Table comment" id = fields.IntegerField( primary_key=True, description="Primary key \r*/'`/*\n field for the comments") message = fields.TextField( description="Comment messages entered in the blog post") rating = fields.IntegerField(description="Upvotes done on the comment") escaped_comment_field = fields.TextField( description="This column acts as it's own comment") multiline_comment = fields.TextField(description="Some \n comment") commented_by = fields.TextField()
class VenueInformation(Model): name = fields.CharField(max_length=128) capacity = fields.IntegerField() rent = fields.FloatField() team = fields.OneToOneField("models.Team", on_delete=fields.SET_NULL, null=True)
class BadTournament(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() created = fields.DateTimeField(auto_now_add=True, db_index=True) def __str__(self): return self.name
class Product(models.Model): class Meta: db_table = "store_product" ordering = [ 'id', ] id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=255) price = fields.CharField(max_length=16) images = fields.ManyToManyField( Image, through='ProductImage', ) categories = fields.ManyToManyField(Category, through='ProductCategory', related_name='products') brand = fields.ForeignKey(Brand, on_delete=fields.CASCADE, null=True, default=None, related_name='products') vendor = fields.ForeignKey(Vendor, on_delete=fields.CASCADE, null=True, default=None, related_name='products') def __str__(self): return self.name
class UniqueTogetherFields(Model): id = fields.IntegerField(primary_key=True) first_name = fields.CharField(max_length=64) last_name = fields.CharField(max_length=64) class Meta: unique_together = ("first_name", "last_name")
class Team(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() events: fields.ManyToManyRelation[Event] def __str__(self): return self.name
class UniqueTogetherFieldsWithFK(Model): id = fields.IntegerField(primary_key=True) text = fields.CharField(max_length=64) tournament: fields.ForeignKeyRelation[Tournament] = fields.ForeignKey( "models.Tournament") class Meta: unique_together = ("text", "tournament")
class Tournament(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() events: fields.ReverseRelation["Event"] def __str__(self): return self.name
class Tournament(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() def __str__(self): return self.name class Meta: app_label = "tournaments"
class Image(models.Model): class Meta: db_table = "store_image" ordering = [ 'id', ] id = fields.IntegerField(primary_key=True) src = fields.CharField(max_length=255)
class Event(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() class Meta: db_table = "event" def __str__(self): return self.name
class Event(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() tournament: fields.ForeignKeyRelation[Tournament] = fields.ForeignKey( "models.Tournament", related_name="events") participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField( "models.Team", related_name="events", through="event_team") def __str__(self): return self.name
class TeamTwo(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() eventtwo_through: fields.ManyToManyRelation[EventTwo] class Meta: app_label = "events" def __str__(self): return self.name
class Reporter(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField() events: fields.ReverseRelation["Event"] class Meta: db_table = "re_port_er" def __str__(self): return self.name
class DecimalFields(Model): class Meta: ordering = [ 'id', ] id = fields.IntegerField(primary_key=True) decimal = fields.DecimalField(max_digits=18, decimal_places=4) decimal_nodec = fields.DecimalField(max_digits=18, decimal_places=0) decimal_null = fields.DecimalField(max_digits=18, decimal_places=4, null=True)
class Tournament(Model): id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=255, description="Tournament name", db_index=True) created = fields.DateTimeField(auto_now_add=True, description="Created datetime") events: fields.ReverseRelation["Event"] class Meta: table_description = "What Tournaments we have"
class Category(models.Model): class Meta: db_table = "store_category" ordering = [ 'id', ] id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=255) image = fields.ForeignKey(Image, on_delete=fields.CASCADE, null=True) def __str__(self): return self.name
class Event(Model): id = fields.IntegerField(primary_key=True) name = fields.TextField( description="Name of the event that corresponds to an action") datetime = fields.DateTimeField( null=True, description="Datetime of when the event was generated") class Meta: db_table = "event" table_description = "This table contains a list of all the example events" def __str__(self): return self.name
class Team(Model): name = fields.CharField(max_length=50, primary_key=True, description="The TEAM name (and PK)") key = fields.IntegerField() manager = fields.ForeignKey("models.Team", related_name="team_members", null=True) talks_to = fields.ManyToManyField("models.Team", related_name="gets_talked_to") class Meta: table_description = "The TEAMS!" indexes = [("manager", "key"), ["manager_id", "name"]]
class Event(Model): id = fields.BigIntegerField(primary_key=True) name = fields.TextField() tournament: fields.ForeignKeyRelation["Tournament"] = fields.ForeignKey( "models.Tournament", related_name="events") reporter: fields.ForeignKeyNullableRelation[Reporter] = fields.ForeignKey( "models.Reporter", null=True) participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField( "models.Team", related_name="events", through="event_team", backward_key="idEvent") modified = fields.DateTimeField(auto_now=True) token = fields.TextField(default=generate_token) alias = fields.IntegerField(null=True) def __str__(self): return self.name
class Event(Model): id = fields.IntegerField(primary_key=True, description="Event ID") name = fields.CharField(max_length=255, unique=True) tournament: fields.ForeignKeyRelation[Tournament] = fields.ForeignKey( "models.Tournament", related_name="events", description="FK to tournament") participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField( "models.Team", related_name="events", through="event_team", description="How participants relate", ) modified = fields.DateTimeField(auto_now=True) prize = fields.DecimalField(max_digits=10, decimal_places=2, null=True) token = fields.CharField(max_length=100, description="Unique token", unique=True) class Meta: table_description = "This table contains a list of all the events"
class SourceFields(Model): id = fields.IntegerField(primary_key=True, db_column="sometable_id") chars = fields.CharField(max_length=255, db_column="some_chars_table", db_index=True) fk = fields.ForeignKey("models.SourceFields", related_name="team_members", null=True, db_column="fk_sometable") rel_to = fields.ManyToManyField( "models.SourceFields", related_name="rel_from", through="sometable_self", forward_key="sts_forward", backward_key="backward_sts", ) class Meta: db_table = "sometable" indexes = [["chars"]]
class SourceFields(Model): eyedee = fields.IntegerField(primary_key=True, db_column="sometable_id", description="Da PK") chars = fields.CharField( max_length=50, db_column="some_chars_table", db_index=True, description="Some chars" ) blip = fields.CharField(max_length=50, default="BLIP", db_column="da_blip") fk: fields.ForeignKeyNullableRelation["SourceFields"] = fields.ForeignKey( "models.SourceFields", related_name="fkrev", null=True, db_column="fk_sometable", description="Tree!", ) fkrev: fields.ReverseRelation["SourceFields"] o2o: fields.OneToOneNullableRelation["SourceFields"] = fields.OneToOneField( "models.SourceFields", related_name="o2o_rev", null=True, db_column="o2o_sometable", description="Line", ) o2o_rev: fields.Field rel_to: fields.ManyToManyRelation["SourceFields"] = fields.ManyToManyField( "models.SourceFields", related_name="rel_from", through="sometable_self", forward_key="sts_forward", backward_key="backward_sts", description="M2M to myself", ) rel_from: fields.ManyToManyRelation["SourceFields"] class Meta: db_table = "sometable" unique_together = [["chars", "blip"]] table_description = "Source mapped fields"
class StraightFields(Model): eyedee = fields.IntegerField(primary_key=True, description="Da PK") chars = fields.CharField(max_length=50, db_index=True, description="Some chars") blip = fields.CharField(max_length=50, default="BLIP") fk: fields.ForeignKeyNullableRelation["StraightFields"] = fields.ForeignKey( "models.StraightFields", related_name="fkrev", null=True, description="Tree!" ) fkrev: fields.ReverseRelation["StraightFields"] o2o: fields.OneToOneNullableRelation["StraightFields"] = fields.OneToOneField( "models.StraightFields", related_name="o2o_rev", null=True, description="Line" ) o2o_rev: fields.Field rel_to: fields.ManyToManyRelation["StraightFields"] = fields.ManyToManyField( "models.StraightFields", related_name="rel_from", description="M2M to myself" ) rel_from: fields.ManyToManyRelation["StraightFields"] class Meta: unique_together = [["chars", "blip"]] table_description = "Straight auto-mapped fields"
class Choice(models.Model): question = fields.ForeignKey('models.Question', ) choice_text = fields.CharField(max_length=200) votes = fields.IntegerField(default=0)
class Vendor(models.Model): id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=64)
class Users(models.Model): id = fields.IntegerField(primary_key=True) username = fields.CharField(max_length=20) def __str__(self) -> str: return f"User {self.id}: {self.username}"
class Team(Model): id = fields.IntegerField(primary_key=True)