Skip to content

Django : vers Projet et Procedure managés#1829

Draft
celine-m-s wants to merge 1 commit intomainfrom
celinems/procedure-objet
Draft

Django : vers Projet et Procedure managés#1829
celine-m-s wants to merge 1 commit intomainfrom
celinems/procedure-objet

Conversation

@celine-m-s
Copy link
Collaborator

@celine-m-s celine-m-s commented Feb 9, 2026

This is a WIP as tests are failing when core models reference users
models.
This seems to be because migrations are run before the
conftest hook but we should investigate.

For the moment, here is a good strategy for the future:

  • Run django-admin inspectdb tablename and compare the output with the
    existing model. Make sure it matches.
  • Make the model managed and run django-admin makemigrations.
  • In production environment, the migration will fail when trying to
    create alrady existing tables. Connect and run migrations as faked.
    django-admin migrate --fake app migrationumber

That way, we will smoothly manage tables and hopefully get rid of the
conftest hack.

PS: No need remove the model from the conftest as it targets only unmanaged
ones.

Notes

class Procedure:
  # ...
      # Uncomment this line when the model is ready to be managed.
    # owner = models.ForeignKey(
    #     "users.Profile",
    #     on_delete=models.SET_NULL,
    #     blank=True,
    #     null=True,
    #     related_name="procedures",
    # )

class Project:

    # Uncomment this line when the model is ready to be managed.
    # owner = models.ForeignKey(
    #     "users.Profile",
    #     db_column="owner",
    #     blank=True,
    #     null=True,
    #     on_delete=models.SET_NULL,
    #     related_name="projects",
    # )

This is a WIP as tests are failing when core models reference users
models.
This seems to be because migrations are run before the
conftest hook but we should investigate.

For the moment, here is a good strategy for the future:
- Run `django-admin inspectdb tablename` and compare the output with the
  existing model. Make sure it matches.
- Make the model managed and run `django-admin makemigrations`.
- In production environment, the migration will fail when trying to
  create alrady existing tables. Connect and run migrations as faked.
  `django-admin migrate --fake app migrationumber`

That way, we will smoothly manage tables and hopefully get rid of the
conftest hack.

PS: No need remove the model from the conftest as it targets only unmanaged
ones.
@celine-m-s celine-m-s self-assigned this Feb 9, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant