Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Sending messages to groups in Django Channels 2
I am completely stuck in that I cannot get group messaging to work with Channels 2! I have followed all tutorials and docs that I could find, but alas I haven't found what the issue seems to be yet. What I am trying to do right now is to have one specific URL that when visited should broadcast a simple message to a group named "events". First things first, here are the relevant and current settings that I employ in Django: CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { 'hosts': [('localhost', 6379)], }, } } ASGI_APPLICATION = 'backend.routing.application' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'corsheaders', 'channels', 'channels_redis', 'backend.api' ] Next, here is my EventConsumer, extending the JsonWebsocketConsumer in a very basic way. All this does is echo back when receiving a message, which works! So, the simple send_json response arrives as it should, it is ONLY group broadcasting that does not work. class EventConsumer(JsonWebsocketConsumer): groups = ["events"] def connect(self): self.accept() def disconnect(self, close_code): print("Closed websocket with code: ", close_code) self.close() def receive_json(self, content, **kwargs): print("Received event: {}\nFrom: {}\nGroups: {}".format(content, self.channel_layer, self.groups)) self.send_json(content) def event_notification(self, event): self.send_json( { 'type': 'test', 'content': event } ) And here … -
Ansible-Playbook debug task skipping without reason
I am running an Ansible playbook to create a docker container with a Django application. I add an RSA key to the container, create directories, and try to clone the Django repository into the container. I get an authentication error, so I'm trying to debug the issue, first off seeing if the RSA key exists. When I add a debug task however, and run the playbook, it just says 'skipped', and doesn't offer any message. I'm new to Ansible, and read the documentation, but couldn't find a reason why. Ansible Tasks - name: Upload Deploy Private Key {{home_path}}/.ssh/id_rsa copy: src=keys/django-keys dest="{{home_path}}/.ssh/id_rsa" mode=0400 - name: Check that key exists stat: path: {{home_path}}/.ssh/id_rsa register: stat_result - debug: var: stat_result verbosity: 3 Shell docker: TASK [base : Upload Deploy Private Key /path/.ssh/id_rsa] ******** docker: Sunday 18 February 2018 12:37:33 -0600 (0:00:00.500) 0:02:03.199 ******* docker: changed: [default] docker: TASK [base : Check that /path/.ssh/id_rsa exists] **************** docker: Sunday 18 February 2018 12:37:34 -0600 (0:00:00.861) 0:02:04.060 ******* docker: ok: [default] docker: TASK [base : debug] ******************************************************* docker: Sunday 18 February 2018 12:37:34 -0600 (0:00:00.334) 0:02:04.718 ******* docker: skipping: [default] -
Django m2m field doesn't assign to parent object in view
I've read the Django 1.11 docs on this topic and countless questions here on SO. I'm sure I'm missing something simple, but I cannot see why my problem is occurring and have fruitlessly tried endless variations to solve, so I submit it to wiser minds for consideration. (I will post the relevant code below, wherein I believe the problem lies. And will post more if necessary, but I don't want to drown this post in code in advance if it doesn't contribute...) I am implementing a tagging system for my project. I've tried the various plug-in solutions (taggit, tagulous, etc) and each for their own reason doesn't work the way I would like or doesn't play well with other parts of my project. The idea is to have a Select2 tagging field allow users to select from existing tags or create new. Existing tags can be added or removed without problem. My difficulty is in the dynamic generation and assignment of new tags. Select2 helpfully renders the manually-entered tags in the DOM differently than those picked from the database. So upon clicking submit, I have javascript collect the new tags and string them together in the value of a hidden … -
Itterate over all current sessions in django
Is it possible in django to itterate all current sessions? I want to implement a calendar where it is impossible to book a timeslot that someone else is booking. I Keep a list of timeslots id's in the session before the user proceeds to checkout. -
unable to create a attrs for fields
i am unable to add attrs for my fields. See my code as below. by adding the attrs for one one fields its working but adding for all fields its not working here my form class AddProducts(forms.ModelForm): class Meta: model = ProductsModel fields = '__all__' def __init__(self, *args, **kwargs): super(AddProducts, self).__init__(*args, **kwargs) for field in self.fields: field.widget.attrs['class'] = 'mdl-textfield__input' and my html {% extends 'home/base.html' %} {% block body %} <main class="mdl-layout__content"> <div class = "mdl-grid"> <form method="post"> {% csrf_token %} {% for field in form %} <div class="mdl-cell mdl-cell--6-col login-card-text mdl-textfield mdl-js-textfield"> {{ field }} <label class="login-card-input mdl-textfield__label" for="{{ field.name }}">{{ field.label }}</label> </div> {% endfor %} <br> <button type="submit" name="logout" class="demo_btn_color mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">Submit</button> </form> </div> </main> {% endblock %} and my view def createProducts(request): template_name = 'home/dashboard_edit.html' form = AddProducts() if request.POST: form = AddProducts(request.POST) if form.is_valid(): form.save() # user = authenticate(username=username, password=password) # if user is not None: # if user.is_active: # login(request, user) # return redirect('home:index') # return render(request, 'home/add_user.html', {'form': form}) return redirect('home:adduser') return render(request, template_name, {'form': form}) -
Load JSON file's content to Heroku's environment variable
I am using Google Speech API in my Django web-app. I have set up a service account for it and am able to make API calls locally. I have pointed the local GOOGLE_APPLICATION_CREDENTIALS environment variable to the service account's json file which contains all the credentials. This is the snapshot of my Service Account's json file: I have tried setting heroku's GOOGLE_APPLICATION_CREDENTIALS environment variable by running $ heroku config:set GOOGLE_APPLICATION_CREDENTIALS="$(< Speech-Api-Proj.json)" $ heroku config GOOGLE_APPLICATION_CREDENTIALS: { ^^ It gets terminated at the first occurrence of " in the json file which is immediately after { and $ heroku config:set GOOGLE_APPLICATION_CREDENTIALS='$(< myProjCreds.json)' $ heroku config GOOGLE_APPLICATION_CREDENTIALS: $(< Speech-Api-Proj.json) ^^ The command gets saved into the environment variable I tried setting heroku's GOOGLE_APPLICATION_CREDENTIALS env variable to the content of service account's json file but it didn't work (because apparently the this variable's value needs to be an absolute path to the json file) . I found a method which authorizes a developer account without loading json accout rather using GOOGLE_ACCOUNT_TYPE, GOOGLE_CLIENT_EMAIL and GOOGLE_PRIVATE_KEY. Here is the GitHub discussion page for it. I want something similar (or something different) for my Django web-app and I want to avoid uploading the json file to … -
How to search with date and given time
I want to show the details when user enter a datefield and also time range like 1:00am to 3:00 am how to do this in Django using query set I have search related o this but I don't find any useful material please help me -
tests stall using docker, selenium for django app
Been struggling a bit with selenium tests through Docker. hoping for some input. If it is the first time I am starting the container, I can run a single test perfectly. Then, the process stalls on the next test with this value showing from the selenium_hub container: selenium_hub | 16:27:06.882 INFO - Got a request to create a new session: Capabilities {browserName: chrome, version: } and this showing in the terminal with Django test function running: System check identified no issues (0 silenced). Log in | Django site admin F If i try to run any tests again with the same containers without stopping / restarting them, the process stalls in the same point on the very first test. I appreciate any help. Here's my docker-compose.yml: version: '2' services: db: image: postgres django: container_name: django build: . command: python manage.py runserver 0.0.0.0:8080 volumes: - .:/code ports: - "8080:8080" depends_on: - db selenium_chrome: container_name: selenium_chrome image: selenium/node-chrome-debug volumes: - /dev/shm:/dev/shm environment: - HUB_PORT_4444_TCP_ADDR=selenium_hub - HUB_PORT_4444_TCP_PORT=4444 ports: - "5900:5900" depends_on: - selenium_hub selenium_firefox: container_name: selenium_firefox image: selenium/node-firefox-debug volumes: - /dev/shm:/dev/shm environment: - HUB_PORT_4444_TCP_ADDR=selenium_hub - HUB_PORT_4444_TCP_PORT=4444 ports: - "5901:5900" depends_on: - selenium_hub here's my tests: from django.test import TestCase, tag from selenium import … -
delete is not allowed in django rest
I am writing a restful web service for an Android app by django rest framework . before when I writed a model ( ex:profile) and a view with ModelViewSet and a serilazer with ModelSerializertested a json and a url with simple route for: www.example.com/profiles/ , I got a json with delete option I mean I could got : Allow: GET, POST,DELETE, HEAD, OPTIONS and know I have written a lot of codes with ModelViewSet but I can not see Delete in Allow and can not get anything of delete request , in postman I get : "detail": "Method \"DELETE\" not allowed." before I added codes for permissions and authentication but now i create a new project and without any security issues , what happened in my project ? why I can not access to Delete ? why is not allowed for me ? and how can I fix this problem . models.py: from django.db import models class User(models.Model): username = models.CharField(max_length=50 , unique=True) password = models.CharField(max_length=50) idName = models.CharField(max_length=50 , blank=True , null=True) enable = models.BooleanField(default=False) name= models.CharField(max_length=50) family = models.CharField(max_length=50) email = models.EmailField() user_image = models.ImageField(unique=True , blank=True , null=True , upload_to='user_images') birthDay = models.DateTimeField(blank=True , null=True) GcmRegisterationId = … -
how to use PUT to update a value in django
Desperate need help. How to write this?enter image description here -
how can i run this python script from javascript onClick
The problem is that we have a button that we want to use when the user clicks it, it must run a python script that will do what we implemented it. Can I please know what the mistake I did, so in future I won't be able to fall for it again. I'm trying to run a python script from java event listener or html, or anyway that I could run the script if the button is clicked js code button_pressed = document.getElementById("press-btn"); button_pressed.addEventListener("click", myFunction); function myFunction() { debugger; System.Diagnostics.Process.Started("python.exe","testAPI.py"); } HTML CODE <div class="row"> <form method="post" action="#" class="contact-form"> <div class="row"> <div class="col span-3-of-3"> <p class="center-text">-uOttaHack Hackathon project: </p> </div> <div class="col span-3-of-3"> <br> <p class="center-text">Creating described video for real life using Google Vision API and Raspberry Pi.</p> </div> </div> <div class="row"> <div class="col span-1-of-3"> </div> <div class="col span-2-of-3"> </div> </div> <div class="row"> <div class="col span-1-of-3"> </div> <div class="col span-2-of-3"> <input type ="button" class="btn-press" id ="press-btn" name="btn" value="Scan me"> </div> </div> DJANGO(PYTHON) export DJANGO_SETTINGS_MODULE='config.settings.production' export DJANGO_SECRET_KEY='<secret key goes here>' export DJANGO_ALLOWED_HOSTS='<www.your-domain.com>' export DJANGO_ADMIN_URL='<not admin/>' export DJANGO_MAILGUN_API_KEY='<mailgun key>' export DJANGO_MAILGUN_SERVER_NAME='<mailgun server name>' export MAILGUN_SENDER_DOMAIN='<mailgun sender domain export DJANGO_AWS_ACCESS_KEY_ID= export DJANGO_AWS_SECRET_ACCESS_KEY= export DJANGO_AWS_STORAGE_BUCKET_NAME= export DATABASE_URL='<see below>' -
Django Framework : Attribute error 'Settings' object has no attribute 'TEMPLATE_DIRS'
I am a newbie in Django framework, unable to understand this issue. While running ./runtests.py command it gives attribute error message. Here is the error detail. ./runtests.py Testing against Django installed in '/usr/local/lib/python2.7/dist-packages/django' Traceback (most recent call last): File "./runtests.py", line 440, in <module> options.debug_sql) File "./runtests.py", line 239, in django_tests state = setup(verbosity, test_labels) File "./runtests.py", line 111, in setup 'TEMPLATE_DIRS': settings.TEMPLATE_DIRS, File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 57, in __getattr__ val = getattr(self._wrapped, name) AttributeError: 'Settings' object has no attribute 'TEMPLATE_DIRS' -
How to display form in django
I'am little confiused because my code in django does't work and I don't know why. I want to create a form displaying in html file. When I click on thh button, the url have to redirect me in the html file where I've put the form code. But the django return me a error 'User' object has no attribute 'nazwa_set' My models.py is: from django.db import models from django.contrib.auth.models import User class Firma(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="Użytkownik") nazwa = models.CharField(max_length=250,verbose_name='Nazwa firmy', unique=False) class Meta: verbose_name = 'Firmę' verbose_name_plural = 'Firmy' def __str__(self): return self.nazwa class Cudzoziemiec(models.Model): OBYWATELSTWA = ( ('RU', 'Rosja'), ('UA', 'Ukraina'), ('BY', 'Białoruś'), ) TYTUL_POBYTOWY = ( ('WZ', 'Wiza'), ('KP', 'Karta pobytu') ) user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="Użytkownik") nazwa = models.ForeignKey(Firma, on_delete=models.CASCADE, verbose_name="Firma") obywatelstwo = models.CharField(max_length=250,choices=OBYWATELSTWA, verbose_name="Obywatelstwo") imie = models.CharField(max_length=80, verbose_name="Imię", unique=False) nazwisko = models.CharField(max_length=150, verbose_name="Nazwisko", unique=False) data_ur = models.DateField(auto_now=False, auto_now_add=False, verbose_name="Data urodzenia") miejsce_ur = models.CharField(max_length=100, verbose_name="Miejsce urodzenia") paszport = models.CharField(max_length=30, verbose_name="Paszport") data_start_pasz = models.DateField(auto_now=False, auto_now_add=False, verbose_name="Data wydania paszportu") data_koniec_pasz = models.DateField(auto_now=False, auto_now_add=False, verbose_name="Data ważności paszportu") dok_pobytowy = models.CharField(max_length=250,choices=TYTUL_POBYTOWY, verbose_name="Tytuł pobytowy") data_start_pobyt = models.DateField(auto_now=False, auto_now_add=False, verbose_name="Dokument pobytowy ważny od") data_koniec_pobyt = models.DateField(auto_now=False, auto_now_add=False, verbose_name="Dokument pobytowy ważny do") class Meta: verbose_name = 'Cudzoziemca' verbose_name_plural = 'Cudzoziemcy' def __str__(self): … -
Queryset: Compare a field with a substring of another field of the same model
I am trying to check if the first 3 characters of a Charfield (charfield_1) are similar to another Charfield (charfield_2) of the same model. Tried: User.objects.filter(charfield_2__startswith=Substr('charfield_1', 1, 3)) Tried using F and Func without any success. I keep getting: django.db.utils.DataError: invalid input syntax for integer: "1%" LINE 1: ...CE(REPLACE((SUBSTRING("model_name"."charfield_2", '1%', 3)),... Any idea how to make this work? -
How to escape single quote in django form widget
I am trying to set HTML <input> attribute through django ModelForm. with the following code. class ProductForm(ModelForm): class Meta: model = Product fields = '__all__' widgets = {'product_image' :FileInput(attrs={'data-form-data':'{"csrfmiddlewaretoken": "{{ csrf_token }}"}'}), } what i am trying to get, is like this (notice single-quote after data-form-data) <input type="file" name="product_name" data-form-data='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'> But i got this instead (notice double-quotes after data-form-data) <input type="file" name="product_name" data-form-data="{"csrfmiddlewaretoken": "{{ csrf_token }}"}"> How can i prevent django to automatically convert single-quote to double-quotes ? thank you in advance. -
Get User's organization(s) in django-organizations
For the app django-organizations, how do you get a User's organization? From the doc's it says >>> from organizations.utils import create_organization >>> chris = User.objects.get(username="chris") >>> soundgarden = create_organization(chris, "Soundgarden", org_user_defaults={'is_admin': True}) >>> soundgarden.is_member(chris) True >>> soundgarden.is_admin(chris) True >>> soundgarden.owner.organization_user <OrganizationUser: Chris Cornell> >>> soundgarden.owner.organization_user.user >>> <User: chris> >>> audioslave = create_organization(chris, "Audioslave") >>> tom = User.objects.get(username="tom") >>> audioslave.add_user(tom, is_admin=True) <OrganizationUser: Tom Morello> and in my code I can easily do : @login_required def bandView(request, bandSlug): loggedInUser = get_object_or_404(User, username=request.user.get_username()) organization_requested = get_object_or_404(Organization, slug=bandSlug) if organization_requested.is_member(loggedInUser): #User is a member of the organization elze: # Not in this band but I am trying to work the other way now: @login_required def artistView(request): loggedInUser = get_object_or_404(User, username=request.user.get_username()) #something like.... loggedInUser.organizations #would print [<band1>,<band2>] #or add a function to the Organization[User] class Organizations.all().filter(member=loggedInuser) Organizations.getMembership(loggedInuser) Notes I have verified the user is a member of the organization as an OrganizationUser in both Admin and database print loggedInPerson.organizations_organizationuser -> organizations.OrganizationUser.None print loggedInPerson.organizations_organization -> organizations.Organization.None print loggedInPerson.organizations_organization_set -> errors print dir(loggedInPerson) -> ['DoesNotExist', 'EMAIL_FIELD', 'Meta', 'MultipleObjectsReturned', 'REQUIRED_FIELDS', 'USERNAME_FIELD', 'class', 'delattr', 'dict', 'doc', 'eq', 'format', 'getattribute', 'hash', 'init', u'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'setstate', 'sizeof', 'str', 'subclasshook', 'unicode', 'weakref', '_check_column_name_clashes', '_check_field_name_clashes', '_check_fields', '_check_id_field', '_check_index_together', … -
python utcfromtimestamp for -144714 returns error
I have faced a bad error. I am using django and I am saving my datetime values as epoch time in database but when I want to convert them in python I face an error. if I use this code datetime.datetime.utcfromtimestamp(-14471).strftime('%Y-%m-%d') '1969-12-31' it works fine but if I use datetime.datetime.utcfromtimestamp(-144714).strftime('%Y-%m-%d') Traceback (most recent call last): File "<input>", line 1, in <module> OSError: [Errno 22] Invalid argument it does not work. well I can not convert my database values but why this error happens. what other options do I have to deal with this problem and why it shows such behavior ? I am using python 3.6.4 -
Django skip long migration history for new DB schema
Django using django-tenant-schemas My project requires runtime tenant creation (postgres schema creation), but due to long django migration history, migrations of a new schema take > 10 minutes which is far too long. So a method is required which skips the migrations, but brings the DB in the correct state. Reading What should I use instead of syncdb in Django 1.9? and https://docs.djangoproject.com/en/2.0/ref/django-admin/#cmdoption-migrate-run-syncdb ... it seems following could be a solution: python manage.py migrate auth # performs migrations for auth and contenttypes contrib apps python manage.py migrate --run-syncdb # creates the rest of the database But what are the consequences of this? Does it mean backwards migrations will not be possible for new schemas? (OK in this project as new schema doesn't have history anyway) Does it also mean future migrations cannot be applied since there is no correct migration history? That would obviously be a no-go. FYI version info: Django==1.11.7 django-tenant-schemas==1.8.0 -
trying to display render objects in django template in different places
I am using bootstrap in my template. I have 2 columns. In the first one, a list of my cars is displayed. I want that in second column if I click a car name from first column, only models specific to that car will be shown. How can I do that? <div class="row"> <div class="col-md-3"> {% for car in cars %} {{ car.name }} {% endfor %} </div> <div class="col-md-9"> {% for car in cars %} {% for model in models %} {% if model.car == car %} {{ model.name }} {% endif %} {% endfor %} {% endfor %} </div> </div> -
Filtering against query parameters Django REST Framework, Many to Many
I'm trying to build some kind of API, but I need to filtering request against query parameters in the URL (http:// ... / ?arg1=foo1&arg2=foo2&...). In my model scheme, I used a many to many relationships. Here is some of my code: my_app/models.py from django.contrib.postgres.fields import JSONField from django.db import models class MyData(models.Model): name = models.CharField(max_length=20) values = JSONField() class MyModel(models.Model): time = models.DateTimeField() country = models.CharField(max_length=50) data = models.ManyToManyField(MyData) my_app/serializers.py from rest_framework import serializers from my_app.models import MyModel, MyData class MyDataSerializer(serializers.ModelSerializer): class Meta: model = MyData fields = ('name', 'values',) class MyModelSerializer(serializers.ModelSerializer): data = MyDataSerializer(many=True, read_only=True) class Meta: model = MyModel fields = ('country', 'data',) my_app/views.py from rest_framework import generics from my_app.serializers import MySerializer from my_app.models import MyModel class MyView(generics.ListAPIView): serializer_class = MySerializer def get_queryset(self): queryset = MyModel.objects.all() names = self.request.query_params.get('Simon', None) if names: queryset = queryset.filter(data__name__in=names.split(',')) return queryset and here are the responses Response to http://127.0.0.1:8000/hello/ HTTP 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/json Vary: Accept [ { "country": "Spain", "data": [ { "name": "Mark", "values": {"A": "Hello, it's Wario"} }, { "name": "Simon", "values": {"A": "Hello, it's Mario"} }, ] }, { "country": "Italy", "data": [ { "name": "Jake", "values": {"A": "Hello, it's Luigi"} } ] } … -
Django multi table inheritance: move instance between child models
Assume I have in models.pysomething like: Class ModelA(models.Model): # many fields, including relatives = models.ManyToManyField(Person) ) # also, A is foreign key to other models: Class SomeOtherModel(models.Model): mya = models.ForeignKey(A) # now we produce two classes with multi-table inheritance # WITHOUT any additional fileds Class InhertA1(ModelA): pass Class InhertA2(ModelA): pass So as as I understand, this will create Tables for ModelA, InheritA1 and InheritA1; each instance of ModelA will get a row in the ModelA-table only, each instance of InheritA1 will have a row both in the ModelA-table (basically containing all the data) and another in the InheritA1-table (only containing a PK and a OneToOne key pointing to the ModelA-table row), etc. Django queries for ModelA-objects will give all objects, quries for InheritA1-objects only the InheritA1 ones etc. So now I have an InheritA1-object a1, and want to make it into a InheritA2-object, without changing the according ModelA-object. So previously the parent-IbeToOne Key of a1 points to the ModelA-row with key 3, say (and the ForeignKey of some SomeOtherModel-object is set to 3). In the end, I want a InheritA1-object a2 pointing to the same, unchanged ModelA-row (and the object a1removed). It seems that django doesn't offer any such move-Class-functionality? … -
How can I make search and pagination work for my filtered entries?
So I've set up pagination and search for all the courses names that can be listed from my Course model. Now, I want to set up pagination and search again, but this time only for some specific courses. By using a jQuery function, when a user presses on one of the faculty names listed on the left column, all the courses on the right column, from my Course model that have been previously listed, get replaced with the courses from that specific faculty. And here I don't know how exactly how I should add pagination and search again, mostly because I don't know exactly how this interacts with my jQuery and the proper way to do it. Here is a screenshot with what it should look like: https://i.imgur.com/RyyELnP.png def index(request): query_list = Course.objects.all() query = request.GET.get('q') if query: query_list = query_list.filter(Q(name__icontains=query)) paginator = Paginator(query_list, 1) page = request.GET.get('page') try: courses = paginator.page(page) except PageNotAnInteger: courses = paginator.page(1) except EmptyPage: courses = paginator.page(paginator.num_pages) context = { 'courses': courses, 'faculties': Faculty.objects.all(), 'departments': Department.objects.all(), 'studies': StudyProgramme.objects.all(), 'teachers': Teacher.objects.all() } return render(request, 'courses/index.html', context) <script> $(document).ready(function () { $('.btnClick').on('click', function () { var faculty_id = $(this).attr('id'); $('#' + faculty_id + '_tab').show().siblings('div').hide(); }); $('.btnClick0').on('click', function … -
What app should you put your index in in Django?
I'm unfamiliar with the organizational conventions of Django. What app should I put the index page in? I have a login and registration app so far. Should I use flatpages? Should I use flatpages for the index page and login and registration forms and only use the login and registration app views for accepting POST requests? -
setting up django setting.py with mysql database
Im using mysql in my windows7 for a yr and its working fine. i recently know about django and trying to catch up the tuturial. Im having a problem to set up the setting.py and i think its on 'NAME' path. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.path.join('C:/ProgramData/MySQL/MySQL Server 5.7/Data/mysql', 'db.frm'), 'USER': '***', 'PASSWORD':'***' } } -
Django: django.core.exceptions.ImproperlyConfigured: WSGI application 'wsgi.application' could not be loaded; Error importing module
I used to check every answer to this question< but NOTHING helped me. Here's a error: edjango.core.exceptions.ImproperlyConfigured: WSGI application 'wsgi.application' could not be loaded; Error importing module. In settings file is: WSGI_APPLICATION = 'wsgi.application' and WSGI file is: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyLittleTest.settings") application = get_wsgi_application() Can you help me with this issue plz?