Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
postgresql backup DB linked to django restore error
PostgreSQL 10 with PostGIS 2.4 linked to a Django (1.11.18). Currently moving my DB to a remote server and going through the backup and restore process. Backup Process PGAdminIII - backing up with tar format. All the dump options are default (only blobs are selected in Dump Options #1, verbose messages in Dump Options #2). I back it up and there are no errors. Restore Process Using default settings in PGAdminIII. I get this error for every single table in the DB. These errors are causing issues in my application querying for data from the DB -
Why am I getting a key error in my Django code given below?
from django import forms from django.core import validators class FormName(forms.Form): name=forms.CharField() email=forms.EmailField() verify_email=forms.EmailField(label='Confirm your email') text=forms.CharField(widget=forms.Textarea) def clean(self): #Allows us to grab all the clean data at once all_clean_data=super().clean() #This will clean the entire Form email=all_clean_data['email'] vmail=all_clean_data['verify_email'] if email != vmail: raise forms.ValidationError("Make sure your emails match") In this code, I am getting a key error at verify_email vmail=all_clean_data['verify_email'] KeyError: 'verify_email' -
Django JSONField list of dicts "contains" filter inside Subquery
I'm trying to filter model objects which contain key-value pair from OuterRef in their JSONField with list of dicts. I have a model EntityObject with fields "type" and "data". It works witout Subquery: EntityObject.objects.filter( type='child', data__list_of_dicts__contains=[{'some_key': 'value'}] ) Also it works inside Subquery without __contains (but needs values from JSONField to be annotated). For example I can count entities which have data.some_other_key equal to data.some_key of parent entity: (EntityObject.objects .filter(type='parent') .annotate(data_some_key=Cast( KeyTextTransform('some_key', 'data'), models.CharField()) ) .annotate(cnt=Subquery( EntityObject.objects .filter(type='child') .annotate(data_some_other_key=Cast( KeyTextTransform('some_other_key', 'data'), models.CharField()) ) .filter(data_some_other_key=OuterRef('data_some_key') .values('type') .order_by() .annotate(cnt=Count('*')) .values('cnt')[:1], output_field=models.IntegerField() )) Now I try to combine both queryies like this: (EntityObject.objects .filter(type='parent') .annotate(data_some_key=Cast( KeyTextTransform('some_key', 'data'), models.CharField()) ) .annotate(data_some_other_key=Cast( KeyTextTransform('some_other_key', 'data'), models.CharField()) ) .annotate(cnt=Subquery( EntityObject.objects .filter(type='child') .annotate(data_list_of_dicts=KeyTransform('list_of_dicts', 'data')) # not sure if this is correct .filter(data_list_of_dicts=[{OuterRef('data_some_key'): OuterRef('data_some_other_key')}] .values('type') .order_by() .annotate(cnt=Count('*')) .values('cnt')[:1], output_field=models.IntegerField() )) But it throws an error: TypeError: OuterRef(data_some_key) is not JSON serializable Is there any way of doing it without using RawSQL or looping? -
In the Django admin interface, is there a way to check a few list items and trigger an action to copy field contents to clipboard?
For example, if I had a model: StoragePosition(models.Model) which has a field, 'name'. I would want to enter the model's list/change view. Then select a few items, choose a 'copy names to clipboard' action. Then be able to paste in the format: name_1 name_2 name_3 I would especially want it to be able to paste contents into an excel spreadsheet, each name in its own cell. -
When I include a template in another template how can I pass the path of a source file?
I have two templates that go together, one inside the other. The inner one has an icon that needs to change according to the content of the parent template. I've tried to pass the icon path using a variable: src="{% url 'main_bar_icon' %}"> and I added this line of code in the parent template: {% with main_bar_icon='../static/dist/img/logout-icon.svg' %} {% include 'main_bar.html' %} {% endwith %} So, this is my inner template: {% block main_bar %} <a href=""> <img class="app-main-bar-icon" src="{% url 'main_bar_icon' %}"> </a> {% endblock main_bar %} And this is my parent template: {% block content %} {% with main_bar_icon='/dist/img/logout-icon.svg' %} {% include 'main_bar.html' %} {% endwith %} {% endblock content%} In the browser I get this: <img class="app-main-bar-icon" src(unknown) alt="icon"> -
Django 2 Many to Many relationships
I'm working on a project using Python(3.7) and Django(2.1) in which I need to build a relationship between users and organizations. I'm using the default Django User model and a profile model to add extra information to users. Many users can join an organization and an Organization can have many members, a user can create an Organization, these behaviors I need to implement, according to my understanding we need to build a ManyToMany relationship for Organizations model, but don know how to use this relationship to display the information, e.g display a user's organizations on his profile page. Here are my models: class Organization(models.Model): name = models.CharField(max_length=255, blank=False) users = models.ManyToManyField(User, related_name='members', null=True) def __str__(self): return self.name class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='media/default.jpg', upload_to='profile_pics') goals = MultiSelectField(choices=goals_choices, default='') def __str__(self): return f'{self.user.username} Profile' -
How to build a shopify application with django
I have a homework : The objective is to create a Shopify app. The app will allow a customer to login to the shop using his Twitter account. Stack using : Django + DRF + Vanilla Js (for the front end). But i have never build an app for shopify apps store, and all tutorials found about django an shopify are very old and not updated. And others are only about Ruby... So i post here to hope find somebody to explain (not necessary in details) how can i setup my django app and make it reachable on shopify app store. Where an customer can try to login in his shop with a twitter account. Ps: I want just the step to follow and configure the entire app... Thank for reading and trying to help me ! -
login_required next not redirecting
I'm working through a tut in the book Django 2 By Example with PyCharm and Chrome. I'm using Django 2.0.8 as specified in the book. As it says, I have the following base.html template: {% load staticfiles %} <!DOCTYPE html> <html> <head> <title>{% block title %}{% endblock %}</title> <link href="{% static 'css/base.css' %}" rel="stylesheet"> </head> <body> <div id="header"> <span class="logo">Bookmarks</span> {% if request.user.is_authenticated %} <ul class="menu"> <li {% if section == "dashboard" %} class="selected" {% endif %}> <a href="{% url 'dashboard' %}">My dashboard</a> </li> <li {% if section == "images" %} class="selected" {% endif %}> <a href="#">Images</a> </li> <li {% if section == "people" %} class="selected" {% endif %}> <a href="#">People</a> </li> </ul> {% endif %} <span class="user"> {% if request.user.is_authenticated %} Hello {{ request.user.first_name }}, <a href="{% url 'logout' %}">Logout</a> {% else %} <a href="{% url 'login' %}">Log-in</a> {% endif %} </span> </div> <div id="content"> {% block content %} {% endblock %} </div> </body> </html> This seems to log me in some of the time? It will work once, then I log out and it won't let me log in again. My views.py has a login_required view that redirects to a dashboard template and assigns a section context: @login_required β¦ -
Cannot import BACKEND 'channels_redis.core.RedisChannelLayer' specified for default
Cannot import BACKEND 'channels_redis.core.RedisChannelLayer' specified for default WebSocket DISCONNECT /ws/chat/cvc/ [127.0.0.1:56904] -
Django: how to import a function
Python 3.6.7 Django 2.1.5 In PyCharm Community edition I created a new project called simple_pr. Then I organized a Django project: django-admin startproject simple_project Then an application: python manage.py startapp home My Pythonpath: /home/michael/PycharmProjects/simple_pr/simple_project /opt/pycharm-community-2018.3.2/helpers/pydev /home/michael/PycharmProjects/simple_pr /opt/pycharm-community-2018.3.2/helpers/third_party/thriftpy /opt/pycharm-community-2018.3.2/helpers/pydev /home/michael/.PyCharmCE2018.3/system/cythonExtensions /home/michael/PycharmProjects/simple_pr/simple_project /usr/lib/python36.zip /usr/lib/python3.6 /usr/lib/python3.6/lib-dynload /home/michael/PycharmProjects/simple_pr/venv/lib/python3.6/site-packages /home/michael/PycharmProjects/simple_pr/venv/lib/python3.6/site-packages/setuptools-39.1.0-py3.6.egg /home/michael/PycharmProjects/simple_pr/venv/lib/python3.6/site-packages/pip-10.0.1-py3.6.egg Project structure: (venv) michael@michael:~/PycharmProjects/simple_pr$ tree . βββ simple_project β βββ home β β βββ admin.py β β βββ apps.py β β βββ __init__.py β β βββ migrations β β β βββ __init__.py β β βββ models.py β β βββ tests.py β β βββ views.py β βββ manage.py β βββ simple_project β βββ __init__.py β βββ __pycache__ β β βββ __init__.cpython-36.pyc β β βββ settings.cpython-36.pyc β βββ settings.py β βββ urls.py β βββ wsgi.py βββ venv urls.py from django.contrib import admin from django.urls import path from simple_project.home.views import current_datetime urlpatterns = [ path('admin/', admin.site.urls), ] home.views.py from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html) Traceback: /home/michael/PycharmProjects/simple_pr/venv/bin/python /opt/pycharm-community-2018.3.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 37559 --file /home/michael/PycharmProjects/simple_pr/simple_project/manage.py runserver pydev debugger: process 5982 is connecting Connected to pydev debugger (build 183.4886.43) pydev debugger: process 5988 is connecting Performing system checks... Unhandled exception in thread started β¦ -
can't validate imagefield with ajax function
i have a form with ModelForm and have a extra field (ImageField). I tried to validate this field in forms.py def clean_icono(self): icon = self.cleaned_data['icono'] if icon: w, h = get_image_dimensions(icon) if w != 127: raise forms.ValidationError("El icono debe ser de 127 pixeles de ancho") if h > 84: raise forms.ValidationError("El icono debe ser de 84 pixeles de largo") else: raise forms.ValidationError("No se encuentra un icono") return icon in the html i have a ajax function which display the error in the modal $('#bd_form').on('submit', function (e) { e.preventDefault(); var data = new FormData($('form').get(0)); $.ajax({ type: $(this).attr('method'), url: this.action, data: data, // recupera los datos del formulario para usarlos en caso de error, no funciona con imagenes y archivos cache: false, processData: false, contenType: false , success: function (data, status) { $('#popup').find('#bd_form').off('submit', '#bd_form'); $("#bd_form").load(" #bd_form"); $('#popup').modal('hide'); $("#bd_table").load(" #bd_table"); }, error: function (request, type, errorThrown) { var data = jQuery.parseJSON(request.responseText); $('#popup').find('#bd_form').off('submit', '#bd_form'); $('#popup').find('#errores').empty(); for (var key in data) { $('#popup').find('#errores').append(key + ': ' + data[key] + '<br>'); } $('#popup').find('#form-error').show(); } }); return false; }); but i always get "No se encuentra un icono" error, i cant save the imagefield. I tried send the data with serialize() but doesn't work. I read i β¦ -
dynamic model creation using Django
I am trying to create dynamic model using below code in sqlite3 database. When I check the database, The table is not created in database name='task' attrs = { 'field1': models.CharField(max_length=40), 'field2': models.CharField(max_length=40), '__module__': 'core.models' } model = type(name, (models.Model,), attrs) m=model(field1='Switch on', field2='lights') m.save() Also when I try to create a record using below code errors out the table 'core_task' not found. Kindly let me know what am i missing here. Thanks, Subash Base search: Django: dynamic models disappear after creation -
How to add non-standard languages to Dango?
Tell me, how can I add a language to Dango, which is not supported by the standard? In the file settings.py identified: ... LANGUAGES = ( ('ru', 'Π ΡΡΡΠΊΠΈΠΉ'), ('en', 'English'), ('ady', 'ΠΠ΄ΡΠ³Π°Π±Π·Ρ'), ) LOCALE_PATHS = ( (os.path.join(BASE_DIR, 'locale/'),) ) ... In the folder locale created directories with language codes and spelled commands: django-admin makemessages --all django-admin compilemessages Files .mo and .po were created in these directories. But when I opened the site, an error appeared "Unknown language code ady" File add_lang.html {% load i18n %} {% get_available_languages as LANGUAGES %} {% get_language_info_list for LANGUAGES as languages %} <ul> {% for language in languages %} <li><a href="/{{ language.code }}/">{{ language.name_local }}</a></li> {% endfor %} </ul> -
What's the right way for a RESTful app to upload files?
I'm building a React application along with a Django REST API, and I wanna use Cloudinary for my image management/storage. My question is: What would be the right way to do it? 1) The react application through the React SDK provided by Cloudionary upload directly to Cloudionary and then the response is sent to my Django Rest app. 2) The react application uploads directly to my Django Rest App and then my Django Rest app uploads to Cloudionary through the Django SDK provided by Cloudionary. What's the right way to do it and what would be the benefits of one over the other? Or is it really indifferent? -
Disable atomic transaction in Django 1.11 change view
Django 1.11 has following piece of code @csrf_protect_m def changeform_view(self, request, object_id=None, form_url='', extra_context=None): with transaction.atomic(using=router.db_for_write(self.model)): return self._changeform_view(request, object_id, form_url, extra_context) in env/lib/python3.6/site-packages/django/contrib/admin/options.py As per doc Django 1.11 is supposed to be working in auto commit mode but the changeform_view does not seem to aligned to the documentation and I see that, form save is happening within a transaction. How can I enable autocommit mode for django form ? -
Scheduling a task at particular time using django-background-tasks
I am trying to use django-background-tasks to schedule a task at midnight and then repeat daily. I am able to achieve repeat feature but unable to get it to run at scheduled time. The timezone in my django project is UTC. Something i have tried so far: now = datetime.datetime.now() date = datetime.date(now.year, now.month, now.day) print(timezone.get_current_timezone()) time = datetime.time(9, 49, 0, tzinfo=timezone.get_current_timezone()) aware_datetime = datetime.datetime.combine(date, time) schedule_email_notification(schedule=aware_datetime, repeat=Task.DAILY) Documentation is not clear on how to do so. If someone can help? -
How to convert a lookup to an expression to use in `QuerySet.annotate`?
The subject may be a little bit obscure, so here is an example. Let's say I have a model: class TestModel(models.Model): user = models.ForeignKey(User, ...) I want a QuerySet containing a has_user field that would basically map to the following SQL query select id, user_id is not null as has_user from app_testmodel How can I explain this user_id field to Django when using QuerySet.annotate? I am aware that Django has concepts like models.F, models.Q, models.lookups, models.expressions etc., but I am unable to understand how to apply them in my case. To the best of my knowledge, this is a question of converting a "lookup" to a boolean "expression" where A "lookup" is something like 'user_id__isnull' or lookups.IsNull(models.F('user_id')) in Django ORM language. An "expression" is something like expressions.ExpressionWrapper(?, output_field=models.BooleanField()). So far I only managed to convert the user_id is not null expression to case when user_id is not null then true else false end, which maps to Python code like this: from django.db import models from django.db.models import expressions # ... qs = TestModel.objects.all().annotate(has_user= expressions.Case( expressions.When( user__isnull=False, then=expressions.Value(True), ), default=expressions.Value(False), # # Tell Django the expected type of the field, see `output_field` in # https://docs.djangoproject.com/en/2.1/ref/models/expressions/ # output_field=models.BooleanField())) But it is an β¦ -
How to handle Django through_fields with non-fixed direction
Django's ManyToManyField through_fields attribute takes a tuple of the format(foreign_key_to_intermediate_model, foreign_key_from_intermediate_to_target_model) I have a data-structure that essentially looks like this (simplified for the example) class Person(models.Model): name = models.CharField() relations = models.ManyToManyField( Person, through='Relationship', through_fields=(???)) class Relationship(models.Model): child = models.ForeignKey(Person) parent = models.ForeignKey(Person) holiday_card_sent = models.BooleanField() I need to annotate the relationship (did they send a card), but a single person will be both a child and a parent in different relationships. The relationship has a directionality, but not the person. A person will also have multiple children and multiple parents. It feels like I'm missing something obvious here. Should I just be creating my own __init__ method to handle this? Will that lose out on lookup performance that Django would normally give? -
How to import a function
Python 3.6.7 Project structure: . βββ simple_project βββ simple_project β βββ db.sqlite3 β βββ home β β βββ admin.py β β βββ apps.py β β βββ __init__.py β β βββ migrations β β βββ models.py β β βββ tests.py β β βββ views.py β βββ manage.py β βββ simple_project β βββ __init__.py β βββ __pycache__ β βββ settings.py β βββ urls.py β βββ wsgi.py Pythonpath: /home/michael/PycharmProjects/simple_project/simple_project/opt/pycharm-community-2018.3.2/helpers/pydev/home/michael/PycharmProjects/simple_project/opt/pycharm-community-2018.3.2/helpers/third_party/thriftpy/opt/pycharm-community-2018.3.2/helpers/pydev/home/michael/.PyCharmCE2018.3/system/cythonExtensions/home/michael/PycharmProjects/simple_project/simple_project/usr/lib/python36.zip/usr/lib/python3.6/usr/lib/python3.6/lib-dynload/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/setuptools-39.1.0-py3.6.egg/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/pip-10.0.1-py3.6.egg /home/michael/PycharmProjects/simple_project/simple_project /opt/pycharm-community-2018.3.2/helpers/pydev /home/michael/PycharmProjects/simple_project /opt/pycharm-community-2018.3.2/helpers/third_party/thriftpy /opt/pycharm-community-2018.3.2/helpers/pydev /home/michael/.PyCharmCE2018.3/system/cythonExtensions /home/michael/PycharmProjects/simple_project/simple_project /usr/lib/python36.zip /usr/lib/python3.6 /usr/lib/python3.6/lib-dynload /home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages /home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/setuptools-39.1.0-py3.6.egg /home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/pip-10.0.1-py3.6.egg urls.py from django.contrib import admin from django.urls import path, re_path from simple_project.home.views import current_datetime # Line 19 urlpatterns = [ path('admin/', admin.site.urls), # re_path(r'^$', current_datetime) ] Traceback: /home/michael/PycharmProjects/simple_project/venv/bin/python /opt/pycharm-community-2018.3.2/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 44221 --file /home/michael/PycharmProjects/simple_project/simple_project/manage.py runserver pydev debugger: process 5277 is connecting Connected to pydev debugger (build 183.4886.43) pydev debugger: process 5283 is connecting Performing system checks... Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x7f76c14fd668> Traceback (most recent call last): File "/opt/pycharm-community-2018.3.2/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 632, in __call__ return self.original_func(*self.args, **self.kwargs) File "/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check include_deployment_checks=include_deployment_checks, File "/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/django/core/management/base.py", line 366, in _run_checks return checks.run_checks(**kwargs) File "/home/michael/PycharmProjects/simple_project/venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks new_errors = β¦ -
Django how to pass choices list to a custom select widget
I need to override select widget.`class TooltipSelectWidget(Select) : def __init__(self, *args, **kwargs) : super().__init__(*args, **kwargs) `Then I call it in a form. But I do not see in the docs how to pass the choices list to this customed widget. -
How to mock the get function from requests.session?
I am trying to mock the get function from requests.session and somehow it does not end up happening. I have the following code: #main.py import requests def function_with_get(): c = requests.session() c.get('https://awesome_url.com') # do some other stuff return c def second_function_with_get(client): c.get('https://awesome_url.com') # do some other stuff #test.py from unittest import mock from django.test import TestCase class Testing(TestCase): @mock.patch('main.requests.session.get) @mock.patch('main.requests.session) def test_which_fails_because_of_get(mock_sess, mock_get): client = function_with_get() second_function_with_get(client) assertEqual(mock_requests_session_get.call_count, 2) The test throws an assertion error that mock_get is called 0 times (0 != 2) How should the get function of requests.session() be mocked? -
django:TypeError: expected str, bytes or os.PathLike object, not NoneType
I did a git add in django, and then I gave an error to the runserver. I tried to cancel the add, but I still get an error. django2.0 and python 3.7,I tried to pull, but still can't, it feels like the database is out of order. `System check identified no issues (0 silenced). Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000212F544C7B8> Traceback (most recent call last): File "C:\edu_env\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\edu_env\lib\site-packages\django\core\management\commands\runserver.py", line 123, in inner_run self.check_migrations() File "C:\edu_env\lib\site-packages\django\core\management\base.py", line 427, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "C:\edu_env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "C:\edu_env\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__ self.build_graph() File "C:\edu_env\lib\site-packages\django\db\migrations\loader.py", line 200, in build_graph self.load_disk() File "C:\edu_env\lib\site-packages\django\db\migrations\loader.py", line 99, in load_disk directory = os.path.dirname(module.__file__) File "C:\edu_env\lib\ntpath.py", line 232, in dirname return split(p)[0] File "C:\edu_env\lib\ntpath.py", line 190, in split p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType` -
Signal receiver works in shell but not in frontend
I've been following these instructions to associate a profile to each user upon user creation. When I instantiate and save a user in the shell, the associated profile get saved as well. However, when I sign up a user in the front end, then no associated profile gets created. Furthermore, the console does not execute a print statement embedded in the receiver. I verified that a new user is indeed added to the database. Debug-toolbar does list "post_save" under the sent signals, and also lists desired receiver "create_user_profile" under the corresonding receivers. What could be going on here? The relevant portion of my signals.py is from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from people.models import Profile @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): print(f"create_user_profile: this was called with instance={instance}") if created: Profile.objects.create(user=instance) The contents of the associated apps.py file are from django.apps import AppConfig class PeopleConfig(AppConfig): name = 'people' verbose_name = ('people') def ready(self): import people.signals # noqa and my init.py file has default_app_config = 'people.apps.PeopleConfig' -
Pass parameters to post method in Django Class based views
I am unable to pass parameters from urls.py to my HomeView class view to it's post() method but able to pass parameters to get() method. I am quite unsure why this is happening. What I am trying to accomplish is to make post() method work in 2 different ways by using the parameter that it gets passed along from urls. Here's my views.py class HomeView(TemplateView): template_name = 'new_home.html' section_heading = "" type = "" sub_type = None post_method_type = None def post(self, request): ''' Allows user login, This was added to allow user login from the modal ''' print("Here is :"+self.post_method_type) # <---- Prints Nothing if self.post_method_type == "login": #do login stuff elif self.post_method_type == "navigator": #do navigating stuff def get(self, request, filter=None): ''' Fetches all the posts from the Post model by comparing the tag from the urls.py to the Tag model. ''' print("HERE GET :"+ self.type) # <----- prints value properly # filtering from here on And here's my urls.py # for post path('login/', HomeView.as_view(post_method_type='login'), name="login"), path('navigator/', HomeView.as_view(post_method_type='navigator'), name="navigator"), # for get path('python/', HomeView.as_view(type='py'), name='home_python'), When I use this class as a get method, It's successfully printing py as sent from urls.py but is not able to print β¦ -
Server responded with a status of 415 (Unsupported Media Type) - vue.js and python django
{"errors":[{"detail":"Unsupported media type \"application/json;charset=UTF-8\" in request.","source":{"pointer":"/data"},"status":"415"}]}