In Django, how can you add a column to an existing model’s database table?
- Create a new model and migrate it
- Directly modify the database schema
- Django doesn't support adding columns to existing models
- Use the "makemigrations" command
In Django, you can add a column to an existing model's database table by using the "makemigrations" command to create a migration and then applying it with "migrate." Modifying the database schema directly is not recommended.
Loading...
Related Quiz
- Which of the following loop types executes at least once, irrespective of the test condition?
- Which library would you primarily use for implementing linear regression in Python?
- What is the primary difference between the methods append() and extend() when applied to a list?
- What is the primary use of the __init__ method in a Python class?
- You've imported a module using the import keyword but later realized that you want to reload it to reflect the changes. What would be the best approach?