imagefield

Fetching images from URL and saving on server and/or Table (ImageField)

情到浓时终转凉″ 提交于 2019-12-13 09:13:19
问题 I'm not seeing much documentation on this. I'm trying to get an image uploaded onto server from a URL. Ideally I'd like to make things simple but I'm in two minds as to whether using an ImageField is the best way or simpler to simply store the file on the server and display it as a static file. I'm not uploading anyfiles so I need to fetch them in. Can anyone suggest any decent code examples before I try and re-invent the wheel? Given an URL say http://www.xyx.com/image.jpg, I'd like to

Django ImageField Alternatives

青春壹個敷衍的年華 提交于 2019-12-13 07:58:31
问题 I am using shared host with virtualenv to run Django Things run well, however, I can not use ImageField because gcc can not run, and I can not install Pillow. Is there any other way that can be use instead of ImageField ? Can I use FileField instead ? As I know it has problem with image dimension or something. Thank you 来源: https://stackoverflow.com/questions/30544126/django-imagefield-alternatives

Can't set ImageField url attribute

只愿长相守 提交于 2019-12-13 02:36:16
问题 I want to change my ImageField's attribute, however I'm constantly getting the Can't set attribute error. My model is class Society(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(unique=True) summary = models.TextField(blank=True,null=True) members = models.ManyToManyField(User,null=True,blank=True) gallery = models.ForeignKey(Gallery,null=True,blank=True) avatar = models.ImageField(upload_to=get_society_path) def save(self,*args,**kwargs): super(Society, self)

Django show ImageField

非 Y 不嫁゛ 提交于 2019-12-11 15:33:42
问题 I have extended the base User from Django with the OneToOne method. class Employee(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE) floor = models.CharField(max_length = 100) avatar = models.ImageField(upload_to='userimages') The image is uploaded to media/userimages. Now, when I try to show the avatar, I am trying this way, but it doesn't show anything. <img src="media/{{ user.employee.avatar.url }}" alt=""> If I just output user.employee.avatar.url, I get: 'media

How to get the first image field from a node without knowing the field's name?

ε祈祈猫儿з 提交于 2019-12-11 10:49:44
问题 The site I am working on uses many content types and almost all of them use one or more image fields. Image fields are not shared between content types, so there is a big number of them. What I need is to get the first image field from a node, assuming there are more image fields linked to a node and without knowing the name of any of these fields. The first one is considered to be the one with a lower weight . 回答1: This should build you an array of the "lightest" imagefield per content type.

Can a wagtail ImageField be restricted to by image dimension

此生再无相见时 提交于 2019-12-11 06:23:51
问题 Can I set make a Wagtail ImageField only accept images of of certain dimensions ? 回答1: Don't know if it's possible, but you can do something like this to restrict uploading images of large sizes: from wagtail.wagtailadmin.forms import WagtailAdminPageForm class BlogPageForm(WagtailAdminPageForm): def clean(self): cleaned_data = super().clean() if (cleaned_data.get('image') and somehow_check_if_img_to_large(): self.add_error('image', 'Error! image is to large!') return cleaned_data class

Django - ImageField, upload, store and serve image in development server

随声附和 提交于 2019-12-10 22:13:45
问题 I'd like to have an ImageField in the admin form for my model (say, for an individual's profile). And I'd like to display this image in a view later on. This is the model I have : class Individual(models.Model): ind_name = models.CharField(max_length=100) ind_photo = models.ImageField(default="default.jpg") def __str__(self): return self.ind_name This is what I have in the settings for my website : STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") MEDIA_URL = '/static

Drupal Imagfield/Filefield in custom form

拟墨画扇 提交于 2019-12-10 19:58:23
问题 i have created a module with this among others this function in it: <?php function ils_ladda_upp_form() { $form['upload'] = array( '#method' => 'post', '#attributes' => array( 'enctype' => 'multipart/form-data', ) ); $form['upload']['album_name'] = array( '#type' => 'textfield', '#title' => t('Albumnamn'), '#required' => 1 ); $form['upload']['album_location'] = array( '#type' => 'textfield', '#title' => t('Plats'), ); $form['upload']['album_date'] = array( '#type' => 'date', '#title' => t(

Django ImageField will not display on webpage

╄→尐↘猪︶ㄣ 提交于 2019-12-10 18:52:43
问题 I am using an imageField in my Django model and the photo is not being recognized when I try to display it in the html. Here is my models.py from django.db import models class LatestRelease(models.Model): title = models.CharField(max_length=50) description = models.CharField(max_length=300) cover = models.ImageField(upload_to='personal/static/img/') display = models.BooleanField(default=True) Here is view.py from django.shortcuts import render from personal.models import LatestRelease def

Django ImageField default

给你一囗甜甜゛ 提交于 2019-12-10 02:47:54
问题 models.py: class UserProfile(models.Model): photo = models.ImageField(upload_to = get_upload_file_name, storage = OverwriteStorage(), default = os.path.join(settings.STATIC_ROOT,'images','generic_profile_photo.jpg'), height_field = 'photo_height', width_field = 'photo_width') photo_height = models.PositiveIntegerField(blank = True, default = 0) photo_width = models.PositiveIntegerField(blank = True, default = 0) views.py: def EditProfile(request): register_generator() source_file =