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


Python Images.save方法代码示例

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


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

示例1: gallery

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import save [as 别名]
def gallery(request,imagename=None):
	print imagename
	if request.method == 'POST':
		title = request.POST['pname']
		img_data = request.POST['pdata']
		p = Images(title = title, img_data = img_data)
		p.save()
	if 	request.method == 'GET':
		image = Images.objects.filter(title = imagename)
		for i in image:
			data = i.img_data
		print json.dumps(data)
		t = get_template('paint.html')
		html = t.render(Context({}))
		if data:
			html="""<script>var data=JSON.parse(' """+data+""" ');</script>"""+html		
		else:
			html="""<script>alert("Image not found")</script>"""+html
		return HttpResponse(html)
开发者ID:josejibin,项目名称:Paint-App-Using-Django,代码行数:21,代码来源:views.py

示例2: add_image

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import save [as 别名]
def add_image(request):
    form = ImageForm()
    if request.POST:
        form = ImageForm(request.POST, request.FILES)
        if form.is_valid():
            image = request.FILES['image_file']
            comment = form.cleaned_data['comment']
            format = image.name.split('.')[-1]
            p = Images(comment = comment, name = '',
            useragent = request.META['HTTP_USER_AGENT'],
            ip = request.META['REMOTE_ADDR'], views = 0 ,views_last_hour = 0,
            md5 = 0, format = format)
            p.save()
            save_image(image, p.id)
            return HttpResponseRedirect('/%s' % to_62(p.id))
        else:
            form = ImageForm()
            return render_to_response("forms/add_image.html", {'form': form})
    else:
        return render_to_response("forms/add_image.html", {'form': form})
开发者ID:denplis,项目名称:Picco,代码行数:22,代码来源:views.py

示例3: add_image

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import save [as 别名]
def add_image(request):
    #last_image_id = Images.objects.order_by('-id')[0].id else last_image_id = 0
    form = ImageForm()
    if request.POST:
        form = ImageForm(request.POST, request.FILES)
        if form.is_valid():
            image = request.FILES['image_file']
            
            save_image(image)
            
            #thumb_image = thumbnail(image)
            #save_image(thumb_image)
            p = Images(comment=request.POST['comment'], name = file.name,
            useragent=request.META['HTTP_USER_AGENT'],
            ip=request.META['REMOTE_ADDR'], views=0, md5=0 )
            p.save()
            return HttpResponse(image.name)
            #return render_to_response("forms/add_image.html", {'form': form})
        else:
            return render_to_response("forms/add_image.html", {'form': form})
    else:
        return render_to_response("forms/add_image.html", {'form': form})
开发者ID:denplis,项目名称:Picco,代码行数:24,代码来源:views.py

示例4: xmlparse

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import save [as 别名]
def xmlparse():
    #pagecode = urllib.urlopen("http://www.esmadrid.com/opendata/alojamientos_v1_es.xml")
    pagecode = urllib.urlopen("http://cursosweb.github.io/etc/alojamientos_es.xml")
    xmlsheet = pagecode.read()
    noticias=xmlsheet.split("<service ")
    for noticia in noticias[1:-1]:
        url = noticia.split("<web>")[1].split("</web>")[0]
        try:
            alojamiento = Alojamientos.objects.get(url=url)
        except Alojamientos.DoesNotExist:
            name = noticia.split("<name><![CDATA[")[1].split("]]></name>")[0]
            address = noticia.split("<address>")[1].split("</address>")[0]
            zipcode = noticia.split("<zipcode>")[1].split("</zipcode>")[0]
            country = noticia.split("<country>")[1].split("</country>")[0]
            latitude = noticia.split("<latitude>")[1].split("</latitude>")[0]
            longitude = noticia.split("<longitude>")[1].split("</longitude>")[0]
            city = noticia.split("<subAdministrativeArea>")[1].split("</subAdministrativeArea>")[0]
            alojamiento = Alojamientos(name=name, url=url, address=address, zipcode=zipcode, country=country, latitude=latitude, longitude=longitude, city=city)
            alojamiento.save()
            images = noticia.split('<url>')
            for image in images[1:6]:
                image_url = image.split('</url>')[0]
                image = Images(url=image_url, alojamiento=alojamiento)
                image.save()
开发者ID:rodrigobersan,项目名称:X-Serv-Practica-Hoteles,代码行数:26,代码来源:views.py


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