Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to put view.py in a folder? [closed]
I have created a django project and I want to create folder 'faqs' and put my view.py in faqs folder. How do I edit my urlpatterns in urls.py so that when localhost/faqs loads, view.py inside faqs appears on screen. -
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object named 'django_content_type' in the database
I installed Django 3.2.6 and I am able to spin up the server using python manage.py runserver however when I want to do migrate through python manage.py migrate i am getting the above error message. How can I solve that? -
django in_bulk multiple fields
Can I create Django in_bulk with multiple fields as the key? for example, I have a model class Sig(models.Model) name = models.CharField(max_length=80) version = models.IntegerField() description = models.CharField(max_length=80) class Meta: constraints = [ models.UniqueConstraint(fields=['name', 'version'], name='AK1') ] Expected output An in_bulk style dictionary with { ('name', 'version') -> Sig object } I'm using Django 3.2 The alternative solution I've found is to create a dictionary using native python instead of django's features which I fear will be slower. -
Can anyone help me on why my clone formset data isnt saved?
Im having the trouble of saving a cloned formset data right now. Now it just saved whatever its at the last row. The cloning works well as shown in the pic. Everything is working well for my web except for this part. To all the pros out there, im a beginner in this, please help me. Would really appreciate it. Stuck at this for 4 days already Assuming all the fields are with text. Those in red circle are not saved and the one in blue circle is saved upon clicking save Here is my code: views.py def device_add(request): if request.method == "POST": device_frm = DeviceForm(request.POST) ##Part A1 dd_form = DeviceDetailForm(request.POST) #di_form= DeviceInterfaceForm(request.POST) di_formset = modelformset_factory(DeviceInterface, fields=('moduletype', 'firstportid', 'lastportid'), extra=1,max_num=3) di_form=di_formset(request.POST) if device_frm.is_valid(): # Create and save the device # new_device here is the newly created Device object new_device = device_frm.save() if dd_form.is_valid(): # Create an unsaved instance of device detail deviceD = dd_form.save(commit=False) # Set the device we just created above as this device detail's device deviceD.DD2DKEY = new_device # If you did not render the hostname for the device detail, set it from the value of new device deviceD.hostname = new_device.hostname deviceD.save() if di_form.is_valid(): deviceI=di_form.save(commit=False) for deviceI in … -
JSONDecodeError at Expecting value: line 1 column 1 (char 0)
I have tried using the methods with recent answers from this platform but am still getting this error. I am reading my data from the database to update my cart. When i click on the up button it just works okay, whenever i click on the remove button(down error i get File "C:\Users\hp\Desktop\UmojaWater\products\views.py", line 177, in updateItem productId = data['productId'] KeyError: 'productId' [20/Aug/2021 05:56:55] "POST /update/ HTTP/1.1" 500 64093 When i check teh json file on browser it brings the jsonencoding type. In general, the encoding is teh one causing all these problems. I can append the number of products but i cannot decrese them. How can i fix this. Here is my view.py code def AllProducts(request): if request.user.is_authenticated: customer = request.user order, created = Order.objects.get_or_create( customer=customer, complete=False) items = order.orderitem_set.all() cartitems = order.get_cart_items else: items = [] order = {' get_cart_total': 0, 'get_cart_items': 0} cartitems = order['get_cart_items'] allproducts = Product.objects.all() context = {'allproducts': allproducts, 'cartitems': cartitems} return render(request, "products/AllProducts.html", context) @login_required def userCart(request): if request.user.is_authenticated: customer = request.user order, created = Order.objects.get_or_create( customer=customer, complete=False) items = order.orderitem_set.all() cartitems = order.get_cart_items else: items = [] order = {' get_cart_total': 0, 'get_cart_items': 0} cartitems = order['get_cart_items'] context = {'items': items, 'order': … -
Application labels aren't unique, duplicates: staticfiles
I'm having trouble figuring out what I'm duplicating here. I'm trying to migrate my files so I can deploy on Heroku. It says that "staticfiles" is duplicated, but I can't see where the conflict is. Does migration need to be done in order to deploy? or is there something wrong with my database? import dj_database_url import os ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] INSTALLED_APPS = [ 'whitenoise.runserver_nostatic', 'wiki_app', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.postgres', ] MIDDLEWARE = [ 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'coding_dojo_final_project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'coding_dojo_final_project.wsgi.application' ... WHITENOISE_USE_FINDERS = True ... STATIC_URL = '/static/' db_from_env = dj_database_url.config(conn_max_age=500) DATABASES['default'].update(db_from_env) STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -
Django CMS live support chat plugin
I'm building a website using django cms and I need to add a chat to it so that customers can quickly contact tech support. This chat can also be a chatbot that answers some questions and gives the option to contact technical support. Is there a django cms plugin that allows me to do this or can someone recommend me in another way? -
django.core.exceptions.ImproperlyConfigured, need hel
Here's the error message: django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'basicsiteApp' from '/Users/msa/trydjango/basicsite/basicsiteApp/init.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import. I don't have anything written in init.py file because I don't know what I need to write in it so it can work. Here's what I have in views.py: basicsiteApp/views.py from django.shortcuts import render from .forms import SignUpForm from django.contrib import messages def signup(request): if request.method == 'POST' form = SignUpForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'Account Created') return render(request, 'signup.html') else: form = SignUpForm() render(request, 'signup.html') -
How to make PDF fillable?
I have links to unfillable PDFs and I want to make them fillable in my python application. I could use Adobe SDK for Python, but does this allow me to automate PDF fillability. I just want to create the fillable fields and display the PDF for users to fill out. I have 10,000 PDFs, so I want to just call the API to make them fillable. -
Stuck two days on this NoReverseMatch thing
Coded in Pycharm Django version 3.2.6 Project hw_v2 app aftersales ... Templates Project URL urlpatterns = [ path('', include(('index.urls', 'index'), namespace='index')), path('admin/', admin.site.urls), path('mkt/', include(('marketing.urls', 'marketing'), namespace='mkt')), path('com/', include(('commercial.urls', 'comercial'), namespace='com')), path('aft/', include(('aftersales.urls', 'aft'), namespace='aft')), path('gen/', include(('general.urls', 'general'), namespace='gen')), path('user/',include(('user.urls','user'),namespace='user')), path('bootstrapTable/',include('bootstrapTable.urls')),] App/aftersales URL: urlpatterns = [ path('', views.aft,name='afti'), path('edit/<int:id>',views.aft_edit,name='aft_edit'), path('view/<int:id>',views.aft_view,name='aft_view'),] Error Page HTML: <td> <a href="{% url 'aft:aft_view' id=itm.id %}" class="lni lni-magnifier"></a> <a href="#" class="lni lni-close"></a> <a href="{% url 'aft:aft_edit' id=itm.id %}" class="fadeIn animated bx bx-edit-alt"></a> </td> Error: NoReverseMatch at /aft/view/1 Reverse for 'aft' not found. 'aft' is not a valid view function or pattern name. Request Method: GET Request URL: http://127.0.0.1:8000/aft/view/1 Django Version: 3.2.6 Exception Type: NoReverseMatch Exception Value: Reverse for 'aft' not found. 'aft' is not a valid view function or pattern name. Exception Location: D:\0 PROJECTS\14 django_website_ali\hw_v2\venv\lib\site-packages\django\urls\resolvers.py, line 694, in _reverse_with_prefix Python Executable: D:\0 PROJECTS\14 django_website_ali\hw_v2\venv\Scripts\python.exe Python Version: 3.9.2 Python Path: [WindowsPath('D:/0 PROJECTS/14 django_website_ali/hw_v2'), 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\app', 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2', 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2', 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\app', 'D:\\Program Files\\JetBrains\\PyCharm ' '2020.1\\plugins\\python\\helpers\\pycharm_display', 'D:\\Program Files\\Python39\\python39.zip', 'D:\\Program Files\\Python39\\DLLs', 'D:\\Program Files\\Python39\\lib', 'D:\\Program Files\\Python39', 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\venv', 'D:\\0 PROJECTS\\14 django_website_ali\\hw_v2\\venv\\lib\\site-packages', 'D:\\Program Files\\JetBrains\\PyCharm ' '2020.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend'] Server time: Fri, 20 Aug 2021 09:01:56 +0800 I've been stuck here for two days. The error came out … -
is there a solution to the fcntl error when running heroku local web on windows?
I've been trying to run my Django project on heroku local web though, I'm stuck with this error and don't seem to know what to do as a workaround? ModuleNotFoundError: No module named 'fcntl' -
Getting Django to log info to the console and errors to a file
I've made the following logging config: settings.py LOGGING = { "version": 1, "disable_existing_loggers": False, "filters": { "require_debug_false": {"()": "django.utils.log.RequireDebugFalse",}, "require_debug_true": {"()": "django.utils.log.RequireDebugTrue",}, }, "formatters": { "django.server": { "()": "django.utils.log.ServerFormatter", "format": "[{server_time}] {message}", "style": "{", } }, "handlers": { "console": {"level": "INFO", "filters": ["require_debug_true"], "class": "logging.StreamHandler",}, "file": { "level": "ERROR", "filters": ["require_debug_false"], "class": "logging.FileHandler", "filename": BASE_DIR / "debug.log", }, "django.server": {"level": "INFO", "class": "logging.StreamHandler", "formatter": "django.server",}, "mail_admins": { "level": "ERROR", "filters": ["require_debug_false"], "class": "django.utils.log.AdminEmailHandler", }, }, "loggers": { "django": {"handlers": ["file", "console"], "level": "INFO",}, "django.server": {"handlers": ["django.server"], "level": "INFO", "propagate": False,}, }, } And just want normal Django console logging alongside file logging when any errors happen. Presently this logs console information just fine and creates a debug.log, but does not output anything to it. This has been tested by just causing a syntax error in the settings file. What is wrong with this config? -
Is there a way how to get a value of a link
I've been working on Django App and I wanna make a function in this. All I wanna do is to redirect a user to a search page with an input of a tag name when the user clicked one of tags of a blog. For example, when a user clicked a tag named 'test', the user would be sent to the search page. And, one of the three inputs has a value 'test', and the result's blogs below is filtered by 'test'. I hope this made sense to u. Below are the codes I believe u need. blog.html {% extends 'base.html' %} {% block title %}|{{ blog.title }}{% endblock %} {% block content %} <div class="header-bar"> <a href="{% url 'latest_blogs' %}">&#8592; 戻る</a> </div> <div class="body-container blog"> <div class="blog-info"> <div class="user-and-date"> <!-- {% if request.user == blog.user %} <a href="{% url 'dashboard' user.id %}">あなた</a>が{{ blog.created }}に作成 {% else %} {{ blog.user }}が{{ blog.created }}に作成 {% endif %} --> <p>{{ blog.user }}</p> <p>{{ blog.created }}</p> </div> <div class="icons"> {% if request.user == blog.user %} <a href="{% url 'blog_update' blog.id %}" class="far fa-edit"></a> {% endif %} </div> </div> <div class="blog-main"> <h2>{{ blog.title }}</h2> <!-- <h3>コンテンツ1</h3> --> <p class="blog-content">{{ blog.content_1 }}</p> {% if blog.content_2 … -
ModuleNotFoundError: No module named 'listings' despite directory being in PATH
I have a file structure like so. remindMe │ │ ├───remind_me_django │ └───listings │ models.py │ __init__.py │ └───scrapy └───scrapy_project │ items.py │ __init__.py │ └───spiders I'm trying to import my models.py file into items.py but to no avail. When attempting to import into items.py, I get a ModuleNotFound error. Other suggestions say to add my directory to my path but that's been unsuccessful so far as well. sys.path.append("C:\\Users\\Denze\\Projects\\remindMe\\remind_me_django\\listings") from listings.models import Product I've also tried: from remind_me_django.listings import Product The funny thing is with this import, if I right click on the import within VSCODE and go to it's definition, it opens up that modules init file, so VSCODE knows what I'm referencing but Python does not? -
How to create a custom Django user model in an existing project (still early on in the project)
I'm trying to create a custom Django user model as I am using Auth0 for my user authentication but still want to store the user information for Auth0 within my Django project and database. I already have Django project that I ran migrations on so I can't make a custom User model from the beginning if I were to do it at the start of a project. At being said though, I'm still really earlier in the project. I only have 1 user (being the superuser) and the other models I have don't have any references to any user models. I'm still new to Django and I'm a bit confused on how to go about creating a custom Django user model in this certain situation and any help would be really appreciated, thank you. -
How to lock same time slot multiple times in django?
We building a Django application where we want to manage time slots such that where multiple user can use same time slot to order their product. On the contrary a delivery truck can ship product up to 9 times per day (9:30 AM, 10:30AM, 12:30 PM, 02:30PM, 04:00PM, 06:00PM, 08:00PM, 09:00PM, 12:00AM) . If we have 2 trucks then we can deliver our product in 9:30 AM twice in a day. Time Slots for per day delivery. We manage to lock/reserve/order the date only one time. We want to Reserve our current time with current date also all of the date of month dynamically. We can’t manage to order same time slot multiple times. How we can implement multiple order in same time slot? class OrderDashboard(models.Model): time = models.TimeField() reserved = models.BooleanField(default=False) class Reserved(models.Model): time = models.TimeField() date = models.DateField() # @login_required() def order_fuel(request): from django.db.models import Q date_time = OrderDashboard.objects.all() reservation = False if request.method == "POST": time = request.POST.get('time') date = request.POST.get('date') reserved = Reserved.objects.filter(Q(time=time) & Q(date=date)) if reserved: reservation = True print(reservation) return HttpResponse('Time already reserved!') else: reserved_ins = Reserved( time=time, date=date ) reserved_ins.save() return HttpResponse('Order confirmed') dict = {'date_time': date_time, 'reservation': reservation} return render(request, 'Uftl_App/orderfuel.html', context=dict) -
Django ajax pagination (without using JQuery), to update a portion of a page
I am using Django 3.2 I have a ListView derived CBV that returns a paginated list of objects. The list of objects is shown in a small portion of the main (heavy) page, and I want to update only the portion of the page that shows the list. For reasons I won't go into here, I can't seem to use jQuery (basically, I am using onclick() and if I define the onclick callback function within $().ready({}); then the function is not defined by the time it is called) - so I have to define the function using POJS (Plain Old JS). Here is a snippet of what I have so far: Javascript func in base template: function doIt(url, token, pagenum) { fetch(`${url}?page=${pagenum}`, { method: 'post', headers: { 'Accept': 'application/json, text/html, */*', 'Content-Type': 'text/html', 'X-CSRFToken': token }, //body: JSON.stringify({a: 7, str: 'Some string: &=&'}) }).then(res => res.text()) .then(res => console.log(res)); } /path/to/pagination-template # Test line <li class="page-item"><a class="ajax-pager page-link" onclick="doIt('{{ request.build_absolute_uri }}{{ object.get_absolute_url }}', '{{csrf_token}}', {{ i }});" href="#"</a></li> When I click on the anchor tag, a POST request is issued, and the server (i.e. Django) responds with a 200 OK status. However, nothing is logged on my console. Note: I … -
Upload file to Django backend by reading the file path from local machine
I am new to django and trying to get below scenario working. Can someone please guide me? Upload a master file which has absolute path of multiple files from my local machine or client machine which I want to process. In Django template, within Javascript, I am trying to read each of the file location from my local system and upload it to Django backend server. Is there any simple way to upload the file in Django by using the absolute path of a file from client machine? -
Django admin static files magically served
I just setup a simple Django website, and commented out path('admin/', admin.site.urls), with STATIC_URL = '/static/' in the settings.py, When I goto http://localhost:8100/static/admin/css/nav_sidebar.css, I see this static file is magically severed. What's really going on? I have not setup the static url serving in my urls.py yet? -
How to load a Jupyter Notebook for a Django project on a remote server?
I would like to run a Jupyter Notebook on a remote server where my Django project is hosted, but after I start the Notebook I'm unable to load the web page in a browser. When Jupyter Notebook is started localy I can easily load the page http://127.0.0.1:8888/?token=*** , but when started remotely with SSH the page http://IP_ADDRESS:8888/?token=*** doesn't load. What is the reason for this ? From my understanding it is supposed to start a webserver on port 8888 on the remote server. My Django project use Uvicorn server on port 8000. (env) zzz@ubuntu-2cpu-4gb-de-fra1:/var/www/capital$ python manage.py shell_plus --notebook [I 21:43:44.221 NotebookApp] Serving notebooks from local directory: /var/www/capital [I 21:43:44.222 NotebookApp] The Jupyter Notebook is running at: [I 21:43:44.222 NotebookApp] http://localhost:8888/?token=3cce26532860d8f8db0e6e27d945168a90b0f48cec912152 [I 21:43:44.222 NotebookApp] or http://127.0.0.1:8888/?token=3cce26532860d8f8db0e6e27d945168a90b0f48cec912152 [I 21:43:44.222 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 21:43:44.225 NotebookApp] No web browser found: could not locate runnable browser. [C 21:43:44.225 NotebookApp] To access the notebook, open this file in a browser: file:///home/zzz/.local/share/jupyter/runtime/nbserver-19178-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=3cce26532860d8f8db0e6e27d945168a90b0f48cec912152 or http://127.0.0.1:8888/?token=3cce26532860d8f8db0e6e27d945168a90b0f48cec912152 -
Represent data consumed from 3rd party api in django with chart.js
I am working on a website that shows you the vitamins in the food I am using a 3rd party api that provides the data I need the problem is I can't find a way to represent this data in chart.js, what I am basically trying to do is get the data from the api then extract the labels and the amount that I need from the data but i don't know how to pass it to the template and be able to actually use it in my javascript file. this is the code I am currently trying to make work with it currently f**ed up cuz I keep adding and deleting to it but I hope you get what I am trying to do views.py def food_info(food_id, amount): info = requests.get( f'{base_url}/food/ingredients/{food_id}/information?amount={amount}&unit=grams&apiKey=') food = info.json() nutrients_data = food['nutrition']['nutrients'] labels = [nutrient['title'] for nutrient in nutrients_data if nutrient['amount'] > 0] return JsonResponse(data={'labels':labels}) def search_food(request): if request.method == 'POST': name = request.POST.get('name') amount = request.POST.get('amount') result = requests.get( f'{base_url}/food/ingredients/search?query={name}&addChildren=false&number=1&apiKey=') result = result.json() food_id = result['results'][0]['id'] food_info(food_id,amount) return render(request, 'food/test.html') class FoodChartData(APIView): authentication_classes = [] permission_classes = [] def get(self, request, format=None): labels = ['Cholesterol', 'Saturated Fat', 'Phosphorus', 'Poly Unsaturated Fat', 'Fiber'] … -
Django Custom Login Form Submission Does Not Go to LOGIN_REDIRECT_URL or Display Errors
I am trying to create a custom login form in Django 3.2. When I use a standard boilerplate login form using {{ form.as_p }}, a successful login takes me to the LOGIN_REDIRECT_URL defined in settings.py. An unsuccessful login shows the errors above the form. But when I use a custom login form, a successful login takes me right back to the login page. I looked at the generated HTML for the working form but cannot tell what I am doing wrong. An unsuccessful login acts the same way and doesn't show any errors. What am I missing here? registration/login.html (works as expected) <html> <body> <h1>Log In<h1> <form method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit">Log In</button> </form> </body> </html> registration/login.html (does not work) <html> <body> <h1>Log In<h1> <form method="post"> {% csrf_token %} <div class="mb-3"> <label for="id_username">Email</label> <input id="id_username" class="form-control form-control-lg" type="email" name="email" placeholder="Enter your email" /> </div> <div class="mb-3"> <label for="id_password">Password</label> <input id="id_password" class="form-control form-control-lg" type="password" name="password" placeholder="Enter your password" /> </div> <small> <a href="{% url 'password_reset' %}">Forgot password?</a> </small> <button type="submit">Log In</button> </form> </body> </html> urls.py (at project level) urlpatterns = [ path('auth/', include('django.contrib.auth.urls')), path('', include('app.urls')) ] -
How to make application in django work? Runnig a python script like class in django
I'm bit new with django and I'm lost, I don't know what to do. I'll explain what I want, maybe you can help me. I want to create a web page on my site where you input your data and based on your data you get created a excel template which you download. Most basic, you input name of rows and columns and you download an excel document. Here is what I have tried so far... I have a my_django folder and my_app folder, in my_app I'm trying to create an app to create templates. This is my_app/views.py from django.shortcuts import render from django.http import HttpResponse from .forms import TemplateForm import xlsxwriter from xlsxwriter import workbook def home(request): return render(request, 'my_app/home.html') def create_template(request): return render(request, 'my_app/create_template.html') class CreateMyWebTemplate(): def create_template(doc_name, name_sheet, years, name_columns): file = xlsxwriter.Workbook(doc_name + '_template.xlsx') worksheet_data = file.add_worksheet() worksheet_data.write_row(0, 1, years) worksheet_data.write_column(1, 0, name_columns) file.close() return file This is my_app/urls.py from django.urls import path from . import views urlpatterns = [ path('', views.home, name='my-home'), path('create-template/', views.create_template, name='my-create-template'), ] This is my_app/template/my_app/create_template.html {% extends "my_app/base.html" %} {% block content %} <div class="create-template-box"> <form action="/"> <h1>Create your template</h1> <div class="item"> <p>Document name</p> <div class="name-item"> <input type="text" name="doc_name" placeholder="Input document … -
Overriding get_queryset, but get empty result set
So I have a database of books, and I want to search it based on filters and keywords so I've overridden the get_queryset method in my BookSearch view: class BookSearch(generics.ListAPIView): serializer_class = ProductDetailViewSerializer model = ProductDetailView def get_queryset(self): queryset = None categories = self.kwargs['categories'].rstrip() keywords = self.kwargs['keywords'].rstrip() if isinstance(categories, str) and isinstance(keywords, str): book_filter = BookFilter(categories) sql = self.get_sql(categories, keywords, book_filter) queryset = ProductDetailView.objects.filter( id__in=RawSQL(sql, book_filter.params) ) message = f"{queryset.query}" log_to_file('BookSearch.log', 'BookSearch.get_queryset', message) return queryset That log_to_file call logs the query that django uses, which I've abbreviated here but is as follows: SELECT `jester_productdetailview`.`id`, `jester_productdetailview`.`isbn`, `jester_productdetailview`.`title` FROM `jester_productdetailview` WHERE `jester_productdetailview`.`id` IN ( select id from jester_productdetailview where ( authors like '%Beatrix%' or illustrators like '%Beatrix%' or title like '%Beatrix%' ) ) ORDER BY `jester_productdetailview`.`title` ASC If I run that query in my database manually, I get 186 rows: '119371','9780723259572','A Beatrix Potter Treasury' '130754','9780241293348','A Christmas Wish' '117336','9780241358740','A Pumpkin for Peter' ... To get the query above, I call the view through the API, yet by the time the queryset is returned, there are no results ??? http://127.0.0.1:8000/api/book-search/{"filter": "all"}/Beatrix/ returns [] -
Connect remote mysql to django
i have a MySQL database in cpanel and i want to connect my django project to this database when i try to connect it it show a message that i can't connect to localhost but i don't want to connect to localhost i want to connect to my remote database in cpanel. i have tried to connect to (MySQL workbench) and it connected without a problem. This is a picture of my settings and error