Re: Django Makemigration Error Can't Serialize

2020-01-09 Thread Caique Reinhold
The problem is on the on_delete=models.SET() lines.

The models.SET() option does not accept field declarations. It should be 
given a method or a queryset that must return an instance of the 
relationship model.

You can read more about how to use SET in the documentation: 
https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.SET
 


On Thursday, January 9, 2020 at 9:57:08 AM UTC-3, Wesley Montcho wrote:
>
> Hello everyone, 
> I'm a beginner in coding and i choose python,  like my favorite. 
>
>
> I am interresting myself to python frameworks, and technologies, and I'm 
> trying to have knoweldge in web develoment through django; 
>
> But, recently i have some error of migration in my django project that i 
> cannot fix; 
>
> When i try to make migrations i have this error:
>
> ValueError: Cannot serialize: 
>  0x01885B094160>
> There are some values Django cannot serialize into migration files.
> For more, see 
> https://docs.djangoproject.com/en/2.2/topics/migrations/#migration-serializing
>
>
>
> please i want some person to help me about this, i have somme challenge 
> and this error make me late; 
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c76cdcf4-a507-4b84-b3d5-2e89f544ba61%40googlegroups.com.


Django Makemigration Error Can't Serialize

2020-01-09 Thread Wesley Montcho
Hello everyone, 
I'm a beginner in coding and i choose python,  like my favorite. 


I am interresting myself to python frameworks, and technologies, and I'm 
trying to have knoweldge in web develoment through django; 

But, recently i have some error of migration in my django project that i 
cannot fix; 

When i try to make migrations i have this error:

ValueError: Cannot serialize: 

There are some values Django cannot serialize into migration files.
For more, see 
https://docs.djangoproject.com/en/2.2/topics/migrations/#migration-serializing



please i want some person to help me about this, i have somme challenge and 
this error make me late; 

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6753e5ad-a617-429e-b092-caad0924cd73%40googlegroups.com.
from django.db import models
from django.db.models.query_utils import DeferredAttribute


# Create your models here.
class Sexe(models.Model):
genre = models.CharField(max_length=10)
abreviation = models.CharField(max_length=1)

def __unicode__(self):
return self.abreviation


class Activite(models.Model):
nom_domaine = models.CharField(max_length=100)
description = models.TextField()

def __unicode__(self):
return self.nom_domaine


class Personne(models.Model):
# Informations basiques concernants l'utilisateur
nom = models.CharField(max_length=30)
prenom = models.CharField(max_length=30)
pseudo = models.CharField(max_length=10, null=True)
date_de_naissance = models.DateField()
sexe = models.OneToOneField(Sexe, on_delete=models.SET(Sexe.abreviation))

# Information supplementaires
telephone = models.CharField(max_length=20)
profession = models.CharField(max_length=30)
domaine_activite = models.ForeignKey(Activite, on_delete=models.SET(str(Activite.nom_domaine)))

# Informations de connection au compte
email = models.EmailField()
mot_de_passe = models.CharField(max_length=255)

# Details par rapport l'activté sur le compte de la personne
amis = models.ManyToManyField('self', null=True)

def __unicode__(self):
return str(self.nom) + " " + str(self.prenom)


class Message(models.Model):
destinateur = models.ForeignKey(Personne, related_name="sender",
on_delete=models.SET(str(Personne.nom)+"..."+str(Personne.prenom)), blank=True,
null=False)
destinataire = models.ForeignKey(Personne,
 on_delete=models.SET(str(Personne.nom)+"..."+str(Personne.prenom)), blank=False,
 null=False)
contenu = models.TextField()
date_envoi = models.DateField(auto_now=True)

def __unicode__(self):
if self.contenu > 20:
return str(self.destinateur) + "; " + str(self.contenu[:19]) + "..."
else:
return str(self.destinateur) + "; " + str(self.contenu)


class Publication(models.Model):
auteur = models.ForeignKey(Personne, on_delete=models.SET(str(Personne.nom)+"..."+str(Personne.prenom)))
contenu = models.TextField(null=False)
image_attache = models.ImageField(null=True)

def __unicode__(self):
if self.contenu > 20:
return str(self.destinateur) + "; " + str(self.contenu[:19]) + "..."
else:
return str(self.destinateur) + "; " + str(self.contenu)


class Profil(models.Model):
user = models.OneToOneField(Personne, on_delete=models.SET(str(Personne.nom)+"..."+str(Personne.prenom)))
photo_de_profil = models.ImageField()

def __unicode__(self):
return str(self.user.nom) + " " + str(self.user.prenom)


class ProfilImage(models.Model):
profil = models.OneToOneField(Profil, on_delete= models.CASCADE)
image = models.ImageField(upload_to='WesBox/images/')
featured = models.BooleanField(default=False)
thumbnail = models.BooleanField(default=False)
active = models.BooleanField(default=True)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)