Rails: change column type, but keep data

A standard migration using the change_column method will convert integers to strings without any data loss. rake db:rollback will also do the reverse migration without error if required. Here is the test migration I used to confirm this behaviour: class ChangeAgeToString < ActiveRecord::Migration def self.up change_column :users, :age, :string end def self.down change_column :users, :age, … Read more

How to set initial data for Django admin model add instance form?

Alasdair’s approach is nice but outdated. Radev’s approach looks quite nice and as mentioned in the comment, it strikes me that there is nothing about this in the documentation. Apart from those, since Django 1.7 there is a function get_changeform_initial_data in ModelAdmin that sets initial form values: def get_changeform_initial_data(self, request): return {‘name’: ‘custom_initial_value’}

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