Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to pass three variable to custom template tag?
I am trying to pass 3 variables to my custom filter, but I can’t do it. Is there any such possibility in Django? {{ item.cost|pay_blago:'{{item.can_pay_blago_to_currency}}, {{item.rest}}'}} @register.filter def pay_blago(cost, args): print(args.split(',')) -
Documenting Django Rest Framework API
Looking for self describing api for django rest framework application we are using Django 2 and Django Rest Framework 3.7.3 We are looking to document the api based on view doc strings or meta-data I have tried drf docs and drf auto docs and there dont seem to support our app Someone mentioned pydocs, but dont think this will work Our worse case would be using Sphinx I think we would like an api that gives an example ideally Example request: GET /tests HTTP/1.1 Example response: HTTP/1.1 200 OK Content-Type: application/json [ { "name": "test1", }, { "name": "test2", } ] Status Codes: 200 OK – List of a tests. -
Django Next and Previous Object Does not Work
I have multiple lessons in a Table under a Course. When the User Views a Lesson from a Course, the need to be able to access Links to the Previous and Next Course as well. models.py class Course(models.Model): title = models.CharField(max_length=255) description = models.TextField() created_dt = models.DateTimeField(auto_now_add=True) enrollment = models.ManyToManyField(get_user_model()) def __str__(self): return self.title class Step(models.Model): title = models.CharField(max_length=255) description = models.TextField() code_sample_1 = models.TextField(blank=True) code_sample_2 = models.TextField(blank=True) code_sample_3 = models.TextField(blank=True) code_sample_4 = models.TextField(default=" ", blank=True) project_1 = models.TextField(blank=True) project_2 = models.TextField(blank=True) project_3 = models.TextField(blank=True) video_url = models.CharField(max_length=255,blank=True) resources = models.TextField(default=" ",blank=True) file_url = models.CharField(max_length=255,blank=True) order = models.IntegerField(default=0) course = models.ForeignKey(Course,on_delete=models.CASCADE) class Meta: ordering = ['order',] def __str__(self): return self.title def get_absolute_url(self): return reverse('course_steps', args=[str(self.id)]) def get_next_by_title(self): try: return self._get_next_or_previous_by_FIELD('title', is_next=True) except Step.DoesNotExist: return None def get_previous_by_title(self): try: return self._get_next_or_previous_by_FIELD('title', is_next=False) except Step.DoesNotExist: return None Code in Template <a href="{{ step.get_previous_by_title.get_absolute_url }}">{{ step.get_previous_by_title.title }}</a> This has generated an error as below 'str' object has no attribute 'attname' -
Visual Studio: how to ignore known exceptions when debugging?
I'm debugging with Visual Studio Code Version 1.34. I've setup a breakpoint that is not reached because of exceptions that are not critical. How do I stop that behaviur? I'm coping the configuration file for debugging with Django in VSC. launch.json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "extensionHost", "request": "launch", "name": "Launch Extension", "runtimeExecutable": "${execPath}", "args": [ "--extensionDevelopmentPath=${workspaceFolder}" ], "outFiles": [ "${workspaceFolder}/out/**/*.js" ], "preLaunchTask": "npm" }, { "name": "Python: Django", "type": "python", "request": "launch", "program": "${workspaceFolder}\\manage.py", "args": [ "runserver", "--noreload", "--nothreading" ], "django": true } ] } -
How To Use get_queryset with Django DetailView With self.request.GET.get("q")
I am trying to figure out how to incorporate get_queryset with my Django detailview. In the normal use case, I have this working, add get_queryset to the DetailView and voila! It works....However this use case is a little different. I am using a FormView to get a search value and then upon success, I return a detailview. This working properly too. When I try to incorporate a get_queryset to override the queryset, that's when things go awry. Here's my code... FormView class AuthorSearchView(LoginRequiredMixin,FormView): form_class = AuthorSearchForm template_name = 'author_search.html' def get_form_kwargs(self): kwargs = super(AuthorSearchView, self).get_form_kwargs() kwargs['user'] = self.request.user kwargs['q'] = self.request.GET.get("q") return kwargs Then in my author_search.html....I have <form method="GET" autocomplete=off action="{% url 'Author:author_search_detail' %}"> When the user enters a value in the search...it returns a DetailView screen... class AuthorSearchDetailView(LoginRequiredMixin,DetailView): model = Author context_object_name = 'author_detail' template_name = 'author_search_detail.html' def get_object(self, queryset=None): return get_object_or_404(Author, request_number=self.request.GET.get("q")) return get_object_or_404 The code above works fine...Note I am not using a PK reference in my action reference...as it is not needed for this approach...my URL in the case of the code above is.... url(r'^author_search_detail/$',views.AuthorSearchDetailView.as_view(), name='author_search_detail'), However, when I try to incorporate get_queryset instead of get_object with the code below.... def get_queryset(self): queryset = super(AuthorSearchDetailView, … -
How to use threading ,for showing progress bar in uploading a file in django , ajax and jquery?
I am very very new to django and python . I have a project where I have to show the progress bar of the upload of a file to a form. Since I am using windows I cant use Celery . I tried using Ajax and Jquery alone for the progress bar but they are not matching the upload percentage in the django server part. So I tried using threads. (I tried many methods none worked, so hence coming here) My Idea: 1) After user submits , $.ajax function , it goes to startThreadTask where I start a thread. (In this view function I want to access the file, request.FILES[ ] , but it is throwing .MultiValueDictKeyError: 'uploader') 2)After accessing the File ( assuming the 1st error has been solved) , now it will start a thread and call a function passing this file as a parameter. I end if f.size== sizex(The amount I have written using chunks). 3)After starting the thread it will come back and access the Success function in ajax function which (1) did. In the success function it is recursively checking for the amount written by calling the checkThreadTask which returns a JSONResponse. $.ajax({ type: "GET", … -
Social Login for only registered users
I need to implement social login but there is a condition that user must be registered on the website before login through facebook or google. I am planning to use django-oauth-toolkit. For this, I need to connect user's social account to our website once he is registered. Then while social logging of a user, i need to check whether the user is registered on the website and already connected his account to the social account. So I need some guidance who have already done this or have knowledge of this. -
How do I pass year month and date in a function to created related directory?
I have a model: def author_document_path(instance, filename): return f"documents/{ instance.author.username }/%y/%m/%d/{filename}" def author_blog_images(instance, filename): return f"blog-images/{instance.author.username}/%y/%m/%d/{filename}" class Blog(models.Model): title = models.CharField(max_length=255) # other fields thumbnail = models.ImageField(upload_to=author_blog_images) documents = models.FileField(upload_to=author_document_path) What is the right way of passing f"blog-images/{instance.author.username}/%y/%m/%d/{filename}" in above two functions because these functions doesn't create year folders as 2019, month folder as 5 and day folder as 30. The directories look like this after uploading respected files and images: this is not what I want I want it to look like: Can you help me with this. Thank you so much. -
Can I navigate to media file URL in browser and see it/play it?
I have MEDIA_ROOT and MEDIA_URL defined like this in my project's settings: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' In the MEDIA_ROOT folder there is a file logo.png. Should I be able to go to localhost:8000/media/logo.png in the browser and see the image? If so, what might be the reason that I get page not found error when I do this: Using the URLconf defined in testproject.urls, Django tried these URL patterns, in this order: 1.admin/ [name='index'] The current path, media/logo.png, didn't match any of these. -
Django DRF - Update multiple records in one PUT or POST?
Ive scoured the existing questions for hours and have not seemed to develop an answer through the many samples ive seen. I am trying to do a update of multiple records at once, it seems like there is a plethora of ways to achieve this, thus far none have prevailed for me. My latest attempt which I feel isn't too far away? is below Thank you for any help current error is: { "detail": "Method \"PUT\" not allowed." } models.py class SiteCircuits(models.Model): site = models.ForeignKey(Site, on_delete=models.CASCADE) circuit = models.ForeignKey(Circuit, on_delete=models.CASCADE) site_count = models.IntegerField(verbose_name="How many sites circuit is used at?", blank=True, null=True) active_link = models.BooleanField(default=False, verbose_name="Active Link?") timestamp = models.DateTimeField(auto_now=True, blank=True, null=True) views.py class MonitoringConnectivitySet(generics.RetrieveUpdateDestroyAPIView): queryset = SiteCircuits.objects.all() serializer_class = MonitoringSerializerConnectivity permission_classes = (IsAdminUser,) serializser.py class MonitoringSerializerConnectivity(serializers.ModelSerializer): class Meta: model = SiteCircuits fields = ('site_id','circuit_id','active_link',) def update(self, instance, validated_data): instance.site_id = validated_data.get('site_id', instance.site_id) instance.circuit_id = validated_data.get('circuit_id', instance.circuit_id) instance.active_link = validated_data.get('active_link', instance.active_link) instance.save() return instance urls.py path('conn_set/', views.MonitoringConnectivitySet.as_view()) JSON data I am sending [{"site_id": 101, "circuit_id": 333, "active_link": "False"}, {"site_id": 101, "circuit_id": 370, "active_link": "False"}, {"site_id": 102, "circuit_id": 341, "active_link": "False"}, {"site_id": 64, "circuit_id": 321, "active_link": "False"}, {"site_id": 64, "circuit_id": 196, "active_link": "True"}, {"site_id": 64, "circuit_id": 195, "active_link": "False"}, {"site_id": 35, "circuit_id": … -
Django connection to Mongo Atlas Cluster
I am trying to connect my Django1.9 application with cloud DB instance at Mongo Atlas using Pymongo. Our DB name is accounts. So far I was connecting my local mongodb instance using mongoengine.connect( username=MONGODB_DATABASES[db]['user'], password=MONGODB_DATABASES[db]['password'], host=MONGODB_DATABASES[db]['host'], port=MONGODB_DATABASES[db]['port'], db=MONGODB_DATABASES[db]['name'] ) According to example, I have to use below string to connect. import pymongo client = pymongo.MongoClient("mongodb+srv://<DB USER>:<password>@clustername-osaot.mongodb.net/test?retryWrites=true&w=majority") db = client.test I am able to connect to cluster via mongo shell. But when I run above code, I get errors >>> client = pymongo.MongoClient("mongodb://BackendUser:Xunison_123@cluster0-osaot.mongodb.net/test?retryWrites=true&w=majority") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.6/site-packages/pymongo/mongo_client.py", line 248, in __init__ res = uri_parser.parse_uri(entity, port) File "/usr/lib/python3.6/site-packages/pymongo/uri_parser.py", line 308, in parse_uri options = split_options(opts) File "/usr/lib/python3.6/site-packages/pymongo/uri_parser.py", line 211, in split_options return validate_options(options) File "/usr/lib/python3.6/site-packages/pymongo/uri_parser.py", line 153, in validate_options option, value = validate(option, value) File "/usr/lib/python3.6/site-packages/pymongo/common.py", line 306, in validate value = validator(option, value) File "/usr/lib/python3.6/site-packages/pymongo/common.py", line 53, in raise_config_error raise ConfigurationError("Unknown option %s" % (key,)) pymongo.errors.ConfigurationError: Unknown option retryWrites >>> client = pymongo.MongoClient("mongodb://BackendUser:Xunison_123@cluster0-osaot.mongodb.net/test?w=majority") Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/pymongo/mongo_client.py", line 363, in __init__ self._ensure_connected(True) File "/usr/lib/python3.6/site-packages/pymongo/mongo_client.py", line 924, in _ensure_connected self.__ensure_member() File "/usr/lib/python3.6/site-packages/pymongo/mongo_client.py", line 797, in __ensure_member member, nodes = self.__find_node() File "/usr/lib/python3.6/site-packages/pymongo/mongo_client.py", line 888, in __find_node raise AutoReconnect(', '.join(errors)) pymongo.errors.AutoReconnect: … -
I can upload images to specific directory but can't view them in template (Page not found (404))
I am trying to add upload image to admin form in my Django project i found on github (https://github.com/mdn/django-locallibrary-tutorial). I can upload image to folder (my_app(catalog)/media/images/image.png) but when i try to call it in template I can only see that image icon that appears when there is no picture. settings.py STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'catalog/media') model.py class Book(models.Model): image = models.ImageField(blank=True, null = True, upload_to='images') template book_detail.html img src="{{ book.image.url}}" width="250" views.py class BookDetailView(generic.DetailView): model = Book urls.py from django.urls import path from . import views from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('', views.index, name='index'), path('book/create/', views.BookCreate.as_view(), name='book_create'), path('books/', views.BookListView.as_view(), name='books'), path('book/<int:pk>', views.BookDetailView.as_view(), name='book-detail'), urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) this is how it looks like (i print {{ book.image }} next to the picture (images/screenshot_4.png) http://prntscr.com/nvevq8 this is error i get http://prntscr.com/nvewla -
Hide pictures from article preview
I'm learning Django by making a news / blog web app. On my home page i would like to list my articles so i made a simple template with this : {% for article in last_articles %} <div class="article"> <h3>{{ article.title }}</h3> <p>{{ article.content | truncatewords_html:80 | safe }}</p> <p><a href="{% url 'read' slug=article.slug id=article.id %}">Read More</a> </p> </div> <br/> <hr/> {% empty %} <p>Nothing for the moment</p> {% endfor %} The problem is that I have some pictures on my article.content so my question is : Is there a way to remove them like truncatewords but for picture. I didn't find solutions on official doc. Thanks -
Copy folder chosen in input tag in a specific folder using javascript or jquery
I have an html template in django in which I select a folder using: <input type="file" id="files" name="files[]" onchange="getfolder(event)" webkitdirectory mozdirectory msdirectory odirectory directory multiple /> In the getfolder(event) the content of the directory is shown in an output span. What I want to do is to copy the user selected folder inside the static django folder. I can't put this folder at the beginning inside the static django folder because the folder that the user can choose is a folder of a really big database. How can I do that using javascript or jquery ? -
How do I bypass asking end-user for username while adding a blog post using a form and automatically display logged in user as post author?
I am working on a simple blog which has a model Post. I am trying to create a form for adding blog posts (or adding comments to posts for that matter) so that end users don't have to fill out a form box asking the end user for a username. I would like to be able to just ask for a title and body text for a blog post, and when hit post, it will be posted as the authenticated user. I tried not including 'user' field in fields in forms, but it seems to be mandatory. Maybe I need to just make it hidden somehow using widgets? In templates, I could maybe write the following: {% if user.is_authenticated %} <p>Posting as {{request.user}}</p> {% else %} <p><a href={% url 'register' %}Please register to add a blog post</a></p> {% endif %} Though I am not sure, I think it would make more sense to have logic in my views.py file. Here's my 'blog.models' file: class Post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts') title = models.CharField(max_length=200) slug = models.SlugField(unique=True) text = models.TextField() published_date = models.DateTimeField(auto_now=True) # pip install Pillow image = models.ImageField(null=True, blank=True, upload_to='photos/%Y/%m/%d/',) def summary(self): """Return a summary for very long posts … -
I get error 500 when i request with a anon user and not error 401, using "rest_framework.permissions.IsAuthenticated" , in Django rest framework
I'm building an api where users have to be logged in to see the content with django, and django rest framework. Using 'rest_framework.permissions.IsAuthenticated' and rest_framework.authentication.TokenAuthentication as it says in the documentation. Settings.py REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ), } and it works perfectly, it does not allow to anonymous users see the contents, but the problem is that it responds with an error 500 and not 401 Unauthorized as it should. i get this exeption when I make a request without any token: TypeError: int() argument must be a string, a bytes-like object or a number, not 'AnonymousUser' Does anyone know what can be done for the IsAuthenticated and TokenAuthentication permissions to return 401 and not 500? -
UpdateView with formset DJANGO
I want to update multiple objects (formset). I have a model and i can to create multiple objects with this: class FormSeguridadView(CreateView): v = 0 insp = 0 form_class = RespFormSeguridad RespFormset = formset_factory(RespFormSeguridad, extra=0) template_name = 'formularios/formSeguridad.html' def get_context_data(self, **kwargs): v = self.v insp = self.insp context = super(FormSeguridadView, self).get_context_data(**kwargs) context['pregDocuObra'] = PRG.objects.filter(PRG_TIP=1) context['seguridad_form'] = self.RespFormset(initial=[ {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 11}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 12}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 13}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 14}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 19}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 20}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 21}, {'RESP_INSP': insp, 'RESP_FORM': v, 'RESP_PRG': 22}, ]) return context def post(self, request, *args, **kwargs): resp_formset = self.RespFormset(self.request.POST, self.request.FILES) if resp_formset.is_valid(): for respuestas in resp_formset: respuestas.save() return HttpResponseRedirect(reverse("index")) else: print(resp_formset.errors) return HttpResponseRedirect(reverse("index")) But i tried to update with this code: class FormSeguridadUpdateView(UpdateView): form_class = RespFormSeguridad template_name = 'formularios/formSeguridadUpdate.html' queryset = RESP.objects.all() def get_object(self, queryset=None): id_ = self.kwargs['pk'] return get_list_or_404(RESP, RESP_INSP=2) def form_valid(self, form): print(form.cleaned_data) return super().form_valid(form) But it doesn't work. It Throws an error: AttributeError at /inspections/1/updateFormSeguridad/ 'list' object has no attribute '_meta' I dont know how to resolve this. Thanks you. -
lambda function inside re.sub?
how can use lambda function inside re.sub to replace with its order like bellow current code: import re text = "John{28}, William{48}, James{8}, Charles{38}" print(text) name = re.compile('{(.*?)}') line = name.sub('{}', text) print(line) Expecting result: John{1}, William{2}, James{3}, Charles{4} is re.sub is the best way to do this? -
Django and php with single apache server
I have a Django website which is running on ubuntu AWS(EC2) instance using Apache server and I set a virtual host for that i.e developer.example.com.(/var/www/example.com) now I want to change my home page and some other pages (not all) from Django to PHP and I create a new folder in /var/www/example.com/php/ and put all the php pages in that folder and I am able to access it by developer.example.com/php/ and it is working fine but I want that whenever I hit developer.example.com it should open my php pages if I have defined them in .htaccess file, if not it should open the previously used Django pages. basically, I want to be able to decide whether the same URL opens php file or Django file. I am trying t do this from .htaccess file I tried: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^[^/]*$ php/index.php [L] RewriteCond %{REQUEST_URI} !^/php/ RewriteRule ^(.*)$ /php/$1 [L,R=301] RewriteEngine on RewriteCond %{HTTP_HOST} ^developer.example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.developer.example.com$ RewriteCond %{REQUEST_URI} !php/ RewriteRule (.*) /php/$1 [L] But none of them works -
Basic movie database interacting with external API
In job offers I often see the word "REST-API". So, I'd like to learn what REST-API actually is. I have some experience in Django. Well, I'm a beginner actually. I found on GitHub a simple task: https://github.com/netguru/python-recruitment-task The only thing I don't understand is how to do this: POST /movies: Request body should contain only movie title, and its presence should be validated. Based on passed title, other movie details should be fetched from http://www.omdbapi.com/ (or other similar, public movie database) - and saved to application database. Request response should include full movie object, along with all data fetched from external API. How should it looks like? How to validate the "presence"? How to download data from public databases? -
Cannot resolve keyword 'contact_date' into field. Choices are: Contact_date, email, id, listing, listing_id, message, name, phone, user_id
I am developping a app in Django 2.1.5.In my Contact app I found this error. My views.py code in Contacts app(Only for dashboard part): from django.shortcuts import render,redirect from django.contrib import messages,auth from django.contrib.auth.models import User from contacts.models import Contact def dashboard(request): user_contacts = Contact.objects.order_by('-contact_date').filter(user_id=request.user.id) context = { 'contacts': user_contacts } return render(request, 'accounts/dashboard.html', context) The error code is: Cannot resolve keyword 'contact_date' into field. Choices are: Contact_date, email, id, listing, listing_id, message, name, phone, user_id -
How to make faster large data (5,000,000) in Django with Datatables No django-datatables-view No Rest Framework
I want to take large data (examples 5 000,000) with datatables in Django .But Proccessing is slowly (Page Load is 12 seconds).Users login to webpage. Then Click to Test .html. Backend procces run to test_json in Views. Views call taking db data with to_dict_json. On Models.py. This method in Views return Json response objects. How to make faster large data in Django with datatables Models.py class SysTest(models.Model): class Meta: db_table = 'sysTest' id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) Tip = models.ForeignKey(SysRefTip, on_delete=models.CASCADE) Kod = models.CharField(_("Kod"), max_length=20, blank=False, null=False) Aciklama1 = models.CharField(_("Açıklama 1"), max_length=100,blank=True, null=True) Aciklama2 = models.CharField(_("Açıklama 2"), max_length=100,blank=True, null=True) GrupKod = models.CharField(_("Grup Kodu"), max_length=20,blank=True, null=True) SayKod = models.FloatField(_("Sayısal Değer"),blank=True, null=True) def to_dict_json(self): return{ 'Id':self.id, 'Kod':self.Kod, 'Aciklama1':self.Aciklama1, 'Aciklama2':self.Aciklama2, 'GrupKod':self.GrupKod, 'SayKod':self.SayKod, } View.py def test_json(request): persons = SysTest.objects.all() data = [person.to_dict_json() for person in persons ] response = {'data': data} return JsonResponse(response,safe=False,content_type="application/json") Urls.py from django.urls import path, include from Referans.Views import testView from django.conf.urls.i18n import i18n_patterns app_name ="Test" urlpatterns = [ path('', testView.test_listele , name="test"), path('test/json/', testView.test_json, name='test_json'), ] test.html <div class="card-body"> <table id="myTable2" class="table datatable-responsive-control-right"> <thead> <tr> <th>Id</th> <th>Kod</th> <th>Açıklama1</th> <th>Açıklama2</th> <th>SayKod</th> <th>GrupKod</th> </tr> </thead> </table> </div> {% block js%} <script> $(document).ready( function () { var t0 = performance.now(); degerleriGetir('test/json') var … -
How to implement a hash function that runs before django's hasher?
We are creating a IOT system using a RPC procedure. The RPC is using a login system that checks against django's user model if the password is correct. We still need to encrypt the password when sent by the RPC so we thought to send a partial hash to check, basicly having two different password checkers one for django and one for the rpc. Something like this: def RPC_pass_check(user, RpcHashPassword): return user.check_password(RpcHashPassword) def djangos_pass_check(user, clearPassNoHash): password = hash_used_by_RPC(clearPassNoHash) return user.check_password(password) This would mean we need a custom make_password for django too that would use hash_used_by_RPC(password) before djangos normal hashing procedures. How or at least where should we implement such a function? -
How to set image path in django template
I'm trying to display already stored database image in template. But here i'm getting only name of the image. How to solve this, Where i did mistake. models.py class Images(models.Model): image = models.ImageField(upload_to='images', blank=True, null=True) settings.py STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' urls.py urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) views.py def display(request): myimages_objs = Images.objects.all().values() for i in myimages_objs : myimages_objs = i['image'] return render(request, 'index.html', {'myimages_obj ': myimages_objs }) index.html <div class="divi"> <img src="{{ myimages_obj }}" alt="image"> </div> -
I am getting [WinError123] while executing my project in pycharm using django
I am using django 2.2.1 and developing a website in pycharm. Whenever i try to run my project using i get the following error and process is terminated: OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '' I have uninstalled and reinstalled django several times still error exists