Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to connect docker to oracle external database outside docker container?
i have create database on oracle. How to connect oracle external database with docker? -
How to get request user id in Django Serializers?
I'm getting KeyError: 'request' while i want to get the current user id through user request. I tried something like this: validated_data['user_id'] = CarOwnerCarDetails.objects.get(user_id=self.context['request'].user.id) but it's throwing me KeyError. How to get the current user id through request in serializers? if any help would be much appreciated. Thank you so much in advance my friends. models : class CarOwnerCarDetails(models.Model): user_id = models.OneToOneField(User, on_delete=models.CASCADE) car_plate_number = models.CharField(max_length=20, null=True, blank=True) class GetQuotes(models.Model): user = models.ForeignKey(CarOwnerCarDetails, on_delete=models.CASCADE, blank=True, null=True) subject = models.CharField(max_length=240, blank=False, null=True) serializers : class ShopGarageGetQuoteSerializer(ModelSerializer): subject = CharField(error_messages={'required':'subject key is required', 'blank':'subject is required'}) user_id = serializers.CharField(read_only=True) class Meta: model = GetQuotes fields= ['user_id', 'subject'] def create(self,validated_data): subject = validated_data['subject'] validated_data['user_id'] = CarOwnerCarDetails.objects.get(user_id=self.context['request'].user.id) quotes_obj = GetQuotes.objects.create( subject=subject, user_id=validated_data['user_id'] ) return validated_data views.py : class ShopGarageGetQuoteAPIView(APIView): permission_classes = (IsAuthenticated,) def post(self,request,*args,**kwargs): data = request.data serializer = ShopGarageGetQuoteSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response({'success' :'True','message' : 'Quotes send successfully','data' : serializer.data},status=200) return Response(serializer.errors,status=400) -
Wagtailadmin allow group only to view in CMS admin
Hello everyone I've been working with wagtail for a while I faced and interesting thing when I create a group with only view permissions and access to wagtail all its fancy tabs like pages and images begone. I might assume that it is due to permissions of add/edit missing. But the question is is it possible in a fast easy way make something like that? display_what_needed and still be with this menu which disappear -
How to implement Agora into a Django project?
I would like to implement Agora voice and video SDK into a Django project. I have found some articles on this issue such as https://medium.com/@rayanuthalas/build-a-video-call-website-using-django-agora-a20ba6b8e7d5 Which might be helpful for someone with a previous experience but for so first time implementer it is too little, also they omit chunks of code here and there which makes it impossible to follow. I have found some package for Django - https://pypi.org/project/django-agora/ but it seems inactive and it hasn't even reached version 1. I would appreciate any tips on what to follow or any advice on how to implement it with Django. Or if you have an experience with another such SDK with Django and you know it is fairly straight forward to implement, I am open to suggestions too. Any material will be appreciated. -
Django Filter Default Date
Unfortunately I can't wrap my head around how to set a default value for a Date Filter, as described in some other posts it should be possible to set it in the init function, but to no avail: filters.py: class LoaderErrorFilter(django_filters.FilterSet): product = django_filters.ModelChoiceFilter(queryset=Product.objects.all(), label='Product*') operator = django_filters.CharFilter(field_name="operator", lookup_expr='contains', label='Operator') load_from = django_filters.DateFilter(label='From*') load_to = django_filters.DateFilter(label='To*') error = django_filters.CharFilter(field_name="error", lookup_expr='contains', label='Error') def __init__(self, *args, **kwargs): super(LoaderErrorFilter, self).__init__(*args, **kwargs) self.form.initial['load_from'] = datetime.datetime.today().replace(day=1) self.form.initial['load_to'] = datetime.datetime.today() if self.data == {}: self.queryset = self.queryset.none() The queryset will be filled after the user makes a selection since there are different models affected depending on the choices. Any ideas would be highly appreciated! -
Django cache framework not working with django-cms
I am using django 3.1 and the database caching and it is working properly, but when I included the django-cms in the project the cache table started giving an error that psycopg2.errors.UndefinedTable: relation "abc_cache_table" does not exist is there any config that I am missing to add? any help and suggestion will appriated. Thank you. -
SystemError: <built-in function uwsgi_sendfile> returned a result with an error set
I habe deploy my django app on pythonanywhere but have an error with export in excel my code works except on pythonanywhere I try to use from werkzeug.wsgi import FileWrapper but module werkzeug is not found... how to fix this issue? views.py from django.shortcuts import render, get_object_or_404, redirect from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse from django.db.models import Q from django.utils.translation import ugettext as _ import time from django.utils import timezone from datetime import datetime # http://www.learningaboutelectronics.com/Articles/How-to-create-an-update-view-with-a-Django-form-in-Django.php from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import permission_required from randomization.models import Medicament, Randomisation, is_randomizable, categorie_medicament from parameters.models import Profile, Pays, Region, Site, Thesaurus from pharmacy.models import Entree, Sortie, Parametrage, Alerte, Stock, alerte_existe, alerte_activation, mise_a_jour_alerte, stock_site_existe, liste_medicaments_a_envoyer_site,liste_medicaments_a_envoyer_pays, quantite_medicament_a_expedier, liste_medicaments_a_expedier import os import xlwt import csv @login_required def export(request): response = HttpResponse(content_type='application/ms-excel') export_date = str(timezone.now())[0:10] sites = [s.sit_abr for s in request.session.get('user_authorized_sites')] pays = Pays.objects.get(pay_ide = request.session.get('user_pays')).pay_abr filename = str(export_date) + "_intensetbm_export.xls" response['Content-Disposition'] = 'attachment; filename= "{}"'.format(filename) # response['Content-Disposition'] = 'attachment; filename="intensetbm_export.xls"' wb = xlwt.Workbook(encoding='utf-8') # styles normal_style = xlwt.XFStyle() ... if request.user.has_perm('randomization.can_export_data_randomization'): ws = wb.add_sheet('crf_ran') row_num = 0 columns = ... wb.save(response) return response -
Need help in adding Foreign key using django models
Okay so I don't know how to frame this. I have two models Employee and Customer. I am storing the Employee as foreign key in Customer model under emp_id. The epm_id stores the primary key of the employee who admits the customer. I am not sure how to do this in django. Here are my models: class Customer(models.Model): firstname = models.CharField(max_length=15) lastname = models.CharField(max_length=15) age = models.IntegerField() sex = models.CharField(max_length=10) phoneno = models.IntegerField() emailid = models.CharField(max_length=25) address = models.CharField(max_length=50) children = models.IntegerField() adults = models.IntegerField() roomtype = models.CharField(max_length=10) aadharno = models.CharField(max_length=15) daysstayed = models.IntegerField() date_visited = models.DateTimeField(default=timezone.now) emp_id = models.ForeignKey(Employee,on_delete=models.SET_NULL,blank=True,null=True) class Employee(models.Model): firstname = models.CharField(max_length=15) lastname = models.CharField(max_length=15) age = models.IntegerField() sex = models.CharField(max_length=10) phoneno = models.IntegerField() emailid = models.CharField(max_length=25) address = models.CharField(max_length=50) salary = models.IntegerField() designation = models.CharField(max_length=10) password = models.CharField(max_length=10) aadharno = models.CharField(max_length=15) datejoined = models.DateField(default=timezone.now) I need some help here. -
How to display the user groups because they didn't show in django view?
I have CRUD operations for users which can be done only from admin and he can assign users to 6 different groups. It saved in the database and everything works well. The problem I faced now is that the groups are not visualize in my views (in the UI) I attached picture to show what I mean: model.py class CustomUserManager(BaseUserManager): def create_user(self, email, password, **extra_fields): if not email: raise ValueError(_('The Email must be set')) email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.set_password(password) user.save() return user def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active', True) if extra_fields.get('is_staff') is not True: raise ValueError(_('Superuser must have is_staff=True.')) if extra_fields.get('is_superuser') is not True: raise ValueError(_('Superuser must have is_superuser=True.')) return self.create_user(email, password, **extra_fields) class CustomUser(AbstractUser): username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email username = models.CharField(max_length=30, blank=True, default='') is_superuser = models.BooleanField(default=True) is_admin = models.BooleanField(default=True) is_employee = models.BooleanField(default=True) is_headofdepartment = models.BooleanField(default=True) is_reception = models.BooleanField(default=True) is_patient = models.BooleanField(default=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=True) forms.py class UserForm(ModelForm): class Meta: model = CustomUser fields = ['email', 'password',] useradd.html <h1 class="display-4">Add new user</h1> <form action="" method="post" autocomplete="off"> {% csrf_token %} {{ form.as_p }} <button … -
Django 'GuideResource' object has no attribute '_meta'
I've upgraded a django project to the latest version 3.1.2 from an older version and one issue is Meta Classes imports. I have this model which intends to inherit meta classes like so class Guide(Contact): operator = models.ForeignKey('guides.SafariOperator', blank=True, null=True, on_delete=models.CASCADE) level = models.ForeignKey('guides.MembershipLevel', blank=True, null=True, on_delete=models.CASCADE) expiry_date = models.DateField(default=django.utils.timezone.now) language = models.ManyToManyField('guides.Language', blank=True) class Meta: ordering = ['name'] class GuideResource(resources.ModelResource): id = fields.Field(column_name='Bd/Sr', attribute="id") sortorder = fields.Field(column_name='Bd/Sr', attribute="sortorder") #description = fields.Field(column_name='Company', attribute="description") address = fields.Field(column_name='Wk PO Box', attribute="address") telephone = fields.Field(column_name='Tel', attribute="telephone") fax = fields.Field(column_name='Fax', attribute="fax") email = fields.Field(column_name='E-mail', attribute="email") class Meta(Guide): pass which then throws this error Traceback (most recent call last): File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 233, in inner return view(request, *args, **kwargs) File "/home/sammy/webapps/kpsga/import_export/admin.py", line 154, in import_action context['fields'] = [f.column_name for f in resource.get_fields()] File "/home/sammy/webapps/kpsga/import_export/resources.py", line 113, in get_fields return [self.fields[f] for f in self.get_export_order()] File "/home/sammy/webapps/kpsga/import_export/resources.py", line 296, in get_export_order return self._meta.export_order or self.fields.keys() Exception Type: AttributeError at /admin/guides/guide/import/ Exception Value: 'GuideResource' object … -
Django Form: comma separated decimal numbers throwing validation errors
I have a form where user can enter decimal/integer values as comma separated like, 500,000 or 500,000.00. When I process the field using the Django ModelForm it raises the validation error like Enter a number, I want to remove those "," before the value makes into the DB. My Form: class EmployeeSalaryForm(forms.ModelForm): class Meta: model = Salary fields = [ 'basic_salary', 'convyence_allowance', 'medical_allowance', 'mobile_allowance', 'executive_allowance', 'gross_salary', 'epf', 'health_benefit', 'ctc', 'join_bonus', 'var_pay', ] basic_salary = forms.DecimalField(max_digits=11,decimal_places=2) convyence_allowance = forms.DecimalField(max_digits=11,decimal_places=2) medical_allowance = forms.DecimalField(max_digits=11,decimal_places=2) mobile_allowance = forms.DecimalField(max_digits=11,decimal_places=2) executive_allowance = forms.DecimalField(max_digits=11,decimal_places=2) gross_salary = forms.DecimalField(max_digits=11,decimal_places=2) epf = forms.DecimalField(max_digits=11,decimal_places=2) health_benefit = forms.DecimalField(max_digits=11,decimal_places=2) ctc = forms.DecimalField(max_digits=11,decimal_places=2) join_bonus = forms.DecimalField(max_digits=11,decimal_places=2, required=False) var_pay = forms.DecimalField(max_digits=11,decimal_places=2, required=False) def clean_basic_salary(self): basic_salary = self.cleaned_data['basic_salary'] return basic_salary.replace(',', '') def clean_convyence_allowance(self): convyence_allowance = self.cleaned_data['convyence_allowance'] return convyence_allowance.replace(',', '') def clean_medical_allowance(self): medical_allowance = self.cleaned_data['medical_allowance'] return medical_allowance.replace(',', '') def clean_mobile_allowance(self): mobile_allowance = self.cleaned_data['mobile_allowance'] return mobile_allowance.replace(',', '') def clean_executive_allowance(self): executive_allowance = self.cleaned_data['executive_allowance'] return executive_allowance.replace(',', '') def clean_gross_salary(self): gross_salary = self.cleaned_data['gross_salary'] return gross_salary.replace(',', '') def clean_epf(self): epf = self.cleaned_data['epf'] return epf.replace(',', '') def clean_health_benefit(self): health_benefit = self.cleaned_data['health_benefit'] return health_benefit.replace(',', '') def clean_ctc(self): ctc = self.cleaned_data['ctc'] return ctc.replace(',', '') def clean_join_bonus(self): join_bonus = self.cleaned_data['join_bonus'] return 0 if join_bonus == None else join_bonus.replace(',', '') def clean_var_pay(self): var_pay = self.cleaned_data['var_pay'] return 0 … -
How to rename default "id" field in django
Is there any way to rename the default Primary key(model) Value "id".(I am not talking about my own created fields)? admin.py class ShiftChangeAdmin(ImportExportModelAdmin): list_display=['id','ldap_id','Vendor_Company','EmailID','Shift_timing','Reason','last_updated_time'] -
Integrating Google Calendars API into Django
I found some examples on using the API in Python, but I was wondering if there is any guidance or examples on using the Calendars API in a Django project. For our website, we want users to be able to enter an event name, start time, and number of hours (event duration) into a form, and for this information to then be used to generate the appropriate Google Calendars event. One concern we had was that the start/end date strings look like they are very specifically formatted, so we were wondering how to translate the form input into start/end time strings. -
How can I call parent's parent class method withouting calling parent's method when using chaining inheritance?
I have a serializer class looks like this: class BargainOrdersAdminSerializer(BargainOrdersSerializer): def update(self, instance, validated_data): if validated_data.get('logistics_company') and validated_data.get('logistics_tracking_no'): validated_data.update(is_shipped=True) return super().update(instance, validated_data) # here, it will also call `BargainOrdersSerializer`'s update method which is not I am expected. As you can see, it inherits from another serializer class as below: class BargainOrdersSerializer(ModelSerializer): ...... def update(self, instance, validated_data): order = instance.order order.status = 'W' order.save(update_fields=['status']) wxpay_query.apply_async((order.id,), countdown=60, link_error=wxpay_error_handler.s(order.id)) return super().update(instance, validated_data) Which also override update method. And now, when I call super().update(instance, validated_data) in child class BargainOrdersAdminSerializer, it calls its parent class's overrided update also which is not I am expected. I want to ignore it. One approach I can figure out is copying the update source code in ModelSerializer and write some custom code in BargainOrdersAdminSerializer's update method. But, it is stupid right? How can I handle it properly? -
How to Access the Logic from a Docker Container?
I am working with a Django App now, and I am new with Docker and a Rookie who is trying turn the App into Microservices. The logics and models I am using are written in a common file. What approach do I have to follow so that I can make my loosely coupled as Microservice? -
Connecting Django models to database names with primary key name other than ID
I have a project where primary column name is 'N' in place of standard 'id'. I have no access to the original database to change it, so I hoped that the following code will do the trick: class ExSLoc(models.Model): id = models.IntegerField(primary_key=True, db_column='n') class Meta: db_table = original_db_table managed = False It actually does, but I run into a strange bug from Django model forms, telling that: 'ExSLoc' object has no attribute 'id' Here's the full traceback. | Traceback (most recent call last): website_1 | File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 174, in get_response website_1 | response = self.process_exception_by_middleware(e, request) website_1 | File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 172, in get_response website_1 | response = response.render() website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 160, in render website_1 | self.content = self.rendered_content website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 137, in rendered_content website_1 | content = template.render(context, self._request) website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/backends/jinja2.py", line 70, in render website_1 | return self.template.render(context) website_1 | File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1090, in render website_1 | self.environment.handle_exception() website_1 | File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 832, in handle_exception website_1 | reraise(*rewrite_traceback_stack(source=source)) website_1 | File "/opt/project/templates/rfs_submission/rfs_new_0.html", line 1, in top-level template code website_1 | {% extends "rfs_submission/rfs_new.html" %} website_1 | File "/opt/project/templates/rfs_submission/rfs_new.html", line 9, in top-level template code website_1 | {% … -
I want to host my django webpage from my computer publically (Globally)
I've made a django app which I want to host from my own computer using my public IP such that anyone from any part of the world can access it through http://0.0.0.0:8000 where the 0's will be replaced by my public IP. In simple words, I want to make my computer the server for my website. Can anyone help? -
hide previous collapse when i press on other button and show button data - django
hello i want to hide previous collapse when i press on other button and show button data I'm using this format , my problem is data keep show when i press on other button ... i want show just the data when i press on some button and hide other data my html code : <div class="d-flex justify-content-center"> <div class="btn-group" role="group" aria-label="Basic example"> <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#phone_pics" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> phone pics </button>&nbsp; <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#space" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> phone space </button>&nbsp; <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#review" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> review </button>&nbsp; </div> </div> <!-- this for phone pics --> <div id="phone_pics" class="collapse" aria-expanded="true"> <br> <div class="d-flex justify-content-center"> <div class="img"> {% for img in mobile_posts.mobile_images_set.all %} <div class="d-flex justify-content-center"> <img src="{{img.get_image}}" class="img-responsive img-thumbnail" width="50%" height="80%"> </div> {% endfor %} </div> </div> </div> <!-- this for review --> <div id="review" class="collapse" aria-expanded="true"> <br> <iframe width="100%" height="400px" src="{{mobile_posts.mobile_review_video}}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> </div> <!-- this for space --> <div id="space" class="collapse show" aria-labelledby="headingOne" > <br> </div> -
Get class name of descendant in mixin
I want to get the name of the descendant class in the mixin for GenericRelation in Django. Do you have any ideas on how to do that? class ItemMixin: items = GenericRelation(Item, related_query_name="Here I want to get name of a child class") -
How to resolve django react app with webpack?
I am creating django + react project.So instead of running npx create-react-app my-app I created this folder structure inside the frontend django app. To run react components I have webpack with script like this inside package.json file "scripts": { "dev": "webpack --mode development ./frontend/src/index.js -o ./frontend/static/frontend/main.js", "build": "webpack --mode production ./frontend/src/index.js -o ./frontend/static/frontend/main.js" } ├── src │ ├── components │ │ ├── App.js │ │ └── layout │ │ └── Header.js │ └── index.js ├── static │ └── frontend │ └── main.js ├── templates │ └── frontend │ └── index.html ├── tests.py ├── urls.py └── views.py so when I run npm run dev It will see main.js as package and it will create ./frontend/static/frontend/main.js/main.js** as the compiled output file. so when I run django server it will show static file main.js not found (means HTTP 404). So how do I resolve this issue? -
django orm cumulate values of count from group by function
I am new to Django and ORM, and I could not figure out ORM query for cumulate group by count value. Let's make a model simpler with columns with id, reg_dt. What I am trying to do is to get the number of registered users daily, and cumulate the counted number. id | reg_dt 1 | 2020-11-16 2 | 2020-11-16 3 | 2020-11-17 4 | 2020-11-17 5 | 2020-11-17 6 | 2020-11-18 Info.objects.values('reg_dt').annotate(tot_cnt=Count('reg_dt')).order_by('reg_dt') This orm query gives me reg_dt | tot_cnt 2020-11-16 | 2 2020-11-17 | 3 2020-11-18 | 1 And I finally want to make the result something like reg_dt | cumsum 2020-11-16 | 2 2020-11-17 | 5 2020-11-18 | 6 What would be the approach to get cumulated values? -
How to use Django ORM outside of a Django directory?
This is the file structure I want: ./overall_project_directory ./my_django_project ...django stuff ./my_gui ...gui stuff django_and_gui_meet.py Ideally, Django knows nothing about the GUI and the GUI knows nothing about Django for separation of concerns reasons. django_and_gui_meet.py is the only file that contains both Django models and GUI elements. I have read all of these questions: 1, 2, 3, 4, 5, 6. I've also looked at these templates: 7, 8. I've also looked at the Django Docs for using Django without an settings file. I still can't figure out if what I want to accomplish is possible. What I've Tried This is the current file structure I have for a test repo: django_standalone_orm/ ├── db # this is a django project made with `django-admin startproject db` │ ├── db │ │ ├── asgi.py │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── db.sqlite3 │ ├── __init__.py │ ├── manage.py │ ├── people │ │ ├── admin.py │ │ ├── apps.py │ │ ├── in_directory_ui.py # cannot load django models here │ │ ├── __init__.py │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ ├── __init__.py │ │ ├── models.py │ … -
django-ckeditor: Is there a django config/setting to get <br> instead of <br />?
I'd like to have <br> elements from CKEditor instances like that, not <br />. I found this question with an answer, but I don't know where that code should go, in config.js? In my <script> element/JS file? And, actually, I want to know if I can use a config in CKEDITOR_CONFIGS to change this. Why the <br />? Also, why do I get a newline after the <br> element in the HTML? This causes me to get <br />\r\n in my model instance attributes and thus, in my database. The \r\n won't actually cause a problem, but it would be easier if I get rid of it; I think <br> should suffice. -
nginx 404 on root/homepage with Django + Gunicorn
I'm migrating my website from one host to another. The migration has been mostly 99% successful except for the fact that whenever I navigate to the home page of the site, I get nginx's 404 page. Every other page, static & media file is rendered properly. I've wracked my brain trying to find a solution but I haven't found any, let alone someone having a similar issue (instead, others have a working home page but 404 on all others). I have two different domains (one that my company owns, the other is owned by the city we're in). I've updated the DNS on the domain I own to ensure it's working with the new host and it is. When I navigate using the host (example.com) or the server's IP address, the website loads all pages correctly - except the homepage, which - again - returns nginx's 404. All other 404 errors display the 404 page I've set up via Django. Whenever this issue crops up, the gunicorn error log adds a line stating that the service is 'Booting worker with pid: ...' nginx.conf --> save for the paths and port, this conf is identical to the conf running on my … -
Django img src and variety of browsers / OS
I have html documents from django project on which pictures are displayed normally. <!DOCTYPE html> <html> <head> </head> <body> {% load static %} <img src="{% static '/img/bOGlcNacDB_Logo.png' %}"> </body> </html> This is working normally on Linux, Windows, Firefox/Chrome, but not on MacOS Safari/Chrome. Only Firefox. I found out that if I simply replace the src by a random image url, then it is working everywhere: <!DOCTYPE html> <html> <head> </head> <body> {% load static %} <img src="http://...jpg"> </body> </html> But then I am stuck and wonder if there is not something specific to django that I would not know. I tried: <img src="http://mywebsite/...png"> <img src="/...png"> <img src="../../static/img/...png"> No success. Thanks for helping to make this working on MacOS Safari/Chrome.