Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django, How to set up function to modify models variables
i am new in django, please can somone explain me how this should work properly: I have created app called taskai: from django.db import models # Create your models here. class taskai(models.Model): title = models.TextField() image = models.ImageField(upload_to='images/',null=True) desc = models.TextField(blank=True) inp = models.IntegerField(null=True) def __str__(self): return self.title def skaiciai(self, inp): for i in range(10): self.inp += i return print(self.inp) i am just playing with models and functions in django, i want to print in site modified inp value. I am adding in admin panel title, image, desc and inp (for exmaple 5). Output should be 50, how can i make it work ? -
How to create Django models with ManyToMany relation with tables in different PostgreSQL schemas, one model using just part of unmanaged table
I have a Django application which works just fine. Problem is that it needs to be migrated and that brings some changes. Whole application used to be in PostgreSQL schema intake. Problem is with following models. class Authority(models.Model): id = models.IntegerField(primary_key=True) code = models.IntegerField() name = models.CharField(max_length=255) class Doc(behaviors.Timestampable): id = models.IntegerField(primary_key=True) authorities = models.ManyToManyField(Authority, related_name="docs", ) I need Authority model to use existing table named authority_list. Table is in different schema named lists and it contains many columns. I need only three of them. Table is used by other apps too and is used only for reading. I tried creating router like this: ROUTED_MODELS = [models.Authority] class DefaultRouter: def db_for_read(self, model, **hints): if model in ROUTED_MODELS: return 'lists' return None def db_for_write(self, model, **hints): if model == models.Authority: raise Exception("This model is read only!") return None DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'OPTIONS': { 'options': '-c search_path=intake,lists,public' }, 'NAME': 'dmx', 'USER': 'postgres', 'HOST': 'localhost', }, 'lists': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'OPTIONS': { 'options': '-c search_path=lists,intake,public' }, 'NAME': 'dmx', 'USER': 'postgres', 'HOST': 'localhost', }, DATABASE_ROUTERS = ('dmx.db_routers.DefaultRouter',) Changed Authority model class Authority(models.Model): class Meta: managed = False db_table = "authority_list" It didn't work like I wanted so I found somewhere … -
Table 'django_migrations' already exists after dropping database
I recently had a database issue so I decided to nuke it since I had no important data. I deleted my migrations folder in my app directory and dropped the database. However now when I go to recreate everything with manage.py migrate I get the following error: File "../manage.py", line 21, in <module> main() File "../manage.py", line 17, in main execute_from_command_line(sys.argv) File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/migrate.py", line 234, in handle fake_initial=fake_initial, File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 91, in migrate self.recorder.ensure_schema() File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 69, in ensure_schema raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1050, "Table 'django_migrations' already exists")) I have tried running this after deleting the database, and after recreating the empty database. I can be 100% sure there are no tables there right now. So I have no idea why it thinks that table is there. -
How many ways we can save values from Django form to Database
I have started learning Django recently using a Udemy course. While going through the course instructor asked to save values from a Form to database. After searching on the internet I figured out how to put form values into database and everything is working fine. Below is my views.py and forms.py files. forms.py class FormName(forms.Form): fname = forms.CharField( label="First Name") lname = forms.CharField(label="Last name:") email = forms.EmailField() verify_email = forms.EmailField(label='Verify Email:') def clean(self): all_clean_data = super().clean() email = all_clean_data['email'] vmail = all_clean_data['verify_email'] if email != vmail: raise forms.ValidationError("Check the emails") views.py def signup(request): form = forms.FormName() if request.method == 'POST': form = forms.FormName(request.POST) if form.is_valid(): post = User() post.fname=request.POST.get('fname') post.lname=request.POST.get('lname') post.email=request.POST.get('email') post.save() return render(request,'third_app/greet.html') else: return render(request,'third_app/oops.html',{'form':form}) return render(request, 'third_app/signup.html',{'form':form}) Now coming to question, the instructor is using meta class to store the form values to the database. Below are his forms.py and views.py files. I am curious about what is the difference between my method and the instructor's. forms.py class FormName(forms.ModelForm): class Meta(): model = User fields = 'all' views.py def signup(request): form = forms.FormName() if request.method == 'POST': form = forms.FormName(request.POST) if form.is_valid(): form.save(commit=True) return render(request,'third_app/greet.html') else: return render(request,'third_app/oops.html',{'form':form}) return render(request, 'third_app/signup.html',{'form':form}) Thanks. -
Edit data Query using graphene
I would like to edit data with a query (GraphQL) using graphene Group Model: class GroupEntity(models.Model): uuid = models.TextField() namegroup = models.CharField(max_length=100) description = models.TextField() profilimage = models.TextField() and i have a query to query all groups and their data class Query(object): all_entitygroup = graphene.List(EntityType) def resolve_all_entitygroup(self, info, **kwargs): return GroupEntity.objects.all() And I can get the data with a query this by: { "data": { "allEntitygroup": [ { "id": "1", "description": "descrlol", "uuid": "11112", "namegroup": "nom", "profilimage": "img" } } How can I modify this data, for example if I want to change the 'uuid' of this specific user ? -
get image as per category django drf
Everything working but i want to fetch image based on category. models.py: class Image(models.Model): title = models.CharField(max_length = 100) image = models.ImageField(upload_to = 'home/tboss/Desktop/image' , default = 'home/tboss/Desktop/image/logo.png') category = models.ForeignKey('Category', null=True, blank=True, on_delete=models.CASCADE) image_keyword = models.TextField(max_length=1000) def __str__(self): return self.title serializers.py: class ImageSerializer(serializers.ModelSerializer): class Meta: model = Image fields = ('title','category','image') views.py: class ImageView(generics.ListCreateAPIView): authentication_classes = [] permission_classes = [] pagination_class = None serializer_class = ImageSerializer def get_queryset(self): cat = int(self.request.query_params['category']) return Image.objects.all().filter(category = cat) urls.py: path('image/', views.ImageView.as_view(), name = 'category_image') current its working like this: localhost:8000/image?category=<category_id> no trailing slash what i want to achieve add category parameter with trailing slash: path('image/<category>/', views.ImageView.as_view(), name = 'category_image') i was not able to pass category parameter in get_query function any suggestions -
Export zip file with Django Rest Framework
I created this view that should return a zip file to be downloaded: class ExportAgents(APIView): """ View to export requested agents """ def post(self, request): """ Export requested agents will receive list of agent ids, export data, and return a zip file """ print(request.data["agents_list"]) list_ids = request.data["agents_list"] response = Response(export_agent(list_ids, user_id=1), content_type='application/zip') # export_agent(list_ids, user_id=1) will return a zip file, works fine. response['Content-Disposition'] = "attachment; filename=exported_data.zip" response.accepted_media_type = None response.renderer_context = None return response But it doesn't return a zip file to the frontend. It returns this error instead: UnicodeDecodeError at /intents/agents_export 'utf-8' codec can't decode byte 0xb7 in position 10: invalid start byte Any help? Thanks. -
Display django chartit graph in right order with PivotDataPool
How to display chartit graph in the right order with PivotDataPool When I use PivotDataPool the graphe is not in the right order. It concern the month number. Chartit PivotDataPool graph is in this order 1, 10, 11, 2, 3, 4, 5, 7, 8, 9. I want to have right order like 1, 2, 3, 4 , 5, 6, 7, 8, 9, 10, 11. ![Graph image][1] ![1]:(https://imgur.com/UPBZY8G) PivotDataPool( series= [{'options': { 'source': DerangementAdsl.objects.filter(annee=year), 'order_by': ['mois'], 'categories' : ['mois'], 'legend_by': ['sous_traitant'], 'legendIndex':1, }, 'terms': { 'total': Count('id') } } ]) pivcht = PivotChart( datasource=ds, series_options=[{ 'options': { 'type': 'column', 'stacking': True, 'order_by': 'mois', }, 'terms': ['total'] }], chart_options={ 'title': { 'text': 'Répartition dérangements relevés / structure' }, 'xAxis': { 'title': { 'text': 'Semaine' } } } ) -
Django Pagination for search results
How to paginate dynamically generated data like search results, I have tried this but its not working. This is my code in views paginator = Paginator(search_result, 25) page = req.GET.get('page') results = paginator.get_page(page) return render(req, 'search.html', {'results': results}) This is what I have in my template {% for result in results %} {{ result }} {% endfor %} -
git add . && git commit -m 'Initial commit
At line:1 char:11 + git add . && git commit -m 'Initial commit' + ~~ The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine -
Filtering for the Infinite Scroll list does not work - Django, Ajax
I'm trying to implement filtering for mine infinite scroll list in Django. My example looks like this: views.py def search(request): search = Influencer.objects.all() #get data media = request.GET.get('media', False) popularity_compartment = request.GET.get('popularity_compartment', False) if media: search = search.filter(media=media) if popularity_compartment: search = search.filter(popularity_compartment=popularity_compartment) #paginator paginator = Paginator(search, 20) page = request.GET.get('page', 1) try: search_paginator = paginator.page(page) except PageNotAnInteger: search_paginator = paginator.page(1) except EmptyPage: search_paginator = paginator.page(paginator.num_pages) context = {'search_paginator': search_paginator,} return render(request, 'app/template.html', context) So I have two filters that should work on my infinite list. I use them in this way in a template.html <!-- Paginator with object --> <div class=" infinite-container"> {% for object in search_paginator %} <!-- Object --> <div class="card mb-3 hover-shadow-lg infinite-item"> [...] </div> {% endfor %} </div> <!-- Load more --> {% if search_paginator.has_next %} <div class="mt-4 text-center"> <a href="?page={{ search_paginator.next_page_number }}" class="btn btn-sm btn-neutral rounded-pill shadow hover-translate-y-n3 infinite-more-link">Loading...</a> </div> {% endif %} <!-- Infinite Scroll --> <script src="{% static 'assets/js/jquery-3.1.1.min.js' %}"></script> <script src="{% static 'assets/js/jquery.waypoints.min.js' %}"></script> <script src="{% static 'assets/js/infinite.min.js' %}"></script> <script> var infinite = new Waypoint.Infinite({ element: $('.infinite-container')[0] }); </script> Although my example looks complex, I think it presents a minimal configuration to show the problem. The problem is that the filter … -
Need to get the output in the same page (using django model forms with ajax)
I've tried to reinvent a situation, I've faced recently with a simple example, as follows: I'm new to using ajax with django and this is what I'm trying to do.. I have a single page ('home') and there are two buttons Form1 and Form2; clicking either one of the buttons executes an ajax call and gets it's corresponding form without refreshing (I'm able to pass a get request properly using jquery function with ajax call to display it on the 'home' page itself, without refreshing). It looks like this: Each of those select fields are pre-populated with django model values thorugh Model.object.create(name=name) in the IDLE, and have only one field(besides the pk id). If I select a value from either of both dropdowns and hit process, it should display the length of the selected string, without refreshing the page (just as how the page doesn't refresh while switching the forms) ----> This is where I'm exactly struck and I know the approach I'm using is wrong, but not sure on how to correct it. Can someone please help me in completing the intended purpose of this django app. Sorry for the pasted length of the whole code; for helpers' convenience … -
Comments in posts
Im having trouble getting my comments to show in the tickets they save fine to the database and I can see how many comments are on a post but will not post the comments. Models: class Ticket(models.Model): id = models.AutoField(primary_key=True, unique=True, auto_created=True) staffmember = models.ForeignKey('users.Users', verbose_name='Users',on_delete=models.CASCADE, default=True, related_name='ticket') ticketId = models.UUIDField(default=uuid.uuid4, editable=False) ticketName = models.CharField(max_length=200) ticketDescription = models.TextField(max_length=10000) ticketTime = models.DateTimeField(default=timezone.now) role = models.CharField(max_length=40, choices=Roles, default=developer) condition = models.CharField(max_length=40, choices=Condition, default=Opened) priority = models.CharField(max_length=40, choices=priority, default=low) class Comment(models.Model): id = models.AutoField(primary_key=True, unique=True, auto_created=True) IdTicket = models.ForeignKey('ticket.Ticket', verbose_name='Ticket', on_delete=models.CASCADE, related_name='comment') user = models.ForeignKey('users.Users', verbose_name='Users', on_delete=models.CASCADE, related_name='comments') timestamp = models.DateTimeField(default=timezone.now) description = models.CharField(max_length=1000) Views: class EditTicketView(UpdateView, LoginRequiredMixin): model = Ticket post_form_class = EditTicketForms comment_form_class = CommentForm template_name = 'editTicket.html' fields = ['ticketName', 'ticketDescription', 'condition', 'priority', 'role'] success_url = reverse_lazy('dashboard') def CreateCommentView(request, pk): post = get_object_or_404(Ticket, pk=pk) if request.method == "POST": form = CommentForm(request.POST) if form.is_valid(): Comment = form.save(commit=False) Comment.ticketId = post #form.cleaned_data('description') Comment.save() return redirect('viewComment', pk=post.pk) else: form = CommentForm() return render(request, 'Createcomment.html', {'form': form}) Html: I'm trying to display the comments when you click into the ticket im not sure if i am going about it the right way or not as i mentioned the number of comments on a ticket … -
Typeform Security API and Django: Not Verifiying Hash Correctly
I am trying to use Typeform's security for their webhooks. This involves 1) Receiving the signed packets and extracting the signature 2) Getting the body of the requst 3) Creating a hash with a secret key on the payload 4) Matching the hash with the received signature My web framework is Django (Python based). I am following the example at the TypeForm link here: https://developer.typeform.com/webhooks/secure-your-webhooks/. For the life of me, I can't figure out what's going on. I've tried it in both Python and Ruby, and I can't get the hash right. I call a Ruby script from Python to match the output, but they are different and neither work. Does anyone have any insight? I'm starting to think that it might have something to do with the way that Django sends request bodies. Does anyone have any input? Python implementation: import os import hashlib import hmac import base64 import json class Typeform_Verify: # take the request body in and encrypt with string def create_hash(payload): # convert the secret string to bytes file = open("/payload.txt", "w") # write to a payload file for the ruby script to read later file.write(str(payload)) # access the secret string secret = bytearray(os.environ['DT_TYPEFORM_STRING'], encoding="utf-8") file.close() … -
Want ot know the deatils of django server setup?
I AM DOING A startup using DJANGO BACKEND AND I AM TARGETTING 100K WEB TRAFFIC What should I plan ABOUT server BANDWIDTH,MEMORY,STORAGE, ETC. -
Implement Datatables Server side implementation in django
currently I'm trying to implement ServerSide Rendering in Django. I had done it before with PHP but definitely don't have anymore idea doing this with django. So far I got this jquery code for server side processing. $("#tblDatasets").DataTable({ serverSide: true, ajax: { url: "/gat/layers/" + layer.id + "/filter-table/", dataSrc: function (response) { console.log(response); } }, ordering: false, }); and have this data format return by the ajax request I implemented it before like this using Laravel and Mysql and want to implement the same with Django. Thank you for your help. any guidance is appreciated. -
"ProgrammingError: Table doesn't exist" for Many to Many relation
I have a model Part: class Part(models.Model): PartID = models.AutoField(primary_key=True, unique=True) SiteID = models.ForeignKey('Site', on_delete=models.CASCADE, null=True) Comment = models.CharField(max_length=255, blank=True) Subtype = models.ForeignKey('Subtype', on_delete=models.CASCADE, null=True) Location = models.CharField(max_length=255, blank=True) ConnectedTo= models.ManyToManyField('self', null=True) BatchNo = models.CharField(max_length=32, blank=False, null=True) SerialNo = models.CharField(max_length=32,blank=True) Manufacturer = models.CharField(max_length=32, blank=False, null=True) Length = models.FloatField(blank=True, null=True) InspectionPeriod = models.IntegerField(blank=True, null=True) LastInspected = models.DateField(blank=True, null=True) InspectionDue = models.CharField(max_length=255, blank=True) I used to have PartID as an integer field but I thought I'd try using an Autofield as this will auto increment and users don't need to worry about creating a unique ID when creating a Part. I needed to drop the table part_ConnectedTo because it said I was trying to change PartID which the table relied on. So I did that, flushed my DB and made my migrations - everything fine. But then when I run my app I get the error: (1146, "Table 'MyDB.myapp_part_ConnectedTo' doesn't exist") Have I done something wrong in my model definition? Or am I missing a step to create this table? -
How to display only 4 images per row?
Here I am trying to display images row by row and per row images will be 4.But the below code displays the all images in one row. The result I am getting The result I want is {% for gallery in galleries %} <div class="row"> <div class="col-md-3 col-sm-6 col-xs-12"> <a href="{{gallery.images.url}}"> <img src="{{gallery.images.url}}" height="200" width="200"/> </a> <p>{{gallery.album}}</p> {% if forloop.counter|divisibleby:4 %} </div> <div class="col-md-3 col-sm-6 col-xs-12"> {% endif %} </div> </div> {% endfor %} -
How to create the Front End of a website where I can drag and drop everything in django framework?
What I have done : 1. Successfully created a django project. 2. Tested html pages with urls.py What I want to do now : 1. Easily design the home page with drag and drop functionalities like GUI. 2. Link the newly designed page with urls.py So I was looking for a suggestion on how to do that. I have tried bootstrap ,was wondering if there's a better option. -
Django Project on ec2 server giving PermissionError
I recently cloned by django project onto an ec2 server. I'm using gunicorn for the project. When I run gunicorn --bind 0.0.0.0:8000 website.wsgi:application it runs fine and the site launches. However, when I navigate to a page that pulls data from a local csv file, I get the following error: PermissionError: [Errno 13] Permission denied: '//home/ubuntu/Fantasy-Fire/website/optimizer/Predictions.csv' I tried running gunicorn with sudo and strangely I got this error: ImportError: No module named website.wsgi Why would I not have permission to some of the files in the project? -
Set value of a select input to the value of last request in Django form template
Here is my template code <div class="form-group row"> <label for="{{ form.diagnosis.id_for_label }}" class="col-sm-4 col-form-label col-form-label-sm">{{ form.diagnosis.label }}</label> <div class="col-sm-8"> <input type="text" class="form-control form-control-sm{% if form.diagnosis.errors %} is-invalid{% endif %}" id="{{ form.diagnosis.id_for_label }}" name="{{ form.diagnosis.html_name }}" value="{{ form.diagnosis.value }}" required> {% if form.diagnosis.errors %} <div class="invalid-feedback"> {% for error in form.diagnosis.errors %} {{ error }} {% endfor %} </div> {% elif form.diagnosis.help_text %} <small class="form-text text-muted"> {{ form.diagnosis.help_text }} </small> {% endif %} </div> </div> <div class="form-group row"> <label for="{{ form.assigned_employee.id_for_label }}" class="col-sm-4 col-form-label col-form-label-sm">{{ form.assigned_employee.label }}</label> <div class="col-sm-8"> <select class="custom-select custom-select-sm{% if form.assigned_employee.errors %} is-invalid{% endif %}" id="{{ form.assigned_employee.id_for_label }}" name="{{ form.assigned_employee.html_name }}"> {% for id, name in form.fields.assigned_employee.choices %} <option value="{{ id }}"{% if form.assigned_employee.value == id %} selected{% endif %}>{{ name }}</option> {% endfor %} </select> {% if form.assigned_employee.errors %} <div class="invalid-feedback"> {% for error in form.assigned_employee.errors %} {{ error }} {% endfor %} </div> {% elif form.assigned_employee.help_text %} <small class="form-text text-muted"> {{ form.assigned_employee.help_text }} </small> {% endif %} </div> </div> As you can see, I have created the form template manually and would like to keep it that way. I can set the values of previously submitted fields using {{ form.field.value }}. But I can't do the … -
Why firstname and lastname fields are not entering in database but just the email and password in the customUser i created?
I created a customUser from AbstractBaseUser with fields email, firstname, lastname and password which comes inbuilt and userManager from BaseUserManager as you can see below. But only the email and password are getting commited onto the database not lastname and firstname. I use mysql as dbms. model from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager # Create your models here. class UserManager(BaseUserManager): def create_user(self, email, firstname, lastname, password=None, is_active=True, is_staff=False, is_admin=False): if not email: raise ValueError("user must have an email") user_obj = self.model( email = self.normalize_email(email) ) user_obj.set_password(password) user_obj.active = is_active user_obj.staff = is_staff user_obj.admin = is_admin user_obj.save(using=self._db) return user_obj def create_staffuser(self, email, firstname, lastname, password=None): user = self.create_user(email, firstname, lastname, password=password, is_staff=True) return user def create_superuser(self, email, firstname, lastname, password=None): user = self.create_user(email, firstname, lastname, password=password, is_staff=True, is_admin=True) return user class customUser(AbstractBaseUser): email = models.EmailField(max_length=225, unique=True) firstname = models.CharField(max_length=225) lastname = models.CharField(max_length=225) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = UserManager() def __str__(self): return self.email def get_full_name(self): return self.email def get_short_name(self): return self.email @property def is_staff(self): return self.staff @property def is_admin(self): return self.admin @property def is_active(self): return self.active I pass the values from my signup template {% extends 'base1.html' … -
Error 404 when calling ajax in dialog onOk
I am facing this issue. Anyone can give me some clues? CKEDITOR.dialog.add('nameDialog', function (editor) { ... onOk: function () { $.ajax({ url: "{% url 'util:upload_doc_to_s3' %}", // url : "http://127.0.0.1:8000/util/upload_doc_to_s3/", type : "POST", data : { fileObj: fileObj, csrfmiddlewaretoken: '{{ csrf_token }}' }, // handle a successful response success : function(json) { console.log('done triggered'); console.log(response) }, // handle a non-successful response error : function(xhr,errmsg,err) { console.log('fail triggered'); }, }); } } In this code, i got invalid url 404 error. I was expecting this url. expecting url: http://localhost:8000/util/upload_doc_to_s3/ However, it become this, http://localhost:8000/util/product_tab/edit/cfd/13/%7B%%20url%20'util:upload_doc_to_s3'%20%20%%7D?callback=jQuery2220038196995506981635_1575017580560 404 (Not Found) In the url, the 'util/product_tab/edit/cfd/13/' is the current path of page. Can someone explain this to me? -
Django React Python Post Request Image Classification
plants_serializer = PlantSerializer(data=request.data) data = request.FILES['plantImage'] path = os.path.abspath('../PlantPharmacy/media/images/ ') path = path.strip() filename = path + str(data) if plants_serializer.is_valid(): plants_serializer.save() result = predict(filename) obj = Plants.objects.get(plantImage = filename) obj.classification = result obj.save() return Response(plants_serializer.data, status=status.HTTP_201_CREATED) else: print('error', plants_serializer.errors) return Response(plants_serializer.errors, status=status.HTTP_400_BAD_REQUEST) Hi! So I'm trying to edit a Django database model entry (setting its "classification" field as result gotten through a prediction function), but when I search for the image (Plants.objects.get(plantImage = filename) it says file does not exist, even though I have saved it. I have a feeling that its because it takes a moment for the database to recognize the file. I am trying to find a way to work around this because I need to return the image classification, but I am unsure to do so or a way to work around it. get a "DoesNotExist( "%s matching query does not exist."" error. -
Using Semantic-UI with Django
I'm a complete beginner in web dev, i've done the complete Django tutorial and then i tried to use Semantic-UI to beautify my web app. After searching different solutions to solve the problem (I've used this guide to install Django). So in my settings.py i wrote these configuration lines : STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') This to "INSTALLED_APPS" : 'django_semantic_ui' And this to "TEMPLATES" --> "'context_processors'" : 'django.template.context_processors.static' Here's a view of my index.html : {% load static %} {% load dsu %} <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}"> <link rel="stylesheet" href="{{ MEDIA_URL }}css/semantic.css"/> <button class="ui button"> Test </button> {% if latest_question_list %} <ul> {% for question in latest_question_list %} <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li> {% endfor %} </ul> {% else %} <p>No polls are available.</p> {% endif %} As you can see i just tried to display a simple Semantic-ui button, but the only thing i get is a simple HTML button. Thank you for your attention to these matters.