spike
spike

Reputation: 73

How do fix "Installed 0 object(s) (of 4) from 1 fixture(s)"?

I am trying to install a fixture. Django finds the fixture file but does not install the file.

My model is this:

class TipoCondominio(models.Model):
    descricao = models.CharField(max_length=30)

    criado = models.DateTimeField(auto_now_add=True)
    alterado = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'tipo_condominio'

    def __str__(self):
        return self.descricao

I set in the settings.py file the path:

FIXTURE_DIRS = (
      os.path.join(BASE_DIR, "fixtures",),
)

My fixtures file is this:

[
    {
        "model" : "tipos.TipoCondominio",
        "pk" : 1, 
        "fields" : { 
            "descricao" : "Residencial"         
        }
    },
    {
        "model" : "tipos.TipoCondominio",
        "pk" : 2, 
        "fields" : { 
            "descricao" : "Comercial"        
        }
    },
    {
        "model" : "tipos.TipoCondominio",
        "pk" : 3, 
        "fields" : { 
            "descricao" : "Ambos"         
        }
    },
    {
        "model" : "tipos.TipoCondominio",
        "pk" : 4, 
        "fields" : { 
            "descricao" : "Outro"
            }
    }
]

When I run the command:

python manage.py loaddata tipo_condominio.json

I receive:

Installed 0 object(s) (of 4) from 1 fixture(s)

And... the fixtures don't install in database.

I would like the fixtures to be installed. Can anyone help?

Upvotes: 1

Views: 966

Answers (1)

spike
spike

Reputation: 73

I use the django-tenant framework and because of this, to perform the migration correctly I must use the schema I would like to perform the modifications on.

The command:

python manage.py tenant_command loaddata domain_type.json --schema = administrator

Resolved the problem.

Thanks to all for your help!

Upvotes: 2

Related Questions