It is no longer possible in Django 1.7 to reference a model at import time.

This commit is contained in:
Mikaël Ates 2015-01-06 12:18:37 +01:00
parent 48fb14d2a9
commit d17efc19da
2 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,13 @@
from django.apps import AppConfig
class DossiersConfig(AppConfig):
name = 'calebasse.dossiers'
def ready(self):
PatientRecord = self.get_model('PatientRecord')
PatientRecord.DEFICIENCY_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('deficiency_')]
PatientRecord.MISES_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('mises_')]
default_app_config = 'calebasse.dossiers.DossiersConfig'

View File

@ -1063,6 +1063,3 @@ def create_patient(first_name, last_name, service, creator,
patient.policyholder = patient.patientcontact
patient.save()
return patient
PatientRecord.DEFICIENCY_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('deficiency_')]
PatientRecord.MISES_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('mises_')]