Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django addition and with tag
Using django 2.0, I need to set the value of a variable A to a sum of two functions in my html with the with tag I tried using the add tag but failed. here is what I want {% with A=object.members.count + object.moderators.count %} -
Django: no attribute 'get_by_natural_key'
i currently try the implement my very own user model. Therefor i created a new app "accounts". But each time when i try to create anew user i get the following error: self.UserModel._default_manager.db_manager(database).get_by_natural_key(username) AttributeError: 'Manager' object has no attribute 'get_by_natural_key' accounts - models.py: from django.db import models from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) #User Model Manager class UserManager(BaseUserManager): def create_user(self, username, password=None): """ Creates and saves a User with the given username and password. """ if not username: raise ValueError('Error: The User you want to create must have an username, try again') user = self.model( user=self.normalize_username(username), ) user.set_password(password) user.save(using=self._db) return user def create_staffuser(self, username, password): """ Creates and saves a staff user with the given username and password. """ user = self.create_user( username, password=password, ) user.staff = True user.save(using=self._db) return user def create_superuser(self, username, password): """ Creates and saves a superuser with the given username and password. """ user = self.create_user( username, password=password, ) user.staff = True user.admin = True user.save(using=self._db) return user class User(AbstractBaseUser): user = models.CharField(verbose_name='username',max_length=30,unique=True,) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) # a admin user; non super-user admin = models.BooleanField(default=False) # a superuser # notice the absence of a "Password field", that's built in. USERNAME_FIELD = … -
Django: Database entry twice
I use Stripe in my Django project and first I charge the customer. After I have the var charge, I enter this data in my Charge model, as well as I save data in my Fee model. Now I realised once I save the foreign key: charge=new_charge_obj, the whole POST request is running twice. Is my approach wrong to assigning the foreign key (Charge) for my Fee model if request.method == 'POST': stripe.api_key = "XYZ" # TODO Marc (it said keep api in call?) token = request.POST.get('stripeToken') # atomic ? #try: charge = stripe.Charge.create( amount=900, application_fee=100, currency='EUR', # TODO Marc source=token, stripe_account="XYZ", # TODO Marc: Replace with organizer stripe account ) new_charge_obj = Charge.objects.create( amount=charge.amount, # amount_refunded=charge.amount_refunded, charge_id=charge.id, livemode=charge.livemode, paid=charge.paid, refunded=charge.refunded, currency=charge.currency, failure_code=charge.failure_code, failure_message=charge.failure_message, fraud_details=charge.fraud_details, outcome=charge.outcome, status=charge.status, application_fee=charge.application_fee, captured=charge.captured, created=charge.created, ) application_fee = stripe.ApplicationFee.retrieve(charge.application_fee) Fee.objects.create( fee_id=application_fee.id, livemode=application_fee.livemode, currency=application_fee.currency, amount=application_fee.amount, charge=new_charge_obj, ) -
How to assign UserProfile with WishList without using a default user
I have an app that contains a model UserProfile() class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) city = models.CharField(max_length=50, default='') phone = models.IntegerField(default='0') image = models.ImageField(upload_to='profile_image', blank=True) def __str__(self): return self.user.username connecting to a default user(User). I wanted to connect my user with a wishlist model class WishList(models.Model): toy_name_wish = models.ForeignKey(Toy, on_delete=models.CASCADE) user_wish = models.ForeignKey(UserProfile, on_delete=models.CASCADE) def __str__(self): return self.user_wish And using generic view with def post(self, request): I created simple logic for a toy that will be shown in admin part as a user's wish item class DetailToyView(TemplateView): template_name = 'app/detail_toy.html' #other defs def post(self, request, toy_id): toy = get_object_or_404(Toy, pk=toy_id) user_profile = UserProfile() wishlist = WishList() try: selected_toy = get_object_or_404(Toy, pk=toy_id) except(KeyError, Toy.DoesNotExist): return render(request, 'app/detail_toy.html', {'toy': toy}) else: user_profile.user = self.request.user user = user_profile.user wishlist.toy_name_wish = toy wishlist.user_wish = user wishlist.save() return HttpResponseRedirect(reverse('app:detail-category-toy', args=(toy.id,))) If it's important here's my urls.py file from django.urls import path from django.conf.urls import url from . import views from django.contrib.auth import views as auth_views app_name = 'app' urlpatterns = [ path('', views.index, name='index'), # INDEX path('personal-page/', views.personal_page, name='personal-page'), # SIGN_IN, SIGN_OUT AND SIGN_UP path('sign-in/', auth_views.login, {'template_name': 'app/sign_in.html'}, name='sign-in'), path('sign-out/', auth_views.logout, {'next_page': '/'}, name='sign-out'), path('sign-up/', views.sign_up, name='sign-up'), # DETAIL_PAGES #url(r'^book-detail/(?P<book>[0-9]+)/$', views.detail_book, name='book'), url(r'^detail_category_toy/(?P<category_id>[0-9]+)/$', views.detail_category_toy, … -
Django siite-treee building treee
Hey guys i want to ask you some wierd question , i am trying to build tree for Posts Like site tree has.Do you have some advices where to find instuction or something like that how to build a tree ? -
Content not displaying while using wagtailtrans package on the page
In my models.py file I have defined StandardPage class to which I want to add transenter code herelations.In this class I have defined these: class StandardPage(TranslatablePage,Page): introduction = models.TextField( help_text='Text to describe the page', blank=True) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text='Landscape mode only; horizontal width between 1000px and 3000px.' ) video_url = models.URLField(null=True,blank=True) body = StreamField([ ( 'main_content',blocks.ListBlock(BaseStreamBlock() ,label = 'content') )] , blank=True, null=True, verbose_name="Page body" ) content_panels = Page.content_panels + [ FieldPanel('introduction', classname="full"), StreamFieldPanel('body'), ImageChooserPanel('image'), FieldPanel('video_url'), ] @property def standard_page(self): return self.get_parent().specific def get_context(self, request, *args, **kwargs): language = request.LANGUAGE_CODE standard_page = request.site.standard_page pages = TranslatablePage.objects.live().filter(language__code=language).specific().child_of(standard_page) context = super(StandardPage, self).get_context(request, *args, **kwargs) context['page'] = self.standard_page return context While template base.html contains: {% load i18n %} {% load wagtailtrans_tags wagtailcore_tags wagtailuserbar %} {% load static %} <!DOCTYPE html> <html class="no-js"> <head> <meta charset="utf-8" /> <title> {% block title_suffix %} {% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %} {% endblock %} </title> <meta name="description" content="" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> {# Global stylesheets #} <link rel="stylesheet" type="text/css" href="{% static 'css/mysite.css' %}"> <link href="{% static 'css/bootstrap.min.css' %}" type="text/css" rel="stylesheet" /> <link href="{% static 'fonts/font-awesome-4.7.0/css/font-awesome.min.css' %}" type="text/css" rel="stylesheet" /> <link href="{% static 'css/streamfields.css' %}" … -
Django returning bad help text in my signup page
As you can see the help text is not being rendered as UL instead its just plain text Here is my code Forms.py: class CustomUserCreationForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = CustomUser now = datetime.datetime.now() fields = ('username', 'email', 'gender', 'security_question', 'answer', 'birth_date', 'resume') widgets={ 'birth_date' :DatePickerInput( options={ 'maxDate':str(datetime.datetime.now()), } ) } Views.py: class SignUp(generic.CreateView): form_class = CustomUserCreationForm success_url = reverse_lazy('login') template_name = 'users/signup.html' signup.html: {% extends 'base.html' %} {% block title %}Sign Up{% endblock %} {% block content %} <div class="login-page"> <h1>Sign up</h1> <form method="post" enctype="multipart/form-data"> {% csrf_token %} <!-- {{ form.as_p }} --> <div class="form"> {% for field in form %} <p> {{ field.label_tag }}<br> {{ field }} {% if field.help_text %} <small style="color: grey">{{ field.help_text }}</small> {% endif %} {% for error in field.errors %} <p style="color: red">{{ error }}</p> {% endfor %} </p> {% endfor %} <button type="submit">Sign up</button> </div> </form> </div> {% endblock %} Can someone help me figure out how do i Fix the issue ? i am using Django2.0.6 -
For filtering data in Django, build dynamic query for multiple columns
I have to filter data from model based on the run time values. I am getting 5 values via query string. My querystring is like below: http://127.0.0.1:8000/personal/search/?month=&year=&account=&deliveryManagedFrom=&marketmName= So, I want to include all or none of the values in the filter so that it displays the desired result. Below is the filter query which I am writing: sum_tt_count = NetworkRelatedInformation.objects.filter(month=month, year=year, account_id=account, account__deliveryManagedFrom=deliveryManagedFrom, account__marketName=market).aggregate(Sum('tt_count')) totalttcount = sum_tt_count['tt_count__sum'] It is working well in case, all the values have been provided. In case, if any value is blank, it should not consider that value and display output as per other filter criteria. Pls suggest how to implement an OR filter with 5 data inputs. It is not necessary that all 5 data inputs have values . So the value can be None or the value in the querystring -
how can i display comments below the respective post in the home page
i want to implement something like fb does like displaying all the respective comments below their respective posts in home page model.py from django.db import models from django.contrib.auth.models import User class Post(models.Model): post = models.CharField(max_length=500) image = models.ImageField(upload_to = 'profile_image') user = models.ForeignKey(User ,on_delete = 'models.CASCADE') created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __str__(self): return self.post class Comment(models.Model): user = models.ForeignKey(User,on_delete = 'models.CASCADE') post = models.ForeignKey(Post, null = True, on_delete = 'models.CASCADE') comment = models.TextField() created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __str__(self): return self.comment views.py class HomeView(TemplateView): template_name = 'home/home.html' def get(self, request): form = HomeForm() form1 = CommentForm() posts = Post.objects.filter(user = request.user).order_by('-created') comments = Comment.objects.all() users = User.objects.exclude(id=request.user.id) args = { 'form': form, 'posts': posts, 'users': users, 'form1':form1, 'comments':comments, } return render(request, self.template_name, args) def post(self, request): form1 = CommentForm() text = '' if request.method == 'POST': form = HomeForm(request.POST,request.FILES) if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() text = form.cleaned_data['post'] form = HomeForm() form1 = CommentForm() return redirect('home:home') if request.method == 'POST': form1 = CommentForm(request.POST,Post.id) text1 = '' post = '' if form1.is_valid(): comment = form1.save(commit = False) comment.user = request.user ***this where i am unable to assign my comment to the respective post*** ***comment.post_id … -
Django modelformset_factory with prefix not scaling
I have been trying to scale modelformset_factory and run into the issue that modelformset_factory is working correctly when I implement with just 2 formsets. Code here: https://gist.github.com/martin1007/6474f3a7f14540bae729e8b4d31f8ca2 But when I try to scale it using lists it does not work. Code here: https://gist.github.com/martin1007/71e07c27aeeb265fa9d55eea3f33aebe Any ideas why is that? Thank you in advance. -
After editing a locally installed package in Heroku it resets
I've noticed that after the packages required written in "requirements.txt" were installed they are not installed anymore every time I push changes into the Heroku application I'm working, so I was assuming that those files were not modified anymore. I then changed a file in /app/.heroku/python/lib/python2.7/site-packages/target_library/target_file but when I do git push the file goes back to its original state, although the library is not being installed again. Is there a way to avoid libraries to be reseted or any workaround? -
Django admin panel customization
I have two models as Selling Product and Buying Product. On admin panel I have Selling Product and Buying Product links. I want to bring one more link in the dashboard itself called Expired Product, an expired product is one with expired field set to True in Selling Product and Buying Product models. The Expired Product link on admin dashboard should list all expired products from Selling and Buying Products Is it possible to customize admin panel this way? If yes how can i do so? -
how to use a prefined table into django views and admin?
Simply, I would like to use a table into views, admin which is already created by me using PostgreSQL. I mean, I don't want to re define that table in django, But would like to use that table just like a table which has been defined into django's models.py. -
Django-TinyMCE Theme options
TINYMCE_DEFAULT_CONFIG has an option to set a theme which in the code I copied, is set to "advanced". I would like to change this to "modern" or one of the other options but it doesn't seem to allow this? Or do I need to download the theme to somewhere? And how do I know which button options are attributed to which plugin? TINYMCE_DEFAULT_CONFIG = { 'plugins': "paste,searchreplace, wordcount", 'theme': "advanced", "theme_advanced_buttons3_add" : "cite,abbr", 'cleanup_on_startup': True, 'custom_undo_redo_levels': 10, 'theme_advanced_buttons1': "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", 'theme_advanced_buttons2': "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 'theme_advanced_buttons3': "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 'theme_advanced_buttons4': "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", 'extended_valid_elements': "iframe[src|title|width|height|allowfullscreen|frameborder|webkitAllowFullScreen|mozallowfullscreen|allowFullScreen]", 'theme_advanced_toolbar_location': "top", 'theme_advanced_toolbar_align': "left", 'theme_advanced_statusbar_location': "bottom", 'theme_advanced_resizing': True, } -
Django was installed but fail to import
I have installed Django,but cannot execute manage.py [root@iz2ze9wve43n2nyuvmsfx5z forum]# python manage.py shell Traceback (most recent call last): File "manage.py", line 17, in <module> "Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? Django exists there In [1]: import django In [2]: django Out[2]: <module 'django' from '/usr/local/lib/python3.6/site-packages/django/__init__.py'> In [3]: django.__file__ Out[3]: '/usr/local/lib/python3.6/site-packages/django/__init__.py' -
How to configure Django to redirect multiple / into single
For example my website is https://mywebsite.com/path//to//id///. I want to 301 redirect it to For example my website is https://mywebsite.com/path/to/id/ -
Djagno: how to pass an email as a key in a dict to a template
Is it possible to pass an email as a dictionary key to a django template. This is possible views.py bad_dict = {'b@b.com': 1, 'c@c.com' :2 } new_dict = { 'one' : 10, 'two' : 20 } if request.method == "GET": return render(request, 'a.html', {'bad_dict': bad_dict, 'new_dict':new_dict}) html aa{{ bad_dict.b@b.com }}bb aa{{ new_dict.one }}bb If you useaa{{ new_dict.one }}bb it works perfectly and you get aa10bb. However, if you use aa{{ bad_dict.b@b.com }}bb it gives you this error: Could not parse the remainder: '@b.com' from 'bad_dict.b@b.com' Is there anyway to get around this? I supposed I could strip '@' and '.', but that seems to coarse. Maybe there is a better way? -
Limiting number of <br> tags generated via Django's linbreaksbr filter
For a user-generated content forum built via Django, I'm contemplating using the filter linkbreaksbr when displaying content in the template. One problem is that it converts all user-entered new lines into <br> tags. That opens it to abuse (e.g. posts where the submitter enters numerous new lines between sentences). Whenever there are multiple new line characters, I'd prefer the result to be a single <br>. Is there any way to achieve this functionality via Django's linebreaksbr? If not, what would be a way to override this and create my required functionality? It would be nice to get an illustrative answer. -
Django test django.db.utils.ProgrammingError: (1146, "Table 'DB.Table' doesn't exist")
I'm running a simple test case in Django, I have a model Subscribers but when I run python manage.py test It gives me the following error Creating test database for alias 'default'... System check identified no issues (0 silenced). E ====================================================================== ERROR: test_subscriber_fullname (gatpulsecore.tests.test_models.SubscribersTest) Test method get_fullname ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py", line 71, in execute return self.cursor.execute(query, args) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\cursors.py", line 170, in execute result = self._query(query) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\cursors.py", line 328, in _query conn.query(q) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 516, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 727, in _read_query_result result.read() File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 1066, in read first_packet = self.connection._read_packet() File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 683, in _read_packet packet.check_error() File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "C:\Users\dania\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.ProgrammingError: (1146, "Table 'test_gatpulsedevinstance.subscribers' doesn't exist") My model looks like this from django.db import models class Subscribers(models.Model): """ Subscriber Model """ idsubscribers = models.AutoField(primary_key=True) legalid = models.CharField(max_length=45, blank=True, null=True) name = models.CharField(max_length=45, blank=True, null=True) lastname = models.CharField(max_length=45, blank=True, null=True) initialdate = models.DateField(blank=True, null=True) bday = models.DateField(blank=True, null=True) email = models.CharField(max_length=100, blank=True, null=True) phone = models.CharField(max_length=45, blank=True, null=True) emergencyphone = models.CharField(max_length=45, blank=True, null=True) photolink = models.CharField(max_length=200, … -
Custom Django back-end how do I add PUT functionality?
When attempting to update my model from my front-end. I'm getting a "Method Put Not Allowed" error. I'm trying to add content for the first time using a DRF back-end written by someone else. How can I add PUT functionality so I can Update data? Here is the serializers.py , models.py, and views.py code specific to the model I am trying to update...let me know if I need to post another files contents. my serializer.py class MedicationSerializer(serializers.HyperlinkedModelSerializer): cat = CatSerializer() class Meta: model = Medication fields = ( 'id', 'cat', 'name', 'duration', 'frequency', 'dosage_unit', 'dosage', 'notes', 'created', 'modified', 'showRow', ) def create(self, validated_data): cat_data = validated_data.pop('cat') cat_obj = Cat.objects.get(**cat_data) medication = Medication.objects.create(cat=cat_obj, **validated_data) return medication the models.py looks like this class Medication(models.Model): cat = models.ForeignKey(Cat, blank=True, null=True) name = models.CharField(max_length=100) duration = models.TextField(blank=True, null=True) frequency = models.CharField(max_length=2) dosage_unit = models.CharField(max_length=2, default=Weight.MILLILITERS) dosage = models.IntegerField(blank=True, null=True) notes = models.CharField(max_length=2048, blank=True, null=True) created = models.DateTimeField(blank=True, null=True) modified = models.DateTimeField(blank=True, null=True) showRow = models.BooleanField(default=True) def save(self, *args, **kwargs): # Save time Medication object modified and created times self.modified = datetime.datetime.now() if not self.created: self.created = datetime.datetime.now() super(Medication, self).save(*args, **kwargs) def __str__(self): if self.cat: cat_name = self.cat.name else: cat_name = "NO CAT NAME" return … -
Django 2.0 Populating Database with a Script
I'm trying to populate my Django database with a script so I don't have to enter in the data manually. So far I have the following: from my_app.models import ModelInApp import django django.setup() def add_data(data1, data2): d, created = ModelInApp.objects.get_or_create(data1=data1, data2=data2) print("- Data: {0}, Created: {1}".format(str(d), str(created))) return d def populate(): # data is a list of lists for row in data: data1 = row[0] data2 = row[1] add_data(data1, data2) if __name__ == "__main__": populate() The data variable is a list of lists containing the data I want to put into my database. The problem is, when I run the script, I get a django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. error. I am using PostgreSQL as the database. What am I doing wrong? -
Summernote lite bullet and number list not defaulting to custom default fontsize
I am testing the summernote WYSIWYG editor, the lite version WITHOUT bootstrap in my Django implementation. Everything seems to be working well with the exception of the bullet and number size. They appear to be at the default size of 6, when my default fontSize is at 22. The fontSize is defaulting to 22 as depicted below, it just has no impact on the bullet and the number list buttons. They stay at 6. I am using the code below in my HTML: <textarea id="summernote" name="book"></textarea> <script> $('#summernote').summernote({ width: 755, height: 300, toolbar: [ ['undo', ['undo',]], ['redo', ['redo',]], ['style', ['bold', 'italic', 'underline',]], ['font', ['strikethrough',]], ['fontsize', ['fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ] }); $('#summernote').summernote('fontSize', 22); </script> I am trying to get the bullet and numbers to match the format of my fonts, but can't seem to get them to match my default fontSize. I am using the SummerNote widget in my form as shown below: widgets = { 'book': SummernoteWidget(), } I can't seem to tell if this is expected behavior, or if there is someway to get them all in sync, the fontsize, the bullet list, and the number list. I tried moving the fontSize line of code … -
Divio docker tutorial
I am a noob and I am trying to create a website following the tutorial from this guy: http://support.divio.com/academy/basic-how-to-build-a-website-and-blog-with-django-cms-60-minutes/introduction. It looks like I am stack at the part which I setup the local server of my project. When I do this a message appears on the power shell which says Waiting for local database server Couldn't connect to database container. Database server may not have started. I tried to find where the database is located but I couldn't do it. Does it have to do that I am using a windows OS and Linux containers? -
Populate fields (add new) in django
How I can add same thing with add new fields in django (admin)?: https://gyazo.com/e31dc35495f61032c9605acc3723946b -
how can load css in django turly
hi guys i try run my code but i can load it truly and i trying for debug it but now reality i can't find any bug and fix it and load it truly i you see any run thing please help me for fix it i will thanks for your reading and your help i use django setting : 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__))) # make Template address path TEMPLATE_URL='/templates/' TEMPLATE_DIR = os.path.join(BASE_DIR,"templates") # make Static address path STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR,"static") STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static/assets/"), ] # make madia address path MEDIA_URL = "/media/" MEDIA_ROOT=(os.path.join(BASE_DIR,'media')) DEBUG = True TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_DIR], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] and my html: <!DOCTYPE html> {% load staticfiles %} <html lang='en'> <head> <meta charset='utf-8' /> <link rel="apple-touch-icon" sizes='76x76' href="{%static 'assets/img/apple-icon.png' %}"> <link rel="icon" type="image/png" sizes='96x96' href="{%static 'assets/img/favicon.png' %}"> <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' /> <title>Insigh Tec</title> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' /> <link type='text/css'href="{% static 'assets/css/bootstrap.css' %}" rel='stylesheet'/> <link type='text/css' href="{% static 'assets/css/gaia.css' %}" rel='stylesheet'/> <!-- Fonts and icons <link href='https://fonts.googleapis.com/css?family=Cambo|Poppins:400,600' rel='stylesheet' type='text/css'> --> <link href= …