0

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'

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. Thank you so much. Also i will use that f-strings. Thank you also for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.