Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can I create a pop up window upon completion of uploading of files in django
I have some files that have large sizes that will be uploaded to http://127.0.0.1:8000/, so it will take some time. I was just wondering: how do I make a pop up window on upon completion in django? Will it be possible? Be it javascript or html? If it is possible, can anyone show and explain the codes to me? Thank you. -
How to adjust rows in columns in django?
I have made a loop in index.html and the pics which I added in views.html, whenever I run the code, all the pics appear in rows. I want it to be appear in columns. How could I do that? views.py def index(request): dest1 = Destination() dest1.desc = 'Hello, How are you?' dest1.img = '01.jpg' dest2 = Destination() dest2.desc = 'Hello, HOw are you?' dest2.img = '02.jpg' dests1 = [dest1, dest2] return render(request, 'index.html',{'dests1':dests1}) index.html {% static 'images/fulls' as baseUrl %} {% static 'images/thumbs' as hiUrl %} {% for dest1 in dests1 %} <div> <a href="{{baseUrl}}/{{dest1.img}}"> <img src="{{hiUrl}}/{{dest1.img}}" alt="" /> <h3>{{dest1.desc}}</h3> </a> </div> {%endfor%} -
How can I import module in external python script django
I have tried to include a python script in the project directory. I want to just run getoffense.py(under project1) and 3 scripts will be run indirectly upon executing getoffense.py. Those three scripts are SampleUtilities.py, RestApiClient.py and config.py.these 3 scripts are under "modules" When i am running this program seperately from django it is working perfectly however when i am using the module path the server gives me error about it. I have explained as better as i can please help as i am new to python and django. this is my project structure C:. ├───.idea └───project1 ├───modules ├───Templates └───__pycache__ I want to run these external python scripts and show the result on an html file. this is my getofense.py import json import os import sys import importlib sys.path.append(os.path.realpath('/modules')) client_module = importlib.import_module('/modules/RestApiClient') SampleUtilities = importlib.import_module('/modules/SampleUtilities') def main(): # First we have to create our client client = client_module.RestApiClient(version='9.0') # ------------------------------------------------------------------------- # Basic 'GET' # In this example we'll be using the GET endpoint of siem/offenses without # any parameters. This will print absolutely everything it can find, every # parameter of every offense. # Send in the request SampleUtilities.pretty_print_request(client, 'siem/offenses', 'GET') response = client.call_api('siem/offenses', 'GET') # Check if the success code … -
Django 2+ : Optional URL using PATH, without making multiple URL
i have this url path('<slug>/thank_you/<user_id>', thank_you, name='thank_you'), i want the <user_id> to be optional, but i dont want to make 2 urls like this path('<slug>/thank_you', thank_you, name='thank_you'), path('<slug>/thank_you/<user_id>', thank_you, name='thank_you2'), i understand that you can make it optional using regex, but thats if you're using django <2 (using url, not path) how do i obtain this ? -
How to copy a model in django with small differences in Meta using a function?
I have a Django project that has lots of models, and lots of relations. I have got a job to create a new model with different name and db_table meta using a function that has a parameter to model that will be copied. I should change ManyToMany and ForeignKey references to newly created/will created new models. I tried DynamicModels in Django with type(name, (models.Model,), attrs), but after some try 'is_relation' attribute error came into action. create_model function will be used to do this action. Class C(models.Model): q = models.CharField(max_length=20) def __str__(self): return self.q Class A(models.Model): x = models.CharField(max_length=20) y = models.DateTimeField(auto_now_add=True) Class B(models.Model): z = models.ForeignKey(A) t = models.ManyToManyField(C) w = models.DateTimeField(auto_now_add=True) def create_model(model): pass I have classes like this which I described in summary. I should create new classes like C1, A1, B1 with different db_table metas. Also, I should change ForeginKey and ManyToMany fields to A1 and C1. -
How can I give specific IP and port that my code requires
In django I am using python osc, using osc server which required IP address and Port no. to run. When I run that specific file on terminal I add the ip and port like: OSC.py --ip --port Now I want to implement this in django but don't know where to add ip and port -
When I deploy a website on a ubuntu server, I can't load image content that was uploaded locally?
1、The project image uses a local upload, so the image link stored in mysql is a link with the local service IP address, which synchronizes the data to the server's mysql data. When opening a website, the image link cannot be loaded because the address in the link cannot be accessed. Do you need to configure which files, can you correct the link correctly? (If the newly uploaded image on the website is loadable, because the service address of the image before the link is the server itself) Local project configuration: project # settings.py Path MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') 2、The images used in the local project are locally uploaded images, and the image links in mysql have local server addresses: Navicat mysql data 3、Use ubuntu_server to deploy the project on the virtual machine, server address: 192.168.164.128, server mysql file,use Navicat for local and server mysql data synchronization: Server mysql file 4、There are also pictures in the project path of the server, and the configuration of nginx: Server image nginx 5、When the project is last run, the image cannot be loaded on the website because the image is still a link with the local service IP address: error message … -
python django - Images are blank when written using decoded base64
My django website aims at allowing users to combine different clothing picture on one single canvas. However, the saved image is blank. I have applied one fiddle, please see here. I've used the methods recommended by some forums. Here is the views.py @csrf_protect @csrf_exempt def savewearingimg(request): imgEncodeString = request.POST.get('imgBase64') if request.method == 'POST' and request.is_ajax(): singleItemNames = request.POST.getlist('singleItemNames[]') saveWearingName = request.POST.get('saveWearingName') #string positionsX = request.POST.getlist('positionsX[]') positionsY = request.POST.getlist('positionsY[]') userWidths = request.POST.getlist('sizes[]') imgEncodeString = request.POST.get('imgBase64').partition(",")[2];//for header removing img64Data = base64.b64decode(imgEncodeString) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) preFileStr = os.path.join(BASE_DIR, "media\\photos\\wearing\\") poFileStr=str(request.user)+'_itemName_'+saveWearingName+'.jpg' filename = preFileStr +poFileStr with open(filename, 'wb') as f: f.write(img64Data) return render(request,'combinewearing.html') And here is part of the javascript combinewearing.js" $(function() { canvas = document.getElementById('save-canvas'); context = canvas.getContext('2d'); }); $('#saveWearingBtn').click(function(){ drawToSave(alreadyPutImg,originalWidths); }); function drawToSave(alreadyPutImg,originalWidths){ loadImagesMike(sources, function(images_) { //the original author is Mike for(var i=0; i<ImgPutArr.length; i++ ){ var img_iter = ImgPutArr[i]; context.drawImage(images_[i],0,0,img_iter.w,img_iter.h); context.drawImage(images_[i],img_iter.x,img_iter.y,img_iter.w,img_iter.h); console.log('images_[i]: '+images_[i] );//[object HTMLImageElement] i++; } }); var myDataURL = canvas.toDataURL(); $.ajax({ type: "POST", url: "/savewearingimg/", data: { 'csrfmiddlewaretoken': "{{ csrf_token }}", 'imgBase64': myDataURL, 'singleItemNames': alreadyPutName,//array storing what users have added to the canvas 'saveWearingName':$('#saveWearingName').val(), //end-users can customized his/her desired wearing title 'positionsX':positionsX, //position array storing every clothing pictures 'positionsY':positionsY, 'sizes':sizes, }, }).done(function(o) { alert('saved'); console.log('saved'); });/*end ajax*/ } function … -
Can Not create a new model and save it into the database. Djanog rest framework view model set
I have a django rest framework project. I am trying to build a view set that overrides the default create method for the ModelViewSet. Right now, I am grabbing all the data that I need to grab from the POSt request and url arguments. I am trying to store them in to a data object and then create a new object in the database based on that same data object. All the data is correct and setup in the object. How can i make the object savable. I am getting an error and I think it is coming from when I try to save. I am not sure though.... Model View Set - create method: @permission_classes((IsAuthenticated)) def create(self, request, *args, **kwargs): namespace = self.kwargs.get('namespace', None) path = self.kwargs.get('path', None) print(request.user) print(request.POST.get('version')) print(request.POST.get('namespace')) print(request.POST.get('path')) print(request.POST.get('value')) print(request.user.id) if namespace is None and path is None: return super().create(request) if namespace and path is None: data = { "person":request.user, 'version':request.Post.get('version'), 'value':request.Post.get('value'), 'user_id':request.user.id, } 'namespace':namespace, 'path':request.Post.get('path'), return super().create(data) if namespace and path: data = { "person":self.request.user, 'version':self.request.Post.get('version'), 'namespace':namespace, 'path':path, 'value':self.request.Post.get('value'), 'user_id':self.request.user.id, } return super().create(data) Model: from django.db import models from django.contrib.auth.models import User from owf_framework.people.models import Person class Preference(models.Model): id = models.BigAutoField(primary_key=True, null=False) version = … -
Problema na utilização do pyzbar em sistema com hospedagem compartilhada
Estou desenvolvendo um sistema web com Django 2.0.6 que em um dado momento, precisa fazer a leitura de uma imagem de um qrcode. Então, na minha máquina local utilizei o pyzbar na minha virtualenv para realizar tal necessidade e funcionou perfeitamente. Fiz a realização de diversos testes, e até então estava funcionando perfeitamente. Assim, tive a necessidade de hospedar o sistema em um servidor compartilhado(já tinha realizado tal procedimento para outro sistema web feito com Django 2.0.6), sendo que desta vez deu erro na hospedagem devido a biblioteca pyzbar, alegando que a biblioteca não estava devidamente instalada. Requisitei o suporte da empresa de hospedagem(hostgator) para verificar o problema e me foi dito o seguinte: "Verifiquei que o erro ao executar o indexWebScg.fcgi estava ocorrendo devido a falta de módulos instalados em seu vritualEnv, fiz a instalação dos módulos necessários, entretanto pude notar que um dos módulos de sua aplicação se trata do "zbar" esse módulo não é compatível com nossos planos compartilhados pois o mesmo exige uma biblioteca a nível de servidor chamada libzbar o qual não é padrão de nossos servidores compartilhados." A minha pergunta é, se tudo que eu preciso usar no sistema está instalado dentro da virtualenv … -
Creating new objects under specific parameters
I am new to django and trying to under the capabilities of django models. I stumbled across Model managers and understand that they can be used to perform customized queries and I understand how they serve that function. But what if I wanted to create a new object but under a specific set of guidelines. For example let's say I had a model as such: #models.py class TestModel(model.Model): num = models.IntegerField(default=5) Now if I create a new object without specifying the value of num it will set its default equal to 5. But is it possible to have a creation function within the model that would give it another value. For example what if I wanted the value to be a random number between 1 and 100. I know that I could always run that function and then set the num field equal to its output and then create the model, but I want to have that function run within the model and execute just by calling TestModel(). Is this possible? -
How to replace QueryDict to python dictionary with same key
I have a QueryDict from HttpRequest (request.POST) and I Have a new dictionary with same key. How can I insert or replace my new dictionary to QueryDict. any help will be appreciated. print(request.POST) <QueryDict: {'csrfmiddlewaretoken': ['FEWFDFdcgfgrthBFFBDFBDF'], 'form-TOTAL_FORMS': ['13'], 'form-INITIAL_FORMS': ['0'], 'form-MIN_NUM_FORMS': ['0'], 'form-MAX_NUM_FORMS': ['1000'], 'form-0-publish': ['05/28/2019'], 'form-0-cell': ['81'], 'form-0-cell_name': ['13a'], 'form-0-jam': ['07.00-08.00'], 'form-0-target': ['60'], 'form-0-model_name': [''], 'form-0-article_no': [''], 'form-0-input_qty': [''], 'form-0-cementing_qty': [''], 'form-0-perbaikan_qty': [''], 'form-0-b_grade_qty': [''], 'form-0-diff_manual_output': [''], 'form-0-scan_bungkus': [''], 'form-0-total_scan_bungkus': [''], 'form-0-manual_output_qty': [''], 'form-0-total_manual_output': [''], 'form-0-scan_pack_qty': ['10'], 'form-0-component_upper_qty': [''], 'form-0-total_scan_pack': [''], 'form-0-grand_total_qty': [''], 'form-0-diff_output_component_upper': [''], 'form-0-problem': [''], 'form-0-tot_prod_hours': [''], 'form-0-tot_prod_ot': [''], 'form-0-time_normal': [''], 'form-0-time_ot1': [''], 'form-0-time_ot2': [''], 'form-0-time_ot3': [''], 'form-1-publish': ['05/28/2019'], 'form-1-cell': ['81'], 'form-1-cell_name': ['13a'], 'form-1-jam': ['07.00-08.00'], 'form-1-target': ['60'], 'form-1-model_name': [''], 'form-1-article_no': [''], 'form-1-input_qty': [''], 'form-1-cementing_qty': [''], 'form-1-perbaikan_qty': [''], 'form-1-b_grade_qty': [''], 'form-1-diff_manual_output': [''], 'form-1-scan_bungkus': [''], 'form-1-total_scan_bungkus': [''], 'form-1-manual_output_qty': [''], 'form-1-total_manual_output': [''], 'form-1-scan_pack_qty': ['20'], 'form-1-component_upper_qty': [''], 'form-1-total_scan_pack': [''], 'form-1-grand_total_qty': [''], 'form-1-diff_output_component_upper': [''], 'form-1-problem': [''], 'form-1-tot_prod_hours': [''], 'form-1-tot_prod_ot': [''], 'form-1-time_normal': [''], 'form-1-time_ot1': [''], 'form-1-time_ot2': [''], 'form-1-time_ot3': [''], 'form-2-publish': ['05/28/2019'], 'form-2-cell': ['81'], 'form-2-cell_name': ['13a'], 'form-2-jam': ['07.00-08.00'], 'form-2-target': ['60'], 'form-2-model_name': [''], 'form-2-article_no': [''], 'form-2-input_qty': [''], 'form-2-cementing_qty': [''], 'form-2-perbaikan_qty': [''], 'form-2-b_grade_qty': [''], 'form-2-diff_manual_output': [''], 'form-2-scan_bungkus': [''], 'form-2-total_scan_bungkus': [''], 'form-2-manual_output_qty': [''], 'form-2-total_manual_output': [''], 'form-2-scan_pack_qty': ['10'], 'form-2-component_upper_qty': [''], 'form-2-total_scan_pack': [''], 'form-2-grand_total_qty': [''], 'form-2-diff_output_component_upper': [''], 'form-2-problem': [''], … -
PySpark as a runtime for Django instead of a regular python env?
Is it possible to use PySpark as a runtime for Django instead of a regular python environment? Since Django is just running Python tasks, could these tasks not be parallelized in Spark? Here in python3 manage.py shell_plus --notebook, I have imported pyspark and ran a query using the ORM. It runs clean. import findspark findspark.init() import pyspark import pyspark.sql sc = pyspark.SparkContext(appName="Django") patients = Patient.nodes.all() print(patients) sc.stop() [1]: #returned the data from my model I suppose this would work for Flask and Pyramid too? -
How to re-render a view in Django with an updated context from listener or callback function?
I've been trying hard to find a solution to this problem. My Django project uses Firebase Admin SDK. Everything works fine but I have a page view which has this piece of code in it def my_view(request): def on_snapshot(doc_snapshot, changes, read_time): print('Data changed!') return render(request, 'xxxxx.html', context) # 'db' is the Firestore object initialized using firebase admin SDK doc_ref = db.document(....) res = doc_ref.get().to_dict() doc_ref.on_snapshot(on_snapshot) context = { 'result': res, ......... ......... } return render(request, 'xxxxx.html', context) The problem is it works fine when the view is first loaded but when the data in the location of doc_ref is changed from the web browser in the Firebase console, the listener function on_snapshot gets called and the message Data changed! gets printed in the console but the return render(.....) never gets triggered. I don't know why this is not working, I've searched online for solutions, many of them are suggesting to use ajax. If the event is triggered by the user in the front-end then ajax is helpful, but in my case, the event is triggered by the listener function. Please help me to get through this. What I want to have realtime updates on my front-end. But this is not … -
django FloatField - how do I retrieve the value
I have a model made like this class SnpsPfm(models.Model): snpid = models.ForeignKey(Snps, models.DO_NOTHING, db_column='SNPID', primary_key=True) # Field name made lowercase. pfmid = models.ForeignKey(Pfm, models.DO_NOTHING, db_column='PFMID') # Field name made lowercase. start = models.PositiveIntegerField() strand = models.PositiveIntegerField() type = models.CharField(max_length=8) scoreref = models.FloatField(db_column='scoreRef', blank=True, null=True) # Field name made lowercase. scorealt = models.FloatField(db_column='scoreALT', blank=True, null=True) # Field name made lowercase. class Meta: managed = False db_table = 'SNPs_PFM' unique_together = (('snpid', 'pfmid', 'start', 'strand'),) def __str__(self): return str(self.snpid + self.pfmid + self.start + self.strand) And i need to do this operation a = SnpsPfm.objects.filter(snpid=qset[0]) score = a[k].scorealt - a[k].scoreref Problem is that it won't let me do that giving me could not convert string to float: 'ARNTL.SwissRegulon I tried to cast them as float but it's obviously not the solution. I even tried to add def __float__(self): return float(self.scoreref) to SnpsPfm but still won't work -
How to route with django and react
I am using django and react together but I dont know how to handle the routing. from . import views from django.conf import settings urlpatterns = [ path('',views.index), ] That is my urls.py when it loads the html, good and fine it does that well but when I refresh my page in another url (which is in react app) it throws a 404, I want to this in a way that I will still have my static assets and admin accessible from django. -
Deploying Django using Nginx Docker Container
Situation: I have a Django Application that I want to deploy, the tools I use for this one are Nginx, Gunicorn, and all of them are inside a docker container Problem: I'm able to view the django app locally using the IP of my docker, IP of my machine, and Loopback IP. However when I try to access it from my laptop, I can't access it. My Machine: Windows 10, I have already enable the expose of port 80 in the windows firewall inbound and outbound. My docker-compose file version: '3' services: dashboard: build: . volumes: - .:/opt/services/dashboard/src - static_volume:/opt/services/dashboard/src/static networks: # <-- here - nginx_network nginx: image: nginx:1.13 ports: - 0.0.0.0:80:80 volumes: - ./config/nginx/conf.d:/etc/nginx/conf.d - static_volume:/opt/services/dashboard/src/static depends_on: - dashboard networks: # <-- here - nginx_network networks: # <-- and here nginx_network: driver: bridge volumes: static_volume: # <-- declare the static volume My dockerfile # start from an official image FROM python:3.6 # arbitrary location choice: you can change the directory RUN mkdir -p /opt/services/dashboard/src WORKDIR /opt/services/dashboard/src # install our two dependencies RUN pip install gunicorn django requests jira python-dateutil # copy our project code COPY . /opt/services/dashboard/src # # expose the port 80 # EXPOSE 80 # define the … -
Getting the information after finishing payment with PayPal using Django
I'm using django-paypal for managing payments on my website and it works well with the money transfer part but I can't get the user information to input into my database. I looked at some stuff online and what people do is just getting the requset.POST and request.GET data and the information is there but somehow it's not working for me. Here is my view: def index(request): paypal_dict = { "business": "testmail@gmail.com", "amount": "10.00", "currency_code": "USD", "item_name": "Donation", "invoice": randomString(20), "notify_url": request.build_absolute_uri(reverse('paypal-ipn')), "return": request.build_absolute_uri(reverse('pay_app:completed')), "cancel_return": request.build_absolute_uri(reverse('pay_app:canceled')), "custom": "premium_plan", # Custom command to correlate to some function later (optional) } form = PayPalPaymentsForm(initial=paypal_dict) return render(request, "pay_app/donation.html", context={'form': form}) @csrf_exempt def paypal_return(request): context = {'post': request.POST, 'get': request.GET} return render(request, 'pay_app/complete-pp.html', context=context) It's probably something simple but I just can't figure it out. -
How to concatenate string and variable in django view.py?
i want to concatenate string and variable in views.py file. i tried {{}} but this is not working on views.py file. try: filename= file.cv #file name comes from db path = "media/" filename return FileResponse(open("path, 'rb'), content_type='application/pdf') except FileNotFoundError: raise Http404() i need to save a string in path variable like "media/cv.pdf" or "media/mycv.pdf" but can't do that. -
Django redirection after login
I have an app where I'm trying to allow login by username alone. I've been doing this: @login_required(login_url='/login') def index(request): # bunch of queries to provide to the add_rule.html via context return render(request, "index.html", context=context) def user_login(request): if request.method == 'GET': return render(request, 'registration/login.html') else: username = request.POST.get('username') user = authenticate(username=username) # custom function login(request, user) # somehow return the above previous index() function with the request that has updated login/username information I'm not exactly sure how I can render the index.html template with the request that now has the login information. The docs are not clear on how things get redirected after login. I apologize if there is not enough information. -
Importing and using an Npm Package for Draggable Components in a Django template using Script Tags
I have a conceptual question that I would like some help answering. I am currently building a Django app, and I would like to use React in a very basic way to add interactivity to my website. I have a piece of information that gets displayed on on my web page that I would like the user to be able to move around freely on the page by clicking and dragging. I found this React plugin called React Draggable that looks like it would do the trick perfectly: https://www.npmjs.com/package/react-draggable. Previously, I followed a guide and added a react component to my Django template (albeit a simple one) using simply script tags so I know it may be possible (see guide here:https://medium.com/@to_pe/how-to-add-react-to-a-simple-html-file-a11511c0235f). Is there a way to successfully import React Draggable using a tag such that I would not need to actually install npm and Node and have it live alongside my Django app. I tried making a textfile of the code and putting into my static folder and used a script tag to import it, but it did not work. I did notice that React Draggable has two dependancies. Could this be the problem? Anyway, is what I am trying … -
Django: model form decimal field not validating
I have a simple model form to create a new product. I show some fields in the template for the user to choose and set other fields in the view. It works fine until I add a decimal field to the form. Then, it seems like the form is not validating because it doesné run the related code. I don´t really know if it has something to do with the field being Decimal or something else. Thanks in advance. The model class PedidosK(models.Model): producto = models.ForeignKey(ProductosBase, help_text="", blank=True, null=True, on_delete=models.CASCADE) comprobante = models.CharField(max_length=200, help_text="", blank=True, null=True) cliente = models.ForeignKey(Contactos, help_text="", blank=True, null=True, on_delete=models.CASCADE) vendedor = models.ForeignKey(User, help_text="", blank=True, null=True, on_delete=models.CASCADE) lista = models.ForeignKey(Marcas, help_text="", blank=True, null=True, on_delete=models.CASCADE) prod_nombre = models.CharField(max_length=200, help_text="", blank=False, null=True) uds = models.IntegerField(help_text="", blank=True, null=True) boxes = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) vu = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) subtotal = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) bonif = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) bonif_categoria = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) bonif_linea = models.DecimalField(help_text="", decimal_places=2, max_digits=100, blank=False, null=True) pedido_minimo = models.IntegerField(help_text="Units por Inner box", blank=True, null=True) def __str__(self): return str(self.producto) The form that works fine class FormularioLineaPedidoKProductoExtra(forms.ModelForm): class Meta: model = PedidosK fields = ['prod_nombre', 'uds', 'vu', 'cliente', … -
How do i host my fullstack application built with {django & react} on Google cloud
I created my portfolio website with django and react. I would like to host on Google cloud free account. Any doc or tutorials link ? In local host to run python server, we do python manage.py for js we do npm run dev. When we host it in Google cloud. How do these two work. Looked for tutorials in youtube. -
Embed ESRI map widget in extended djando template html file
I am trying to embed an ESRI map widget in an HTML template that is extended from another master HTML file. The master is called a layout.html and uses JQuery and Bootstrap with a block for content. The layout.html file has a script section with a $(document).ready(fn(){..}) defined. The extended page only I cannot get the ESRI widget for a map to render anywhere on the page. I have tried to put the script at the start of the extended file, then in the body in the extended file and then at the end of the script(s) block in the layout.html file to no avail. <script src="https://js.arcgis.com/4.12/"></script> I get the error: dojo.js:24 Error: multipleDefine at r (dojo.js:5) at Ia (dojo.js:21) at dojo.js:22 at f (dojo.js:4) at Sa (dojo.js:22) at b (dojo.js:21) at HTMLScriptElement.<anonymous> (dojo.js:23) On moving the said scripts to the footer, I get an error message stating that $().mask is not defined when I do have the jquery.mask.js included. The layout.html file has the following inclusions at the end of the file: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/additional-methods.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script> <script type="text/javascript" src="{% static 'home/js/bootstrap.min.js' %}"></script> <script type="text/javascript" src="{% static 'home/js/custom/register.js' %}"></script> <script type="text/javascript" src='https://www.google.com/recaptcha/api.js'></script> <script type="text/javascript" … -
Unable to Login to Django Admin/webapp login using valid credentials on remote server
I have just finished building my web app and migrated it to digital ocean droplet. When running on my local machine I am able to successfully authenticate the user/view dashboard etc... python3.6.8 & Django 2.2.1 I have gone through the process of setting up Gunicorn and NGINX after several days of debugging I came to the conclusion my issue is Django specific. To verify this conclusion I have ran. manage.py runserver 0.0.0.0:8000 I am able to make GET requests and POST requests (and switch between landing page, signup, homepage etc) and attempt to login if my credentials are wrong. As soon as I try to login with the correct credentials. Then Django will receive the POST request and hangup indefinitely. ufw (firewall is disabled) allowed_hosts = [*] all nonessential security settings in settings.py are disabled as well. I am able to authenticate using manage.py shell by running: python3 manage.py shell >>> from django.contrib.auth import authenticate >>> u = authenticate(username="user", password="pass") >>> u.is_staff True >>> u.is_superuser True >>> u.is_active True Here is my settings.py file import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = os.environ['SECRET_KEY'] DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ #django builtin Imports 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', …