Hi, I have following model described:
class UserProfile(models.Model):
avatar = models.ImageField(blank = True, upload_to='files')
about = models.TextField(blank=True)
rank = models.IntegerField(default = 1)
solvedProblems = models.ManyToManyField(Composition, blank=True)
user = models.ForeignKey(User, unique=True)
country = CountryField(blank = True)
status = models.ForeignKey(UserRank)
where UserRank is:
class UserRank(models.Model):
rankName = models.CharField(max_length = 300)
upLimit = models.IntegerField()
downLimit = models.IntegerField()
I have added the status, country and avatar field later after describing model, so updated the database via sql.
Now database looks this way:
chess_problems=# \d registration_userprofile;
Table "public.registration_userprofile"
Column | Type | Modifiers
-----------+------------------------+-----------------------------------------------------------------------
id | integer | not null default nextval('registration_userprofile_id_seq'::regclass)
about | text | not null
rank | integer | not null
user_id | integer | not null
avatar | character varying(100) |
country | character varying(2) |
status_id | integer |
Indexes:
"registration_userprofile_pkey" PRIMARY KEY, btree (id)
"registration_userprofile_user_id_key" UNIQUE, btree (user_id)
Foreign-key constraints:
"registration_userprofile_status_id_fkey" FOREIGN KEY (status_id) REFERENCES registration_userrank(id) DEFERRABLE INITIALLY DEFERRED
"registration_userprofile_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
The error code I see is:
(, DataError('value too long for type character varying(2)\n',), )
Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/core/servers/basehttp.py", line 280, in run self.finish_response() File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/core/servers/basehttp.py", line 320, in finish_response self.write(data) File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/core/servers/basehttp.py", line 416, in write self._write(data) File "/usr/lib/python2.5/socket.py", line 274, in write self.flush() File "/usr/lib/python2.5/socket.py", line 261, in flush self._sock.sendall(buffer) error: (32, 'Broken pipe')
I feel it happens because I incorrectly updated database to fit the model...But not sure what is wrong, and how to fix it. Same code works locally on mysql instance...But I have psql on prod....