Business logic should be in our life

#My Mistake

Hi Friends,

Happy to meet you all again after nice nap

Yesterday something happened to me by mistake,Actually In my task I need to move the contents of one person who blogged in our django product to his wordpress account So obviously i got a little overview then i discussed with senior person he removed some glitches in my view which was helpful to get it,then after sometime i was doing to copy the content manually to move after a couple of minutes i got scold for my stupendous action from him then i realized it eventually .Because as a developer whatever we do is ,should be in programmatic way and thinking is absolutely important,was my ever bid mistake; then atleast got the view clearly now itself and I started to do it just in django to make the victim’s all contents as a text file in django . That was my immediate work to finish it.So I had gotten his userprofile object and from that I was trying to get his all content

Up=UserProfile.objects.get(email=’XXX’)

wp=WebPage.objects.filter(userprofile=up)

for w in wp:

fin.write(‘\n’+’######PAGE TITLE:#######’+str(w.page_title)+’\n’)

fin.write(‘######PAGE CONTENT######’+’\n’)

fin.write(str(w.page_content)+’\n’)

This was my snippet to make a text file with his content i did the required procedure in python to create a text file it was not revealed here

Again i faced a problem here to move

While I am using this code to move the all contents as a text format which is shown a error “Unicode error”,because it consistes some othe wide characters apart from ascii that was the general one .and my hand was having my chin

I got solution which solved that problem = Unicode error in django it was given saltycrane(search in google)

Use smart_str() and smart_unicode()

This is the elegant way to get the format of string or unicode in django

fin.write(‘\n’+’######PAGE TITLE:#######’+smart_str(w.page_title)+’\n’)

……………………

……………………

It grabs the contents in the correct format and taught a lesson to think thoroughly !!!

Thanks for your time !!!

regards,

Navaneethan R

Advertisements

About Navaneethan

mixed feelings...
This entry was posted in Academic, General_Tech, In my life, Problems, Prob_system and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s