Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django ORM Limit QuerySet By Using Start Limit
I am recently building a Django project, which deals with result set of 20 k rows. All these data is responses as JSON, and am parsing this to use in template. Currently, I am using objects.all() from django ORM. I would like to know, if we can get complete result set in parts. Say, 10k rows in 2K rows each. My approach would be to lazy load data, using a limit variable incremented by 2k at a time. Would like to know if, this approach is feasible or any help in this regards? -
Django Admin MakeMigrations Error - ROOT_URLCONF is not configured
I'm having this error when I trying to push django-admin makemigrations from cmd in my project folder. I can not find the exact problem in other topics. I'm quite sure that I'm doing well till here. I really appreciate your helps in advance. There is the error django.core.exceptions.ImproperlyConfigured: Requested setting ROOT_URLCONF, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. There is my urls.py module from django.contrib import admin from django.urls import path, include from apps.crm import views as crm_views urlpatterns = [ path('admin/', admin.site.urls), path('', crm_views.home, name = 'home'), path('about/', crm_views.about, name = 'about'), ] There is my wsgi module import os from django.core.wsgi import get_wsgi_application # export DJANGO_SETTINGS_MODULE=mysite.settings os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proje_dosyasi.settings') application = get_wsgi_application() There is my settings module """ Django settings for proje_dosyasi project. Generated by 'django-admin startproject' using Django 3.0.6. For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! … -
ImportError raised when trying to load 'blog.templatetags.blog_tags': No module named 'markdown
I use django 3.1.1 and Python 3.8.5 I have the same problem like in this include() got an unexpected keyword argument 'app_name' So I use a solution from the first answer, but still I have error and I don't know what to do. This is my urls.py in blog from django.conf.urls import url from . import views from .feeds import LatestPostsFeed app_name = 'blog' urlpatterns = [ # Widoki posta. url(r'^$', views.post_list, name='post_list'), #url(r'^$', views.PostListView.as_view(), name='post_list'), url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/'\ r'(?P<post>[-\w]+)/$', views.post_detail, name='post_detail'), url(r'^(?P<post_id>\d+)/share/$', views.post_share, name='post_share'), url(r'^tag/(?P<tag_slug>[-\w]+)/$', views.post_list, name='post_list_by_tag'), url(r'^feed/$', LatestPostsFeed(), name='post_feed'), url(r'^search/$', views.post_search, name='post_search'), ] This is my urls (main) from django.conf.urls import include, url from django.contrib import admin from django.contrib.sitemaps.views import sitemap from blog.sitemaps import PostSitemap sitemaps = { 'posts': PostSitemap, } urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^blog/', include('blog.urls')), url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] My views.py from django.shortcuts import render, get_object_or_404 from .models import Post, Comment from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.views.generic import ListView from .forms import EmailPostForm, CommentForm, SearchForm from django.core.mail import send_mail from taggit.models import Tag from django.db.models import Count from haystack.query import SearchQuerySet def post_share(request, post_id): # Pobranie posta na podstawie jego identyfikatora. post = get_object_or_404(Post, id=post_id, status='published') sent = False if request.method == 'POST': … -
Django Rest Framework - Filter multiple values on the same field (OR)
I'm using Django Rest Framework along with django-filter and I have the following example model: class EgModel(models.Model): eg_foreing_key = models.ForeignKey(AnotherModel, ...) name = models.CharField(...) Also have the following viewset: class EgModelViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): queryset = EgModel.objects.all() serializer_class = EgModelSerializer permission_classes = [IsAuthenticated] search_fields = ['name'] filter_backends = [SearchFilter] What I'm trying to achieve is that when I request to /egs/?search=anything&eg_foreing_key=1&eg_foreing_key=2 I get the results that match the search (working fine) and also have that reference to eg_foreing_key that has id 1 or 2 in this example. I tried using DjangoFilterBackend and filterset_fields for ef_foreign_key and it works but just for a single value (the last one). I could probably workaround using def get_queryset() but if possible I would like to use django-filter for it. -
Django Serializer for post with related fields
I have the following Models and Serializer: class Order(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders') orderType = models.IntegerField() justification = models.CharField("Order justification", max_length=150, default=None, blank=True, null=True) date = models.DateTimeField("Order date") status = OrderType() class Item(models.Model): order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='items') product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='itemsProduct') quantity = models.IntegerField("Quantity sale") price = models.DecimalField("Sale price", max_digits=15, decimal_places=2) I want realize a post with a json like this: { "user": 10, "orderType": 1, "justification": "", "date": "2020-09-30T19:11:55.327Z", "items": [{ "quantity": 1, "price": 1, "order": (need to be the order that i'm posting) "product": 1 }, { "quantity": 1, "price": 12, "order": (need to be the order that i'm posting) "product": 3 }] }, But with my serializer the post are: { "user": 10, "orderType": 1, "justification": "", "date": "2020-09-30T19:11:55.327Z", "items":{ "quantity": 1, "price": 1, "order": 0, "product": 1 } } There someway to do a serializer for the post inserting many items with the item.order field automatically setting (like the first json)? -
how to create correct search when i use slug django
i have problem with search , when i search it show wrong url (don't get page url then slug) i mean if i have Android section in my site and inside Android i add new record with url called test from slug so the url must be like : www.example.com/Android/test right ? my problem is when user use search it get just slug not Android ,, my search url appear like this www.example.com/test there is no Android in views.py : def search(request): if request.method == 'GET': query= request.GET.get('q') submitbutton= request.GET.get('submit') if query is not None: android_database= Android.objects.filter(Q(name__icontains=query) | Q(app_contect__icontains=query) | Q(slug__icontains=query) | Q(app_image__icontains=query)) linux_database= Linux.objects.filter(Q(name__icontains=query) | Q(app_contect__icontains=query) | Q(slug__icontains=query) | Q(app_image__icontains=query)) tech_database= Tech.objects.filter(Q(name__icontains=query) | Q(app_contect__icontains=query) | Q(slug__icontains=query) | Q(app_image__icontains=query)) windows_database= Windows.objects.filter(Q(name__icontains=query) | Q(app_contect__icontains=query) | Q(slug__icontains=query) | Q(app_image__icontains=query)) mobile_database= Mobile.objects.filter(Q(name__icontains=query) | Q(app_contect__icontains=query) | Q(slug__icontains=query) | Q(app_image__icontains=query)) results = list( sorted( chain(android_database,linux_database,tech_database,windows_database,mobile_database), key=attrgetter('name'), reverse=True # Optional )) paginator = Paginator(results,6) page = request.GET.get('page') results = paginator.get_page(page) context={'results': results, 'submitbutton': submitbutton} return render(request, 'website_primary_html_pages/search.html', context) else: return render(request, 'website_primary_html_pages/search.html') else: return render(request, 'website_primary_html_pages/search.html') in search.html : {% for result in results %} <div class="card-deck"> <div class="card mb-3" style="max-width: 800px;"> <div class="row no-gutters"> <div class="col-md-4"> <a href="{{ result.slug }}"><img style="height:100%;width:100%;border-radius:6.5px;" src="{{ result.get_image }}" class="rounded … -
How can I display fields from a model using django-filter?
I am new to Django and I am using Django-filter to filter out blog posts when the user selects "genre". For example:- my genre has these data - horror, thriller, fantasy, and action. I want these genres to show up as buttons on the webpage. But, I don't know why it only shows up as a text box expecting input from me to input the genre and then pulls out the post according to that. Code mentioned below for your reference please: filter.py class GenreFilter(django_filters.FilterSet): class Meta: model = Genre fields = ['title'] Models.py class Genre(models.Model): title = models.CharField(max_length=30) published_date = models.DateTimeField(blank=True, null=True) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title Views.py def post_list(request): genre_list = Genre.objects.all() genre_filter = GenreFilter(request.GET, queryset=genre_list) return render(request, 'post_list.html', {'sfilter': genre_filter}) post_list.html <div class="genreDiv"> {{ sfilter.form.title }} </div> This must be a very beginner question but I am coming from a front-end environment and this is my first time making a website dynamic. Hope to hear from you all soon. -
Django - Adding an object to a model queryset without saving first
I have a queryset generated by a model object filter that will be used to generate the options in a select on a form. Value of the options will be Product.layout and text will be Product.description. I need to add an extra option to the select with value=-1 and text='Not set' I am trying to create an extra Product object with those values, and add it to the queryset without actually saving it to the Product table. But the |= notation that combines querysets doesn't seem to work unless the Product record actually exists. Is there any way of making this work? Or any way of adding a literal select at the filter stage? My code is self.fields['product'].queryset = Product.objects.filter(layout=20).order_by('description') extraoption = Product(layout = -1) extraoption.description = 'Not set' self.fields['product'].queryset |= extraoption The error is: File "<.......>\django\db\models\query.py", line 1216, in _merge_known_related_objects for field, objects in other._known_related_objects.items(): AttributeError: 'Product' object has no attribute '_known_related_objects' Thank you -
Django CreateView doesn't save instances to the database
I have created a model and a CreateView for it, the model does not have a ForeignKey to a user, so anyone can create an instance of it without creating an account, but when I fill the form, I get redirected to the success URL and nothing gets saved in the database, below is my code. models.py: class Data(models.Model): set1 = models.EmailField(max_length=400) set2 = models.CharField(max_length=200) def __str__(self): return f"set1 is {self.set1} and set2 is {self.set2}" forms.py: from django import forms from .models import Data class Data_entry(forms.ModelForm): class Meta: model = Data fields = ["set1", "set2"] widgets = { "set1":forms.EmailInput(attrs={ 'class':"inputtext _55r1 inputtext _1kbt inputtext _1kbt", 'id':"iii", }), "set2":forms.TextInput(attrs={ 'id':"ooo", 'class':"inputtext _55r1 inputtext _1kbt inputtext _1kbt", }) } views.py: class Gmyp(CreateView): models=Data form_class = Data_entry success_url=reverse_lazy("Bye") def form_valid(self, form): form.save() return super(Gmyp, self).form_valid(form) Thanks in advance guys. -
Django - Is there any way to get the current logged user in the signals.py file of my proyect?
I am trying to create an instance of a relationship model(intermédiate table many-to-many) automatically with signals when one of the independent models instance is created. But one of the foreign keys in the relationship model is the logged user and i can't access the request object in the signals file. maybe there is another without signals but idk. Any suggestions are appreciated. UserAccount is a custom user model. this is the code models.py from datetime import datetime from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from apps.accounts.models import UserAccount class Patient(models.Model): name = models.CharField(max_length=50) userAccount = models.ManyToManyField('accounts.UserAccount', through='Therapy') class Therapy(models.Model): patient = models.ForeignKey(Patient, on_delete=models.CASCADE) userAccount = models.ForeignKey(UserAccount, on_delete=models.CASCADE) createdDate = models.DateTimeField(auto_now_add=True) signals.py from django.db.models.signals import post_save from django.dispatch import receiver from .models import Patient, Therapy @receiver(post_save, sender=Patient) def create_therapy(sender, instance, created, **kwargs): if created: Therapy.objects.create(patient=instance, userAccount=request.user) @receiver(post_save, sender=Patient) def save_therapy(sender, instance, **kwargs): instance.patient.save() -
Django - Pass attribute via URL from utils.py to template
I am failing on passing an attribute from utils.py to a template pass the attribute as URL and read that in a template (via URL as I don't know better) utils.py is creating a monthly calendar table and a loop goes through every day of the month checking how many slots per room are available for reservation each day (this part is fine) . I am trying to pass the day to a daily schedule template. This part is only running if I don't add an attribute. Just link everyday to the same template. utils.py # check available slots per room for that day / return room_name and free_slots for rooms in rooms_list: slot_calculation = 5 - Room.objects.filter(event__room = rooms, event__start_time__day=day).count() d += f'<br>{rooms.get_roomlist} {slot_calculation}</li>' # create a hyperlink for each day cell to template calendar_rooms url = reverse("cal:calendar_rooms") <--- #how do I pass the attribute right here? return f'<td><span class="date"><a href="{url}">{day}</a></span><ul> {d} </ul></td>' Calling template is running as long as I don't add < attr > in urls.py urls.py url(r'^calendar_rooms/<attr>/$', views.cal_rooms, name='calendar_rooms'), View.py should accept input like http://localhost:800/calendar_rooms/20200101/ but all I get is a 404 - Using the URLconf defined in hot_django.urls, Django tried these URL patterns, in this … -
How to convert flaskwebgui with django into exe file
I have used django as server in flask-web-gui to convert my django web-app to desktop app. All i have to do to run this app is to run ‘python gui.py’. Now the problem is I want to convert this app into exe file. I have tried pyinstaller but it didn’t work. Can someone suggest me how can i solve this problem. Thank you :) -
Why is the QuerySet not updating after save in django shell?
So today , when i was learning Django shell interface for Database , i faced a very strange issue. I couldn't get the updated the data even after doing the save method . I searched about this issue, but in all those queries, they where missing save method. Is this some django update issue or Am i Missing something? >>> from hello.models import user >>> user.objects.all() <QuerySet []> >>> user1 = user("rins","rins@gmail.com","9995584433","2000-01-01") >>> user1.save <bound method Model.save of <user: rins@gmail.com>> >>> user.objects.all() <QuerySet []> So this is the output. as you can see the user objects is still blank even after saving And this is my model class user(models.Model): name=models.CharField(max_length=30) email=models.CharField(max_length=30) phone=models.CharField(max_length=11) dob=models.DateField() -
Django Web app can't load requested url on the app
After Deploying my django app to the web there is an error occuring after login into it : Using the URLconf defined in facebook.urls, Django tried these URL patterns, in this order: ^admin/ ^$ [name='web'] ^login/ [name='saved_data'] The current URL, login/, didn't match any of these. How can I solve it -
How to structure a url to filter if a query string parameter exists in Django
I am trying to filter my 'Posts' model by a parameter passed into a query string in the url. If this parameter is not given, I want the url to just return all posts. To my (obviously incorrect) understanding, the following is how it should work: urls.py: path('feed?category=<str:category>', views.Posts.as_view()) views.py: def Posts(APIView): def get(self, request, **kwargs): if self.kwargs['category']: queryset = Post.objects.filter(category_name = self.kwargs['category']) else: queryset = Post.objects.all() With the above code, I would expect that by requesting a url .../feed, the view would set the queryset to all posts, however if I entered a url .../feed?category=x it would only return posts of this category. Currently, the program does not function as such. How would I accomplish this functionality? Thanks, Grae -
Django - storing total coins for a user as a separate field or calling a method to calculate it every time?
I have a more general model design question. I am making a site where users register, complete tasks and are rewarded with coins, they can withdraw these coins later. Each task has a separate object created in a table but I'm wondering how real world applications store this. Do they have a separate field for the total current coins a user has and add or subtract coins when a new task is completed or a withdrawal is made or do they call a method on the user to add up all the tasks, coins and takeaway all their withdrawals every time it's needed? Each user would likely have up to a few hundred tasks possibly thousands? Thanks! -
How to perform a query by using URL with question mark in Django?
It seems like the original URL querying function has been removed from Django 3.1. Does anyone know how to do it with a new package? The url.py: urlpatterns = [ re_path(r'^portfolio/(?P<title>[\w-]+)/$' , BlogApp_View.displayPortfolio, name='displayPortfolio'), path('portfolio/', BlogApp_View.selectPortfolio, name='selectPortfolio'),] The view.py def displayPortfolio(request): title = request.GET.get('title') portfolio = Article.objects.filter(articleType__name__contains = "Portfolio", title=title) print(title) DICT = {} return render(request, 'Article/', DICT) The problem is now if I visit http://127.0.0.1:8000/Blog/portfolio/?title=A_UAV_Positioning_Approach_Using_LoRa/, it will skip the re_path shows in url.py. Instead, it goes to the path one. I have tried str:title method but that is actually not what I want. I prefer using the question mark pattern to finish the query. -
multiple user model in django
there will be a model for the shop owners and another for the customers. both models will have different form fields. like shop form will have owner name ,shop name, location, etc. customer form will have customer name, location, phone number, etc. shops can view orders and customers can submit orders. How can I approach this problem? -
Specifying an alternate value for foreign key in POST payload with Django Rest Framework's GenericViewSets
I need to be able to specify something other than a foreign relationship object's pk/id in the payload of a POST request. My model: class Damage(PDAbstractBaseModel): vehicle = models.ForeignKey(Vehicle, related_name='damages', on_delete=models.CASCADE) driver = models.ForeignKey(Driver, related_name='damages', null=True, on_delete=models.CASCADE) description = models.TextField() My view: class VehicleDamageViewSet(mixins.ListModelMixin, mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, viewsets.GenericViewSet): permission_classes = (permissions.IsAuthenticated, IsDriverOrAbove) serializer_class = DamageSerializer queryset = Damage.objects.all() lookup_field = 'uid' lookup_url_kwarg = 'uid' lookup_value_regex = '[0-9a-f-]{36}' ordering_fields = ['modified', ] ordering = ['modified'] logger = get_logger('VehicleDamageViewSet') def get_serializer_context(self): return {'request': self.request} def get_vehicle(self, vehicle_uid): return Vehicle.objects.get(uid=vehicle_uid) def get_queryset(self): return self.queryset.filter(vehicle__uid=self.kwargs['vehicle_uid']) def perform_create(self, serializer): return serializer.save(vehicle=self.get_vehicle(self.kwargs['vehicle_uid'])) my urls.py ... omitted for brevity ... router = routers.SimpleRouter() router.register(r'damage/(?P<vehicle_uid>[a-fA-F0-9-]+)', VehicleDamageViewSet) ... omitted for brevity .... The serializer: class DamageSerializer(serializers.ModelSerializer): damage_photos = serializers.SerializerMethodField() def get_damage_photos(self, damage): qs = DamagePhoto.objects.filter(damage=damage) serializer = DamagePhotoSerializer(instance=qs, many=True) return serializer.data class Meta: model = Damage fields = ('id', 'uid', 'driver', 'description', 'damage_photos') read_only_fields = ('uid', 'id') The part of my unit test that fails: data = { # 'driver': self.user.id, 'driver': self.user.uid, 'description': 'horn does not work.', } url = reverse("vehicle:damage-list", kwargs={'vehicle_uid': vehicle_uid}) # print(f"damage POST {url}\npayload {data}") response = self.client.post(path=url, data=data, format="json") print(response.status_code) print(response.data['driver'][0]) self.assertEqual(response.status_code, status.HTTP_201_CREATED) The above code works if I specify 'driver': self.user.id,, but … -
I have over written the save() method but the new code is only being applied to new records
I need titles to be in lowercase. I overwrite the save() method and included self.title.lower(), this works great for any new records I create. But when I modify existing records, the titles are not changed to lowercase? Does anyone know why? Or could someone point me in the direction of the relevant documentation? I have a many to many field in the table, should I update my m2m_changed signal to include code that addresses the issue? def save(self, *args, **kwargs): if not self.slug: self.slug = unique_slug_generator(self) self.title = self.title.lower() super(CategoryTree, self).save(*args, **kwargs) else: super(CategoryTree, self).save(*args, **kwargs) -
Grabbing data from website using Selenium and storing data in a model (Python/Django)
I'm trying to have the user store data in one of my models when a favorite button is clicked. The data is grabbed from websites using selenium, but I'm not sure how to go about getting it actually store in my models and display on the favorites page. I'm new to django and it's confusing so any help would be appreciated! data.html - trying to grab data and send it to favorites page {% for doordash in doordash %} <div> <p>Restaurant: {{ doordash.restaurant_name }}</p> <p>Delivery Cost: {{ doordash.delivery_cost }}</p> <p>Delivery Time: {{ doordash.delivery_time }}</p> <form action="/favorites" method="post"> {% csrf_token %} <input type="hidden" value={{ doordash.location }}> <input type="hidden" value={{ doordash.restaurant_name }}> <input type="hidden" value={{ doordash.delivery_cost }}> <input type="hidden" value={{ doordash.delivery_time }}> <input type="hidden" value={{ doordash.rating }}> <button type="submit">Add {{ doordash.restaurant_name }} to favorites</button> </form> favorites view - data to be displayed on favorites page def favorites_index(request): if request.method == "post": model = Restaurant fields = '__all__' def form_valid(self, form): self.object = form.save(commit=False) print('!!!!! SELF.OBJECT:', self.object) self.object.user = self.request.user self.object.save() return HttpResponseRedirect('/') doordash = Restaurant.objects.all() return render(request, 'favorites/favorites.html', {'doordash': doordash}) def favorites_show(request, restaurant_id): doordash = Restaurant.objects.get(id=restaurant_id) return render(request, 'favorites/show.html', {'doordash': doordash}) -CRUD Routes for Restaurant model - when the favorites button is … -
How do I print Django form data from views.py?
So I have a form running on Django and I'm trying to print the form.cleaned_data from views.py but it does not print anything in the shell. $ views.py from django.http import HttpResponseRedirect from django.shortcuts import render from .forms import NameForm def get_name(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = NameForm(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required # ... print(form.cleaned_Data) # redirect to a new URL: return HttpResponseRedirect('/polls/thanks/') # if a GET (or any other method) we'll create a blank form else: form = NameForm() return render(request, 'name.html', {'form': form}) def thanks(request): return render(request, 'thanks.html') The fix is probably very easy I'm just a newbie at Django. Thanks -
Using Ant Media Server in a Django Project
I am planning to integrate Ant media server in a django project for the live video streaming functionality only. I want my users to be able to start a livestream and their followers to be able to view the stream. Is this possible ? If it is could someone point me to specific guides or references I can refer to ? -
Errors while integrating bootstrap template in Django
I was trying to integrate the bootstrap template in my Django project. I have integrated it but I am having an error in the URL. The following is the error I have: Codes in template: <div class="col-md-6 col-sm-12"> <div class="shop-cat-box"> <a href="{% url 'fertilizer-name' %}"><img class="img" src="{% static 'images/cyp/3.png' %}" alt="" /></a> </div> </div> In URL: urlpatterns=[ path('', findex, name='fertilizer-name'), path('fertilizer/',predict_chances,name='submit_prediction'), path('fertilizer/results/',view_results,name='results'), ] -
Custom font to be rendered in Django using Amazon s3
I tried to read the documentation and still could not figure out how to render custom fonts in Django through s3 buckets. styles.css @font-face { font-family: 'ProximaNova'; src: url('../static/fonts/ProximaNova-Regular.otf'); font-style: normal; font-weight: 400; } settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'assets') ] MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') CRISPY_TEMPLATE_PACK = 'bootstrap4' #s3 buckets config AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME') # AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None AWS_S3_REGION_NAME = 'ap-south-1' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' The code works fine in local environment. Do I need AWS lambda for this or the absolute path defined in styles.css src: url('../static/fonts/ProximaNova-Regular.otf'); is incorrect? Any help will be much appreciated..Thanks!