Problem importing model

0

Hello, I can not do import of this model

I have the model:

class Contrato(models.Model):

within models.py

and inside my serializers.py need to do import

from models import Contrato

nor

from apps.contratos.models import Contrato

Nothing works, other apps run smoothly.

    
asked by anonymous 04.05.2015 / 04:57

3 answers

0

There was an import loop occurring, they were importing each other. Solved, I just removed the import from one of the files and it worked.

    
15.07.2015 / 21:08
0

If your serializer file is in the same module as your model, one way to import would be: from .models import Contrato

    
08.06.2015 / 18:20
0

The question text could be a bit more complete and provide% error%. However, without knowing the structure of the project, the problem may be that the directory where both files are located does not contain the file traceback ( see why ).

If this file is present, the following line should be suffi- cient to import successfully:

from .models import Contrato
    
20.06.2015 / 23:28