Skip to main content

Relationships

Ryx supports the three classic database relationships.

What You'll Learn

Quick Overview

class Author(Model):
name = CharField(max_length=100)

class Post(Model):
title = CharField(max_length=200)
author = ForeignKey(Author, on_delete="CASCADE") # Many-to-one

class Profile(Model):
user = OneToOneField(User) # One-to-one

class Tag(Model):
name = CharField(max_length=50)
posts = ManyToManyField(Post) # Many-to-many