Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Erro ao rodar makemigrations

Abaixo o erro

Applying perfis.0004_auto_20180830_0109...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 102, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 108, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 37, in database_forwards
    field,
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 176, in add_field
    self._remake_table(model, create_fields=[field])
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 74, in _remake_table
    self.effective_default(field)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/schema.py", line 187, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 1735, in get_db_prep_save
    return self.related_field.get_db_prep_save(value, connection=connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 627, in get_db_prep_save
    prepared=False)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 907, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 915, in get_prep_value
    return int(value)
TypeError: int() argument must be a string or a number, not 'datetime.datetime'

Segue o código da model Perfil

from django.db import models
from django.contrib.auth.models import User

class Perfil(models.Model):

    nome = models.CharField(max_length=255,null=False)
    telefone = models.CharField(max_length=15,null=False)
    nome_empresa = models.CharField(max_length=255,null=False)

    contatos = models.ManyToManyField('self')

    usuario = models.OneToOneField(User,related_name='perfil')

    @property
    def email(self):
        return self.usuario.email

    def convidar(self,perfil_convidado):
        Convite(solicitante=self,convidado=perfil_convidado).save()
4 respostas

Júlio, esse é seu código completo de models? Se não for, consegue mandar ele inteiro?

Só uma dica: Pra postar aqui no fórum, quando for colocar um código, clica no botão Inserir Código pra ficar bem formatadinho e mais fácil de ler! :D

Isso mesmo Yan, somente esses models. Obrigado pela dica da formatação do código

Poderia me ajudar nessa dúvida?

Na realidade não é no makemirgrations é no migrate, o makemigrations está rodando o migrate que não roda

solução!

Foi necessário apagar o migrations todo para rodar , após excluir todos arquivos da pasta migrations rodou normalmente