My model has a SlugField. When I try to save an instance of this model with the slug field set to a string which is longer than the field’s max_length parameter (which is 50 by default), I get the following error from Postgresql: value too long for type character varying(50).
Is not Django (or Postgresql) supposed to truncate the string when saving? What can I do to fix it other than truncating it manually every time?
Either install south and resize the column (best option), or create a pre_save signal and add code to truncate the field to 50 characters before it is saved. Something like: