I was migrating data from SQLite to Postgresql. After dumped data from SQLite to XML file, I change database engine to Postgresql, then I tried to load data using 'python manage.py loaddata' command, but it raise 'too long value' error. I didn't capture the actual error message...
To made it quick, I don't want to do any code change ( add max_length validation to the form ) at that time. So I would go with a workaround script that just help me to skip one that exceed limit or cut off the string because it's not very important.
Serialization seemed to be a way to go as I can load instance of a model from XML file, edit then save to Postgresql.
As it said that max_length is 240 characters, I can see that only 'short_description' field has limit at that length. So I'll just focus on 'short_description' field.
from django.core import serializersfix_max_length.py (625 bytes) , listing3.xml (3.9 KB)
def load():
listing3 = open( 'sqlite_data/listing.xml')
listing3_data = listing3.read()
des= serializers.deserialize( "xml", listing3_data )
for each_des in des:
print each_des
#check if an object has attribute name 'short_description'
if getattr( each_dess.object , 'short_description' , ''):
if len( each_des.object.short_description) > 240:
#Cut off text if it exceeds limit
each_des.object.short_description =
each_des.object.short_description[:240]
each_des.save()
You can run the function by go to working directory. Bring up a Django shell.
python manage.py shell
Then load the function we created.
from fix_max_length import load
load()

The site was informative and contain useful content for the visitors. It got good posts as well. I will bookmark this site for future viewing. Thanks for sharing.
This is my first visit to your site and I'm glad I was been able to stumble upon your webpage. I'll bookmark this page from now on.
Now i'm impressed. You happen to be really well informed and intensely clever. An individual wrote something which folks might realize generating the subject exciting for anyone. I'm conserving this particular regarding future use.
Whenever we think well, we're receiving, that whatever you provide is a thing we need to know in regards to the graduate university.
A reputed SEO Company India, Profit By Search is a group of young and dynamic individuals with immense passion for technology and innovations. We ensure our clients the best tailor made SEO techniques for their businesses to cope up with the rapidly changing world of Internet and economy.
I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.
Just want to say your article is striking. The clearness in your post is simply spectacular and i can take for granted you are an expert on this field. Well with your permission allow me to grab your rss feed to keep up to date with forthcoming post. Thanks a million and please keep up the effective work.
I\'m happy I found this blog, I couldn't discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!
The truth that your blog post admittance here only uncovered many of the best fresh understanding and internet based cultural trends at once. How firkin' awesome is the fact that!
I found very useful and interesting posts in this blog which is the great signs for a good blogger.
Interesting article!
Adore and am accustomed to preserving a range with those people transformed things.Only on this way can i am aware what will not be abandoned by time. Forexample, even although you adore someone, lkljljl1i9tyytyu modifications are all around. Then I stepbackward and viewing it silently, then I see the correct feelings.