Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add lists containing dictionaries and sort them?
I've 15 lists, each of them contains dictonaries. I've made all of them into a single list by adding all of them. For that I've used following code: UnSorted List: [ {'timestamp': '2017-10-25 15:17:17', 'pk': 80, 'tag': 'SystemBoundaryTriggers'}, {'timestamp': '2017-10-25 15:17:24', 'pk': 81, 'tag': 'SystemBoundaryTriggers'}, {'timestamp': '2017-10-24 17:14:19', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-24 17:16:13', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-24 17:16:40', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-24 17:40:38', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-24 17:40:39', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-24 17:40:40', 'tag': 'Generate_RequirementsTriggers'}, {'timestamp': '2017-10-25 16:35:08', 'tag': 'User_Sustainability_DefinitionsTrigger'}, {'timestamp': '2017-10-25 16:35:15', 'tag': 'User_Sustainability_IndicatorsTrigger'}, {'timestamp': '2017-10-25 16:35:22', 'tag': 'TaskClarification_gmTrigger'}, {'timestamp': '2017-10-25 16:35:28', 'tag': 'TaskClarification_gmTrigger'}, {'timestamp': '2017-10-25 16:35:36', 'tag': 'TaskClarification_sTrigger'}, {'timestamp': '2017-10-25 16:41:08', 'tag': 'TaskClarification_sTrigger'}, {'timestamp': '2017-10-25 16:41:51', 'tag': 'TaskClarification_sTrigger'}, {'timestamp': '2017-10-25 16:35:46', 'tag': 'Conceptual_gsTrigger'}, {'timestamp': '2017-10-25 16:35:51', 'tag': 'Conceptual_esTrigger'}, {'timestamp': '2017-10-25 16:36:23', 'tag': 'Conceptual_esTrigger'}, {'timestamp': '2017-10-25 16:36:46', 'tag': 'Conceptual_esTrigger'}, {'timestamp': '2017-10-25 16:36:49', 'tag': 'Conceptual_esTrigger'}, {'timestamp': '2017-10-25 16:37:02', 'tag': 'Conceptual_esTrigger'}, {'timestamp': '2017-10-25 16:37:07', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 16:38:40', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 16:38:42', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 16:38:46', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 16:38:52', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 16:40:16', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp':'2017-10-25 16:40:21', 'tag': 'Conceptual_gsmsTrigger'}, {'timestamp': '2017-10-25 17:11:05', 'nstep': '1', 'tag': 'Step Data'}, {'timestamp': '2017-10-25 17:11:05', 'nstep': '2', 'tag': 'Step Data'}, {'timestamp': '2017-10-25 17:18:16', 'nstep': '2', 'tag': 'Step Data'}] I used … -
Django heroku Forbidden (Referer checking failed - no Referer.)
Trying to setup Facebook Messenger webhook to heroku review app. Weired issue can't get rid of Forbidden (Referer checking failed - no Referer.): Heroku logs 2017-10-25T12:48:44.573509+00:00 heroku[router]: at=info method=POST path="/integrations/messenger/webhook/" host=fiobot-pr-10.herokuapp.com request_id=4adf281c-bd8e-40c8-873b-6731372af69c fwd="173.252.98.197" dyno=web.1 connect=0ms service=14ms status=403 bytes=3571 protocol=https 2017-10-25T12:48:44.562928+00:00 app[web.1]: Forbidden (Referer checking failed - no Referer.): /integrations/messenger/webhook/ Tried Made these changes in settings but the problem still occours. CSRF_TRUSTED_ORIGINS = ['*.herokuapp.com'] views.py @csrf_exempt @require_POST def webhook_post(request): """ Respond to messenger POST method web hook call -
AWS AMI Virtual Host showing
i have tried creating the virtual hosts via this following link Digital Ocean Virtual Host However it is using only first vhost settings. i have tried many tutorials but nothing is working. Finally i have put the vhost settings in httpd.conf file Listen 8000 <VirtualHost *:80> ServerName abc.edu ServerAlias www.abc.edu DocumentRoot /var/www/html/abc/frontend/dist <Directory /var/www/html/abc/frontend/dist> Options +Indexes +FollowSymLinks +MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> <VirtualHost *:8000> ServerName apiabc.edu ServerAlias www.apiabc.edu Alias /static /var/www/html/abc/abc/static <Directory /var/www/html/abc/abc/static> Require all granted </Directory> <Directory /var/www/html/abc/abc/abc> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess abc python-path=/var/www/html/abc/abc python-home=/var/www/html/abc/env WSGIProcessGroup abc WSGIScriptAlias / /var/www/html/abc/abc/abc/wsgi.py </VirtualHost> -
Cant figure out DJango error
Hey guys is there any way to figure out what file this error is being thrown for? serverad@ubuntu:~/django14_project/my_django15_project$ python manage.py runserver --traceback --settings=settings -v 3 Performing system checks... Unhandled exception in thread started by Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 125, in inner_run self.check(display_num_errors=True) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 405, in check raise SystemCheckError(msg) django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues: ERRORS: events.SystemLog.text: (fields.E121) 'max_length' must be a positive integer. events.SystemLog.type: (fields.E121) 'max_length' must be a positive integer. System check identified 2 issues (0 silenced). -
What are some ideas for a graduation project involving PHP or Python?
Please some ideas for a graduation project involving PHP or Python in general "Build Web Application"? -
Django POST Response throws exception if page is refreshed/reopened
I'm using Django in order to create a server which will download and track the progress of files. It has an input field for the url of the download link, and once I click on Download, it executes the following javascript code: index.html function startDownload() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { completedFile = xhttp.responseText; document.getElementById(completedFile + "ProgBar").style.width = "100%"; document.getElementById(completedFile + "ProgBar").innerHTML = "Completed!"; setTimeout(delProgBar, 5000, completedFile); } }; xhttp.open("POST", "http://localhost:8000/download/start/", true); xhttp.setRequestHeader("X-CSRFToken", '{{ csrf_token }}'); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var downloadLink = document.getElementById("downloadInput").value; var sendString = "url=" + downloadLink; var downloadArray = downloadLink.split('/'); var downloadName = downloadArray[downloadArray.length-1]; addProgBar(downloadName, "0"); xhttp.send(sendString); } Django views.py def start(request): aux = request.POST['url'] file_name = start_download(aux) print("###########") print(file_name) return HttpResponseRedirect(file_name) This works completely fine IF I don't reload the page after starting the download. The POST Request is only being logged on Django Command Prompt window after it is completed (readyState check). However, the page should show the download progress for other people that open the page after the download started. This however is throwing a big error on Django, with something like 4 Exceptions. I can post it later if necessary, but … -
Django python error
When i run server i receive error, i am using python 2.7 with Django. Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "F:\python\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line utility.execute() File "F:\python\lib\site-packages\django\core\management\__init__.py", line 338, in execute django.setup() File "F:\python\lib\site-packages\django\__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "F:\python\lib\site-packages\django\apps\registry.py", line 85, in populate app_config = AppConfig.create(entry) File "F:\python\lib\site-packages\django\apps\config.py", line 94, in create module = import_module(entry) File "F:\python\lib\importlib\__init__.py", line 37, in import_module __import__(name) ImportError: No module named smart_selects -
Django: Compare two querysets
I have a model named Music and it has artist ManyToManyField. I want to validate that artist and name fields are unique_together. Django will not let to put ManyToManyField into the unique_together list of Meta class. Below is what I am doing and I is giving me an error <"Music: Hello> needs to have a value for field "id" before this many-to-many relationship can be used. class Music(models.Model): name = models.CharField(max_length=256) artist = models.ManyToManyField(Performer, related_name='all_songs') file = models.FileField(upload_to='music/') def save(self, *args, **kwargs): similar_musics = self.__class__.objects.filter(name=self.name) for music in similar_musics: artists = music.artist.all() diff = set(artists.all()).difference(set(self.artist.all())) if diff: raise ValidationError('This song seems to be already created!') super(Music, self).save(*args, **kwargs) What is the easiest way to validate so that artist and name fields unique together ? Additionally, I want to compress music file and stream my compressed music to browser and in the browser uncompress received parts and play. So, it may be similar to spotify but very simple version. What may be best way to do this task? Thank you in advance -
Retrofit: response 500, Internal Server Error
I am working on a project. The web team has implemented the API for signup and login. I will implement the Android part. So when I post a request to the server to sign up, using Postman, It is working. But When I try to signup in Android, It returns 500-Internal Server Error. I used Retrofit for sending request. Here is my code: SignUpActivity.java: public class SingUpActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signup); final EditText email = (EditText) findViewById(R.id.input_email); final EditText username = (EditText) findViewById(R.id.input_name); final EditText password = (EditText) findViewById(R.id.input_password); final EditText gender = (EditText) findViewById(R.id.gender); final EditText location = (EditText) findViewById(R.id.location); Button btn_signUp = (Button) findViewById(R.id.btn_signup); btn_signUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String email_str = email.getText().toString().trim(); String username_str = username.getText().toString().trim(); String password_str = password.getText().toString().trim(); if(!TextUtils.isEmpty(email_str) && !TextUtils.isEmpty(username_str) && !TextUtils.isEmpty(password_str)) { // Toast.makeText(getApplicationContext(), "username: " + username_str + " email: "+ email_str + " password: " + password_str, Toast.LENGTH_SHORT).show(); sendPost(username_str, email_str, password_str); } } }); } public void sendPost(String email, String username, String password){ Retrofit retrofit = ApiClient.getApiClient(); ApiInterface apiInterface = retrofit.create(ApiInterface.class); Call<JsonResponseSignUp> call = apiInterface.signUp(new SignUpBody(username, email, password)); call.enqueue(new Callback<JsonResponseSignUp>() { @Override public void onResponse(Call<JsonResponseSignUp> call, Response<JsonResponseSignUp> response) { if … -
Django view is not rendering a template when using ajax
So i'm trying to a render a template in view,when i click a button in another template,i make an ajax call to a method in view,but i'm not sure what is wrong in this,i'm not able to render another template,am i doing something wrong in this my view.py @csrf_exempt def checkLogin (request): if request.is_ajax(): param = request.POST.get('param', None) param1 = request.POST.get('param1', None) if (param=="admin" and param1=="admin"): Datenow = datetime.datetime.now().strftime('%H:%M:%S') return render(request,'sample/test.html',{'Datenow': Datenow}) else: Datenow = datetime.datetime.now().strftime('%H:%M:%S') return render(request,'sample/login.html',{'Datenow': Datenow}) return HttpResponseBadRequest() this is my ajax call in my template loginbt.onclick = function() { var uName = $('#username').val(); var pWord = $('#password').val(); $.ajax({type: 'POST', url: '/sample/checkLogin/', // some data url data: {param: uName, param1: pWord}, // some params success: function (response) { // callback if (response.result === 'OK') { if (response.data && typeof(response.data) === 'object') { window.alert("its working"); } } else { // handle an unsuccessful response } } }); } i get a 200OK result when i click the button in the template,but the template just doesn't change,any inputs would be helpful -
Django how to print data when using runserver
I have a dictionary data with how many players every user created: views.py def statistics(request): users = User.objects.all() data = dict() for user in users: players = Players.objects.filter(created__email=user.email).count() if players > 0: data[user.email] = players How can i print this dictionary in the console when i use runserver? I have seen django loggers but i didn't understand them fully. -
Django - formatting string representing a JSON into indented string and rendering it in a template
I have come across several posts addressing this question, but none of them helped. Here's what I want to do: I have a view like this: def test_view(request, request_id): params = '{"tz_name":"Asia/Yerevan","tz_gmt":"GMT+04:00"}' params = json.dumps(params, sort_keys=True, indent=4).encode('utf8') context = {'params':params} template = 'template.html' return render(request, template, context) ...and template.html": <div> {{params|safe}} </div> Basically, I want to render an HTML page that renders indented JSON object. But all my attempts fail. I always end up with HTML that renders my object not indented like this: and the corresponding HTML looks like this: <div id="json_container" style="font-size: 13px;"> "{\"tz_name\":\"Asia/Yerevan\",\"tz_gmt\":\"GMT+04:00\"}" </div> Any hints on this? -
TruncDate timezone parameter is not working in Django
Not able to change TImezone in Trunc functions. It always take timezone from settings.py import pytz ind = pytz.timezone('Asia/Calcutta') Query: queryset = Order.objects.annotate(date=TruncDate('created_at', tzinfo=ind)).values('date') While inspecting sql query by queryset.query SELECT DATE(CONVERT_TZ(`nm_order`.`created_at`, 'UTC', UTC)) AS `date` FROM `nm_order` Reference: Trunc in Django But for Extract, it's get working ORM: queryset = Order.objects.annotate(date=ExtractDay('created_at',tzinfo=ind)).values('date') Query: SELECT EXTRACT(DAY FROM CONVERT_TZ(`nm_order`.`created_at`, 'UTC', Asia/Calcutta)) AS `date` FROM `nm_order` Am I miss something in Trunc ? TimeZone Settings in my settings.py IME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True -
Connect to upstream client from nginx to gunicorn fails
I followed the steps in link and installed gunicorn and nginx "https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7" Now If I try from localhost / different computer in same network then it works fine. When I allocate a public IP address to the machine and try to access it I get the following error message, 2017/10/25 11:19:31 [crit] 12866#0: *1 connect() to unix:/tmp/controller.sock failed (2: No such file or directory) while connecting to upstream, client: 220.227.187.194, server: 127.17.3.124, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/controller.sock:/", host: "117.91.133.124" I tried the to disable selinux for network to socket with following command, As in the link "(13: Permission denied) while connecting to upstream:[nginx]" setsebool -P httpd_can_network_connect 1 All above steps are not solving my issue, even I tried to change to socket to /tmp directory in gunicon but its not working. The issue is only when trying to access from public IP not from private IP. All machines if I do curl local_ip_address it gives me nginx works fine and 200 OK -
how to mention/tag users with '@' on a django developed project
I am trying to implement the "@" feature used on social sites such as twitter to tag or mention users on my django project. Say for example, "@stack" when clicked should go to stack's profile. How to do that would be helpful to me. -
How to render django inlineformset_factory using javascript
I have a model Post with Comment as ForeignKey. i used inlineformset_foctory to update releted answer to Question object with dajngo templates, but now i want to display formset using javascript. To be spacific, i want to create a link comment so when clicked it display a form that will update Post -
Contact names searching in huge database
I have a project where the main task is to search for contact names stored in database. For example, I have web application where I type in searching field some cell number: "777555444" and as result it returns me a proper name: "John Doe". If proper name was not found, cell number is appended to another database table of unknown numbers. The database could have a billion of contacts. So: 1) the searching should be performed in multithread fasion 2) the maximum memory saving by database (loading into RAM and loading memory from the disk in case of insufficiency) 3) regular database indexation in case of searching for proper "contact names - cell numbers" that where not found before. For example, admin uploaded some list of contacts to the database. But user have already performed searching for one of cell number existed in that uploaded list. It means that cell number is in the table with unknown numbers and now it should be deleted from there. So, what is the best way to implement all this specific features? What techology should I use? For example, my preferable choice is python/Django/mysql. But is that usable in my case? Off course, I … -
Django with Apache working for admin page but gives 404 for all other urls
I am a django beginner. I tried to deploy my django(1.10) site from local server using apache2 (2.4.7) Port opened. Admin page is getting opened properly but all other views are not getting opened. URLS.PY from django.conf.urls import url,include from django.contrib import admin from django.views.generic import RedirectView from django.conf import settings urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^treedump/',include('treedump.urls')), url(r'^$', RedirectView.as_view(url='/treedump/', permanent=True)), url(r'^accounts/', include('django.contrib.auth.urls')), ] .CONF FILE IN APACHE <VirtualHost *:80> ServerName ********* DocumentRoot /var/www/html/ Alias /static /data1/ekmmsc/webapp/ekmmsc/static WSGIDaemonProcess ekmmsc python-path=/data1/ekmmsc/webapp/ekmmsc python- home=/data1/ekmmsc/webapp/ekmmsc/ekmmscenv WSGIProcessGroup ekmmsc WSGIScriptAlias /ekmmsc /data1/ekmmsc/webapp/ekmmsc/ekmmsc/wsgi.py # Other directives here ... <Directory "/var/www/html/"> allow from all order allow,deny AllowOverride All AddType text/css .css AddType text/javascript .js </Directory> <Directory "/data1/ekmmsc/webapp/ekmmsc/static"> Require all granted </Directory> <Directory "/data1/ekmmsc/webapp/ekmmsc/ekmmsc"> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> OUTPUT Not Found The requested URL /treedump/ was not found on this server. Any help will be appreciated , i have been working almost for 2 days on this. Please help. -
dynamic date range query in django
I have written the following function to get minimum date from MySQL table and to display 60 days of data. def listingpage(request): fields = ['promotion_name', 'period' , 'indicator', 'value'] cursor = connection.cursor() cursor.execute('''SELECT min(period) FROM promocal''') time_zone = cursor.fetchone() print(time_zone[0]) time_threshold = time_zone[0] + timedelta(days=10) qs = list(Promocal.objects.filter(period__lte=time_threshold)) json_data = serializers.serialize('json', qs, fields=fields) listing = json_data json_data1 = json.dumps(listing) response = HttpResponse(json_data1) return response Now I want to display the data for the next 60 days. Can anyone help me achieve this? -
django User permissions and Permission Required Mixin
In this code, Django will check for all the permission in the tuple permission_required and if the user having all the permission get access to the view. I want to provide the view if the user having any permission in the given list or tuple. Eg: In this particular case if the user only having the polls.can_open permission I want to provide the view from django.contrib.auth.mixins import PermissionRequiredMixin class MyView(PermissionRequiredMixin, View) permission_required = ('polls.can_open', 'polls.can_edit') -
Finding untagged objects in the Django admin
I am using django-taggit and the Django admin interface. I have some objects and would like to filter them by tag, for that I add my tags field to the ModelAdmin's list_filter. That works fine, and I can select "All" to get all items, or a specific tag, and it shows all items including this tag (using an URL like ?tags__id__exact=56). The filter list also includes an option "-", which generates an URL like ?tags__isnull=True. This list is always empty. I would assume the purpose behind this option would be to show all untagged items, but if that is the case it doesn't work. What can I do to get a list of untagged items in the admin? I have been thinking of subclassing SimpleListFilter, but then I'd have to replicate the logic in the existing list filter. Or, I could subclass the existing filter, but I don't know which class it is. Any ideas? -
combine model and detect changes of both model when submit form
I have combined two model form "User" and "UserPhone" using TabularInline in admin.py, but when i save both model data with single submit button i can only detect changes of "User" model def save_model(self, request, obj, form, change): print "form:",form.changed_data but i need to check changes of "UserPhone" model data also when i save both model data on a single submit. Admin.py class UserPhoneInline(admin.TabularInline): model = UserPhone class UserAdmin(admin.ModelAdmin): list_display = () inlines = [ UserPhoneInline, ] def save_model(self, request, obj, form, change): obj.save() print "form:",form.changed_data,"change:",change class UserPhoneAdmin(admin.ModelAdmin): list_display = () list_filter= [] -
Python Celery chain wait for remote service to finish
I'm using celery to upload video file to remote service, start some processing there and when they are ready - downloading results. I'm having problems with chaining this process. This is what I tried: chain( set_task_status.si(task_pk, TASK_UPLOAD), upload.si(task_pk=task_pk), set_task_status.si(task_pk, TASK_WAIT), start_service.si(task_pk=task_pk, service='transcriber').set( countdown=3), check_progress.si(task_pk), start_service.si(task_pk=task_pk, service='subtitling').set( countdown=3), check_progress.si(task_pk), set_task_status.si(task_pk, TASK_DOWNLOAD), get_transcript.si(task_pk=task_pk), get_subtitles.si(task_pk=task_pk), set_task_status.si(task_pk, TASK_FINISHED) ).apply_async() And it works but right now I use while loop with time.sleep(30) inside check_progress task. Remote service needs to process the video I sent and it takes some time. Function check_progress sends request to remote API and gets progress of this processing. Processing needs to finish before next task in chain can be executed. The problem with this is one celery worker will be constantly busy and won't be able to take another task while it waits for remote service to finish. Is it possible to loop one task in chain (using countdown to delay execution) until remote service finishes? Or maybe I can pause celery chain somehow? -
unable to run server when django toolbar is enabled
We are handling a very large django codebase, we are using django debug toolbar, the problem is so weird, if I put DEBUG_TOOLBAR=True in my django.settings , I am not able to perform any activity with manage.py like python manage.py runserver or python manage.py collectstatic any of it. When I press CTRL+C to terminate, I am unable to, it got stuck there. Here is my django debug toolbar configuration. DEBUG=True DEBUG_TOOLBAR = True if DEBUG and DEBUG_TOOLBAR: INSTALLED_APPS += ( 'debug_toolbar', ) INTERNAL_IPS = ( '127.0.0.1', 'XX.XX.XXX.XXX', ) DEBUG_TOOLBAR_PANELS = [ 'debug_toolbar.panels.timer.TimerPanel', 'debug_toolbar.panels.sql.SQLPanel', 'debug_toolbar.panels.cache.CachePanel', 'debug_toolbar.panels.signals.SignalsPanel', 'debug_toolbar.panels.redirects.RedirectsPanel', ] DEBUG_TOOLBAR_CONFIG = { 'RENDER_PANELS': True, 'RESULTS_CACHE_SIZE': 2, 'RESULTS_STORE_SIZE': 10, # Required for ddt_request_history 'SHOW_TOOLBAR_CALLBACK': lambda request: True } MIDDLEWARE_CLASSES += ( 'saul.middleware.profile.ProfileMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', ) However, I have gone through the answers of below question, but none of it worked. django-debug-toolbar not showing up -
Not able to navigate to a different page using django views
I'm trying to go to a different page using login credentials,but for some reason Getting Template does not exist error,this is my views.py def checkLogin (request): if request.is_ajax(): param = request.POST.get('param', None) param1 = request.POST.get('param1', None) if (param=="admin" and param1=="admin"): Datenow = datetime.datetime.now().strftime('%H:%M:%S') return render(request,'./login.html',{'Datenow': Datenow}) else: Datenow = datetime.datetime.now().strftime('%H:%M:%S') return render(request,'../../sample.html',{'Datenow': Datenow}) return HttpResponseBadRequest() and this is my error, i know i'm messing p the path,but i'm not sure what the convention is in this case,tried ./ ..// ..//../ and so on,but doesn't seem to work TemplateDoesNotExist at /sample/checkLogin/ ./login.html Request Method: POST Request URL: http://127.0.0.1:8000/sample/checkLogin/ Django Version: 1.11.6 Python Executable: C:\Users\Halo\AppData\Local\Programs\Python\Python36\python.exe Python Version: 3.6.2