These docs are a work-in-progress and are currently undergoing a major rewrite!


The standard Forge project template comes with a set of User and Team models.

Creating models

When you add your own models, you should also add your own app(s) to contain them. In our experience, it's not uncommon to have one model per app unless you have models that are very closely related (like Team and TeamMembership). So if you plan to have "projects", it usually makes sense to start an app named projects with a model named Project.

forge django startapp projects


You can use any combination of the mixins when creating your models. Technically these are "abstract" models, so you don't actually need models.Model in your class definition if you use at least one of these.

from django.db import models
from forge.models import TimestampModel, UUIDModel

class Project(TimestampModel, UUIDModel):
    name = models.CharField(max_length=255)


A TimestampModel includes two fields: created_at and updated_at.

In practice, you can use this on almost every model in your app unless you have a specific reason not to.

from django.db import models
from forge.models import TimestampModel

class Project(TimestampModel):
    name = models.CharField(max_length=255)


A UUIDModel includes a unique uuid field. This is a standard way to identify objects in URLs and APIs where you'd rather not expose the auto-incrementing id field.

In URLs, this can often be an alternative to a user-managed SlugField, which can require a lot more effort to get right (uniqueness, edits/redirects, reserved names, etc.).

Note that our implementation does not replace the primary key of a model.

from django.db import models
from forge.models import UUIDModel

class Project(UUIDModel):
    name = models.CharField(max_length=255)