def fetch(csv_file): with codecs.open(csv_file, 'r', encoding='utf-8') as csvf: for line in csvf: if not wpexists(line[:line.find(',')]): line = unicodedata.normalize('NFKD', unicode(line, 'latin1')) wp, name, tags = get_data(line) w = Wallpaper() w.file = wp w.title = name w.save() w.tags = tags w.save()
def handle_upload(request): """ Función que se encarga de manipular el wallpaper una vez en el servidor. """ post = request.POST.copy() try: wallpaper = Wallpaper() wallpaper.author = post.get('author') wallpaper.title = post.get('title') wallpaper.uploader = request.user wallpaper.save() wallpaper.tags = post.get('tags') except Exception, e: print e return None