当前位置: 首页>>代码示例>>Python>>正文


Python Photo.image方法代码示例

本文整理汇总了Python中photologue.models.Photo.image方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.image方法的具体用法?Python Photo.image怎么用?Python Photo.image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在photologue.models.Photo的用法示例。


在下文中一共展示了Photo.image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_uploaded_file

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def handle_uploaded_file(f,title):
    """ """
    photo = Photo()
    photo.title = u'%s %s' % (time_slug_string(), title) 
    photo.slug = time_slug_string()
    photo.image = f
    photo.save()
    return photo    
开发者ID:codesyntax,项目名称:cssocialprofile,代码行数:10,代码来源:load_images.py

示例2: handle_uploaded_file

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def handle_uploaded_file(f, author):
    photo = Photo()
    extra = PhotoExtended()
    photo.title = u"%s %s" % (author, time_slug_string())
    photo.slug = u"%s-%s" % (author, slugify(time_slug_string()))
    photo.image = f
    photo.save()
    extra.photo = photo
    extra.author = author
    extra.save()
    return photo
开发者ID:codesyntax,项目名称:bitakora,代码行数:13,代码来源:images.py

示例3: uploadimagejson

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def uploadimagejson(request):
  p = Photo()
  if request.user.is_authenticated():
    if request.method == 'POST':
      pt = codegenerator()+codegenerator()
      p.image = request.FILES['file']
      p.title = pt
      p.title_slug = slugify(pt) #+codegenerator()
      p.save()
#  template = loader.get_template('redactorimageupload.html')
    params = { 'photo' : p }
#  context = RequestContext(request, params)  
  return render_to_response('redactorimageupload.html',params,context_instance = RequestContext(request))
开发者ID:emakarov,项目名称:blog-wl-school,代码行数:15,代码来源:views.py

示例4: import_folder

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import image [as 别名]
def import_folder(request=None, gallery_name=None):
    count = 0
    current_site = Site.objects.get(id=settings.SITE_ID)
    if gallery_name:
        gallery = Gallery.objects.filter(slug=gallery_name)
        if not gallery:
            gallery = Gallery(title=gallery_name, slug=gallery_name)
            gallery.save()
    else:
        gallery = Gallery.objects.first()
        if not gallery:
            gallery = Gallery(title="MyFirstGallery", slug='MyFirstGallery')
            gallery.save()

    for filename in os.listdir(IMPORT_FOLDER):
        if not os.path.isfile(filename):
            if filename[-3:] in image_extensions:
                logger.debug('Reading file "{0}").'.format(filename))

                full_name = os.path.join(IMPORT_FOLDER, filename)

                if Photo.objects.filter(title=filename).exists():
                    logger.debug('file already exist in system: "{0}").'.format(filename))
                    dst_name = os.path.join(IMPORT_CONFLICT_FOLDER, filename)
                    shutil.move(full_name, dst_name)
                else:
                    storage_path = models.get_storage_path(None, filename)
                    dst_name = os.path.join(settings.MEDIA_ROOT, storage_path)
                    shutil.move(full_name, dst_name)

                    photo = Photo(title=filename,
                                  slug=slugify(filename),
                                  caption=filename,
                                  is_public=True)
                    photo.image = storage_path
                    photo.save()
                    photo.sites.add(current_site)
                    gallery.photos.add(photo)
                    count += 1

    if request:
        messages.success(request,
                         _('{0} photos have been added to gallery "{1}".').format(
                             count,
                             gallery.title),
                         fail_silently=True)
开发者ID:chenyi1976,项目名称:django-photologue,代码行数:48,代码来源:import_folder.py


注:本文中的photologue.models.Photo.image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。