christiankreuzberger / django-rest-imageupload-example Goto Github PK
View Code? Open in Web Editor NEWA Django Rest Image Upload Example
License: MIT License
A Django Rest Image Upload Example
License: MIT License
Thank you for putting together this tutorial. However 18MB of sample images is unnecessary. Not a big deal, just a suggestion.
after integrating the project image is not uploading ... Giving error as image uploading failed
I have 2 question hope you make me clear.
Environment:
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
Django==2.1.7
django-filter==2.1.0
djangorestframework==3.9.1
Markdown==3.0.1
Pillow==5.4.1
pytz==2018.9
Error in step 3 when adding the API urls to the backend for browsing:
File "/.../django-rest-imageupload-example/venv/lib/python3.6/site-packages/django/urls/conf.py", line 39, in include
'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
ref: https://code.djangoproject.com/ticket/28691
fix is to add the line app_name="imageupload_rest"
to imageupload_rest/urls.py
from django.conf.urls import url, include
from rest_framework import routers
app_name="imageupload_rest"
router = routers.DefaultRouter()
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
]
I have cloned and am using the framework.
I am not able to figure out how to upload an image via a POST request.
Is it necessary for to create directory first?
below my tracetack.:
Internal Server Error: /api/images/ Traceback (most recent call last): File "C:\anwar\poken-psp-venv1\lib\site-packages\django\core\handlers\exception.py", line 41, in inner response = get_response(request) File "C:\anwar\poken-psp-venv1\lib\site-packages\django\core\handlers\base.py", line 187, in _get_respo nse response = self.process_exception_by_middleware(e, request) File "C:\anwar\poken-psp-venv1\lib\site-packages\django\core\handlers\base.py", line 185, in _get_respo nse response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\anwar\poken-psp-venv1\lib\site-packages\django\views\decorators\csrf.py", line 58, in wrapped_ view return view_func(*args, **kwargs) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\viewsets.py", line 83, in view return self.dispatch(request, *args, **kwargs) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\views.py", line 483, in dispatch response = self.handle_exception(exc) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\views.py", line 443, in handle_exceptio n self.raise_uncaught_exception(exc) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\views.py", line 480, in dispatch response = handler(request, *args, **kwargs) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\mixins.py", line 21, in create self.perform_create(serializer) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\mixins.py", line 26, in perform_create serializer.save() File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\serializers.py", line 214, in save self.instance = self.create(validated_data) File "C:\anwar\poken-psp-venv1\lib\site-packages\rest_framework\serializers.py", line 906, in create instance = ModelClass.objects.create(**validated_data) File "C:\anwar\poken-psp-venv1\lib\site-packages\django\db\models\manager.py", line 85, in manager_meth od return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\anwar\poken-psp-venv1\lib\site-packages\django\db\models\query.py", line 393, in create obj.save(force_insert=True, using=self.db) File "C:\anwar\lat\django-rest-imageupload-example\django_rest_imageupload_backend\imageupload\models.p y", line 78, in save self.thumbnail = create_thumbnail(self.image) File "C:\anwar\lat\django-rest-imageupload-example\django_rest_imageupload_backend\imageupload\models.p y", line 47, in create_thumbnail image.save(os.path.join(settings.MEDIA_ROOT, new_filename)) File "C:\anwar\poken-psp-venv1\lib\site-packages\PIL\Image.py", line 1823, in save fp = builtins.open(filename, "w+b") IOError: [Errno 2] No such file or directory: 'C:\\anwar\\lat\\django-rest-imageupload-example\\django_re st_imageupload_backend\\..\\uploaded_media\\28dc9166-8b83-4cd1-8a67-3cea6b31cfa7_thumb.jpg' [02/Aug/2017 18:03:59] "POST /api/images/ HTTP/1.1" 500 19024
This is not an issue, but I am trying to extend this project by adding few more functionalities to it like:
1)I want to add one more button for every image called segment(see image)
2)on clicking this button that corresponding image should be passed to my view(python script).this python script returns four values(x,y,w,h) and i want to render these coordinates as a bounding box on the corresponding image.
Can you point me to the right resources to learn about this and implement it.
In the years that have passed since this tutorial was created it looks like Node module version rot has set in.
After a bit of tinkering these are the version of the node modules that are working for me:
npm install [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
Hi, I've followed along and want to thank you so much. Did you ever create chapter 3?
Cheers
Wayne
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.