JoeyStk / CV_Generator

This program stores your working and academic experience and then allows you to select certain entries and create a PDF from it
1 stars 0 forks source link

Model 'Academic Experience' required #5

Open amikable-tech opened 1 year ago

amikable-tech commented 1 year ago

Requirements

  1. Educational background starting with the most recent down to the oldest.
  2. Year when degree was achieved should also be included.
  3. Text field with major activities done should also be included.
amikable-tech commented 1 year ago

hi guys when i created the class AcademicExperience, i ran python3 manage.py makemigrations and i got this error

image

Please what do i do in this situation. or should have i run a different command instead

@JoeyStk & @to-sta

to-sta commented 1 year ago

@amikable-tech this prompt is raised because there is a database with data and migrations in the project. Like the message stats:

It is impossible to add a non-nullable field 'user' to personalinformation without specifying a default. This is because the database needs somthing to populate existing rows.

There are mulitple ways of dealing with this:

Setting the null keyword argument for the user field to True or default=None. But these are both just hotfixes. Since we have the db.sqllite3 and the __pycache__/ files in the gitignore, i will delete these files and make another commit. I will also add migrations to the .gitignore file for now @JoeyStk since we are not in production there is no need to keep migrations yet.

class PersonalInformation(models.Model):
    name = models.CharField(max_length=25, blank=False)
    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
    ...
class PersonalInformation(models.Model):
    name = models.CharField(max_length=25, blank=False)
    user = models.ForeignKey(User, on_delete=models.CASCADE, default=None)
    ...

Then it should work well 😃. You should copy your changes and then pull the latest version.

to-sta commented 1 year ago

Now there is no db.sqllite3 inside the repo as well as migration files (0001_ intial.py,...) and __pycache__. You might have to delete your db.sqllite3 before you make migrations again.