Home > database >  I can't use the command ' python manage.py makemigrations' in django VSC
I can't use the command ' python manage.py makemigrations' in django VSC

Time:11-18

I already did 'python manage.py migrations'. Now i want to create '0001_inital.py' file in migrations with the code 'python manage.py makemigrations'. Firstly this is my models.py;

from django.db import models



class Room(models.Model):
    #host =
    #topic =
    name = models.CharField(max_Length=200)
    description = models.Textfield(null=True, blank = True)
    #participants = 
    updated = models.DateTimeField(auto_now = True)
    created = models.DateTimeField(auto_now_add = True)


    def __str__(self):
        return str(self.name)

And here is the some of the errors that when i write 'python manage.py makemigrations'.

File "", line 1006, in _find_and_load_unlocked

File "", line 688, in _load_unlocked

File "", line 883, in exec_module

File "", line 241, in _call_with_frames_removed

File "C:\Users\c.aktel\OneDrive\Masaüstü\laan\base\models.py", line 5, in class Room(models.Model): File "C:\Users\c.aktel\OneDrive\Masaüstü\laan\base\models.py", line 8, in Room name = models.CharField(max_Length=200)

File "C:\Users\c.aktel\OneDrive\Masaüstü\laan\new_env\lib\site-packages\django\db\models\fields_init_.py", line 1121, in init super().init(*args, **kwargs)

TypeError: Field.init() got an unexpected keyword argument 'max_Length'

CodePudding user response:

It should be max_length not max_Length and TextField not Textfield so the correct is:


class Room(models.Model):
    #host =
    #topic =
    name = models.CharField(max_length=200)
    description = models.TextField(null=True, blank = True)
    #participants = 
    updated = models.DateTimeField(auto_now = True)
    created = models.DateTimeField(auto_now_add = True)


    def __str__(self):
        return f"{self.name}"

Also I'd recommend you to use f-strings in __str__() method of model.

Then run both the migration commands.

  • Related