django dump previous migrations 1

django dump previous migrations

python manage.py makemigrations your_app
python manage.py migrate your_app

Here is what the above code is Doing:
1. It’s creating a new model called Post.
2. It’s defining a field called title, which is a CharField.
3. It’s defining a field called text, which is a TextField.
4. It’s defining a field called created_date, which is a DateTimeField.
5. It’s defining a field called published_date, which is a DateTimeField.
6. It’s defining a method called publish, which will tell Django when the post was published.
7. It’s defining a method called __str__, which is the Python way of overriding what a class displays when you call print(obj).

Similar Posts