Issue I’ve got a field in one model like: class Sample(models.Model): date = fields.DateField(auto_now=False) Now, I need to filter the objects by a date range. How do I filter all the objects that have a date between 1-Jan-2011 and 31-Jan-2011?
Continue readingTag: django
Prevent Django Pipeline from post processing certain files
Issue I’m currently implementing Django Pipeline to minify my CSS/JS but I would like to stop it appending unique identifiers to certain files. This is because I am using django-tinymce and certain popups fail due to Django Pipeline. I get
Continue readingOSError: [Errno 32] Broken pipe with Django-pipeline
Issue I have recently installed django-pipeline on CentOS 5.7. I have yuglify installed at /usr/local/bin/yuglify and have changed PIPELINE_YUGLIFY_BINARY to point there. However whenever I run collectstatic I get the following: OSError: [Errno 32] Broken pipe Any help will be
Continue readingIs there any way to load, minimize and combine different javascript files for different templates in Django?
Issue Now, I put some common javascript files in PIPELINE_JS settings. But I also want to load more specific js files based on each individual template. I know I can simply add a script tag to include corresponding js files
Continue readingUsing Django Pipeline, why am I running into JS errors?
Issue I’ve configured Django Pipeline (verison 1.3.15) for a single group of JS files. I’ve configured them in the same order that they appear in my page normally. Everything works fine with collectstatic, etc. When I view the source, everything
Continue readingWhy does django-pipeline's {% compressed_js … %} tag output each script separately?
Issue I’ve configured pipeline as follows: STATICFILES_FINDERS = ( ‘django.contrib.staticfiles.finders.FileSystemFinder’, ‘django.contrib.staticfiles.finders.AppDirectoriesFinder’, ‘pipeline.finders.PipelineFinder’, ) # Static files storage STATICFILES_STORAGE = ‘pipeline.storage.PipelineStorage’ # Pipeline JS compressor PIPELINE_JS_COMPRESSOR = ‘pipeline.compressors.jsmin.JSMinCompressor’ PIPELINE_JS = { ‘website-main’: { ‘source_filenames’: ( ‘shared/jquery/jquery-1.10.2.min.js’, ‘shared/bootstrap/js/bootstrap.min.js’, ‘shared/jquery/jquery.cookie.js’, ), ‘output_filename’: ‘pipeline-compressed/website-main.js’,
Continue readingDjango pipeline generates empty files
Issue I’ve got several apps in my django project and I’m using pipeline to compress files and all works fine, but I have an app called “mypage” for which every file generated after calling collectstatic is empty! (if I copy
Continue readingdjango pipeline breaks admin when DEBUG=False
Issue here is the settings for css PIPELINE_CSS = { ‘base’: { ‘source_filenames’: ( ‘scss/core.scss’, ), ‘output_filename’: ‘css/min.css’, }, ‘ie8’: { ‘source_filenames’: ( ‘css/ie-8-overrides.css’, ), ‘output_filename’: ‘css/ie8.css’, }, } Somehow it complains about: ValueError: The file ‘admin/css/base.css’ could not be
Continue readingDjango-pipeline producing empty files
Issue Right now, when running python manage.py collectstatic produces a minified file but it is completely empty. Here are my settings.py (I am on a windows environment): STATICFILES_STORAGE = ‘pipeline.storage.PipelineStorage’ PIPELINE_ENABLED = True PIPELINE_DISABLE_WRAPPER = True PIPELINE_CSS_COMPRESSOR = ‘pipeline.compressors.yui.YUICompressor’ PIPELINE_JS_COMPRESSOR
Continue readingIs there a way to prevent django-pipeline from creating new jsx files every time it compiles react.js code?
Issue I currently have the PyReact JSX compiler installed using django-pipeline. Whenever I run collectstatic on my files, rather than overwriting a prior version of my react .jsx and compiled .js files, it creates a new version in the same
Continue readingHow can I use django-pipeline for JSX with browserify?
Issue I am setting up the asset pipeline for a new project. We already use React.js along with webpack in a gulp-based build system and would like to use React for the new project as well. Now, since the application
Continue readingStrange Issue When Minifying CSS via django-pipeline
Issue I’m using django-pipeline to minify my CSS. Everything minifies correctly until I use PipelineCachedStorage so I can get the versioned, cache-busting filenames. I get the following error: ValueError: The file ‘img/glyphicons-halflings.png’ could not be found with <pipeline.storage.PipelineCachedStorage object at
Continue readingDjango Pipeline node cannot find lessc
Issue I’m configuring Django Pipeline, which I have done before on Linux without issues. On OSX I get the following issue when using Less: CompilerError: env: node: No such file or directory The message comes from the stderr of the
Continue readingx-amz-acl being set incorrectly when using collectstatic with latest version of Boto, Pipeline, and Storages
Issue I’m in the process of bringing my app’s dependencies up-to-date. I made the following changes to requirements.txt: boto: upgraded to 2.34.0 django-pipeline: upgraded to 1.4.2 django-require: upgraded to 1.0.6 django-storages: was on latest (1.1.8) Now when I try to
Continue readingDjango-pipeline 'compressed' is not a valid tag library: ImportError raised loading pipeline.templatetags.compressed: No module named conf
Issue I’m getting this error and I have no clue why suddenly I’m having issue with django-pipeline. I’m running the project under a virtualenv and I’ve tried to create a new one with the basic app required to see if
Continue readingcollectfiles failes for pipeline / yUglify: The system cannot find the path specified
Issue I’ve been trying to get django-pipeline to work to combine and minify my css and js assets. I don’t seem to be able to sort the following issue out. When I run: python manage.py collectstatic –noinput I get an
Continue readinggetting django-pipeline and bower to play nicely together
Issue I am installing bower components to external/bower_components/ under my project root. I have additional static files under static as well as some that are part of installed apps. I’m trying to use django-pipeline to minify static files that all
Continue readingDjango Pipeline generates empty file
Issue I have a new Django project, all seems to work fine. I am using Django pipeline, however when I run “collectstatic” command, it generates all the files but my main css and js files are blank, well the js
Continue readingOverriding Bootstrap in django-pipeline
Issue I have a Django application with which I am using the django-pipeline package and bootstrap.css: PIPELINE_CSS = { ‘myCSS’: { ‘source_filenames’: ( ‘css/bootstrap.css’, ‘css/bootstrapoverride.css’, ), ‘output_filename’: ‘bootmin.css’, ‘variant’: ‘datauri’, }, } As you can see above I have included
Continue readingOverriding Bootstrap in django-pipeline
Issue I have a Django application with which I am using the django-pipeline package and bootstrap.css: PIPELINE_CSS = { ‘myCSS’: { ‘source_filenames’: ( ‘css/bootstrap.css’, ‘css/bootstrapoverride.css’, ), ‘output_filename’: ‘bootmin.css’, ‘variant’: ‘datauri’, }, } As you can see above I have included
Continue readingUncaught ReferenceError: Parent is not defined
Issue I’m using django-pipeline along with browserify based on the documentation here – http://gregblogs.com/how-django-reactjs-and-browserify/ I have it working perfectly fine when loading NPM/Bower packages like so – ‘build_js’: { ‘source_filenames’: ( ‘js/bower_components/jquery/dist/jquery.js’, ‘bootstrap/js/bootstrap.js’, ‘js/bower_components/react/react-with-addons.js’, ‘js/bower_components/react/react-dom.js’, ‘datatables/js/jquery.dataTables.js’, ‘datatables/js/dataTables.bootstrap.js’, ‘js/node_modules/marked/marked.min.js’, ‘js/node_modules/react-router/umd/ReactRouter.js’, ‘js/child.js’,
Continue readingdjango-pipeline DEBUG=True, compressed file not found
Issue OK. I going mad using django-pipeline and I am one step away from not using it at all. I am not in production yet. All of the below is happening in development (DEBUG=True) mode. My css static files live
Continue readingFileNotFoundError with browserify during django collectstatic
Issue I am using django-pipeline-browserify to bridge django-pipeline and browserify. However, I am not able to collectstatic without the following error. And I am able to manually compile the js file by copying the command showed in the error message.
Continue readingWebapp Roboto font anomaly only when live site is viewed from Windows
Issue There’s a webapp where we use Roboto font, it’s loaded directly from Google: @import url(//fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,300italic); The website looks OK when viewing from OSX. The live website doesn’t load Roboto though when it is viewed from browsers on Windows (Chrome,
Continue readingHow to prevent name mangling of javascript functions in django-pipeline
Issue I am using django version 1.82 with django-pipeline. I call a particular javascript function from html by name. <form class=”navbar-form navbar-right vcenter” action=”javascript:search();” role=”search” id=’searchform’> Unfortunately in the compressed js file, the name of the function is changed and
Continue readingdjango-pipeline wipes out my entries in Django Database Cache
Issue I’m working on a Django application which uses django-pipeline for dealing with browsers’ file caching issues (and also for other benefits). STATIC_URL = ‘/static/’ STATICFILES_STORAGE = ‘pipeline.storage.PipelineCachedStorage’ STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, ‘bower’), ) STATICFILES_FINDERS = ( ‘django.contrib.staticfiles.finders.FileSystemFinder’, ‘django.contrib.staticfiles.finders.AppDirectoriesFinder’, ‘pipeline.finders.PipelineFinder’,
Continue readingdjango-pipeline crashes python social auth
Issue Currently I’m working in a little project that is contemplating social authentication (so python-social-auth is great). Also, I wanna to integrate django-pipeline to handle my assets (css principally). JS to perform a social sign up: vm.doSocialAuth = function(provider) {
Continue readingdjango-pipeline: Why do these JS lines cause yui-compressor to crash?
Issue I have a Django app, and within the app I’m trying to bundle and minify all Javascript files and CSS files. To do this, I’m using django-pipeline 1.2.6, and I have configured my settings file such that it uses
Continue readingDjango-pipeline is not been able to access a file. Access Denied Error
Issue I am using Django-pipeline for asset minification and compression but there seems to be an error when I try to run ./manage collectstatic I get the following error.. django.core.exceptions.SuspiciousFileOperation: Attempted access to ‘/home/darwesh/projects/first/api/static/js/app/check.js’ denied. Here is my settings.py file
Continue readingDjango pipeliner: /usr/bin/env: yuicompressor: No such file or directory
Issue I have the following versions of django and django-pipeline: Django==1.10.3 django-pipeline==1.6.9 In /usr/bin/ I see “yui-compresssor” listed. Running collectstatic gives the following error. pipeline.exceptions.CompressorError: /usr/bin/env: yuicompressor: No such file or directory When I run my site with debug set
Continue readingValueError: Empty key names are not allowed when using collectstatic django
Issue I am using django-pipeline S3PipelineManifestStorage with django-storages When I use collectstatic to upload and post-process(minify) my assets, I get an error when post-processing. Earlier, collectstatic worked fine and gave no error. Here’s the full traceback Traceback (most recent call
Continue readingValueError: Empty key names are not allowed when using collectstatic django
Issue I am using django-pipeline S3PipelineManifestStorage with django-storages When I use collectstatic to upload and post-process(minify) my assets, I get an error when post-processing. Earlier, collectstatic worked fine and gave no error. Here’s the full traceback Traceback (most recent call
Continue readingRuntimeError when building CSS from SCSS files of Foundation-sites with Django-pipeline
Issue My issue is in the same context as Django-Bower + Foundation 5 + SASS. I’m trying to compile foundation from scss to css. The problem is that I’m encountering the following RuntimeError: /home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/lib/sass/exec/sass_scss.rb:287:in `watch_or_update’: File /home/hakim/github/myquotes/static/quotes/app.css doesn’t exist. (RuntimeError)
Continue readingWhy django-pipeline does not collect static?
Issue I’ve followed django-pipeline docs and I am having an issue when collecting static, the console shows that the specified file is not found. collectstatic works without djanog-pipeline. I also tried to add static file at the same level as
Continue readingdjango-pipeline FileNotFoundError when i perform manage.py collectstatic
Issue It’s last some lines of traceback : File “C:\PycharmDev\TestVirtualEnv\testEnv1\lib\site-packages\pipeline\compressors\__init__.py”, line 247, in execute_command stdin=subprocess.PIPE, stderr=subprocess.PIPE) File “C:\Python34\Lib\subprocess.py”, line 859, in __init__ restore_signals, start_new_session) File “C:\Python34\Lib\subprocess.py”, line 1112, in _execute_child startupinfo) FileNotFoundError: [WinError 2] … And in settings.py : BASE_DIR
Continue readingUsing Django pipeline browserify on Windows
Issue I’m trying to follow http://gregblogs.com/how-django-reactjs-and-browserify/. I went through some hoops to get collectstatic working but it runs without error now. However when I try to load the page which contains my react component, another compilation process kicks in (I
Continue readingdjango-pipeline and s3boto storage don't seem to work together
Issue I’m trying to use django-pipeline-1.1.27 with s3boto to compress and filter static files, and then upload them to an s3 bucket. If I just use: PIPELINE_STORAGE = ‘pipeline.storage.PipelineFinderStorage’ Then it works and I get a static folder with the
Continue readingAutomatically remove source files after collectstatic with django-pipeline
Issue With django-pipeline, is it possible to automatically remove source files after collectstatic ? for example : PIPELINE_JS = { ‘stats’: { ‘source_filenames’: ( ‘js/jquery.js’, ‘js/d3.js’, ‘js/application.js’, ), ‘output_filename’: ‘js/stats.js’, } } collectstatic : $ python manage.py collectstatic $ ls
Continue readingHow to specify a device-specific css file when I compress all the css files using pipeline in Django?
Issue In order to use CSS3 Media Queries to create a mobile version of my website, I’m gonna create a seperate css file used for small screen devices. If I don’t use pipeline compressor in django, I would just add
Continue readingDjango pipeline can't find static css files
Issue I’ve configured django-pipeline to compress js and css. While js works, it is not able to find css files. The files can be found using findstatic command. I’m testing it with just one file now which has a single
Continue readingDjango-pipeline not serving files in development mode
Issue I’m trying to compile static with django-pipeline, but can’t manage to serve static in dev mode. Since I’m not a Django developer, I may be wrong how Django serves static files itself. Here’s my project structure: project (project itself)
Continue readingDjango Pipeline, Heroku, and SASS
Issue I’ve been trying to get django-pipeline setup so that I can compile and concat my assets. I would also like to remove the compiled css files from my repository to avoid merge conflicts in pull requests. I’ve been trying
Continue readingYuglify compressor can't find binary from package installed through npm
Issue I have a fresh virtualenv environment and have got the latest django-pipleline. The JS compression with Closure works perfect, but CSS compression with Yuglify fails, due a node error: STATICFILES_STORAGE = ‘pipeline.storage.PipelineCachedStorage’ PIPELINE_JS_COMPRESSOR = ‘pipeline.compressors.closure.ClosureCompressor’ PIPELINE_CSS_COMPRESSOR = ‘pipeline.compressors.yuglify.YuglifyCompressor’ When
Continue readingDjango-storages + django-pipeline + gzip
Issue I would like to gzip my static assets to s3 with the Gzip and s3 mixins from django storages, and serve the gzipped files with the static/compressed template tag. Is this possible? I don’t see information in the docs
Continue readingdjango-pipeline throwing ValueError: the file could not be found
Issue When running python manage.py collectstatic –noinput I’m getting the following error: Post-processing ‘jquery-ui-dist/jquery-ui.css’ failed! Traceback (most recent call last): File “manage_local.py”, line 10, in <module> execute_from_command_line(sys.argv) File “/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/__init__.py”, line 367, in execute_from_command_line utility.execute() File “/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/__init__.py”, line 359, in execute
Continue readingHow to install Node Packages for an Elastic Beanstalk Python 3.7 Project Running on 64bit Amazon Linux 2?
Issue I am using a Django package named django-pipeline to compress js and css files. When I deploy my project, I run Django’s collectstatic command, from .ebextensions folder: 01_django.config: container_commands: … 07_collectstatic: command: "source /var/app/venv/*/bin/activate && python3 manage.py collectstatic –noinput"
Continue readingdjango pipeline FileNotFoundError when the path is right
Issue I’m trying to add pipeline to my django project. But it’s throwing me winerror 2 (FileNotFoundError) when I’m trying to execute collectstatic settings.py STATIC_URL = ‘static/’ STATICFILES_STORAGE = ‘pipeline.storage.PipelineStorage’ STATIC_ROOT = ‘static’ STATICFILES_FINDERS = ( ‘django.contrib.staticfiles.finders.FileSystemFinder’, ‘django.contrib.staticfiles.finders.AppDirectoriesFinder’, ‘pipeline.finders.PipelineFinder’, )
Continue readingHow to get the line number where error occurred instead of line number from where error logged in Django
Issue I am using logging in my django project to log errors. However whenever any error occurs at any line, the line number in logs is where the error was logged and not where the error occured. For example in
Continue readingIs it possible to use Django's SafeExceptionReporterFilter with something else than the AdminEmailHandler?
Issue I’m trying to filter out sensitive informations using Django’s @sensitive_post_parameters. I thought prepending these annotations over a the few specific fonctions would be enough, but it doesn’t work. I’ve set breakpoint inside SafeExceptionReporterFilter and it only breaks when being
Continue readingDjango rest framework logging different levels on different files
Issue I am working on Django REST framework and I want to have separate files for logging data. I want to have a file for the simple transactions e.g. GET, PUT, POST etc. and one file with the errors that
Continue readingDjango logging – logging on ValidationError not working
Issue So I want to be able to track any ValidationErrors being raised by the def clean method on a certain form. I have the a form called AdForm, the validation on the form does work, I can see the
Continue readingWagtail Empty log file with debug=false
Issue I’m using wagtail 2.7, Django 2.2.5 and i’m trying to make logging to file. When DEBUG=True, all work fine and i have my logs. But when DEBUG=False in production my log file is empty. I tried a lot of
Continue readingHow to log Django warnings and errors to log file in Production?
Issue What I want to achieve is that warning and errors that happen in production (i.e. DEBUG=False) are logged into to a rotating log file. I tried this LOGGING = { ‘version’: 1, ‘disable_existing_loggers’: True, ‘handlers’: { ‘file’: { ‘level’:
Continue readingHow do you log server errors on django sites
Issue So, when playing with the development I can just set settings.DEBUG to True and if an error occures I can see it nicely formatted, with good stack trace and request information. But on kind of production site I’d rather
Continue readingHow to refuse an upload before it completes in Django?
Issue I would like my Django application to decide whether to accept or reject an upload based on request headers and/or session data. If the upload is to be rejected, I would like the app to reset the connection rather
Continue readingImages are not being stored?? – Django
Issue These are my following settings: MEDIA_ROOT = ‘/home/webapps/test_project/media/’ MEDIA_URL = ‘http://192.168.0.2:8090/site_media/’ ADMIN_MEDIA_PREFIX = ‘/media/’ These are my model fields: large = models.ImageField(blank=True, null=True, upload_to=”images”) thumb = models.ImageField(blank=True, null=True, upload_to=”images”) What happens is… when I save a model with the
Continue readingDjango – HTTP Uploading of Multiple Images
Issue I looked at this question: Uploading multiple files with Django but it did not seem to help as I have issues regarding it: I don’t want to deal with flash sessions using SWF Upload and Uploadify because I need
Continue readingUploading images from Django view
Issue Models: from django.db import models class Image(models.Model): advertisement = models.ForeignKey(‘Advertisement’) image = ImageWithThumbsField(upload_to=store_path, blank=True) class Advertisement(models.Model): #some code here class AdvertOne(Advertisement): #some code again class AdvertTwo(Advertisement): #and again Forms: from models import Advertisement from django.forms import * class AdvertisementForm(ModelForm):
Continue readingHow to deselct something when selected previously in FileField Django Form?
Issue I have a form which includes filefield to upload some files. Sometimes what happens is at first, I select one file from browse to upload but then i realize i do not want to upload it anymore.How can i
Continue readingIssues with display multiple images
Issue I want to display images which are stored in database. If I used this. in view product = Upload_files.objects.get(id=1) and in form <img src=”/media/{{ form.image }}/” /> then it will show the image of id=1 . But if I
Continue readingIssues with uploading images
Issue I want to upload images and they must be store in media folder.But when I upload an image it is uploaded and its name is store in database but image is not stored in media folder (even I don’t
Continue readingWhy is my image upload failing in django?
Issue I am trying to build a django app and host it on webfaction. My model looks like this: class Post(models.Model): title = models.CharField(max_length=512) image = models.ImageField(upload_to=’blogImages/’) body = models.TextField() visible = models.BooleanField() date_created = models.DateTimeField(auto_now_add=True) date_updated = models.DateTimeField(auto_now=True) tags
Continue readingDjango cannot use pk on upload_to in an object yet saved
Issue I have built a wizard in my project. In the first step I create an object “Building” and save it in the db. In the second step I let the user upload an image of the building saved in
Continue readingException occurred processing WSGI script – IOError: failed to write data
Issue I’m trying to save an image at the server side.I recieve it as base64 string so I decode it first and then save it in the database.However this failed, so I checked the server error log and I found
Continue readingAttempted access to '/media/uploads/
Issue I’ve problem with upload method on the admin/ urls: In my settings: # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: “/var/www/example.com/media/” MEDIA_ROOT = os.path.join(PROJECT_PATH, “media”) # URL that handles the media served from
Continue readingFile upload form in Django
Issue I’m trying to create a simple upload form for my project in Django 1.5 an Python 2.7. This is my File class: class File(models.Model): middleschool = ‘MS’ highschool = ‘HS’ university = ‘U’ blank = ‘-‘ school_choices = ((middleschool,
Continue readingValidate uploaded file format and show error if it's not intact in Django admin page
Issue I have my own text data file format to my Django application. After uploading one file to Django through admin page, how can I show error to admin uploader if file contents is not in proper format? Is there
Continue readingDjango image upload succeeds with url written to DB but no image shows upload target folder
Issue I have form in Django class BusinessForm(forms.Form): name = forms.CharField( required = True, max_length=MAX_NAME_LENGTH, widget=forms.TextInput(attrs={‘placeholder’: ‘e.g Boston Market’})) image = forms.ImageField() which belongs to this model class Business(models.Model): “”” Describes Bussines data type “”” name = models.CharField(max_length=BUS_NAME_LENGTH) img =
Continue readingwhere django create InMemoryUploadedFile object of uploaded file?
Issue when a HTTP Post request came with a file , django will create a InMemoryUploadedFile instance for each uploaded file. I’d like to extend InMemoryUploadedFile and add a few field and finally customize the upload file behavior of django.
Continue readingDjango Is it efficient for DB to store uploaded files in model?
Issue I have a form and if I store the file using form.save(), is the entire file content stored in DB or just the file path? Suppose I have hundreds of thousands or millions of files. Is it efficient to
Continue readingDjango uploading file not in MEDIA_ROOT path is giving me SuspiciousOperation error
Issue I want to upload files to a path that is still in my django project, but in my MEDIA_ROOT path. When I try to do this I get a SuspiciousOperation error. Here are the paths as defined in my
Continue readingValueError on ImageField when trying to delete image or creating new user in Django
Issue I have put an ImageField on my Django model, and with the pre-existent profiles it works (the image upload), but I can’t delete the image from the admin panel and I can’t create a new user. The thrown error
Continue readingSimple Django Image Upload – Image file not saving
Issue Right I’m learning how to do a simple image upload form to upload an image to MEDIA_ROOT. The form renders fine, I get no errors, but the file is not showing up in the MEDIA_ROOT directory. If followed the
Continue readingHow to upload multiple images in Django using Dropzone and saving path dynamically ?
Issue I am working on a Django project where users should be able to upload images using Dropzone.js At the moment user images would be saved under mypp/images folder However I would like to save the path of uploaded images
Continue readingDjango-models: use field from foreign key
Issue I’m working on an image gallery project in DJango, just for the sake of it. And well, I have a class named Gallery and a class named ImageGallery. The class named gallery would look like this: class Gallery(models.Model): gallery
Continue readingHow to add a file from a filefield in Django to urls and views?
Issue I’m doing a Django project, and I have a model called Projects, in this model I have a FileField inwhich files get uploaded to /media/files/YEAR/MONTH/DATE/. settings.py: MEDIA_ROOT = os.path.join(BASE_DIR, ‘media’) MEDIA_URL = ‘/media/’ models.py: class Project(models.Model): … file_upload =
Continue reading(Django) By updating the UserProfile, the image is not saving correctly
Issue I made a view, to update a userprofile. When uploading an image the image is saved correctly, but when updating the profile again, the image is not saved anymore, how can I solve that problem? I am glad for
Continue readingHow to convert text from TextArea to file?
Issue I have a form where User can fill either text to translate or attach a file. If the text to translate has been filled, I want to create a txt file from it so it seems like User uploaded
Continue readingHow do I get the filepath of an uploaded file?
Issue I’m having difficulty passing the path of a file to a library called Textract. def file_to_string(filepath): text = textract.process(filepath) print text return text Here is my upload form in views.py if request.method == ‘POST’: upload_form = UploadFileForm(request.POST, request.FILES) if
Continue readingServing Media in Production
Issue This is well known topic, on how to setup, serve MEDIA Files, but there is a lot of no no to serving them in production, this is just one example from answered question on SO, Django does not serve
Continue readingHow does Django rename uploaded files?
Issue If upload a file image.png from a web browser, a new file named image.png will appear in the upload directory on the server. If I then upload another file named image.png (same name), a new file named image_aj642zm.png will
Continue readingCannot upload image in django using filefield
Issue I am not able to upload image. here is my models.py class Post(models.Model): author = models.ForeignKey(‘auth.User’) title = models.CharField(max_length=200) text = models.TextField() image = models.FileField(upload_to = ‘post/static/images/’ , null= True, blank= True) created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True)
Continue readingHow do I save the foreign key?
Issue I want to upload multiple images. class IssuePanel(models.Model): issue = models.ForeignKey(ComicIssue, on_delete=models.CASCADE) panel = models.FileField(upload_to=’comic_issues_files/panels/’) date_uploaded = models.DateTimeField(auto_now_add=True) After following the examples on django-multiupload’s repository on github, I have this on forms.py class PanelsForm(forms.ModelForm): class Meta: model = ComicIssue
Continue readingDjango cant upload image
Issue I am trying to add avatar to my model, but uploading dosent work. settings.py MEDIA_ROOT = os.path.join(PROJECT_ROOT, ‘media’) MEDIA_URL = ‘/media/’ models.py class Casting(models.Model): … casting_picture = ImageField(upload_to=’/media/photos’) template casting.html there a lot of fields, so in short: <form
Continue readingDjango Upload Image in specific folder without FileField or ImageField and MEDIAROOT
Issue My App needs to upload different profile images in different folders inside the static folder. One more thing, I’m not using models, I just want to take the picture I choose in html input file and copy to the
Continue readingDjango, upload image error
Issue In my aplication, the users can change their profile data, like full name, gender, profile image and other stuff. The problem is when the user want to keep the same profile picture and the file input is empty. How
Continue readingDjango Rest Framework: Cannot serialize or save uploaded image
Issue Cannot serialize or save uploaded an image in APIview. If saving, a file is broken and cannot be open. If serialzing, getting: {“avatar”:[“No file was submitted.”]} Request content: MultiValueDict: {u’name’: [<TemporaryUploadedFile: Avatar.jpg (image/jpeg)>]} Settings: FILE_UPLOAD_HANDLERS = [ ‘django.core.files.uploadhandler.TemporaryFileUploadHandler’, ]
Continue readingUpload File using Angular and Django
Issue So, I have a issue that i cant find a solution for. I am developing an application using Django where my front end has to be in angular-js. Now I am able to render forms and also post the
Continue readingMultiple images in django form with multiupload
Issue I need to add multiple images in django form to one model. I did a research and for form outside of django I try to setup django-multiupload. My models.py: class Profile(models.Model): … … first = models.ImageField(“first”, upload_to=’first’) second =
Continue readingDjango Media Directory HTTP 404 for Uploaded Images
Issue My project structure is: – api/ – urls.py … – avatars/ – 16701016.jpg – 16701019.jpg … – frontend/ – static/ – frontend/ – templates/ – urls.py … – website/ – settings.py – urls.py … Part of the settings.py file:
Continue readingSerialize multiple InMemoryUploadedFile using ListField : Django REST Framework
Issue How can I serialize multiple InMemoryUploadedFile using serializers.ListField() ?? code snippet #views.py @api_view([‘POST’, ‘GET’]) def create_post(request): if request.method == ‘POST’: altered_request_data = request.data.copy() in_memory_upload_files_list = [value for value in request.FILES.values()] altered_request_data[‘files’] = in_memory_upload_files_list serializer = PostSerializer(data=altered_request_data) serializer.is_valid(raise_exception=True) serializer.save() return
Continue readingUpload Image in the wrong directory in django ImageField
Issue When I upload a photo, the photo is loaded successfully, but the photo is placed in the wrong directory. Instead of placing the image on the path to ‘media/posts-pics/’ – as I have outlined in my Post model –
Continue readingUpload Image in the wrong directory in django ImageField
Issue When I upload a photo, the photo is loaded successfully, but the photo is placed in the wrong directory. Instead of placing the image on the path to ‘media/posts-pics/’ – as I have outlined in my Post model –
Continue readingHow do you convert a PIL `Image` to a Django `File`?
Issue I’m trying to convert an UploadedFile to a PIL Image object to thumbnail it, and then convert the PIL Image object that my thumbnail function returns back into a File object. How can I do this? Solution The way
Continue readingDjango / file uploads permissions
Issue I wrote a django app, but I have a little problem with the file permissions of the uploads files from a web form. Basically I can upload a .mp3 file but it always keep chmod 600. The container folder
Continue readingDjango CSV upload UploadForm to database Clean
Issue i would like to store the data from my uploaded CSV file, called data_file I cant loop over the rows by column name in my csv file. I get Encoding errors(UTF, ASCII), also when i use IO String. I
Continue readingDjango – upload images with additional information
Issue So let’s say I have a blog website. And each blog consists of images. So, I want to sort the images depending on which blog they belong to. But when uploading, how do I automatically pass the blog id
Continue readingUnicodeEncodeError: 'ascii' codec can't encode character
Issue When uploading files with non-ASCII characters I get UnicodeEncodeError: Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/ Exception Value: ‘ascii’ codec can’t encode character u’\xf8′ in position 78: ordinal not in range(128) See full stack trace. I run Django 1.2 with MySQL
Continue readingImage uploaded but not saved in media and database Django
Issue Am creating a settings page where the user should be able to chang there image and biodata. But only the biodata gets updated when I print the request.FILES.GET("profile_picture") it prints the name of the photo I uploaded. why is
Continue readingFailed – No file Downloading uploaded files in Django
Issue I have a model here in Django in which an entity can have several uploaded files: from django.db import models from model_utils.models import TimeStampedModel from .managers import ProviderManager class Provider(TimeStampedModel): full_name = models.CharField(‘Nombre’, max_length=100, unique=True) phone1 = models.CharField("TelĂ©fono", max_length=50,
Continue reading