migrating django-model field-name change without losing data

Changing the field name while keeping the DB field Adding an answer for Django 1.8+ (with Django-native migrations, rather than South). Make a migration that first adds a db_column property, and then renames the field. Django understands that the first is a no-op (because it changes the db_column to stay the same), and that the … Read more

How to show all fields of model in admin page?

If you want to include all fields without typing all fieldnames, you can use list_display = BookAdmin._meta.get_all_field_names() The drawback is, the fields are in sorted order. Edit: This method has been deprecated in Django 1.10 See Migrating from old API for reference. Following should work instead for Django >= 1.9 for most cases – list_display … Read more

Does Django automatically generate indexes for foreign keys columns?

Django automatically creates an index for all models.ForeignKey columns. From Django documentation: A database index is automatically created on the ForeignKey. You can disable this by setting db_index to False. You may want to avoid the overhead of an index if you are creating a foreign key for consistency rather than joins, or if you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)