After moving to the latest version of Django one of the functions I
wrote fails to work.
I'll drop the code...

def year_cal(sectie, req_year = None, req_month=None):
   cur_year= str(datetime.datetime.now().year)
   cur_month= datetime.datetime.now().strftime("%b")
   all_month_list = ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul',
'aug', 'sep', 'okt', 'nov', 'dec']
   month_list = []
   if req_year is None:
      req_year = cur_year
      req_month= cur_month
   else:
      if int(req_year) > int(cur_year):
         req_year = cur_year
      if req_month is None:
         req_month = trans_month('jan')
      else:
         req_month = trans_month(req_month)

   prev_year_url = sectie.get_absolute_url() + str(int(req_year) - 1)
+ '/' + req_month
   next_year_url = sectie.get_absolute_url() + str(int(req_year) + 1)
+ '/' + req_month

   if int(req_year) == int(cur_year):
      next_year_url = False
      toggle_latest = False
      for month in all_month_list:
         if trans_month(month) == str.lower(req_month):
            current = True
         else:
            current = False
         if trans_month(month) ==  str.lower(cur_month):
            url =  sectie.get_absolute_url() + str(req_year) + '/' +
month
            toggle_latest = True
         else:
            if(toggle_latest):
               url = False
            else:
              url = sectie.get_absolute_url() + str(req_year) + '/' +
month

         month_dict = {
            'url' : url,
            'caption' : month,
            'current' : current,
         }

         month_list.append(month_dict)
   else:
      for month in all_month_list:
         url = sectie.get_absolute_url() + str(req_year) + '/' + month
         if trans_month(month) == str.lower(req_month):
            current = True
         else:
            current = False
         month_dict = {
            'url' : url,
            'caption' : month,
            'current' : current,
         }

         month_list.append(month_dict)

   return {'prev_year_url': prev_year_url, 'req_year': req_year,
'next_year_url': next_year_url, 'month_list': month_list }

register.inclusion_tag('year_cal.html')(year_cal)


The first error I get is about the line

str.lower(cur_month)

because str expects a str but gets a unicode.

Can some of you please give some simple tricks about moving from str
to unicode?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to