Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
String keys to human readable text in django
I am trying to transform various message keys to a human readable text in a template, for example: database_skill => "Database Skill" experience_3_4 => "3 to 4 years of experience" I tried with internationalization but it doesn't seem to be working correctly. A .po file is generated for en-us, I add the "translation" but I can not see it in the template once I use it: msgid "database_skills" msgstr "Database Skills" Template: {% load i18n %} Translated: {% translate "database_skills" %} => this still shows "database_skills" My settings: LOCALE_PATHS = ( os.path.join(BASE_DIR, "app/locale"), ) LANGUAGE_CODE = "en-us" LANGUAGES = ( ('en-us', 'English'), ) Am I doing something wrong? Or should I go for another approach? -
Secure a django form from altered input value
I have the following models (simplified for the question). class Dossier(models.Model): email = models.EmailField(max_length=200, verbose_name="E-mail") creation_date = models.DateTimeField(auto_now_add=True) status = models.IntegerField(choices=StatusDossier.choices, default=1) uuid = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False) def save(sefl, *args, **kwargs): obj_c, creat_c = Candidat.objects.get_or_create( email=self.email, dossier=self, maindossier=obj ) super(Dossier, self).save(*args, **kwargs) class Applicant(models.Model): email = models.EmailField() first_name = models.CharField(max_length=64, blank=True, null=True) last_name = models.CharField(max_length=64, blank=True, null=True) dossier = models.ForeignKey(Dossier, on_delete=models.CASCADE) Every time Dossier is created, a Candidat is automatically created. Nothing fancy. In my workflow, the said applicant then receives an email with a link that brings him to a Form that he has to fill and submit. Here are the form : class CandidatTourForm(models.ModelForm): class Meta: model = Candidat fields = [ "email", "first_name", "last_name", "dossier", ] It's a rather classical form, nothing special about it. But i've been testing my view function (see below) and I noticed that when I do a POST request using postman, if I alter the dossier id provided in the form (hidden field) and replace it with another existing id, the Candidat is of course saved to the Dossier corresponding to the id given in the POST request. Here is the view: def candidat_form_tour(request, dossier_uuid, candidat_id): dossier = get_object_or_404(Dossier, uuid=dossier_uuid) candidat = … -
How can create, list, and destroy be performed in one view at a time in django?
I made a like model to implement the like function and made a corresponding view so that it would be good to send a post request. By the way, I am going to implement this one view to be unlike if I receive a delete request at once. So I will first use get method to get one like model and then map the pk of that like model to url. But when I send a delete request to the view, the following error appears. Traceback (most recent call last): File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\viewsets.py", line 114, in view return self.dispatch(request, *args, **kwargs) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 505, in dispatch response = self.handle_exception(exc) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception raise exc File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "D:\school\대회 및 프로젝트\CoCo\feed\views.py", line 138, in destroy super().destroy(request, *args, **kwargs) File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\mixins.py", line 90, in destroy instance = self.get_object() File "C:\Users\kurak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\rest_framework\generics.py", line 88, in get_object … -
ValueError at /profiles/user-profile/ Field 'id' expected a number but got 'handsome'
Well I am trying to add or remove user from follower list of particular user and user to toggle and profile of user if correct but it showing me this error when i hit on a follow button . How can i fix it ? models.py class ProfileManager(models.Manager): def toggle_follow(self, request_user, username_to_toggle): profile_ = UserProfile.objects.get(user__username__iexact=request_user) user = request_user is_following = False if username_to_toggle in profile_.follower.all(): profile_.follower.remove(username_to_toggle) else: profile_.follower.add(username_to_toggle) is_following = True return profile_, is_following class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) follower = models.ManyToManyField(User, related_name ='is_following',blank=True,) avatar = models.ImageField(("Avatar"), upload_to='displays', default = '1.jpg',height_field=None, width_field=None, max_length=None,blank = True) create_date = models.DateField(auto_now_add=True,null=True) objects = ProfileManager() viewspy class UserProfileFollowToggle(View): def post(self, request, *args, **kwargs): username_to_toggle = request.POST.get("username") profile_, is_following = UserProfile.objects.toggle_follow(request.user, username_to_toggle) return redirect(f'/profiles/{username_to_toggle}') if more detial is require than tell me i will update my question with that information. -
python: run few lines of code independently and return the value
In my Django project, I am having some user defined code logic which needs to be implemented averageValue=0; for n in range (0,7) averageValue=averageValue+price[1+n]*volume[1+n]; end score=price[1]*volume[1]/averageValue; return score; For this code i will be passing the price[] (array) and volume[] (array) Currently this code is stored in database I can get the code in django using customlogic = CustomLogic.objects.get(id=1)['code'] I want the logic code to run entirely different env, without having access to any other variables in the main code ..main code .. populate price[] (array)` and `volume[] (array)` .. customlogic = CustomLogic.objects.get(id=1)['code'] # get score from the customlogic by passing price[] and volume[] .. score = customlogic (pass) price[] volume[] and then i can save the store in the db -
Running collectstatic command from Dockerfile
My goal is to run collectstatic command inside Dockerfile, but when trying to build the image, I run into KeyError messages coming from settings.py file on lines where environmental variables are used, for example: os.environ['CELERY_BROKER'] This is apparently because the container is not yet built, so Docker does not know anything about the environment variables. Is there any command to import all the variables to Docker? Or maybe it's a bad idea to run the collectstatic command inside Dockerfile and it should be run inside docker-compose file ? Or maybe as part of a CI/CD task ? My Dockerfile looks like this: COPY . /app/ WORKDIR /app RUN . .env RUN python manage.py collectstatic --noinput RUN ls -la -
How to match objects based on selected manytomany in Django orm
Im trying to get objects based on selected/added items in a ManyToMany field. My models: class Location(models.Model): name = models.CharField(max_length=45) class BenefitLocation(models.Model): benefit = models.ForeignKey(Benefit) location = models.ForeignKey(Location) class Benefit(models.Model): locations = models.ManyToManyField(Location, through='BenefitLocation') Here is what Im trying to do in the orm: selected_locations = Location.objects.filter(id__in[1,2]) #Getting IDs from api request matching_benefits = Benefit.objects.filter(locations=selected_locations) In matching_benefits, I only want those with exactly these selected locations. When I try my code, I get this error: django.db.utils.OperationalError: (1242, 'Subquery returns more than 1 row') How can I get the matching_benefits? -
Multivendor Django Ecommerce can it possible?
I'm trying to build a multivendor ecommerce web application like Amazon for example. For this project I used a python with Django, but now I don't know how to create the same page for each supplier, with the ability to each enter their own products and data. I am looking for a tutorial or documentation on this. Can anyone help me ?. Thank you! -
Why is Django admin giving me TemplateDoesNotExist Error
Using Django==3.1, when I try and go to the admin pages, I'm getting the error raise TemplateDoesNotExist(template_name, chain=chain) admin/apidocs_index.html I never used to get this happening. my urls: urlpatterns = [ path('copo/', include('web.apps.web_copo.urls', namespace='copo')), path('admin/', admin.site.urls), path('rest/', include('web.apps.web_copo.rest_urls', namespace='rest')), path('api/', include('api.urls', namespace='api')), path('accounts/', include('allauth.urls')), path('accounts/profile/', views.index), path('', TemplateView.as_view(template_name="index.html"), name='index') ] and template settings TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ # insert your TEMPLATE_DIRS here os.path.join(BASE_DIR, 'web', 'landing'), os.path.join(BASE_DIR, 'web', 'apps', 'web_copo', 'templates', 'copo'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.csrf', 'django.template.context_processors.request', 'django.template.context_processors.static', # processor for base page status template tags "web.apps.web_copo.context_processors.get_status", "web.apps.web_copo.context_processors.add_partial_submissions_to_context", 'django.contrib.auth.context_processors.auth', ], 'debug': True, }, }, ] I don't have any more details to add at this time -
TemplateDoesNotExist at /appname/: deploying on heroku
I have deployed a Django app on heroku. When I visit the url for that app, I get a 'TemplateDoesNotExist at /appname/' error. However, when I run this app locally using heroku local, it runs perfectly. User@Users-MacBook-Air reponame % git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean User@User-MacBook-Air reponame % git push heroku master Everything up-to-date My working tree is clean and my local master branch corresponds to my heroku remote master branch. This means that the code I have locally is the code that is also present on the heroku servers. The exact Django error message I get is: TemplateDoesNotExist at /appname/ appname/Landing.html Request Method: GET Request URL: https://urlname.herokuapp.com/appname/ Django Version: 3.0.8 Exception Type: TemplateDoesNotExist Exception Value: appname/Landing.html Exception Location: /app/.heroku/python/lib/python3.8/site-packages/django/template/loader.py in get_template, line 19 Python Executable: /app/.heroku/python/bin/python Python Version: 3.8.3 Python Path: ['/app/.heroku/python/bin', '/app', '/app/.heroku/python/lib/python38.zip', '/app/.heroku/python/lib/python3.8', '/app/.heroku/python/lib/python3.8/lib-dynload', '/app/.heroku/python/lib/python3.8/site-packages'] Server time: Thu, 15 Oct 2020 11:41:58 +0000 Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.8/site-packages/django/contrib/admin/templates/appname/Landing.html (Source does not exist) django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/templates/appname/Landing.html (Source does not exist) django.template.loaders.app_directories.Loader: /app/beergame/templates/appname/Landing.html (Source does not exist) The view code that renders the above page is as … -
Is it possible to access the user's filesystem and perform CRUD operations on his filesystem using django or node.js?
I want to access the filesystem of the client , and delete some files from his system. is it possible for me to make any website which can perform such task? if yes using what we can perform these? Django?Node.js? or anything else? if not can i perform the same using any other method? like API etc? thanks in advance. -
Django order by multiple related fields
I have a User and Credits model. Every User has a related Credits object. I want to rank/order a list of Users based on multiple fields in the Credits object: credits (amount) games_played_count (amount) last_game_credits (amount) Hence, if two players have an equal amount of credits the one with the highest games_played_count wins. If that is the same the one with the highest last_game_credits wins. Models: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(max_length=255, unique=True) username = NameField(max_length=25, unique=True) class Credits(models.Model): credits = models.IntegerField(default=1000) year = models.IntegerField(default=date.today().isocalendar()[0]) week = models.IntegerField(default=date.today().isocalendar()[1]) games_played_count = models.IntegerField(default=0) last_game_credits = models.IntegerField(null=True) user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="credits", on_delete=models.CASCADE) class Meta: unique_together = ('year', 'week', 'user') View: class RankingListView(generics.ListAPIView): queryset = User.objects.all() serializer_class = RankingsSerializer def get_queryset(self): year = self.request.query_params.get('year', None) week = self.request.query_params.get('week', None) if week and year is not None: prefetchCredits = Prefetch('credits', queryset=Credits.objects.filter(year=year, week=week)) rankings = User.objects.prefetch_related(prefetchCredits) return rankings What I've tried: rankings = User.objects.prefetch_related(prefetchCredits).order_by('-credits__credits', 'credits__games_played_count', 'credits__last_game_credits ) This gives me duplicates. If I remove the duplicates by iterating through the list the ordering on the last 2 fields doesn't work. rankings = User.objects.prefetch_related(prefetchCredits).annotate(creds=Max('credits__credits')).annotate( gcount=Max('credits__games_played_count')).annotate( lgcount=Max('credits__last_game_credits')).order_by('-creds', '-bcount', '-lgcount) Does not give duplicates but ordering on the last 2 fields doesn't work. class Meta: ordering = ['-credits__credits', '-credits__games_played_count', … -
how to display grouped items in django templates?
I have a django template below: {% regroup budget.productitem_set.all by group_id as grouped_product_list %} {% for entry in grouped_product_list %} {% for item in entry.list %} <tbody> <tr> <td>{{ item.description }}</td> <td>{{ item.quantity }}</td> <td>{{ item.group_id }}</td> </tr> </tbody> {% endfor %} {% endfor %} What ends up happening: ID QUANTITY GROUP_ID test123 23 1 test123 24 1 What output I would like ID QUANTITY GROUP_ID test123 23 1 24 -
Show cutomize message in Django Admin on delete of a record
I am trying to change the default error message of django admin to my own message app that should display like a normal message system here is my model for the app class Role(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(null=True, unique=True, blank=False) def __str__(self): return self.name in on other model this model become the forighn key. here is the second model class LearningPath(models.Model): Path_Name = models.CharField(max_length=500) Role = models.ForeignKey(Role, on_delete=models.DO_NOTHING) after that, I have created some roles and then some Learning Paths. the issue is that I when I delete any of Role that is used inside any of Learning Path it shows me the below error what I want is to show the error message in a normal message app as the normal alert div appear. I have tried to write some code in admin.py but it's not working. here is admin.py code class RoleAdmin(admin.ModelAdmin): list_display = ('name',) prepopulated_fields = {'slug': ('name',)} list_per_page = 20 def delete_model(self, request, obj): try: obj.delete() except IntegrityError: messages.error(request, 'This object can not be deleted!') admin.site.register(Role, RoleAdmin) -
Update Quantity and Update Cart Django
Cart View before Checkout def cart_view(request): #for cart counter if 'product_ids' in request.COOKIES: product_ids = request.COOKIES['product_ids'] counter=product_ids.split('|') product_count_in_cart=len(set(counter)) else: product_count_in_cart=0 # fetching product details from db whose id is present in cookie products=None total=0 if 'product_ids' in request.COOKIES: product_ids = request.COOKIES['product_ids'] if product_ids != "": product_id_in_cart=product_ids.split('|') products=models.Product.objects.all().filter(id__in = product_id_in_cart) #for total price shown in cart for p in products: total=total+p.price return render(request,'ecom/cart.html',{'products':products,'total':total,'product_count_in_cart':product_count_in_cart}) Products Model class Product(models.Model): name=models.CharField(max_length=40) product_image= models.ImageField(upload_to='product_image/',null=True,blank=True) price = models.PositiveIntegerField() description=models.CharField(max_length=40) def __str__(self): return self.name I want that in cart page there will be a field which will take "Integer Input " and Update the Total Price Present Cart View Image How i Want I am new and trying and learning so please help me to sort this out Will i need any new model or views ? Thank You -
To convert code from DJANGO SQLite to MYSQL
Have a look at this code : w_in=appnav_dev_report.objects.filter(Q(de_manager=m),Q(date=day),Q(severity='1') | Q(severity='2') | Q(severity='3'),Q(type='incoming')) This code is currently in Django Sqlite format. I need to convert it into MYSQL format. So how to make changes ?? -
How more Foreign Key works in django
I would like to better understand how ForeignKey works in django, how can I refer field1 with barcode and field2 with job? class User(AuditModel): barcode = models.CharField(max_length=10, unique=True, default="not_specified", null=True, blank=True") name = models.CharField(max_length=100, unique=True, null=False, blank=False) surname = models.CharField(max_length=100, null=False, blank=False) job = models.CharField(max_length=100, null=False, blank=False) def __str__(self): return str(self.barcode) class Test_table field1 = models.ForeignKey(User, blank=False, null=False, on_delete=models.CASCADE, related_name="fields1") field2 = models.ForeignKey(User, max_length=100, unique=True, blank=True, null=True, on_delete=models.CASCADE, related_name="fields2")``` Thanks -
Automatically Update Profile Picture in Django
I have written a command which reads a csv file and creates 50+ users at once. Also, I have downloaded a bunch of avatars that I plan to assign randomly to each user. This is where the problem occurs. I have written the code below which assigns a random image as the default image to each user. models.py def random_image(): directory = os.path.join(settings.BASE_DIR, 'media') files = os.listdir(directory) images = [file for file in files if os.path.isfile(os.path.join(directory, file))] rand = choice(images) return rand class UserProfile(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) avatar = models.ImageField(upload_to='avatars', default=random_image) def save(self, *args, **kwargs): # check model is new and avatar is empty if self.pk is None and self.avatar is not None: self.avatar = random_image super(UserProfile, self).save(*args, **kwargs) However, the code seems to run only when the user uploads a picture which is not what I desire. What I want is once the user is logged it, the model should check if it has an avatar and if not, to assign a random image. So, my questions are these: How can I implement this? Because the system keeps checking this after each log in, it seems to me that it is a little inefficient. To replace this strategy, … -
RelatedObjectDoesNotExist at /profiles/user-follow-feed/ User has no user
Well i am just trying to show feed back of the following users but got an error:RelatedObjectDoesNotExist at /profiles/user-follow-feed/ User has no user. I don't understand how can i fix it. Need help to fix it out. many thanks in advance. views.py class FolloweHomeView(View): def get(self, request, *args, **kwargs): user = request.user.userprofile is_following_user_ids = [x.user.id for x in user.follower.all()] qs = Post.objects.filter(username__id__in=is_following_user_ids).order_by("-create_date")[:3] return render(request, "profiles/follower_home_feed.html", {'object_list': qs}) models.py class ProfileManager(models.Manager): def toggle_follow(self, request_user, username_to_toggle): profile_ = UserProfile.objects.get(user__username__iexact=username_to_toggle) user = request_user is_following = False if user in profile_.follower.all(): profile_.follower.remove(user) else: profile_.follower.add(user) is_following = True return profile_, is_following class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) follower = models.ManyToManyField(User, related_name ='is_following',blank=True,) avatar = models.ImageField(("Avatar"), upload_to='displays', default = '1.jpg',height_field=None, width_field=None, max_length=None,blank = True) create_date = models.DateField(auto_now_add=True,null=True) objects = ProfileManager() def __str__(self): return f'{self.user.username}' traceback: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/profiles/user-follow-feed/ Django Version: 3.0.3 Python Version: 3.8.3 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', 'accounts', 'posts', 'profiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\AHMED\anaconda3\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\AHMED\anaconda3\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\AHMED\anaconda3\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\AHMED\anaconda3\lib\site-packages\django\views\generic\base.py", … -
How to use Django rq + wkhtmltopdf?
Asynchronous worker using wkhtmltopdf generate PDF from HTML template, how to do this? HTML template available Please write an example of such code and how to insert it into the ListView -
Wagtail: wrong filepath when I compile the project
I am trying to upgrade Wagtail from 1.13 to 2.0 and I get this error when trying to migrate: RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. And log is: [...] File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ blocks \ field_block.py", line 16, in <module> from wagtail.wagtailcore.rich_text import RichText File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ rich_text.py", line 10, in <module> from wagtail.wagtailcore.models import Page File "C: \ Program Files \ Python36 \ lib \ site-packages \ wagtail \ wagtailcore \ models.py", line 54, in <module> class Site (models.Model): File "C: \ Program Files \ Python36 \ lib \ site-packages \ django \ db \ models \ base.py", line 118, in __new__ "INSTALLED_APPS." % (module, name) RuntimeError: Model class wagtail.wagtailcore.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. I have previously installed everything necessary for the update and I have passed the script to rename the changed fields. In the log you can see that the path that should point to the core actually points to the old version (wagtailcore) … -
I want to write this code using MySQL. It is now in sqlite
w_in=appnav_dev_report.objects.filter(Q(de_manager=m),Q(date=day),Q(severity='1') | Q(severity='2') | Q(severity='3'),Q(type='incoming')) -
Django custom forms Dynamic Raw Id
I have a table with a foreign key. My problem is that ther's a lot of registers, so I need do that: But all I've found was for the Admin Panel. Any idea for a custom form without admin? -
No Python at ...\AppData\Local\Programs\Python\Python38-32\python.exe
I keep getting the below error No Python at 'C:\Users\Arianda Basil\AppData\Local\Programs\Python\Python38-32\python.exe' I have reinstalled Python many times over and added it to PATH but no change. Here is the PowerShell view -
i want to acces static file js and css from my folder django not from aws
I am using django with aws now i have one problem all files come from aws even my js and css i want to use these file my folder right now i have these setting regarding my aws in my setting.py How can i do this? STATICFILES_DIRS = ['static'] STATIC_URL = '/static/' agents aws AWS_ACCESS_KEY_ID = '*********************' AWS_SECRET_ACCESS_KEY = '*********************' AWS_STORAGE_BUCKET_NAME = 'agents' AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = 'public-read' MEDIAFILES_LOCATION = 'media' AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_LOCATION = 'static' STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' ---using in temp--- <link href="{% static 'css/my_style.css'%}" rel='stylesheet'> css i don't want this <link href="https://agents-docs-django.s3.amazonaws.com/static/css/my_style.css" rel='stylesheet'> i want this <link href="/static/css/my_style.css" rel='stylesheet'>