Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
what is the best way to save survey results in db?
Im developing a single page application with angular for the front side and the django python for the server side. In my app there are 3 surveys with about 20 questions for each. What is the best approach to keeping these answers in my db? I thought about 2 options - To keep each survey in a separate table with a key forigen ID client, To save each survey result in the json format as a field of the cilent table. I searched the web and did not find a clear answer, how do I know what is the best way to build my db? Thanks. -
Django + Apache - [core:error] [pid 10696] [client <IP>:35768] Script timed out before returning headers: wsgi.py
I'm trying to deploy a Django app on CentOS + Apache with mod_wsgi. The app is working fine with Django dev server (manage.py runserver) but not when serving through Apache. This is all I get in logs: [core:error] [pid 10696] [client <IP>:35768] Script timed out before returning headers: wsgi.py Here's my virtual host config for the domain (The same is working fine for my other projects): ServerName subdomain.domain.com ServerAlias another.subdomain.domain.com DocumentRoot /var/www/path/to/root ErrorLog /var/www/path/to/logs/error.log CustomLog /var/www/path/to/logs/requests.log combined WSGIScriptAlias / /var/www/path/to/root/app/wsgi.py WSGIDaemonProcess pname python-path=/var/www/path/to/root python-home=/var/www/path/to/root/venv home=/var/www/path/to/root WSGIPassAuthorization On WSGIProcessGroup pname WSGIApplicationGroup %{GLOBAL} <Directory /var/www/path/to/root/app> <Files wsgi.py> Require all granted </Files> </Directory> Any help is appreciated. Can't seem to find out any way to get a more verbose error message either. PS: It might seem like a duplicate question, but it's not. I've looked into all other similar questions but none of the mentioned solutions help. -
Django Custom Login
i need some parts of the django login Form "django.contrib.auth.forms UserCreationForm and AuthenticationForm" customized for later use. e.g. add captcha to the forms... i already did this for the Registration Form and its working pretty good but i still have some issues getting the login Form working. the current error i get is: File "H:\files\Projekte\PyCharmProjects\quickblog\quickblog\urls.py", line 7, in <module> from accounts import views as views_accounts File "H:\files\Projekte\PyCharmProjects\quickblog\accounts\views.py", line 4, in <module> from accounts.forms import RegistrationForm, EditProfileForm, LoginForm File "H:\files\Projekte\PyCharmProjects\quickblog\accounts\forms.py", line 9, in <module> class LoginForm(AuthenticationForm): File "H:\files\Projekte\PyCharmProjects\quickblog\accounts\forms.py", line 14, in LoginForm username = User(widget=forms.TextInput(attrs={'autofocus': True})) File "C:\Users\fritz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\smartfields\models.py", line 17, in __init__ super(SmartfieldsModelMixin, self).__init__(*args, **kwargs) File "C:\Users\fritz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 484, in __init__ raise TypeError("'%s' is an invalid keyword argument for this function" % kwarg) TypeError: 'widget' is an invalid keyword argument for this function This is my Login and Registration form: class LoginForm(AuthenticationForm): """ Base class for authenticating users. Extend this to get a form that accepts username/password logins. """ username = User(widget=forms.TextInput(attrs={'autofocus': True})) password = forms.CharField( label=_("Password"), strip=False, widget=forms.PasswordInput, ) error_messages = { 'invalid_login': _( "Please enter a correct %(username)s and password. Note that both " "fields may be case-sensitive." ), 'inactive': _("This account is inactive."), } def __init__(self, request=None, *args, … -
NoReverseMatch "Not valid new function or pattern name"
It's been a few hours and I can't seem to find where my error is. my thoughts were its in my category.html file or new_topic.html file. I am trying to add a new topic to a category. There are multiple categories and the topic that is entered will go to a specific category based on what the user chooses. Every time I click on the link to add a new topic to a certain category I receive the error shown above. Everything else works just fine. urls.py. File : app_name = 'blogging_logs' urlpatterns = [ # Home page path('', views.index, name='index'), # Show all Categories path('categories/', views.categories, name='categories'), # Show all topics associated with category re_path(r'^topics/(?P<category_id>\d+)/$', views.topics, name='topics'), # Show single topics re_path(r'^topic/(?P<entry_id>\d+)/$', views.topic, name='topic'), # Page for adding a new category path('new_category/', views.new_category, name='new_category'), # Page for adding new topics re_path(r'^new_topic/(?P<category_id>\d+)/$', views.new_topic, name='new_topic'), ] view.py file: def new_category(request): """Add a new category""" if request.method != 'POST': # No data submitted; create a blank formself. form = CategoryForm() else: # POST data submitted; process data form = CategoryForm(data=request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('blogging_logs:categories')) context = {'form': form} return render(request, 'blogging_logs/new_category.html', context) def new_topic(request, category_id): """ Add new topic to category … -
How can I get the value of a SQL raw query in Django?
I want to get the sum of a specific field using a raw sql query: total_profit = queryset.raw('SELECT SUM("products_product"."profit") AS Total_Profit FROM "products_product"') Using total_profit.columns, it returns ['total_profit']. Although, I don't know how to access it. If I try total_profit["total_profit"], I get the following error: InvalidQuery: Raw query must include the primary key I know that I can achieve the same result with Django ORM: total_profit = queryset.aggregate(total_profit=Sum("profit")) -
Django Admin: A field that sums selected objects from a multiple-select box on the add/change form page
I was trying to implement a sort of simple service order check-out system using the Django Admin, basically I had 2 models: Service and Service_Order: class Service(models.Model): name = models.CharField(max_length=20) price = models.DecimalField(max_digits=10, decimal_places=2, default=None) def __str__(self): return '%s - %s' % (self.name, self.price) class Service_Order(models.Model): order_id = models.CharField(max_length=5) client_name = models.CharField(max_length=50) services = models.ManyToManyField(Service) total_price = models.DecimalField(max_digits=10, decimal_places=2, default=None) ### PLACEHOLDER ### def __str__(self): return self.order_id I want the "add Service Orders" template to be basically like carts where you can select several services that have a price, originally I was gonna use a Many-To-One relationship (one service order can have many services), but instead I'm using a Many-To-One relationship because the "filter_horizontal" option makes the Admin interface attractive and easy to use (I can just select and add the services from the left-hand box and they're moved into the right-hand box), like this: service_order Now my problem is that I wanted to have a field that sums and displays the total sum of the prices of the services in the right-hand box, this could be a field that I could call total_price, which I have as DecimalField in my model (a placeholder for now). In the example shown … -
Django web server removing query string from browser URL
I'm running the Django development web server, and when I add a query string to a URL which is served by a view, the query string is removed from the URL in the browser. For example, when I visit http://127.0.0.1:8000/?test=y, the browser URL shows http://127.0.0.1:8000. The log, though shows the GET parameter: [25/Aug/2018 11:18:41] "GET /?test=y HTTP/1.1" 200 8517 I observe this behavior on all browsers. I'm using Django 1.11.4. -
RuntimeError: Model class snippets.models.Snippet doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
when I run Django use restful_framework. I met an error: RuntimeError: Model class snippets.models.Snippet doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS who can help me. Thanks every one who can help me. my serializers.py code: from rest_framework import serializers from snippets.models import Product class ProductSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('id', 'created', 'name', 'describe', 'price', 'isDelete') -
Docker: Service 'web' failed to build (Django application)
I am trying to create a Docker container for my Django project. I am using macOS High Sierra. I followed the instructions 1:1 but I am still running into this issue here. Anyone had this before? Starting docker_5pm_db_1 ... done Building web Step 1/7 : FROM python:3 ---> 825141134528 Step 2/7 : ENV PYTHONUNBUFFERED 1 ---> Using cache ---> 86fbc1f50cb7 Step 3/7 : RUN mkdir /code ---> Using cache ---> cddc69032a83 Step 4/7 : WORKDIR /code ---> Using cache ---> 5856113960ac Step 5/7 : ADD requirements.txt /code/ ---> Using cache ---> 904ab3d3b831 Step 6/7 : RUN pip install -r requirements.txt ---> Running in bb0e01c4ca4e ERROR: Service 'web' failed to build: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown -
django model structure to load complex json data
I have a huge movie database in json format and i want to load them into my write a python django app which will accomodate those data, How should my models be to accept those data containing multiple dictionaries. Here is a pastebin link to sample of Json and here is my modal codes from django.db import models class Movie(models.Model): id_number = models.CharField(max_length=1000) quality = models.CharField(max_length=500) img = models.URLField() index = models.IntegerField() openload = models.CharField(max_length=500) release = models.CharField(max_length=500) country = models.CharField(max_length=500) runtime = models.CharField(max_length=500) pg = models.CharField(max_length=500) description = models.TextField() original_title = models.CharField(max_length=500) IMDB_Rating = models.CharField(max_length=500) TMDB_Rating = models.CharField(max_length=500) youtube = models.URLField(max_length=500) genre = models.CharField(max_length=500) cast = models.CharField(max_length=500) actors = models.CharField(max_length=500) def __str__(self): return "{}".format(self.name) -
How to call a function from a html button - Django
What I'm trying to do is execute a function when the user clicks the "add to cart" button, the product displayed on the screen will be added to the cart model. So far i've figured out how to add objects to the cart from the shell. What i don't know is how to call a python function with html and how to pass the object to it. Thank you in advance. my template.html: {% extends 'templates/header.html' %} <title>{% block head_title %}{{ object.name }} - {{ block.super }}{% endblock head_title %}</title> {% block head %} {{ block.super }} {% load staticfiles %} <link rel = "stylesheet" href = "{% static 'css/products_detail.style.css' %}" type = "text/css"/> {% endblock head %} {% block content %} <div id='Product-Page'> <p>{{ object.name }}</p> <hr> <div id='Product-Image'> <img src='{{ object.image.url }}' alt='{{ object.image.name }}'/> </div> <div id='Product-Details'> <p id='Product-Name'>{{ object.name }}</p> <p id='Product-Description'><small>{{ object.description }}</small></p> </div> <div id='Product-Buy'> <p id='Product-Price'>{{ object.price }} лв.</p> <p id='Product-Quantity'>{{ object.quantity }} </p> <form class='Product-Form' method='post' action='#'> {% csrf_token %} <input class='Product-Button' type='submit' value='Buy Now'> </form> <form class='Product-Form' method='get' action=''> {% csrf_token %} <input class='Product-Button' type='submit' value='Add to cart'> </form> </div> <hr> </div> {% endblock content%} my view: class ProductDetailView(DetailView): template_name = … -
How to put Tensor objects in the same graph?
I'm trying to create a web-based machine learning application using Django and TensorFlow. In the views.py (server side), I have created several placeholders and operations and save them globally within the views.py. The view then displays (renders) an HTML file called train.html, I call another function from views.py using AJAX, to run the operations I have created previously, but it comes out with the error: TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("input:0", shape=(?, 9, 44), dtype=int32) is not an element of this graph. Here's an over-simplification of my code (without specifying imports, as it's obviously not import problem): views.py # Create TF placeholders and operations input = tf.placeholder(shape=[None, 9, 44], name='input') operation_1 = tf.reduce_mean(input) def index(request): render('my_app/train.html') # Displays train.html page def perform_operation(request): global input, operation_1 sess.run(operation_1, {input: request.POST['input']}) return HttpResponse(1) train.html <script> $.ajax({ url: "{% url 'perform_operation' %}" # Calls perform_operation method in views.py, data: {"input": [1, 2, 3]} }); </script> The error I specified previously points to the "sess.run" line. I've been searching the solution for this all day long, and still nothing comes to light. Any help would be very much appreciated, thank you. -
Adding command arguments to the Django runserver command and handle() method setup for local secure HTTP server
I'll keep this as vague as possible - as it's quite a broad question. I'm building a payment system within my Django project - and it would be amazing to be able to run my project over a secure server connections. And now were moving into a more forced secure internet with more emphasis on site security with in browser alerts etc I think this is something that needs to be added to the Django core management commands. I've started to build this functionality inside an application: management/commands/runsecureserver.py: import os import ssl import sys from django.core.servers.basehttp import WSGIServer class SecureHTTPServer(WSGIServer): def __init__(self, address, handler_cls, certificate, key): super(SecureHTTPServer, self).__init__(address, handler_cls) self.socket = ssl.wrap_socket(self.socket, certfile=certificate, keyfile=key, server_side=True, ssl_version=ssl.PROTOCOL_TLSv1_2, cert_reqs=ssl.CERT_NONE) I'm now wondering - I have the following class that extends from the BaseCommand class from Django's runserver.py where I add my arguments for specifying cert files etc, an inner_run() function which will mimic a lot of the Django runserver inner_run() with added certificate checks, port configurations etc. class Command(BaseCommand): def add_arguments(self, parser): super(Command, self).add_arguments(parser) parser.add_argument(**some argument here***) However, when running: $ python manage.py runsecureserver I receive the following error: NotImplementedError: subclasses of BaseCommand must provide a handle() method So, it's telling me … -
Django is not able to run manage.py runserver how to solve?
I'm trying to run manage.py server but it hit some error! I've just trying to print hello in web but it insn't working (venv) ubuntu@node:~/PycharmProjects/Oin$ python manage.py runserver Performing system checks... Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fd985430158> Traceback (most recent call last): File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 542, in url_patterns iter(patterns) TypeError: 'module' object is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run self.check(display_num_errors=True) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/management/base.py", line 351, in _run_checks return checks.run_checks(**kwargs) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 400, in check warnings.extend(check_resolver(pattern)) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 399, in check for pattern in self.url_patterns: File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/utils/functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/ubuntu/PycharmProjects/Oin/venv/lib/python3.4/site-packages/django/urls/resolvers.py", line 549, in url_patterns raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'openin.urls' from '/home/ubuntu/PycharmProjects/Oin/openin/urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue … -
How to make an Django app for an Already developed Android App?
This is a theoretical question and I want a rough Idea on how to achieve this. An Android app is already developed [ food booking app ] I want to make a website or rather I say web app which does the same work, how will I merge it with the website so that both do the same task? Tbh I am quite a noob to Django I am learning REST API Framework do I Need an API to connect the apps? I have no knowledge of React or angular JS I hope html+css+JS would be enough. Can someone please guide me what to do? -
Django Photologue giving 404 error when trying to display successfully uploaded files
I have django-photologue setup with the included templates, and by all accounts it should be working fine. All included URLS work fine, all pages load and there are no error codes from the console (I am using runserver with manage.py) bar the ones relevant to this issue. In settings.py, I have the following 2 relevant lines: MEDIA_ROOT = '/root/jake/jake_site/home/pl_images' MEDIA_URL = '/pl_images/' The files get uploaded, and are present in /root/jake/jake_site/home/pl_images/photologue/photos but they never display, and only 404 errors are returned when trying to access them. This is the output from the console of using manage.py runserver, after uploading an image, then clicking where the thumbnail should be and trying to display it: [25/Aug/2018 14:00:51] "GET /admin/photologue/photo/ HTTP/1.1" 200 7363 [25/Aug/2018 14:00:53] "POST /admin/photologue/photo/ HTTP/1.1" 200 3461 [25/Aug/2018 14:00:54] "POST /admin/photologue/photo/ HTTP/1.1" 302 0 [25/Aug/2018 14:00:54] "GET /admin/photologue/photo/ HTTP/1.1" 200 4871 [25/Aug/2018 14:00:54] "GET /admin/jsi18n/ HTTP/1.1" 200 3185 [25/Aug/2018 14:00:56] "GET /admin/photologue/photo/add/ HTTP/1.1" 200 9672 [25/Aug/2018 14:00:56] "GET /admin/jsi18n/ HTTP/1.1" 200 3185 [25/Aug/2018 14:01:13] "POST /admin/photologue/photo/add/ HTTP/1.1" 302 0 [25/Aug/2018 14:01:13] "GET /admin/photologue/photo/ HTTP/1.1" 200 7523 [25/Aug/2018 14:01:13] "GET /admin/jsi18n/ HTTP/1.1" 200 3185 Not Found: /pl_images/photologue/photos/cache/test_admin_thumbnail.jpg [25/Aug/2018 14:01:13] "GET /pl_images/photologue/photos/cache/test_admin_thumbnail.jpg HTTP/1.1" 404 2441 [25/Aug/2018 14:01:32] "GET /photologue/photo/test-image/ HTTP/1.1" 200 2915 … -
Django: Using ".first()" on a related queryset triggers queries despite "prefetch_related". Is there a workaround?
I'm trying to optimize some querysets in my Django code by using prefetch_related. However, I've realized that if elsewhere in the code, a queryset function such as first, last, latest etc.. is called on a related queryset, a query is triggered regardless, effectively nullifying the optimization. e.g. class Client(models.Model): # [...] @property def latest_order(self): self.orders.latest('ordered_at') # Order is a Many-to-one related obj Using Client.objects.prefetch_related('orders') is not gonna be useful and latest_order will still trigger a query for each Client. Is there a way around this without altering the Client model's property? Otherwise if that's the best solution, what's the best way to retain the functionality latest_order? The only way I can think of is to just to replicate latest functionality but in memory (via the sorted function), however this means that I lose out on being able to do this operation database-side if it's advantageous (e.g. I'm just looking at 1 client with A LOT of orders). -
RatePay implemented in django project
I'm new to programming and I have to implement ratepay natively into a project. The project is done in python 2.7 with a django and django-oscar framework. I didn't find any sdk to help me with that. Does someone have any advice on how to implement it? Or some steps to follow ? -
Python Requests library to fill out option list
I'm trying to fill out a web form using python requests. Does anyone know the correct syntax when there is a drop down (option list)? I can successfully post to the text boxes on the form, but not the option list import requests URL = 'http://127.0.0.1:8000/recoater/new/' payload = { 'data': '40', 'machine': '"1">MachineA<', } r = requests.post(URL, data=payload) print (r) print(r.text) Returns this: <ul class="errorlist"><li>Select a valid choice. That choice is not one of the available choices.</li></ul> <p><label for="id_machine">Machine:</label> <select name="machine" required id="id_machine"> <option value="">---------</option> <option value="1">MachineA</option> -
Django : Doesn't apply an automatic id field to table
I'm working on a project that has new data coming in every 24 hours. Weather sensor data. To test things locally, I'm importing the data into a new table that I make in postgresql. After creating the django project, I set up the database. I connected Django to my local database, without any models yet. In psql, I make a new table labeled weather_sensors, with several different fields. There is no id field, since Django should set that automatically. After python manage.py migrate and setting a superuser, I then copy the data from the .DAT file and put that data into the table fields. Then: python manage.py inspectdb > models.py I get the model from there, and put it into my models.py. Meta class managed = False, but I delete that because I want Django to manage it. However, it wont. Django, for some reason, doesn't automatically set an id column. So when I try to view the page, it gives me an error stating that weather_sensors.id can't be found. If I manually ALTER the table through psql and add an 'id' column, it works fine. However, if I want to override the id, say with 'location_id = models.IntegerField(primary_key=True)' it … -
Django Rest Framework include_docs_urls adding _0 to action
We have urls in our Django (Rest Framework) applications like: r'^endpoint/(?P<item>[a-z_-]+)/$' r'^endpoint/(?P<item>[a-z_-]+)/(?P<version>[0-9]+(\.[0-9])?)/$' Both have POST methods available. We've been using Swagger for a while to document our API but wanted to look at the coreapi documentation included in Django Rest Framework. Going through our documentation based on the above structure the coreapi action results in: # Initialize a client & load the schema document client = coreapi.Client() schema = client.get("http://localhost:8081/docs/") # Interact with the first url action = ["app", "endpoint &gt; create"] # Interact with the second url action = ["app", "endpoint &gt; create_0"] I can understand where create_0 is coming from, but ideally it would add the keyword name as a suffix instead, e.g. create_version. Is this possible? -
Django cannot access model in admin site
I was trying to adjust a DateField in one of my models to also show the time (DateTimeField). I ended up also making timezone adjustments. After all I decided to not use the time and deleted the additional code and set the field back to DateField. Migrations are made and migrated. Now when trying to access an object from the model either via the page or admin page I receive the error: invalid literal for int() with base 10: b'24 22:00:00' So after trying a few things I just wanted to delete the objects in the model using the admin page. This also resulted in the above error. It seems every page relying on an object from that model throws the error. Is there a way to force delete objects? Can you recommend any other clean up methods? The model is defined as: class PieceInstance(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, help_text='Unique ID for this particular Piece across whole system') piece = models.ForeignKey('Piece', on_delete=models.SET_NULL, null=True) version = models.CharField(max_length=200) date_claimed = models.DateField(null=True, blank=True) claimant = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) date_sent_to_claimant = models.DateField(null=True, blank=True) PIECE_STATUS = ( ('n', 'Not Claimable'), ('a', 'Available'), ('r', 'Reserved'), ('c', 'Claimed'), ) status = models.CharField( max_length=1, choices=PIECE_STATUS, blank=True, default='a', … -
Permanently replace value in Django
After extensive googling, I still havent come up with an effecient way to solve this. Im creating a website using Django. I have a db which contains time data, more specifically dates. The value for "the present" is set to 3000-01-01 (YYYY-MM-DD) as is common practice for time-querying. What I want to do is display a string like "Now" or "Present" or any other value instead of the date 3000-01-01. Is there some sort of global override anywhere that I can use? Seems like a waste to hard-code it in every view/template. Cheers! -
Syntax error while saving postgresql server info in setting.py Django
I am getting Syntax error while saving postgresql server information in setting.py file of Django and running server. Below are the settings i am saving in setting.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'webportal', 'USER': 'postgres', 'PASSWORD': 'password' 'HOST':'localhost', 'PORT' : '5432', } } and the error is :- \Django_Project\project2\WebPortal-Project>manage.py runserver Traceback (most recent call last): File "C:\Users\AJ!!\Dropbox\Django_Project\project2\WebPortal-Project\manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line utility.execute() File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 317, in execute settings.INSTALLED_APPS File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__ self._setup(name) File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 43, in _setup self._wrapped = Settings(settings_module) File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\__init__.py", line 106, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "C:\Users\AJ!!\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "C:\Users\AJ!!\Dropbox\Django_Project\project2\WebPortal-Project\WebPortal\settings.py", line 83 'HOST':'localhost', ^ SyntaxError: invalid syntax Could you please help me figure out what is this syntax error appears. -
Django redirect to previous page saving queries
So I have a page that displays a table and on each row I have a button called delete that deletes that row and all the information related to it in my database. The delete button works fine, as in it deletes the information in my DB, but I'd like to redirect it to the page where I display the table. The problem is that, to access the page that shows the table, it is done through a search with POST method. I thought of saving the parameters that I save when I do the search in a global variable and then render the table page again, with those saved parameters from the initial search, it kinda works, but not they way I want it: It changes my URL to the one that redirects after clicking delete, and, it doesnt update the page manually, so I still see the row I deleted, tho If i refresh it manually, I can't see the deleted row anymore. views.py: def character_delete (request): if request.method == "GET": Id = request.GET.get("idChar") char = Characterweapons.objects.all().filter(characterid=Id).delete() char2 = Characters.objects.all().filter(characterid=Id).delete() global cont return render(request, 'users/characters_found_table.html',cont) Any ideas? Thanks!