shiizuko/Django-alura-space

[pt-br] Correção do nome de classe no models.py / [en-us] Correction of class name in models.py

shiizuko opened this issue · 0 comments

[pt-br]

A classe photography no arquivo "models.py" está com o nome incorreto, pois deveria estar escrita com "P" maiúsculo para seguir as boas práticas de nomenclatura.

Isso pode causar problemas no futuro e dificultar a manutenção do código. Além disso, já foi realizada a migration e criado o banco de dados com essa classe.

Sendo assim, a correção do nome da classe para Photography é necessário.

Código atual está assim:

class photography(models.Model):
    name = models.CharField(max_length=100, null=False, blank=False)
    lengend = models.CharField(max_length=150, null=False, blank=False)
    description = models.TextField(null=False, blank=False)
    picture = models.CharField(max_length=100,null=False, blank=False)

Precisa ser atualizado para:

class Photography(models.Model):
    name = models.CharField(max_length=100, null=False, blank=False)
    lengend = models.CharField(max_length=150, null=False, blank=False)
    description = models.TextField(null=False, blank=False)
    picture = models.CharField(max_length=100,null=False, blank=False)

Com base na situação, acredito que a possível resolução seria:

  1. Alterar o nome da classe photography para Photography no arquivo models.py.
  2. Criar uma nova migration para aplicar essa alteração no banco de dados, executando o seguinte comando:
    python manage.py makemigrations
  3. Aplicar a nova migration ao banco de dados, com o comando:
    python manage.py migrate
  4. Verificar se foi alterada:
    python manage.py sqlmigrate <nome_aplicação> <nome_nova_migracao_criada>
  5. Verificar se o código foi atualizado para o nome Photography

[en-us]

The class photography in the "models.py" file has an incorrect name, as it should be written with an uppercase "P" to follow good naming conventions.

This can cause problems in the future and make the code maintenance difficult. Additionally, a migration has already been performed and the database has been created with this class.

Therefore, correcting the name of the class to Photography is necessary.

The current code is as follows:

class photography(models.Model):
    name = models.CharField(max_length=100, null=False, blank=False)
    lengend = models.CharField(max_length=150, null=False, blank=False)
    description = models.TextField(null=False, blank=False)
    picture = models.CharField(max_length=100,null=False, blank=False)

It needs to be updated to:

class Photography(models.Model):
    name = models.CharField(max_length=100, null=False, blank=False)
    lengend = models.CharField(max_length=150, null=False, blank=False)
    description = models.TextField(null=False, blank=False)
    picture = models.CharField(max_length=100,null=False, blank=False)

Based on the situation, a possible resolution would be:
Change the class name photography to Photography in the models.py file.
Create a new migration to apply this change to the database by running the following command:
python manage.py makemigrations
Apply the new migration to the database with the command:
python manage.py migrate
Verify that the migration was successful by running:
python manage.py sqlmigrate <app_name> <migration_name>
Check that the code has been updated to use the name Photography.