Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can i make people selected 2 choices between 3 options?
I want users to choice 2 selection of my checkbox how can i do that by using Django? I ve tried that forms.py class KaydolForm(forms.ModelForm): secim = (('Bk','banka kartı'),('kk','Kredi Kartı'),('cek', 'çek')) secims=forms.ChoiceField(choices=secim, widget=forms.RadioSelect) but i can choose only one of them -
how to register and get data as json format from third party website in django using user authentication?
Suppose the website owner has given me a authorization token.Now using this token how to fill up a form and then get data as json format using this token from this website? -
File upload with apollo-upload-client not working with django graphene-file-upload backend
I am trying to create a simple imageboard with django backend and react frontend that are connected using GraphQL. I am having trouble trying to create a form that allows users to create new threads.The textual data uploads fine but any files attached with the form are not uploaded to the backed instead {} (an empty dictionary?) is uploaded instead of any files. I have read this answer on SO that evidently solved that users propblem, but I did not understand how and why it worked. Here is my thread model class Thread(models.Model): board = models.ForeignKey( Board, on_delete=models.CASCADE, related_name='thread' ) name = models.CharField(max_length=10, default="Anon") subject = models.CharField(max_length=100, blank=True) content = models.CharField(max_length=3000) files = models.FileField(upload_to="upload/", blank=True) , the schema for thread mutation class ThreadInput(graphene.InputObjectType): name = graphene.String() board_id = graphene.Int(required=True) subject = graphene.String() content = graphene.String(required=True) files = Upload(required=True) # grahene_file_upload.scalars.Upload class CreateThread(graphene.Mutation): thread = graphene.Field(ThreadType) class Arguments: thread_data = ThreadInput() def mutate(self, info, thread_data): thread_data['board'] = Board.objects.get(id=thread_data['board_id']) thread_data.pop('board_id') thread = Thread(**thread_data) thread.save() return CreateThread(thread=thread) and the frontend form for creating new thread. const CREATE_THREAD = gql` mutation createThread( $name: String $boardId: Int! $subject: String $content: String! $files: Upload! ) { createThread ( threadData: { name: $name boardId: $boardId subject: $subject … -
Django: How to create one Class Based view with two models which have one-to-many relationship?
I want users be able to create a post with multiple images (that's why I have separate models). How am I able to do that using class based views and one template? models.py class UserPost(models.Model): id = models.AutoField(primary_key=True) user=models.ForeignKey(Account,on_delete=models.CASCADE) title=models.CharField(max_length=255) text=models.TextField(null=True) category=models.ForeignKey(Category,null=True,on_delete=models.SET_NULL) is_used=models.BooleanField(default=False) price=models.IntegerField(default=0) created_at = models.DateField(auto_now_add=True) updated_at = models.DateField(auto_now=True) is_active = models.BooleanField(default=True) def __str__(self): return self.title + ' | ' + str(self.user) def get_absolute_url(self): return reverse('index') class Image(models.Model): id = models.AutoField(primary_key=True) user_post=models.ForeignKey(UserPost,default=None, on_delete=models.CASCADE) image=models.ImageField(null=True,blank=True,upload_to='images/') def __str__(self): return self.user_post.title def get_absolute_url(self): return reverse('index') -
why rating star width does not change?
I am trying to create a star rating button that will change based on the given rates. here is css code: .star-ratings-css { unicode-bidi: bidi-override; color: #c5c5c5; font-size: 14px; height: 14px; margin: 0 auto; position: relative; padding:0; margin-bottom: 3px; text-shadow: 0.8px 0.8px 0 #a2a2a2; width: 50%; } .star-ratings-css-top { color: #ffe111; padding: 0; position: absolute; z-index: 1; display: block; top: 0; left: 0; overflow: hidden; margin-left: 4px; width: 50%; } .star-ratings-css-bottom{ padding: 0; display: block; z-index: 0; border-radius: 8px; } and this is the part of html code: <div class="row" style="text-align: left;"> <div class="star-ratings-css-problem" style="width: 80px;"> <div class="row pl-5"> <div class="star-ratings-css-bottom"><span>★</span></div> <div class="star-ratings-css-top" style="width: {% widthratio post.likes post.total_like 100 %}%;"><span>★ </span></div> <div style="color: #ffe111">&nbsp;{{ idea.like_ratio }}<span class="text-muted" style="font-size: 13px;"> ({{ post.likes|add:post.loves}})</span></div> </div> </div> </div> problem is the yellow length does not change, I mean style="width: {% widthratio post.likes post.total_like 100 %}%;" is totally behaving useless in the code! but I expect change in the size of yellow part something like: -
How can I integrate my backend app in django with a frontend ui?
I have developed my backend for my web app. I am using django and django-rest-framework combined with postgresql. I am using docker and I have a docker-compose.yml file with two services, one for django and another one for postgresql. How can I create the frontend of my app? Also my project structure looks like: . ├── backend │ ├── accounts │ │ ├── admin.py │ │ ├── api.py │ │ ├── apps.py │ │ ├── __init__.py │ │ ├── models.py │ │ ├── __pycache__ │ │ ├── serializers.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ ├── apartments │ │ ├── admin.py │ │ ├── api.py │ │ ├── apps.py │ │ ├── __init__.py │ │ ├── migrations │ │ ├── models.py │ │ ├── __pycache__ │ │ ├── serializers.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ ├── backend │ │ ├── asgi.py │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── Dockerfile │ ├── expenses │ │ ├── admin.py │ │ ├── api.py │ │ ├── apps.py │ │ ├── __init__.py │ │ ├── migrations … -
Pagination after filtering in django
I have an issue when trying to use pagination after filtering. I make a search form in forms. In the first page, after searching the app show all contracts with conditions, however when I click page 2, it refreshes and shows other results. If I rewrite in search form, it will show the others result in page 2 in my form.py class ContractSearchForm(forms.ModelForm): use_required_attribute = False export_to_CSV = forms.BooleanField(required=False) class Meta: model = Contracts fields = ["contract","name"] in my view.py def list_contract(request): header= "LIST OF CONTRACT" form = ContractSearchForm(request.POST or None) queryset1 =Contracts.objects.all() #pagination paginate_by = 10 paginate_by = request.GET.get('paginate_by', paginate_by) or 10 user_list = queryset1 paginator = Paginator(user_list, paginate_by) page = request.GET.get('page',1) try: queryset1 = paginator.page(page) except PageNotAnInteger: users = paginator.page(1) except EmptyPage: users = paginator.page(paginator.num_pages) context = { "form":form, "header": header, "queryset": queryset1, 'paginate_by':paginate_by, } if request.method == 'POST': #Tạo queryset sang filter queryset2 = Contracts.objects.filter(contract__icontains=form['contract'].value(), name__icontains=form['name'].value().upper() ) #pagination when search paginate_by = 10 paginate_by = request.GET.get('paginate_by', paginate_by) or 10 user_list = queryset2 paginator = Paginator(user_list, paginate_by) page = request.GET.get('page',1) try: queryset = paginator.page(page) except PageNotAnInteger: users = paginator.page(1) except EmptyPage: users = paginator.page(paginator.num_pages) context = { "form":form, "header": header, "queryset": queryset, 'paginate_by':paginate_by, } return render (request, "customer1.html",context) … -
How to set max and min value in django form?
Suppose I want to set max value 8 and min value 5.How to set this in django form -
How can i load a VueJS app from a template using webpack?
I'm just getting started to VueJS and i'm currently trying to add it to my Django project using Webpack-Loader. I have the following two files: App.vue <template> <div id="app"> <img alt="Vue logo" src="./assets/logo.png"> <HelloWorld msg="Welcome to Your first Vue.js App"/> </div> </template> <script> import HelloWorld from './components/HelloWorld.vue' export default { name: 'app', components: { HelloWorld } } </script> App02.vue <template> <div id="app02"> <img alt="Vue logo" src="./assets/logo.png"> <HelloWorld msg="Welcome to Your second Vue.js App0"/> </div> </template> <script> import HelloWorld from './components/HelloWorld.vue' export default { name: 'app02', components: { HelloWorld } } </script> <style> #app02 { font-family: 'Avenir', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style> Here is my main.js: import Vue from "vue/dist/vue.js"; import Vuex from "vuex"; import storePlugin from "./vuex/vuex_store_as_plugin"; import App from './App.vue' Vue.use(Vuex); Vue.use(storePlugin); Vue.config.productionTip = false; /* NOTE: unlike index.js, we are not passing props from our template, so the following render/mount syntax is ok */ new Vue({ render: h => h(App), }).$mount('#app'); And finally, here is my Django html template: {% load render_bundle from webpack_loader %} {% block content %} <h3>My second Vue app goes here</h3> <div id="app"> <app></app> </div> {% render_bundle 'chunk-vendors' %} {% render_bundle 'vue_app_02' %} {% … -
how to forward a request from flask to another api app
I want to create a dynamic handler, which can process all requests and forward them to other apps based on the database diagram -
Extend Django Queryset to add partition information to select specific partition while querying
I am working with table partitioning in MYSQL. I have partitioned my data according to Month such that there are 12 partition for each month. I have applied partition in database level but now want to introduce a queryset method in Django which lets me to select specific partition to query. from django.db import models def Person(models.Model): # My partitioned Model name = models.CharField(max_length=100) created_month = models.IntegerField() # I want query like this Person.objects.using_partition("p0", "p1").filter(name="Kamal") # Generated SQL(MYSQL): SELECT * FROM person_person PARTITION(p0,p1) where name='kamal' As seen above I want to add PARTITION(p0,p1) but after FROM table_name. -
How to set up Gunicorn and NGNIX for a Django project in a production environment?
I'm trying to re-create a production environment on my local computer before deploying the Django project I have built on a server. I am using Gunicorn and NGNIX. When I launch Gunicorn by writing gunicorn mydjangoproject.wsgi, I get my Django project displayed on the address http://127.0.0.1:8000, but without any static files. That tells me that the error lies somewhere within NGINX, but I can't figure out where. I have followed this guide in order to set up Gunicorn and NGNIX on my local computer. I have skipped steps 5 to 7 in the guide because I do not want to deal with sockets on my local computer. Here are the relevant parts of my settings.py file of my Django project: DEBUG = False ALLOWED_HOSTS = ['*'] STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'production_static/') MEDIA_ROOT = os.path.join(BASE_DIR,'media') MEDIA_URL = '/media/' STATICFILES_DIRS = [ BASE_DIR / "static", ] Here's the file that's located at /etc/nginx/sites-available/mydjangoproject: server { listen 8000; server_name 127.0.0.1; location = /favicon.ico { access_log off; log_not_found off; } location /production_static/ { root /home/john/Documents/Django_projects/mydjangoproject/Version_2/mydjangoproject; } location / { include proxy_params; proxy_pass http://127.0.0.1:8000; } } I have done all the other steps at step 8 of the guide I linked - I … -
How filter a model by model
I'm having some trouble in filtering objects from a set of models. I have 3 classes: class Product(models.Model): id = models.UUIDField(default=uuid4, primary_key=True, editable=False) title_fa = models.CharField(max_length=80) title_en = models.CharField(max_length=80) ... class Favorite(models.Model): user = models.ForeignKey(Profile, default=None, on_delete=models.CASCADE) product = models.ForeignKey('seller.Product', default=None, on_delete=models.CASCADE) ... class Profile(models.Model): id = models.UUIDField(default=uuid4, primary_key=True, editable=False) first_name = models.CharField(max_length=80, blank=True, null=True) last_name = models.CharField(max_length=80, blank=True, null=True) shop_name = models.CharField(max_length=80, blank=True, null=True) ... I trying to fillter some thing like this : favorite_product = Product.objects.filter(id=favorite__.id) this is my view functions : def profile(request): id = request.COOKIES['id'] order__ = Order.objects.filter(sender=id) profile__ = Profile.objects.get(id=id) favorite__ = Favorite.objects.filter(user=id) favorite_product = Product.objects.filter(id=favorite__.id) return render(request, 'shop/profile/profile.html', {'order': order__, 'profile': profile__, 'favorite_product': favorite_product}) I want to show that prodoct wich they id is in Favorite model by user = id . -
Which Framework/TechStack to use in Backup Solutions
I want to create an application which take backup of cloud data(eg. SysCloud app or Backupify app). Which Framework(Django or Node.js) will be best in making an backup app and also any recommendation for Database, I will use AWS services like S3 and lustres for storing data. -
transfering ownership of a website that i made
I have been learning Django for a while now and was thinking of starting to freelance but i am not sure how i am supposed to transfer the ownership to other person like am i supposed to give them the code or do i first create a domain and then transfer it to the client, can anyone please tell me the process of transferring the ownership of website to client.Sorry if this is a stupid question as i said i have never done this before and i tried to search for a solution on google but i wasn't able to find a proper answer -
I there anyway to stop python from loading global variables each time when making changes to each other views in django?
I am working on a machine learning project implemented using django and have to impute a big data set as global variable. Problem is when ever I make changes to other function it is reloading each time taking an hour or two to show the output. Is there anyway I can only load the changes made to that particular view other than reloading the entire views code which is imputing each time ? -
how to store form cleaned_data in a Django session
I am developing an ads web site using Django 3.0 and Python 3.8. I want to build multi step form wizard using django session. I have tried previously formtools.wizard but it failed to satisfy all of my requirements. Thus, I decided to write my own code to do that using session to pass form inputs from one class view to another. The first form go through with no error. However, I got the following error message before second form was rendered: Object of type Country is not JSON serializable The view classes are as follow: class PostWizardStepOne(View): form_class = CommonForm template_name = "towns/salehslist/ads_main_form.html" wizard_data = {} def get(self, request, *args, **kwargs): initial = { 'wizard_data':request.session.get('wizard_data', None), } form = self.form_class(initial=initial) return render(request, self.template_name, {'form': form}) def post(self, request, *args, **kwargs): form = self.form_class(request.POST) print(request.POST) if form.is_valid(): for k, v in form.cleaned_data.items(): self.wizard_data[k] = v request.session['wizard_data'] = self.wizard_data request.session.modified = True print(self.wizard_data) return HttpResponseRedirect('PostWizardSecondStep') return render(request, self.template_name, {'form': form}) class PostWizardStepTow(View): template_name = "towns/salehslist/forms/jobPostForm.html" def get(self, request, *args, **kwargs): print(request.session['wizard_data']) return render(request, self.template_name, {}) Here are the urls: path('post/', PostWizardStepOne.as_view(), name = 'PostWizardFirstStep'), path('post/', PostWizardStepTow.as_view(), name = 'PostWizardSecondStep'), Here are the forms: class CommonForm(forms.ModelForm): class Meta: model = Job fields = … -
MongoDB embedded and array fields in django
I have a question about querying embedded and array fields in django. This is my models.py file: from djongo import models class detalji_igrica(models.Model): pegi_rejting = models.IntegerField() izdavac = models.CharField(max_length=64) zanr = models.CharField(max_length=32) datum_izlaska = models.CharField(max_length=32) class Meta: abstract = True class komentari(models.Model): id_korisnika = models.IntegerField() komentar_naslov = models.CharField(max_length=64) komentar = models.TextField() datum_komentara = models.CharField(max_length=32) rejting_korisnika = models.FloatField() class Meta: abstract = True class Igrica(models.Model): sifra_artikla = models.IntegerField() naziv = models.CharField(max_length=32) cena = models.FloatField() konzola = models.CharField(max_length=32) slika = models.CharField(max_length=64) opis = models.TextField() rejting = models.FloatField() vrsta = models.CharField(max_length=32) detalji_igrica = models.EmbeddedField( model_container = detalji_igrica ) komentari = models.ArrayField( model_container = komentari ) Here is my views.py file: @api_view(['GET']) def najjeftinije_prvo(request): igrice = Igrica.objects.get(detalji_igrica__konzola = "PS3") if request.method == 'GET': igrica_serializer = IgricaSerializer(igrice, many=True) return JsonResponse(igrica_serializer.data, safe=False) And here is serializers.py: class IgricaSerializer(serializers.ModelSerializer): class Meta: model = Igrica fields = ( 'id', 'sifra_artikla', 'naziv', 'cena', 'konzola', 'slika', 'opis', 'rejting', 'vrsta', 'detalji_igrica', 'komentari' ) As you can see it has one embedded and one array field imported from djongo models. Now when I want to search for all games for example that have in detalji_igrica a field konzola = PS3, this is the message I get: FieldError at /api/igrice/najjeftinije Unsupported lookup 'konzola' … -
Django: got an unexpected keyword argument 'empty_label'
I am trying to make the DateField default as nothing. The documentation says to set empty_label="Nothing" but i get an error for that. Model: class Post(models.Model): release_date = models.DateField(null=True, blank=True, default=None) Forms: class NewPost(forms.ModelForm): release_date = forms.DateField(widget=forms.SelectDateWidget(attrs={'class': 'form_input_select_date'}, years=YEARS), required=False, empty_label="Nothing") Error: init() got an unexpected keyword argument 'empty_label' -
Can't figure out the error on my jinja2/django template
Here is my template, the if statements aren't working! {% extends "auctions/layout.html" %} {% block body %} {% if bid.name == User %} <br> <h1>You Won the auction</h1> <br> {% endif %} <h1>Title: {{title}}</h1> <br> <h1>Seller: {{listing.name}}</h1> <br> <h1>Description: {{listing.description}}</h1> <br> <h1>Category: {{listing.category}}</h1> <br> <h1>price: {{bid.price}} by {{bid.name}}</h1> <br> <form action="{% url 'Bid' %}" method="post"> {% csrf_token %} <input type="hidden" name="title" value="{{title}}"> <input type="number" name="price"> <input type="submit"> </form> <form action="{% url 'watchlist'%}" method="post"> { % csrf_token %} Add to watchlist <input type="hidden" name="form_type" value="Watchlist"> <input type="hidden" name="title" value="{{title}}"> <input type="submit"> </form> {% if User == "ilias" %} <br> <h1>Close the auction</h1> <br> <form action="{% url 'close' %}" method="post"> {% csrf_token %} <input type="hidden" name="title" value="{{title}}"> <input type="submit"> </form> <br> {% endif %} <form action="{% url 'comment'%}" method="post"> {% csrf_token %} <h1>Add comment</h1> <input type="text" name="content"> <input type="hidden" name="title" value="{{title}}"> <input type="submit"> </form> {%for item in comments%} <h3>{{item.content}} by {{item.name}}</h3> <br> {%endfor%} {% endblock %} Here is my views.py def listings(request, title): try: listing = Listing.objects.get(title=title) except: return HttpResponse('<h3>Page not found</h3>') else: title = listing.title name = listing.name comments = comment.objects.filter(title=title) bid = Bid.objects.get(title=title) User = request.user.username print name return render(request, 'auctions/listing.html', { 'listing': listing, 'title': title, 'comments': comments, 'bid': bid, … -
How do I verify the ID token with Firebase and Django Rest?
I just can't wrap my head around how the authentication is done if I use Firebase auth and I wish to connect it to my django rest backend. I use the getIdTokenResult provided by firebase as such: async login() { this.error = null; try { const response = await firebase.auth().signInWithEmailAndPassword(this.email, this.password); const token = await response.user.getIdTokenResult(); /* No idea if this part below is correct Should I create a custom django view for this part? */ fetch("/account/firebase/", { method: "POST", headers: { "Content-Type": "application/json", "HTTP_AUTHORIZATION": token.token, }, body: JSON.stringify({ username: this.email, password: this.password }), }).then((response) => response.json().then((data) => console.log(data))); } catch (error) { this.error = error; } }, The only thing I find in the firebase docs is this lackluster two line snippet: https://firebase.google.com/docs/auth/admin/verify-id-tokens#web where they write decoded_token = auth.verify_id_token(id_token) uid = decoded_token['uid'] # wtf, where does this go? # what do I do with this? Do I put it in a django View? I found a guide here that connects django rest to firebase: https://www.oscaralsing.com/firebase-authentication-in-django/ But I still don't understand how its all tied together. When am I supposed to call this FirebaseAuthentication. Whenever I try to call the login function I just get a 403 CSRF verification failed. … -
Django rest framework post request while using ModelViewSet
I am new to Django have background in Node.js. I am creating an API using Django, Django rest framework and PostgreSQL. # Model for Event. class Event(models.Model): heading = models.TextField() event_posted_by = models.ForeignKey( CustomUser, on_delete=models.CASCADE, related_name='events_posted', null=True) event_construction_site = models.ForeignKey( ConstructionSite, on_delete=models.CASCADE, related_name='construction_site_events', null=True) def __str__(self): return str(self.id) # Event ViewSet class EventViewSet(viewsets.ModelViewSet): queryset = Event.objects.all() serializer_class = EventSerializer # Event Serializer class EventSerializer(serializers.ModelSerializer): event_construction_site = ConstructionSiteShortSerializer() event_posted_by = CustomUserSerializer() class Meta: model = Event fields = ('id', 'heading', 'event_posted_by', 'event_construction_site') Everything here works fine and expected as well. Here is the output of my GET Request. { "id": 2, "heading": "ABCD", "event_posted_by": { "id": 1, "email": "abcd@gmail.com", "first_name": "A", "last_name": "B", "profile_picture": "...", "company": { "id": 3, "name": "Company 3" }, }, "event_construction_site": { "id": 2 } }, But now when it comes to create an event this is the view django rest framework shows me. { "heading": "", "event_posted_by": { "email": "", "first_name": "", "last_name": "", "company": { "name": "" }, "profile_picture": "", "user_construction_site": [] }, "event_construction_site": {} } Here as far as I know when need "event_posted_by" by in GET Request but we don't want to post the user info. while creating an event, same for information … -
downloading files from firebase-storage python
I'm trying to download files from my firebase storage with python, and I can't seem to figure out how. I've tried a bunch of different tutorials. So I have the credentials set up as an enviromental path: os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials.json' and then based off what I've seen online, I tried this to donwnload the file from storage. In firebase storage it's just located in the base directory, so I did: storer = storage.child("project_name.appspot.com").download("path_to_file_in_storage") and I get: AttributeError: module 'google.cloud.storage' has no attribute 'child' I already have initialized firebase using this: cred = credentials.Certificate('credentials.json') firebase_admin.initialize_app(cred) This clearly is incorrect, so how would I go about doing this? -
Django how to make a user not edit superuser rights?
I'm trying to get to know the django-admin page. I've edit the adminpage in such a way that staff-users only get to edit some field and the superuser get to edit/change all the fields. One of the field the staff-user is able te edit is the is_active field. the problem i'm facing is that the staff-user is also able to edit the superuser his is_active rights. This is a problem because the staff-user is able to make sure the superuser is unable to login to the admin part of my django site. I've tried several solution's but nothing seems to work. Is there a way to make this work? admin.py @admin.register(User) class CustomUserAdmin(UserAdmin): list_display = ('username','email', 'is_staff', 'is_active',) list_filter = ('email', 'is_staff', 'is_active',) fieldsets = ( (None, {'fields': ('username','email')}), ('Permissions', {'fields': ('is_staff', 'is_active','user_permissions')}), ) add_fieldsets = ( (None, { 'classes': ('wide',), 'fields': ('username','email', 'password1', 'password2', 'is_staff', 'is_active')} ), ) search_fields = ('username',) ordering = ('username',) def get_form(self, request, obj=None, **kwargs): form = super().get_form(request, obj, **kwargs) is_superuser = request.user.is_superuser disabled_fields = set() # type: Set[str] if not is_superuser: disabled_fields |= { 'is_superuser', 'user_permissions', 'is_staff', 'date_joined', } if ( not is_superuser and obj is not None and obj != request.user ): #disable … -
django - gunicorn cant access my static files - expected str, bytes or os.PathLike object, not NoneType
I use django with ubuntu, nginx, gunicorn. I reach my index and HTML files but static files doesn't load. (http://159.65.204.133:8000/) command: gunicorn -c conf/gunicorn_config.py config.wsgi error: Request Method: GET Request URL: http://159.65.204.133:8000/static/assets/css/bootstrap.min.css Django Version: 3.1.3 Python Version: 3.8.5 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'app'] 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 "/var/www/dcna/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/var/www/dcna/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/www/dcna/env/lib/python3.8/site-packages/django/views/static.py", line 36, in serve fullpath = Path(safe_join(document_root, path)) File "/var/www/dcna/env/lib/python3.8/site-packages/django/utils/_os.py", line 17, in safe_join final_path = abspath(join(base, *paths)) File "/usr/lib/python3.8/posixpath.py", line 76, in join a = os.fspath(a) Exception Type: TypeError at /static/assets/css/bootstrap.min.css Exception Value: expected str, bytes or os.PathLike object, not NoneType gunicorn_conf: /var/www/dcna/conf/ command = '/var/www/dcna/env/bin/gunicorn' pythonpath = '/var/www/dcna' bind = '159.65.204.133:8000' workers =3 accesslog ='/var/www/dcna/logs/access.log' errorlog ='/var/www/dcna/logs/error.log' nginx conf: /etc/nginx/sites-available/dcna server { listen 80; server_name 159.65.204.133; location /static { alias /var/www/dcna/static; } location / { proxy_pass http://159.65.204.133:8000; } } django settings STATIC_DIR = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads') MEDIA_URL = '/uploads/' my django project_dir: /var/www/dcna/ (env) root@ubuntu-s-1vcpu-1gb-ams3-01:/var/www/dcna# ls -la total 60 drwxr-xr-x 12 root root 4096 Dec 19 15:27 . …