Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Local python module overrides module installed with pip
I am having issues with importing, my own, pip package named the same as a module inside a django-app. Lets say my own pip module is called: fancymodule. I then have a module-folder inside a django-app named the same: * django-project * payments * models.py * fancymodule/ * __init__.py The problem I am having, is that inside payments/models.py, I import: from fancymodule import ApiClient This is suppose to reference the fancymodule installed through pip. But is instead referencing the module inside the payments-django-app instead. If I wanted to reference the module inside the payments-django-app, in my head, this should be: from payments.fancymodule import whatever I get that from the view of payments/models.py, the import fancymodule .. will reference the module inside the folder it self of the specified name.. but can i change/fix this? FYI: Working on an old legacy project. Home someone can help. -
Is FILE_UPLOAD_DIRECTORY_PERMISSIONS required after upgrade to Django 3.1?
There was a web app on Django 2.x with no FILE_UPLOAD_DIRECTORY_PERMISSIONS and FILE_UPLOAD_PERMISSIONS. After upgrade to Django 3.1 (through 3.0) (new) user media files saved to new directories are inaccessible to users via nginx static files serving. They become accesible if I manually fix permissions with chmod -R 755 . in media directory. And I guess it will be fixed for all new files when I set FILE_UPLOAD_DIRECTORY_PERMISSIONS. The question is why it was not needed in django 2.x and how do I not miss something similar next time? Apparently, FILE_UPLOAD_DIRECTORY_PERMISSIONS is not mentioned in https://docs.djangoproject.com/en/3.1/releases/3.0/ and https://docs.djangoproject.com/en/3.1/releases/3.1/ -
how can i save an inline form to the current parent i am working
to be more specific i have a questionaire model and a question with many to many relationship. class poll(models.Model): name=models.CharField(max_length=100) class question(models.Model): text = models.CharField(max_length=200) polls = models.ManyToManyField(poll) in the admin.py i have admin.site.register(question) class questionsinline(admin.TabularInline): model = question.polls.through extra = 1 class polladmin(admin.ModelAdmin): inlines = [questionsinline,] # admin.site.register(question,questionsinline) admin.site.register(poll,polladmin) when i open the admin form to add a new questionnaire it shows as well the option to add a new question. the problem is tha adding a new question needs a questionanaire that don't exists because i am currently makin it -
Django error: Process finished with exit code 134 (interrupted by signal 6: SIGABRT) python2.7 django project
Im facing a very strange error from few days now. I have a python2.7 project that was running smoothly but since few days its been throwing an error: Process finished with exit code 134 (interrupted by signal 6: SIGABRT) Im using virtual environment for my project. What happened was that few days ago I tried installing nginx using brew command and what I believe is brew updated some dependencies that were being used for python2.7 project (this is what i think might be the case). Now since that day , Im facing this issue and I have googled it everywhere but couldn't resolve. Below is some information you might need to figure out. I urgently need to resolve this issue since alot depends on it. Thanks in advance. my requirements.txt file asn1crypto==0.24.0 beautifulsoup4==4.3.2 boto==2.49.0 boto3==1.8.7 botocore==1.11.9 cachetools==3.1.0 certifi==2018.11.29 cffi==1.12.2 chardet==3.0.4 cryptography==2.6.1 Django==1.6.5 django-appconf==0.6 django-autoslug==1.7.2 django-blog-zinnia==0.14.1 django-ckeditor-updated==4.4.4 django-common-helpers==0.6.1 django-compressor==1.4 django-cors-headers==1.1.0 django-crispy-forms==1.4.0 django-cron==0.3.3 django-filter==0.15.3 django-hosts==0.6 django-htmlmin==0.11.0 django-imagekit==3.2.5 django-mobi==0.1.7 django-mobile==0.3.0 django-mptt==0.6.1 django-redis==4.4.0 django-sass-processor==0.2.6 django-simple-captcha==0.4.2 django-storages==1.1.8 django-tagging==0.3.2 django-xadmin==0.5.0 django-xmlrpc==0.1.5 djangorestframework==2.4.8 docutils==0.14 enum34==1.1.6 futures==3.2.0 google-api-core==1.7.0 google-auth==1.6.2 google-auth-oauthlib==0.2.0 google-cloud-bigquery==1.9.0 google-cloud-core==0.29.1 google-resumable-media==0.3.2 googleapis-common-protos==1.5.6 html5lib==1.0b8 httplib2==0.9 idna==2.8 ipaddress==1.0.22 jmespath==0.9.3 libsass==0.18.0 lxml==3.3.5 Markdown==2.6.7 MySQL-python==1.2.5 nginxparser==1.0.1 numpy==1.16.1 oauth2==1.5.211 oauthlib==3.0.1 pandas==0.24.1 pandas-gbq==0.9.0 pilkit==2.0 Pillow==5.3.0 protobuf==3.6.1 pyasn1==0.4.5 pyasn1-modules==0.2.4 pycparser==2.19 pycrypto==2.6.1 pydata-google-auth==0.1.2 pyOpenSSL==19.0.0 … -
Exit server terminal while after celery execution
I have successfully created a periodic task which updates each minute, in a django app. I everything is running as expected, using celery -A proj worker -B. I am aware that using celery -A proj worker -B to execute the task is not advised, however, it seems to be the only way for the task to be run periodically. I am logging on to the server using GitBash, after execution, I would like to exit GitBash with the celery tasks still being executed periodically. When I press ctrl+fn+shift it is a cold worker exit, which stops execution completely (which is not desirable). Any help? -
Django can't multiply sequence by non-int of type 'str'
I have this logic in my views and models, in my views i get the data of what the user inputted, and in my models, i have an automatic computation of discount_price_formula, and other_discount_price_formula why i am having this error? can't multiply sequence by non-int of type 'str' this is my views.py otherdiscountpercentage = request.POST.get("otherdiscountpercentage") S_price = request.POST.get("price") otherdiscountprice = request.POST.get("otherdiscountprice") discountpercentage = request.POST.get("discountpercentage") discountprice = request.POST.get("discountprice") insert_data = Product( price=S_price, discount_percentage=discountpercentage, discount_price=discountprice, Other_discount_percentage=otherdiscountpercentage, Other_discount_price=otherdiscountprice, ) this is my models.py class Product(models.Model): price = models.FloatField(null=True, blank=True, verbose_name="Unit Price") discount_percentage = models.FloatField(max_length=500, null=True, blank=True) discount_price = models.FloatField(null=True, blank=True) Other_discount_percentage = models.FloatField(null=True, blank=True) Other_discount_price = models.FloatField(null=True, blank=True, default=0.0) discount_price_formula = models.FloatField(null=True, blank=True) other_discount_price_formula = models.FloatField(null=True, blank=True) def save(self, *args, **kwargs): self.discount_price_formula = self.price - (self.price * self.discount_percentage) self.other_discount_price_formula = (self.price - (self.price * self.discount_percentage)) - ((self.price - (self.price * self.discount_percentage)) * self.Other_discount_percentage) return super(Product, self).save(*args, **kwargs) def __str__(self): suser = '{0.product}' return suser.format(self) this is my traceback Traceback: File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Desktop\onlinestoreapp\customAdmin\views.py" in InsertProduct 293. insert_data.save() File "C:\Users\Desktop\onlinestoreapp\customAdmin\models.py" in save 209. self.discount_price_formula = self.price - (self.price * … -
How to get domain url in Django?
I want to get domain url to use in view of Django and I use Nginx in my server but I got a problem: I have tried request.META['HTTP_HOST'] or request.build_absolute_uri but it only return 127.0.0.1:8000 (proxy pass in nginx config to Django project). So are there any solution for this? Thanks in advance. -
Django CBV (ListView) paginate_by not allowed with queryset
I'm trying to paginate my tasks but I can't views.py: class DashboardTaskAppView(LoginRequiredMixin, ListView): model = Task template_name = "task_app/task_dashboard.html" context_object_name = 'tasks' today = datetime.date.today() paginate_by = 5 def queryset(self): ordering = ['-due_date'] usr = self.request.user return Task.objects.filter(Q(responsable=usr)) Without paginate_by = 5: WITH paginate_by = 5: TypeError at /task/ object of type 'method' has no len() Request Method: GET Request URL: http://localhost:8000/task/ Django Version: 3.1.2 Exception Type: TypeError Exception Value: object of type 'method' has no len() Exception Location: C:\Users\caior\Desktop\Python\simple_task\venv\lib\site-packages\django\core\paginator.py, line 95, in count Python Executable: C:\Users\caior\Desktop\Python\simple_task\venv\Scripts\python.exe Python Version: 3.8.5 Python Path: ['C:\\Users\\caior\\Desktop\\Python\\simple_task', 'C:\\Users\\caior\\Desktop\\Python\\simple_task\\venv\\Scripts\\python38.zip', 'c:\\users\\caior\\appdata\\local\\programs\\python\\python38-32\\DLLs', 'c:\\users\\caior\\appdata\\local\\programs\\python\\python38-32\\lib', 'c:\\users\\caior\\appdata\\local\\programs\\python\\python38-32', 'C:\\Users\\caior\\Desktop\\Python\\simple_task\\venv', 'C:\\Users\\caior\\Desktop\\Python\\simple_task\\venv\\lib\\site-packages'] Server time: Mon, 09 Nov 2020 09:48:07 +0100 Console: File "C:\Users\caior\Desktop\Python\simple_task\venv\lib\site-packages\django\core\paginator.py", line 95, in count return len(self.object_list) TypeError: object of type 'method' has no len() [09/Nov/2020 09:48:07] "GET /task/ HTTP/1.1" 500 112987 Any help is appreciated, thanks a lot in advance, Kind regards -
how to fix header in datatable with sidebars?
I have used DataTable and tried to fix the header, it is fine until I close the sidebar, when I close the sidebar then header remain constant while scrolling, -
How to break “for loop” in Django template
My code is: {% for key, value in section.items %} {% for key_t, value_t in title.items %} {% if value_t.section_id == key|add:"0" %} <li class="nav-item-header"><div class="text-uppercase font-size-xs line-height-xs"> {{value.title}}</div> <i class="icon-menu" title="Tables"></i></li> {% endif %} {% endfor %} {% endfor %} I want to break the for loop when if the condition is true. like as {% for key, value in section.items %} {% for key_t, value_t in title.items %} {% if value_t.section_id == key|add:"0" %} <li class="nav-item-header"><div class="text-uppercase font-size-xs line-height-xs"> {{value.title}}</div> <i class="icon-menu" title="Tables"></i></li> {% endif %} {{break}} {% endfor %} {% endfor %} How is it possible? please help me... -
How to send Session ID in Cookies using Django Rest Framework
I'm trying to make an cart system using Django. I want to use session id to store products in cart for anonymous users. I am also using Django Rest Framework to create the API which will also be used in an Android Application. Whenever I call the API on 127.0.0.1:8000, it shows me this field on the Response Headers: Set-Cookie: sessionid=nypgq3o486r2qk4ei1excduthrfjuy83; expires=Mon, 23 Nov 2020 08:07:20 GMT; Max-Age=1209600; Path=/ But on calling the API using axios on localhost:3000 this field is missing and no session id is stored on the cookies. I am aware its a cors issue and I have tried few solutions but nothing worked. settings.py CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True SESSION_COOKIE_SAMESITE = None SESSION_COOKIE_HTTPONLY = False What can I do to send the cookies automatically like it is working 127.0.0.1:8000? -
Not authenticated error while using stripe
i am creating an ecommerce website where i have included stripe payment method but when i submit the data there occur not authenticated error. i have no idea what is going wrong, i have followed as same as the video and tried many thing to solved this but still that error was occuring here is my VIEWS.py from django.shortcuts import render, get_object_or_404, redirect from django.views.generic import ListView, DetailView, View from django.core.exceptions import ObjectDoesNotExist from django.contrib.auth.decorators import login_required from django.contrib.auth import authenticate, login, logout from django.contrib.auth.mixins import LoginRequiredMixin from django.conf import settings from django.utils import timezone from django.contrib import messages from .forms import RegistrationForm from .models import * from .forms import * import stripe stripe.api_key = settings.STRIPE_SECRET_KEY class PaymentView(View): def get(self, *args, **kwargs): order = Order.objects.get(user=self.request.user, ordered = False) context = {'order': order} return render(self.request, "payment.html", context) def post(self, *args, **kwargs): order = Order.objects.get(user= self.request.user, ordered = False) token = self.request.POST.get('stripeToken') amount = int(order.get_total() * 100) try: # Use Stripe's library to make requests... charge = stripe.Charge.create( amount= amount , currency="usd", source= token ) # create the payment payment = Payment() payment.stripe_charge_id = charge['id'] payment.user = self.request.user payment.amount = order.get_total() payment.save() # assign the payment to the order order.ordered = True … -
Where to provide necessary Django environment variables in a CI/CD pipeline using Docker and GitHub Actions
I have a Django application that I use GitHub Actions to deploy to an Azure Kubernetes Cluster, When I run the app locally using docker-compose up I get the following error screen; Traceback log Environment: Request Method: GET Request URL: http://0.0.0.0:8000/ Django Version: 3.1 Python Version: 3.8.6 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'djoser', 'oauth2_provider', 'social_django', 'drf_yasg', 'core'] Installed Middleware: ['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'] Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/utils/deprecation.py", line 113, in __call__ response = self.process_request(request) File "/usr/local/lib/python3.8/site-packages/django/middleware/common.py", line 48, in process_request host = request.get_host() File "/usr/local/lib/python3.8/site-packages/django/http/request.py", line 137, in get_host raise DisallowedHost(msg) Exception Type: DisallowedHost at / Exception Value: Invalid HTTP_HOST header: '0.0.0.0:8000'. You may need to add '0.0.0.0' to ALLOWED_HOSTS. I'm unsure where to provide these Environment variables of course by keeping the sensitive ones hidden. The variables found in .dev.env DEBUG="True" SECRET_KEY="...86hoe@14y6)en" ALLOWED_HOSTS="localhost,127.0.0.1 [::1]" DATABASE_HOST="postgres" DATABASE_USER="postgres" DATABASE_NAME="postgres" DATABASE_PASSWORD="postgres" Below are my Dockerfile and docker-compose files; docker-compose --- version: "3.7" services: postgres: environment: POSTGRES_HOST_AUTH_METHOD: trust image: "postgres:12" networks: - internal web: build: "." container_name: identityservice depends_on: - postgres environment: - DEBUG=1 - "SECRET_KEY=\"#e...20m7rxh*%)ki(*=\"" ports: - 8000:8000 networks: - internal stdin_open: true … -
Is there any way to create a location field so that it can be used with MongoDB?
I want to create a user with his location. Which model fields should I use while working with djongo or mongodb database. from djongo import models # Create your models here. class User(models.Model): id = models.IntegerField(unique=True) name = models.CharField(max_length=True) location = models.?? I can use models.PointField() while using PostGres but any suggestions how to work this on with MongoDB NOSQL -
Unable to import 'knox.models' pylint(import-error)
I am building a simple register and login API in Django with Knox authentication. I cannot import only this 'know.models' but others from django and rest_framework. I have checked in settings.py, pylint path and virtual env dependencies. All necessary things are installed and updated. How should I solve this error? -
Migrate or Integrate Python Standalone Script to DJango
I'm new to DJango and Want to know the best way to connect it with Standalone Python application. The Old setup we have is: HTML, Javascript and PHP web portal Python Application to get results and do actions (Connected to Portal through by PHP and Ajax) Right now I migrated the Web portal code to DJango and everything is working fine but I want to connect it to the Python app in a Secure way and without building the whole application again in DJango. How can I do that? -
Django update html label without refreshing page
I am working on a Deep learning project where first we read the real-time video from an ipcamera, get the frame, feed this image/frame to our deeplearning model and this model returns a detected text. in our browser we want to show the image and detected text to the user. so far i am able to show live feed of camera and detected text on the webpage but the problem is the detected text label is not refreshing it is only showing the text detected in the first frame. only live feed is refreshing, to refresh the detected_text label we have to refresh whole page. is there a way we can update only the detected_text label of the index.html whenever the model detects a new text in the image. live camera feed is coming from one url and detected text is being passed as a context from recognizetext view. my index.html page: <html> <head> <meta name="viewport" content="width=device-width, minimum-scale=0.1"> </head> <body style="margin: 0px;"> <h3> image </h3> <img style="-webkit-user-select: none;margin: auto;" src="http://127.0.0.1:8000/api/live/" width="640" height="480"> <h3>{{ detected_text }}</h3> </body> </html> views.py, to get the live camera feed and render index.html : class VideoCamera(object): # for camera feed def __init__(self): self.video = cv.VideoCapture('rtsp://user:password@172.xx.xx.xx:554/live.sdp') (self.grabbed, … -
module 'django.forms' has no attribute 'PhoneNumberField'
from django import forms class ContactForm(forms.Form) name = forms.CharField(max_length=100) email = forms.EmailField() moblie = forms.PhoneNumberField() -
How to show user groups because they didn't show in django view?
I have CRUD operations for users which can be done only from admin and he can assign users to 6 different groups. It saved in the database and everything works well. The problem I faced now is that the groups are not visualize in my views (or in the UI whatever it called) I attached picture to show what I mean: The groups are not showing. Can anyone say what I'm missing? models.py class CustomUserManager(BaseUserManager): def create_user(self, email: str, password: str, group: Group, **extra_fields): if not email: raise ValueError(_('The Email must be set')) email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.set_password(password) user.save() if group is not None: group.user_set.add(user) return user def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active', True) if extra_fields.get('is_staff') is not True: raise ValueError(_('Superuser must have is_staff=True.')) if extra_fields.get('is_superuser') is not True: raise ValueError(_('Superuser must have is_superuser=True.')) return self.create_user(email, password, **extra_fields) class CustomUser(AbstractUser): username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email username = models.CharField(max_length=30, blank=True, default='') is_superuser = models.BooleanField(default=True) is_admin = models.BooleanField(default=True) is_employee = models.BooleanField(default=True) is_headofdepartment = models.BooleanField(default=True) is_reception = models.BooleanField(default=True) is_patient = models.BooleanField(default=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=True) forms.py class UserForm(ModelForm): … -
Hi, someone can help me with some django views?
I hope someone can solve this problem. My goal is to take the last hour posts and insert them in a dictionary with all the info (author, title, text and published date). At the end I want to dumps it in an html file. This is my code: views.py @superuser_only def PostUltimaOra(request): post_detail = {} dt = now() PostsLastHour = Post.objects.filter(published_date__range=(dt-timedelta(hours=1), dt)) for each in PostsLastHour: post_detail = { 'author': each.author, 'title': each.title, 'text': each.text, 'published_date': each.published_date, } dj = json.dump(post_detail) return render(request, 'blog/numeroposts.html', {'dj': dj}) models.py class Post(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title html {% extends 'blog/base.html' %} {% block content %} <h1>{{ 'Posts per utente:' }}</h1> {% for k, v in numero.items %} {{ 'L utente con id n° '}} {{ k }} {{ ' ha pubblicato '}} {{ v }} {{ ' posts' }} <p>{{ ''|linebreaksbr }}</p> {% endfor %} <h2>{{ 'I post pubblicati nell utlima ora sono questi: ' }} {{ dj }}</h2> {% endblock %} -
Django Can I change the Receive Charset only in a specific View?
settings.py DEFAULT_CHARSET = 'UTF-8' views.py class OrderResult(viewsets.ModelViewSet): def create(self, request, *args, **kwargs): payload = request.data <<---- some string broken *** save to database i'd like to receive data with 'euc-kr' only in the above View. -
How to deploy GOOGLE_APPLICATION_CREDENTIALS and use from Django app deployed using Elasticbeanstalk
I have an Django app deployed to AWS using Elasticbeanstalk. I implemented FCM(Firebase Cloud Messaging) relation to Django app. To access FCM feature from Django, it required Firebase Admin SDK installed to django. Firebase Admin SDK requires firebase's private key as json file accessed via env var GOOGLE_APPLICATION_CREDENTIALS. On my local Mac Book env I set local path to private key json file to GOOGLE_APPLICATION_CREDENTIALS in .bash_profile. How do I deploy the firebase's privatge key json file to somewhere safe on AWS(S3 maybe) and access from Django app deployed to AWS using Elasticbeanstalk. -
fusionchart not showing up in django
I am trying to integrate fusion chart in Django, i followed the [official article][1] but the chart is not showing up. I have changed the following files according to the article. My base.html {% load static %} <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>My Site</title> <link rel="shortcut icon" type="image/x-icon" href="{%static '/images/favicon.png'%}" /> <!-- CSS --> <link rel="stylesheet" href="{%static 'css/bootstrap.css'%}" /> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous" /> <link rel="stylesheet" href="{%static 'css/animate.min.css'%}" /> <link rel="stylesheet" href="{%static 'css/owl.carousel.min.css'%}" /> <link rel="stylesheet" href="{%static 'css/style.css'%}" /> <link rel="stylesheet" href="{%static 'css/responsive.css'%}" /> </head> <body> <!-- Begin: Header --> {% include "user/layout/header.html" %} <!-- End: Header --> <!-- Begin: Main --> {% block content %} {% endblock %} <!-- End: Main --> <!-- Footer : Begin---> {% include "user/layout/footer.html" %} <!-- Footer : End --> <!-- Jquery--> <script src="{%static 'js/jquery.min.js'%}"></script> <script src="{%static 'js/bootstrap.js'%}"></script> <script src="{%static 'js/owl.carousel.min.js'%}"></script> <script src="{%static 'js/wow.js'%}"></script> <script src="{%static 'js/custom.js'%}"></script> <script src="{%static 'js/sweetalert.min.js'%}"></script> <script src="{%static 'js/fusioncharts.js'%}"></script> <script src="{%static 'js/fusioncharts.charts.js'%}"></script> <script src="{%static 'js/fusioncharts.maps.js'%}"></script> <script src="{%static 'js/fusioncharts.theme.carbon.js' %}"></script> </body> </html> My View def chart(request): dataSource = {} dataSource['chart'] = { "caption": "About This Product", "showValues": "0", "theme": "carbon" } dataSource['data'] = [] for key … -
RuntimeError: Model class blog.models.Blog doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
settings.py INSTALLED_APPS = [ 'blog.apps.blogConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] Models.py: from django.db import models class Blog(models.Model): name = models.CharField(max_length=100) tagline = model`enter code here`s.TextField() Apps.py class blogConfig(AppConfig): name = 'blog' -
jQuery remote method is not working properly, no error is showing
I am new to jQuery, I am trying to use remote method, it's not working properly, I think the error is in accessing url, I've tried in different patterns , yet it didn't work. I am using Django. Can anyone help me with it? Thanks in advance. <script> $( document ).ready( function () { $( "#signupForm" ).validate( { rules: email: { required: true, good_email : true, remote: {url: "{% url 'check_usn_email' %}"} }, messages: { email: { required: "Please enter your Email address", remote: "An account with that email already exists" } }); }) </script> Urls.py file: path("check_email/",views.check_email, name="check_email") Views.py file: def check_email(request): is_available = 'false' if request.is_ajax(): '''email = request.GET("email") try: User.objects.get_by_natural_key(email) is_available = False except User.DoesNotExist: is_available = True''' return HttpResponse(is_available) html form: <form id="signupForm" method="post" class="login-form text-center" action="/accounts/register/"> {% csrf_token %} <div class="form-group"> <label class="field__label" for="email">Email Address</label> <i class="fas fa-envelope"></i> <input type="email" id="email" class="field__input" placeholder="Email ID" name="email"> </div> </form>