pythonpython-3.xdjangodjango-models

Trying to fix a Django error calling a Module that doesn't exist for an SQLite Database


I'm designing a website using Django and SQLite, using Models to parse information between the database and the front-end. I'm encountering errors that are limiting my developmental process, as I'll explain below. For reference, here's the code that I'm using with my Models:


# Internal = 0, Derived = 1.

class Grade(models.Model):
    name = models.CharField(max_length=100, default="null")
    # classPage = models.ManyToManyField(classPage, related_name="_set")
    amegrade = models.CharField(max_length=10, default="null")
    description = models.CharField(max_length=500, default="null")
    type = models.BooleanField(default=1)

class Student(models.Model):
    studentName = models.CharField(max_length=50, default="null")
    age = models.CharField(default="13", max_length=3)
    house = models.CharField(max_length=10, default="null")
    bday = models.CharField(default="null", max_length=50)

class classPage(models.Model):
    teacher = models.CharField(max_length=50, default="null")
    # classStudents = models.ManyToManyField(Student, related_name="_set")

class timetableItem(models.Model):
    name = models.CharField(max_length=50, default="null")
    timeStart = models.CharField(max_length=50, default="null")
    timeEnd = models.CharField(max_length=50, default="null")
    

class dailyTimetable(models.Model):
    timetableItems = models.ManyToManyField(to=timetableItem)

class weeklyTimetable(models.Model):
    monday = models.OneToOneField(to=dailyTimetable, on_delete=models.CASCADE)

class sideViewButton(models.Model):
    name = models.CharField(max_length=100, default="null")
    directory = models.URLField(max_length=100, default="null")

class Notice(models.Model):
    title = models.CharField(max_length=50, default="null")
    description = models.CharField(max_length=10000, default="null")

I'm using Models in my Database to store information. That works all well and dandy, but I'm trying to migrate new changes to the project using python3 manage.py migrate, and I'm getting thrown an error that "TypeError: fromisoformat: argument must be str". I use Google Bard to help diagnose the issues and the over 100 lines (thereabouts) of error messages, and it says that one of my models is using a DateTime system incorrectly. It says: "The error message is telling you that the fromisoformat() method expects a string as its argument, but you are passing it a datetime.date object." This confuses me because I've tried to solve the error by replacing the DateFields with CharFields, but my project is still saying that I'm trying to use a Model that doesn't exist. Hopefully that makes sense?

Many thanks.


Solution

  • if you are using practice project then

    you should first try

    python manage.py migrate app_name zero

    and delete the migration file

    and then run makemigrations and migrate again it should work because i tried these model in my system and worked fine for me