Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Dynamically filtering with __icontains from input field
I want to filter my fields in a model dynamically from a form input. Already searched a lot but did not find something suitable. As i am fairly new to django and all this stuff i might not see some obvious stuff. The form defines the field to search in and what to search(filter). This should lead to a url like http://localhost:8000/app/search/?col=id&q=1234 In my view i would like to modify the get_queryset() function with a filter like this: def get_queryset(self): query1 = self.request.GET.get('q') query2 = self.request.GET.get('col') object_list = mymodel.objects.filter( Q(query2__icontains = query1) ) Is this possible? Moe -
i want to convert the file(csv,excel,txt) as table in database dynamically
i want to convert the file(csv,excel,) as table in database dynamically and it should take the values from file and convert it as datatype and store it in sq-lite database. "i tried to convert using excel file." "output should save in sq-lite database" def upload(request): if request.method == "POST": form = fr_upload_file.UploadFileForm(request.POST, request.FILES) if form.is_valid(): filehandle = request.FILES['file'] d_excel=excel.make_response(filehandle.get_sheet(), "csv",) file_name=str(filehandle)) print("d_excel",d_excel) return d_excel -
Got Stuck when trying to deploy Sentimental Analysis model using Django
I am working to deploy a sentimental analysis model using django.I have created a simple form in which I am giving option to upload a csv file.Now how can I write a view for it without using models.My purpose is to upload the file then fetching the file from the user.Then reading the csv file as as dataframe.Then doing necessary predictions using the saved pickled models.Please provide after fetching the file from the user.How can I read it as as dataframe using pandas. Thank you very much -
django import-export, export multiple many to many models
I have Rule Model which has multiple RuleCondtion and RuleAction. I want to export these into a csv file. I am using django import-export for this. Example: name, priority, tags, conditions, actions Rule 1, 1000, "tag1,tag2", "[{"identifier":"A", "operator":"B"..}]", "[{"identifier":"A", "operator":"B"..}]" My Models: class Rule(models.Model): name = models.CharField(max_length=128, help_text="Name of Rule") description = models.TextField(help_text="Brief Description of Rule", blank=True) priority = models.IntegerField(default=1000, help_text="Priority of rule, lesser applies first") created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) tags = models.ManyToManyField('Tag', blank=True) disabled = models.BooleanField(default=True) def __str__(self): return self.name class RuleCondition(models.Model): identifier = models.CharField(max_length=128, help_text="Select a Property", blank=True) operator = models.CharField(max_length=128, help_text="Select an Operator", blank=True, choices=CONDITION_OPERATOR_CHOICES) value = models.TextField(help_text="Content to match the rule") rule = models.ForeignKey('Rule', on_delete=models.CASCADE, related_name='conditions') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return 'Rule Condition ' + str(self.id) class RuleAction(models.Model): identifier = models.CharField(max_length=128, help_text="Select a Property", blank=True) operator = models.CharField(max_length=128, help_text="Select an Operator", blank=True, choices=ACTION_OPERATOR_CHOICES) value = models.TextField(help_text="Content to apply on the rule") rule = models.ForeignKey('Rule', on_delete=models.CASCADE, related_name='actions') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return 'Rule Action ' + str(self.id) How can I achieve this, there is no option in the django import-export to do this. -
Can't load two Highcharts on my Django web app
I'm currently using Highcharts with Django. Not too sure it's either an error in implementation at the django views.py or the Highcharts code itself. Tried looking at highcharts document and also simpleisbetterthancomplex class dashboard_view(View): template_name = 'accounts/dashboard.html' def get(self, request, *args, **kwargs): dataset = Profile.objects \ .values('is_active') \ .annotate(is_active_count=Count('is_active', filter=Q(is_active=True)), not_is_active_count=Count('is_active', filter=Q(is_active=False))) \ # categories = list('User') is_active_series_data = list() not_is_active_series_data = list() for entry in dataset: # categories.append('User') is_active_series_data.append(entry['is_active_count']) not_is_active_series_data.append(entry['not_is_active_count']) is_active_series = { 'name': 'Active user', 'data': is_active_series_data, 'color': '#23CE3F' } not_is_active_series = { 'name': 'Inactive user', 'data': not_is_active_series_data, 'color': '#FB3A3A' } chart = { 'chart': { 'type': 'column', 'backgroundColor': '#E3F0E6', 'options3d': { 'enabled': "true", 'alpha': 10, 'beta': 15, 'depth': 50, } }, 'title': {'text': 'Active user on Current Platform'}, 'xAxis': {'categories': ['Active', 'Inactive']}, 'yAxis': { 'title': { 'text': 'No.of users'}, 'tickInterval': 1 }, 'plotOptions': { 'column': { 'pointPadding': 0.2, 'borderWidth': 0, 'depth': 60, } }, 'series': [is_active_series, not_is_active_series] } dump = json.dumps(chart) return render(request, self.template_name, {'chart': dump}) def post(self, request, *args, **kwargs): dataset = Department.objects \ .values('department') \ .annotate(IT_count=Count('department', filter=Q(department="IT")), Sales_count=Count('department', filter=Q(department="Sales")), Admin_count=Count('department', filter=Q(department="Admin")), HR_count=Count('department', filter=Q(department="HR"))) \ .order_by('department') categories = list() IT_series_data = list() Sales_series_data = list() Admin_series_data = list() HR_series_data = list() for entry in dataset: categories.append('%s … -
Custom error messages not working in Django ModelForm
I have a ModelForm and I want to customize some of the error messages for required fields. Some of the customized error messages work, but some don't. Here is my code: error_messages = { 'height': { 'required': _("Your height is required."), }, 'diet': { 'required': _("Your diet is required."), # ~~~~ TODO: not working. }, 'smoking_status': { 'required': _("Your smoking status is required."), # ~~~~ TODO: not working. }, 'relationship_status': { 'required': _("Your relationship status is required."), # ~~~~ TODO: not working. }, **{to_attribute(name='profile_description', language_code=language_code): { 'required': _("Please write a few words about yourself."), } for language_code, language_name in django_settings.LANGUAGES}, **{to_attribute(name='city', language_code=language_code): { 'required': _("Please write where you live."), # ~~~~ TODO: not working. } for language_code, language_name in django_settings.LANGUAGES}, **{to_attribute(name='children', language_code=language_code): { 'required': _("Do you have children? How many?"), } for language_code, language_name in django_settings.LANGUAGES}, **{to_attribute(name='more_children', language_code=language_code): { 'required': _("Do you want (more) children?"), } for language_code, language_name in django_settings.LANGUAGES}, **{to_attribute(name='match_description', language_code=language_code): { 'required': _("Who is your ideal partner?"), } for language_code, language_name in django_settings.LANGUAGES}, 'gender_to_match': { 'required': _("Gender to match is required."), # ~~~~ TODO: not working. }, 'min_age_to_match': { 'required': _("Minimal age to match is required."), }, 'max_age_to_match': { 'required': _("Maximal age to match is required."), }, … -
vh and percentage in CSS?
I'm trying to have the .navbar half of the screen but it is not showing correctly. I'm not sure why? I'm guessing there is another container but i'm not sure why? I set the body to 100vh to cover screen I have .navbar half of that using percentage html file: <!DOCTYPE html> {% load staticfiles %} <html> <head> <link rel="stylesheet" href="{% static "NavBarHtml.css" %}" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> </head> <body class="all"> <div class="navbar"> <div class="navbarButtons"> <button type="button" class="btn btn-outline-primary">Primary</button> <button type="button" class="btn btn-outline-primary">Primary</button> <button type="button" class="btn btn-outline-primary">Primary</button> <button type="button" class="btn btn-outline-primary">Primary</button> <button type="button" class="btn btn-outline-primary">Primary</button> </div> </div> </body> </html> CSS file: .all{ background-color: red; width: 100vh; height: 100vh; } .navbar{ width: 50%; background-color: white; } .navbarButtons{ background-color: aqua; } -
Getting "object of type 'bool' has no len()" when trying to add category in Django after deploying to Heroku
I've recently deployed my Django app to Heroku, and after trying to add a category in admin from the model Category, I get the type error "object of type 'bool' has no len()" Like I said this is after deploying to Heroku. When hosting locally, everything was working fine with no errors. I tried to reset the Postgres database and run migrations again, but still get the same error. Here are my models: # models.py from django.db import models from django.utils.translation import ugettext_lazy as _ class Category(models.Model): name = models.CharField(max_length=200, blank=True) slug = models.SlugField(blank=True) def __str__(self): return self.name class Meta: verbose_name = "categories" verbose_name_plural = "categories" Here is the traceback: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper 606. return self.admin_site.admin_view(view)(*args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner 223. return view(request, *args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py" in add_view 1634. return self.changeform_view(request, None, form_url, extra_context) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper 45. return bound_method(*args, **kwargs) File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 142. response = view_func(request, … -
How to save changes permanently in inspect element?
I have a problem. I am working in django and I downloaded template and made changes in main.css but it is not working. I then made changes in inspect element in browser. But I don't know how to save it permanently. In django I wrote it as {{form}} in HTML page but the changes in main.css is not working. How to deal with that? -
How to block hacker access if detecting unknown GET in Django Middleware
I have block IP implemented in middleware, but it's not good enough. Since I know my url, is it possible to block invalid access of my site if detecting 'access', which is not defined in url.py? I see the probing of site like followings: "GET xyz.cfg/ HTTP/1.1" 500 274 "-" "lib....f33" "CONNECT www.cnn.com:443 HTTP/1.0" 400 184 ")))" Since this is not access url defined in site, I am thinking to detect such access and block it by sending: class BlockHackingMiddleware(object): def process_request(self, request): # How to detect invalid access here? return http.HttpResponseForbidden('<h1>Forbidden</h1>') -
How can I perform the loop in django in javascript (inside ejs)?
In the following code html, {% for d in dates %} and {% for d in tmp_list %} is in django script. I would like to perform the exact same in ejs file using javascript script but I keep getting error. What's my error? I'm rendering from my mongoose schema model object called sensors to sensors.ejs and it contains the following JSON data: { “_id”: “3456c3425df342”, “type”: “thermometer”, “value”: 30, “time”: “2019-08-09T15:38:05.249Z” } The code below was my try: // chart.html using django var chart = bb.generate({ bindto: "#lineChart", data: { x:"x", type: "line", columns: [ ["x", {% for d in dates %} "{{d}}", {% endfor %}], ["temperature", {% for d in tmp_list %} {{d}}, {% endfor %}] ] }, axis: { x: { type: "category" } } }); // chart.ejs var chart = bb.generate({ bindto: "#lineChart", data: { x:"x", type: "line", columns: [ ["x", <% for(var i = 0; i < 30; i++){ %> <%= moment(sensors[i].createdAt).format("HH:mm:ss"+", ") %> <% } %>], ["Temperature", <% for(var i = 0; i < 30; i++){ %> <%= sensors[i].value %> <% } %> ] ] }, axis: { x: { type: "category" } } }); This is the error I get: error message img -
How to make navBar stick in Django?
i understand some fundamentals in Django and trying to build a small project. Currently, i have path in the urls file in the main folder. Within the Urls, i have redirection to functions in the app i created. If i want one element to stick like a NavBar, what is the best way to approach this? Also, how would i create onclick buttons in Django to call functions? urlpatterns = [ path('home/', views.index), path('admin/', admin.site.urls), path('info/', views.contentChange), ] views.py ( my created app): from django.shortcuts import render from django.http import HttpResponse; # Create your views here. def index(request): return render(request, "navBarHtml.html") def contentChange(request): return HttpResponse("HEY!!!!") htmlNavBar: <!DOCTYPE html> {% load staticfiles %} <html> <head> <link rel="stylesheet" href="{% static "NavBarHtml.css" %}" /> </head> <body> <div class="NavBarAll"> <button>1</button> <button>About</button> <button>3</button> <button>About</button> <button>About</button> </div> </body> </html> -
How to remove default view permission in Django?
Trying to remove a view permission after 24 hours. Since view is now a default permission, I'm not sure how to add and remove it. I want to assign it when the model object Purchase is updated and attach it to a user and then remove it after 24 hours. I'm using guardian "remove_perm", but not working. # middleware.py from guardian.shortcuts import remove_perm class PremiumMiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) user = request.user u_p = Purchase.objects.get_object_or_404(user=user).values_list("datetime_done") if u_p.datetime_done != "": if u_p.datetime_done > datetime.datetime.now(): remove_perm('view', user, Purchase) return response Then, I get this error. I'm just not sure how to remove this default "view" permission and add it properly. 'Manager' object has no attribute 'get_object_or_404' -
Manifest: Line: 1, column: 1, Syntax error on Chrome browser
I have a react app that built through npm run build. GET and POST request from the front-end to back-end gives status 200 but I am getting a weird error that may cause all the images from my files not appear on localhost. I have already tried to reinstall node, added 'manifest_version': 2 as it is the current version of chrome manifest. Manifest: Line: 1, column: 1, Syntax error. Below is my index.html file <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Django React Boilerplate</title><link href="/static/css/2.87ad9c80.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={1:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/2.e5ee7667.chunk.js"></script><script src="/static/js/main.9f678b97.chunk.js"></script></body></html> It appeared that the error starts from the beginning of my index.html file. -
List users connected to django-channels Group (channels 1.x)
So, I got as far as finding the group_channels function, but this doesn't seem to store user info. Example: channel_layer = get_channel_layer() context['players_list'] = channel_layer.group_channels('lobby') I get {'players_list': ['daphne.response.WbZyUfNixL!sbzfJEzdPp', 'daphne.response.KfDHQnHLdw!DpoOqdGute', 'daphne.response.JqlcVVMuny!xHLDSaCzUz', 'daphne.response.mWrYVXDKoI!AjkyadSsPe']} as a response. How can I list users connected to Group('lobby')? Thanks in advance -
How to add content_panels when I edit Page
I am developing my wagtail blog site. I want to add the feature what SnippetChooserPanel is shown dynamicaly. When I create a Blog editing page, I want to edit 1/3 SnippetChooserPanel. When I edit a Blog editing page, I want to edit 3/3 SnippetChooserPanel. However, I could not resolve it... I removed 2 SnippetChooserPanel,"B" and "C" in blog/models.py. I can edit only "A" SnippetChooserPanel -> it is OK. I added code in blog/wagtail_hooks.py -> However, SnippetChooserPanel could not see. It is blog/models.py content_panels = Page.content_panels + [ MultiFieldPanel( [ SnippetChooserPanel("A"), # SnippetChooserPanel("B"), # SnippetChooserPanel("C"), ], heading=_("ABC information"), ), ] It is process of 2 and blog/wagtail_hooks.py. If I added @hooks.register("before_edit_page") ... ... Page.content_panels = Page.content_panels + [ MultiFieldPanel( [ SnippetChooserPanel("B"), SnippetChooserPanel("C"), ], heading=_("ABC more information"), ), ] ... ... I can not do it well.. Does anyone can help me? -
How do I serve dynamic images in Django?
I have a Django app that pulls images from emails and creates thumbnails that I want to display in a view. Since these are not static files, and not files uploaded by users, where should I store them and how do I get a URL that can be placed into the src tag so the client browser will download it? I'd like to be able to have the view display the image from a template with code something like this: <img src="{{ path }}" /> where path evaluates to the URL of the image file. I'm fairly new to Django so I'm sure I must be missing something obvious. -
The 'X-Accel-Redirect' option does not work on Windows
I'm developing on Windows and trying to deploy to Ubuntu. But I found a problem here. If you look at the source code below, it works well on Ubuntu, but on Windows you can see that the file contents are empty. What's the suspected problem? (The code below can download the file validly. parent == dir, filename == filename + extension) @login_required def download_file(request, parent, filename): response = HttpResponse() response['Content-Disposition'] = 'attachment; filename={0}'.format(filename) response['X-Accel-Redirect'] = '/static/download/{0}/{1}'.format(parent,filename) print(response['X-Accel-Redirect']) return response -
How do I updated my Django database only when new scraped information is seen?
I have a project that I need to create where when a user navigates to the index page, it displays the current news that python scrapes from a website and add it to my models database and then pass it through as a context to my html template. What I have done is in my views.py file is upon the index page request, python goes to scrape the information and adds it to my database but it does this every time the user makes a GET request to this url. How can I make it so that python is only scraping and updating the database when there’s new news in the website that it’s scraping from and not just adding to the database pre-existing elements -
How to get radio button value from FORM in view.py file
I wanna get the radio button value in view.py file, I'm getting all the values except for radio button value I tried to get data using POST and GET method but both didnt work for me //code Rating 1 2 3 4 5 TypeError at /reservation User() got an unexpected keyword argument 'radoption' -
How to do Exact query Django-Haystack
I'm trying to fix my Django-haystack search results to only return outputs of the exact query. The principal usecase is that a user enter is destination and get only the results that matches this given place. But the problem I have now is that when a user try for example, a query for "Mexico", the search results also returns information in "Melbourne" which is far from being user-friendly and accepted. I just don't know what to try anymore, I've been stuck with this problem since the beginning of the week. Please help. Here's my code: My forms.py from haystack.forms import FacetedSearchForm from haystack.inputs import Exact class FacetedProductSearchForm(FacetedSearchForm): def __init__(self, *args, **kwargs): data = dict(kwargs.get("data", [])) self.ptag = data.get('ptags', []) self.q_from_data = data.get('q', '') super(FacetedProductSearchForm, self).__init__(*args, **kwargs) def search(self): sqs = super(FacetedProductSearchForm, self).search() q = self.q_from_data sqs = sqs.filter(destination=Exact(q)) print('should be applying q: {}'.format(q)) print(sqs) if self.ptag: print('filtering with tags') print(self.ptag) sqs = sqs.filter(ptags__in=[Exact(tag) for tag in self.ptag]) return sqs My search_indexes.py import datetime from django.utils import timezone from haystack import indexes from haystack.fields import CharField from .models import Product class ProductIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField( document=True, use_template=True, template_name='search/indexes/product_text.txt') title = indexes.CharField(model_attr='title') description = indexes.EdgeNgramField(model_attr="description") destination = indexes.EdgeNgramField(model_attr="destination") #boost=1.125 link = … -
Unable to generate post request django class based view with parameters (TemplateResponsemixin, View)
I am not sure why but the post request of this view return Method Not Allowed (POST): / in the terminal and a error 405 on the webpage. views.py class CourseModuleUpdateView(TemplateResponseMixin, View): template_name = 'core/manage/module/formset.html' course = None def get_formset(self, data=None): """ Create a ModuleFormSet object for the given Course object with optional data. """ return ModuleFormSet(instance=self.course, data=data) def dispatch(self, request, pk): self.course = get_object_or_404(Course, id=pk, owner=request.user) return super(CourseModuleUpdateView, self).dispatch(request, pk) def get(self, request, *args, **kwargs): formset = self.get_formset() return self.render_to_response({'course':self.course,'formset':formset}) def post(self, request, *args, **kwargs): formset = self.get_formset(data=request.POST) if formset.is_valid(): formset.save() return redirect('core:manage_course_list') return render(request, self.template_name, {'course': self.course,'formset': formset}) urls.py path('<pk>/module/', views.CourseModuleUpdateView.as_view(), name='course_module_update'), forms.py ModuleFormSet = inlineformset_factory(Course, Module, fields=['title','description'], extra=2, can_delete=True) Any help would be much appreciated. -
Create a CRUD using Django Class-based for a multi-step form?
Is it possible to create a CRUD using Django Class-based (CreateView, ListView, etc ...) for a multi-step form? If not, would anyone have an example of a CRUD of a multistep form? Thanks if anyone helps, I have no idea how to handle this kind of form in Django. -
Is it possible to click a button on a html page from a separate html page?
I have two custom html pages: 'first.html' and 'second.html'. In 'second.html' I have a hidden div. I want to click a button on 'first.html' that will unhide the div in 'second.html'. I want both pages to be open at the same time in different windows/tabs. This is a Django project so I tried to create a def in views.py that will open 'second.html' when the button on 'first.html' is opened. Doing this will just open 'second.html', but I need both pages to be opened at the same time. -
Cannot access to Django admin page with valid username and password in Chrome. But in firefox, it works fine
During an Udemy lecture, I tried to access the Django admin page, but I couldn't enter the page with valid userID and password in chrome. Also, the stylesheet is not applied to the index page. However, in FireFox, it perfectly works. Is there any special thing I should do for Chrome? Please let me know what I do for Chrome. Here are my codes which are setting.py and views.py Thanks in advance in views.py from django.shortcuts import render from django.http import HttpResponse from first_app.models import AccessRecord, Topic, Webpage def index(request): webpages_list = AccessRecord.objects.order_by('date') date_dict = {'access_records': webpages_list} # my_dict = {'insert_me' : "I am from views.py in first_app"} # return render(request, 'first_app/index.html', context=my_dict) return render(request, 'first_app/index.html', context=date_dict) in setting.py """ Django settings for first_project project. Generated by 'django-admin startproject' using Django 2.1.1. For more information on this file, see https://docs.djangoproject.com/en/2.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.1/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__))) TEMPLATES_DIR = os.path.join(BASE_DIR, "templates") STATIC_DIR=os.path.join(BASE_DIR, "static") # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'a=@bj_n7#+65&sop)#o=5nm^po8j35d@c)e#ca)85#i(_wjdz6' # SECURITY …