Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • allgo allgo
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 82
    • Issues 82
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Si vous êtes un personnel Inria et que vous souhaitez participer aux tests de notre future plateforme Gitlab basée sur la version ultimate avec gitlab LFS activé merci de contacter Didier Chassignol.

  • allgo
  • allgoallgo
  • Issues
  • #251
Closed
Open
Created Aug 08, 2018 by BAIRE Anthony@abaireOwner

we should systematically enforce model constraints on .save()

Django has a nasty bugfeature: while we can define many constraints to the models, django does not enforce anything automatically. All validations are to be done manually, and its very easy to miss one of them.

This issue is describe in details here: https://www.xormedia.com/django-model-validation-on-save/

In the implementation of !105 (merged), I added the checks at places that are obvious (03d50ab3 and 63034452), but there are many other places that should be checked.

I think we should apply the solution recommended in the page above: we should derive all our models from a common base class that reimplements save() to enforce these checks every time an object is created or updated.

Example:

class BaseModel(models.Model):
    def save(self, force_insert=False, force_update=False, **kw):
        if not (force_insert or force_update):
            self.full_clean()
        super().save(force_insert, force_update, **kw)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking