imagefield

Django : accessing uploaded picture from ImageField

微笑、不失礼 提交于 2021-02-20 04:38:06
问题 Hi I'm having a problem about referring to uploaded images in HTML. I'm using ImageField to save profile pictures : picture = models.ImageField(upload_to='stories/static/stories/profile_images/', blank=True) As you can see, It'll upload to <App folder>/static/stories/profile_images/ Then I refer it in HTML like this : <div class="profilepic" style="background-image: url('/{{ x.writer.picture }}');"></div> Which directs to ROOT/stories/static/stories/profile_images/.jpg Instead of ROOT/static

django.db.utils.IntegrityError: NOT NULL constraint failed: products_product.image ERROR WITH IMAGE FIELD

一笑奈何 提交于 2020-06-09 18:09:43
问题 I wanna add imagefield to my models.py and upload in my media_cdn directory but when i migrate to base my model.py he give this error django.db.utils.IntegrityError: NOT NULL constraint failed: products_product.image ERROR WITH IMAGE FIELD Output from cmd operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Users\PANDEMIC\Desktop\td10\lib\site-packages\django\db\migrations\operations\fields.py", line 84, in database_forwards field, File "C:\Users

Drupal 7: Rename files on upload (via filefield)

半腔热情 提交于 2020-01-13 14:54:10
问题 I am looking for a way to rename files that are uploaded by users through a filefield. For example, rename user profile photos using uniqid . I found a good solution for D6 at "Drupal 6: How to Change Filename on Upload" but can't find anything for D7. Another option is to use File (Field) Paths, but: The module causes warnings on my setup. Seems to be a bit of an overkill to install a general module for a very specific purpose. 回答1: You can change every file upload by hook_file_presave as

Django ImageField is not updating when update() method is used

我们两清 提交于 2019-12-31 02:56:06
问题 I am updating some of fields in model from views.py file. All other fields are updated properly when I use Profile.objects.filter(id=user_profile.id).update( bio=bio, city=city, date_of_birth=dob, profile_pic=profile_pic, gender=gender ) only, profile_pic = models.ImageField(blank=True) is not updated, Weird thing is when I check my Profile model from admins.py it shows me the file name which I uploaded, But my file is not shown in my /media directory(where I upload my all Images) views.py

Display images in Django

自作多情 提交于 2019-12-30 09:34:20
问题 I have a django app which allows users to submit an image with it. Right now my model looks like class Posting(models.Model): title = models.CharField(max_length=150) images = models.ForeignKey(Image, null=True) class Image(models.Model): img = models.ImageField(upload_to="photos/",null=True, blank=True) and I am trying to display the images in my template however I cannot seem to get it to work. I have gone though countless stack overflow posts and haven't had any luck. In my template I have

iTextSharp Fill Pdf Form Image Field

荒凉一梦 提交于 2019-12-24 09:26:57
问题 I created a pdf form with Acrobat DC 2015. I have a image field on it. I fill text field succesfully. But I don't know how to fill image field. Do you help me? private static void FillPdfForm() { // Original File const string pdfTemplate = @"pdf\form.pdf"; // New file which will be created after fillin PDF var newFile = @"pdf\FilledCV.PDF"; var pdfReader = new PdfReader(pdfTemplate); var pdfStamper = new PdfStamper(pdfReader, new FileStream( newFile, FileMode.Create)); var pdfFormFields =

Add Class to Image Field in Drupal 7

瘦欲@ 提交于 2019-12-21 06:01:01
问题 I have added an image field to content type "Basic Page" and using the "Manage Displays" option have it displayed at the top of the page. However there is no styling on the image and I can't for the life of me figure out how I add a class to the image so that I can add styles. 回答1: If you're using CCK there's almost certainly a class already associated with the image (or at least a class on a div that wraps it). CCK wraps just about everything in a class. Try right clicking the image and

Django - How can I display a photo saved in ImageField?

二次信任 提交于 2019-12-17 18:36:18
问题 I've been going around in circles for hours with this. I have a UserProfile model with profile_pic ImageField. I saved the user photo and now I want to display it, but nothing works. I went through docs, SO, google, with no result. I uploaded a photo, and I can see that the url was saved in the database. This is what I have: # models.py class UserProfile(models.Model): ... title = models.CharField() about_me = models.CharField() profile_pic = models.ImageField(upload_to=content_file_name,

Django - Display ImageField

给你一囗甜甜゛ 提交于 2019-12-17 16:33:31
问题 i just start to use django and i haven't found a lot of info on how to display an imageField, so i made this: models.py class Car(models.Model): name = models.CharField(max_length=255) price = models.DecimalField(max_digits=5, decimal_places=2) photo = models.ImageField(upload_to='site_media') views.py def image(request): carx = Car() variables = RequestContext(request,{ 'carx':carx }) return render_to_response('image.html',variables) image.html {% extends "base.html" %} {% block content %}

How to improve performance in SQL Server table with image fields?

爱⌒轻易说出口 提交于 2019-12-14 00:22:44
问题 I'm having a very particular performance problem at work! In the system we're using there's a table that holds information about the current workflow process. One of the fields holds a spreadsheet that contains metadata about the process (don't ask me why!! and NO I CAN'T CHANGE IT!!) The problem is that this spreadsheet is stored in an IMAGE field in an SQL Server 2005 (within a database set with SQL 2000 compatibility). This table currently has 22K+ lines and even a simple query like this: