Hello Folks I saw than for a better use and readability it's better to put the same logic in a class or a function. I just realised that I putted the choices variable for my fields having multiple choices in the same class model (see below)
class Project(models.Model):
PERSONAL = "PERS"
PROFESSIONAL = "PRO"
FORMATION = "FORM"
TYPE_OF_PROJECT_CHOICES = {
"PERSONAL": "Personel",
"PROFESSIONAL": "Professionel",
"FORMATION": "Formation",
}
title = models.CharField(max_length=100)
short_text = models.TextField(default="")
text = models.TextField(default="")
link = models.TextField(default="")
client = models.TextField(default="")
github_link = models.TextField(default="")
image = models.ImageField(upload_to = "projects")
type = models.CharField(choices =TYPE_OF_PROJECT_CHOICES, default= PERSONAL, max_length=100)
date = models.DateField("date published")
def __str__ (self):
return self.title```
I asked Gemini about it and it was telling me that I am wrong. The class here contain to logics. (the choices + the model's field part).
Gemini proposed me to create an other file "choices.py" or if it's more general to put these variables in the "util.py" and import it to my model.py.
Can I trust Gemini ? What is the more commonly done about it by convention ?