[Answered ]-DataError at /freshleadaction value too long for type character varying(20)

0👍

Hey guys thanks for your efforts. Actually, I applied all those solutions before posting my problem here but suddenly I got an idea and I removed all my Charfields from my fresh_leads_model and cash_buyer_model and left their parameters empty(I mean without max_length=255). although CharField was working on my local machine but was not working on a live server. so I decided to change it from CharField to TextField without max_length limit so Heroku supported it and everything is working fine now.

1👍

I know you said you "deleted the migrations and then migrated the whole schema again," but clearly something must be left over from your original schema.

I would suggest:

  1. Delete the entire database in Heroku if you don’t care about the data: heroku pg:reset DATABASE.
  2. Push up your latest code to Heroku (including the new migrations in a new git commit): git push heroku HEAD:main.
  3. Migrate the database: heroku run python manage.py migrate.

0👍

First of all, there is no model with max_length=20 in the sources codes that you’ve provided. So you need to search for it in other models.
Pay attention:

  1. In Python you need to use CamelCase in class names, so make edits like
class cash_buyer_model(models.Model):

->

class CashBuyerModel(models.Model):
  1. Because this is a Model so you no need to use it in the class names:
class CashBuyer(models.Model):
  1. I see that you’ve mentioned that you’ve already found the needed field, you need to push updated code on Heroku
👤fanni

Leave a comment