Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Heroku Logs: No Module Named Numpy
I'm using Django to deploy a website. There is a call to import numpy in my apps.txt file for an ML function. I have numpy==1.19.5 in my requirements.txt file and I installed numpy in the terminal using pipenv install numpy The website works when I deploy it locally, but when I deploy it to Heroku and run heroku open, I get an application error. Here are the logs: 2021-06-12T14:15:02.802169+00:00 app[web.1]: worker.init_process() 2021-06-12T14:15:02.802170+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process 2021-06-12T14:15:02.802170+00:00 app[web.1]: self.load_wsgi() 2021-06-12T14:15:02.802170+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi 2021-06-12T14:15:02.802171+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-06-12T14:15:02.802172+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-06-12T14:15:02.802172+00:00 app[web.1]: self.callable = self.load() 2021-06-12T14:15:02.802172+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 2021-06-12T14:15:02.802173+00:00 app[web.1]: return self.load_wsgiapp() 2021-06-12T14:15:02.802173+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 2021-06-12T14:15:02.802173+00:00 app[web.1]: return util.import_app(self.app_uri) 2021-06-12T14:15:02.802174+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 2021-06-12T14:15:02.802174+00:00 app[web.1]: __import__(module) 2021-06-12T14:15:02.802175+00:00 app[web.1]: File "/app/wandering_mind/wsgi.py", line 16, in <module> 2021-06-12T14:15:02.802175+00:00 app[web.1]: application = get_wsgi_application() 2021-06-12T14:15:02.802175+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2021-06-12T14:15:02.802176+00:00 app[web.1]: django.setup(set_prefix=False) 2021-06-12T14:15:02.802176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup 2021-06-12T14:15:02.802176+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS) 2021-06-12T14:15:02.802176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate 2021-06-12T14:15:02.802177+00:00 app[web.1]: app_config = AppConfig.create(entry) 2021-06-12T14:15:02.802177+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 116, in create 2021-06-12T14:15:02.802177+00:00 … -
Form is not saving in ajax
I am building a BlogApp and I am trying to submit a form without refreshing the page. I am editing the gender of the user. When i click on submit button then it is keep showing me GET /edit_now?csrfmiddlewaretoken=JnegVCQ818H83U29W8zcx8D9QKIK6GxgvLWf5BE5Ab3BcCpxdeEXUXsMNCtHVrU3&gender=derfef models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE,default='',unique=True) full_name = models.CharField(max_length=100,default='') gender = models.CharField(max_length=20) views.py def edit_now(request): form = EditGender() context = {'form':form} return render(request, 'edit_gender.html',context) def postFriend(request): if request.is_ajax and request.method == "POST": form = EditGender(request.POST) if form.is_valid(): instance = form.save() instance.user = request.user.profile instance.save() ser_instance = serializers.serialize('json', [ instance, ]) return JsonResponse({"instance": ser_instance}, status=200) else: return JsonResponse({"error": form.errors}, status=400) return JsonResponse({"error": ""}, status=400) edit_gender.html <form id="friend-form"> <div class="row"> {% csrf_token %} {% for field in form %} <div class="form-group col-4"> <label class="col-12">{{ field.label }}</label> {{ field }} </div> {% endfor %} <div class = "col text-center"> <input type="submit" class="btn btn-primary" value="Edit" /> </div> </div> <form> <script> $(document).ready(function () { /* On submiting the form, send the POST ajax request to server and after successfull submission display the object. */ $("#friend-form").submit(function (e) { // preventing from page reload and default actions e.preventDefault(); // serialize the data for sending the form data. var serializedData = $(this).serialize(); // make POST ajax call $.ajax({ … -
.ibd files taking too much space on ubuntu server
I'm having a problem with .ibd MySQL files. Scenario: I'm having a ubuntu server of 200GB and deployed an application of Django and using MySQL server. The nature of my application is to store huge data and do some x type of processing on it. I have one table which has 5 to 6 million data recrods. This Table has acquired almost 60GB of space (The space occupied by tablename.ibd file). I tried running Optimize table tablename but the .ibd file doesn't get shrunk. The InnoDb is true. PROBLEM Firstly the storage is running out as the file getting too much large. Secondly when I try to migrate the migration for adding a column on this table while running the server gets out of space because on running migration the .ibd file starts getting bigger and the server eventually runs out of space. I will be very thankful If someone helps me out of this. Note:(I could not purge data from the table as data is very important for me) -
how to save user input to database in django models
in the contact session i have created a form with first_name,last_name and email.if entered my detail i should be able to see details in the admin table in back end but i don't.help me to clear this. i have added my app to my installed apps.in don't know where i have missed. models.py from django.db import models # Create your models here. class Contact(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) emaill =models.EmailField() urls.py from django.contrib import admin from django.conf.urls import path from home import views urlpatterns = [ path('', views.home, name='home'), path('about', views.about, name='about'), path('project', views.project, name='project'), path('contact', views.contact, name='contact'), ] contact.html form action="/contact" method = "POST"> {% csrf_token %} <form> <div class="row"> <div class="col"> <input type="text" class="form-control" name = "textfield" placeholder="First name"> </div> <div class="col"> <input type="text" class="form-control" name = "textfield" placeholder="Last name"> </div> </div> </form> <div class="mb-3"> <label for="exampleInputEmail1" class="form-label">Email address</label> <input type="email" class="form-control" id="exampleInputEmail1" name = "email" aria-describedby="emailHelp"> <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> views.py from django.shortcuts import render,HttpResponse from home.models import Contact def contact(request): if request.method == 'POST': first_name = request.POST.get['first name',''] last_name = request.POST.get['last name',''] email = request.POST.get['email',''] #print(first_name,last_name,email) contact =Contact(first_name=first_name,last_name=last_name,email=email) contact.save() print("the data … -
DRF how to create a very complicated route
I come from java world. Let's say I have 4 models: School, Class, Student, Address. I want to build an api like /api/schools/1/classes/2/students/3/address -> return the address of student has id 3, belong to class 2 and school 1 (may be more complicated in the future) In Java It can be done easily: @GetMapping("/api/schools/{school-id}/classes/{class-id}/students/{student-id}/address") public Address getAddressOf(path parameters) { return myService.doLookup(parameters); } But with DRF I even don't have any knowledge about how to archive it since I'm very new to Python and DRF. For now I just can write 4 ModelViewset corresponding with 4 models listed above to have very basic CRUD endpoints. How can I archive this goal? Thanks in advanced. -
Is there any special configuration for mysql python django?
I am trying to run the command bash ../download_content.sh create_django_tables but i got the error django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? Where as mysql-connector-python, mysql,mysql client are already installed. When i opened the mysql using mysql -u root -p my database is already there,but its not migrating the tables. I need help on this. Thanks in advance -
Two Select boxes appearing for one select tag
I am trying to use select tag to make a dropdown menu , but for some reason , it duplicates itself CODE: <select name="drop"> <option>ar</option> </select> ie: These are the css files i am calling: <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}"> <!-- style css --> <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> <!-- Responsive--> <link rel="stylesheet" href="{% static 'css/responsive.css' %}"> <!-- fevicon --> <link rel="icon" href="{% static 'images/doctor-icon.png' %}" type="image/gif" /> <!-- Scrollbar Custom CSS --> <link rel="stylesheet" href="{% static 'css/jquery.mCustomScrollbar.min.css' %}"> <!-- Tweaks for older IEs--> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css"> <!-- owl stylesheets --> <link rel="stylesheet" href="{% static 'css/owl.carousel.min.css' %}"> <link rel="stylesheet" href="{% static 'css/owl.theme.default.min.css' %}"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" media="screen"> Using Django framework btw So how do I get just one select box rather than two? Thank you -
404 Error when loading image URL from Amazon S3 to Leaflet Tile Layer
I am creating an interactive map on Heroku. Please see demo here. I am using amazon s3 buckets to host my static files and user uploaded images(media). The issue now is the map is not shown. The error is 404 not found. The url does not point to amazon s3 but to heroku. If the url is correct, the app should look like this Code: index.js I believe the mistake is at L.tileLayer but not I can't seem to figure out. document.addEventListener('DOMContentLoaded', function(){ var mapSW= [0,4096], mapNE= [4096, 0]; //Declare Map Object var map = L.map('map', {zoomControl: false}).setView([0,0], 1); //console.log(mapSW) //Reference the tiles L.tileLayer('https://leesonmech-cpomillmap-bucket.s3.amazonaws.com/static/main/palm/{z}/{x}/{y}.png',{ minZoom: 0, maxZoom: 4, continuousWorld: false, noWrap: true, crs: L.CRS.Simple, }).addTo(map) map.setMaxBounds(new L.LatLngBounds( map.unproject(mapSW, map.getMaxZoom()), map.unproject(mapNE, map.getMaxZoom()) )); //Markets and Popups //LatLng var marker = L.marker([83,180],{ draggable: true, }).bindPopup('').addTo(map); const layergroupcategory={} console.log("Layer Group:", layergroupcategory) // Pixels marker.on('dragend', function(e){ marker.getPopup().setContent('Clicked '+ marker.getLatLng().toString() + '<br/ >' + 'Pixels ' + map.project(marker.getLatLng(), map.getMaxZoom().toString())) .openOn(map); }); var overlays = {} for (key in layergroupcategory){ overlays[key] = layergroupcategory[key] } console.log(overlays) L.control.layers(null, overlays,{collapsed: false}).addTo(map); }); settings.py from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent import django_heroku # Quick-start development settings - unsuitable … -
How to check if a user is a superuser in the shell - django
I am trying to check if a user is a superuser in the shell in django. Any help on this would be greatly appreciated. Thank you in advance!!! -
DRF: how to call a serializer (as a nested serializer field) before it is defined?
class ASerializer(serializers.ModelSerializer): b = Bserializer() ... class BSerializer(serializers.ModelSerializer): ... I need to call BSerializer before it is defined. How do I do that? -
django - login view in django rest framework
hello i have blog with drf (django-rest-framework) but i don't know how must write login view, my authentication system is JWT with djangorestframework-simplejwt==4.7.1 package and my django version is django==3.24 -
Type hinting for Django Model subclass
I have helper function for Django views that looks like this (code below). It returns None or single object that matches given query (e.g. pk=1). from typing import Type, Optional from django.db.models import Model def get_or_none(cls: Type[Model], **kwargs) -> Optinal[Model]: try: return cls.objects.get(**kwargs) except cls.DoesNotExist: return None Supose I have created my own model (e.g. Car) with its own fields (e.g. brand, model). When I asign results of get_or_none function to a varibale, and then retriveing instance fields, I get annoying warning in PyCharm of unresolved reference. car1 = get_or_none(Car, pk=1) if car1 is not None: print(car1.brand) # <- Unresolved attribute reference 'brand' for class 'Model' What's the propper type hinting to get rid of this warning? -
Django - Order by custom function
I have multiple projects in my subprogram, each with a different cost which I'm calculating in a custom function in my project model. How can I create a subprogram function that returns a list of projects ordered by the costs function in the projects model? Is this possible todo? Subprogram model: class Subprogram(models.Model): title = models.CharField(max_length=100) def projects_sorted(self): return self.project_set.all().order_by('costs') Project Model: name = models.CharField(verbose_name="Name", max_length=100) subprogram = models.ForeignKey(Subprogram, on_delete=models.CASCADE) def costs(self): costTotals = 0 costs = self.costs_set.all() for bcost in costs: costTotals += bcost.cost return costTotals -
Error loading shared library libjpeg.so.8 in Python Django project with Docker
I'm getting this error and have no idea how to fix this. I've tried to install libraries like jpeg-dev zlib-dev libjpeg-turbo-dev then reinstall Pillow library which is needed for Django Simple Captcha and also install libjpeg-turbo8 via Ubuntu command prompt but it has no effect. I'm using Windows 10. Error: Attaching to website_app_1 app_1 | [2021.06.12 11.36.10] INFO: Watching for file changes with StatReloader app_1 | Exception in thread django-main-thread: app_1 | Traceback (most recent call last): app_1 | File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner app_1 | self.run() app_1 | File "/usr/local/lib/python3.9/threading.py", line 892, in run app_1 | self._target(*self._args, **self._kwargs) app_1 | File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper app_1 | fn(*args, **kwargs) app_1 | File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run app_1 | self.check(display_num_errors=True) app_1 | File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check app_1 | all_issues = checks.run_checks( app_1 | File "/usr/local/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks app_1 | new_errors = check(app_configs=app_configs, databases=databases) app_1 | File "/usr/local/lib/python3.9/site-packages/django/core/checks/urls.py", line 13, in check_url_config app_1 | return check_resolver(resolver) app_1 | File "/usr/local/lib/python3.9/site-packages/django/core/checks/urls.py", line 23, in check_resolver app_1 | return check_method() app_1 | File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 412, in check app_1 | for pattern in self.url_patterns: app_1 | File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__ app_1 | res = … -
How to upload profile image in DRF (without creating a separate endpoint if possible) using Postman
I am trying to create an API to do al kind of creation in my models like(Roles, departments, user, profile etc) but I'm kinda stuck here how to upload image for profile avatar using Postman raw body. Can someone take me through this would be appreciated. Here is my profile model class Profile(HRMBaseModel): profile_avatar = models.ImageField(upload_to='profile_avatars/', blank=True, null=True) full_name = models.CharField(_('full name'), max_length=150, blank=True) father_name = models.CharField(_('father name'), max_length=150, blank=True) dob = models.DateField(max_length=10, blank=True, null=True) personal_email = models.EmailField(_('personal email'), blank=True, null=True) . . . roles = models.ManyToManyField(Role) departments = models.ManyToManyField(Department) nationality = models.ManyToManyField(Nationality) . . . def __str__(self): return str(self.full_name) Here is my serilzer with create method. class ProfileSerializer(serializers.ModelSerializer): roles = serializers.SlugRelatedField( many=True, slug_field="role_name", allow_null=True, required=False, queryset=Role.objects.all() ) departments = serializers.SlugRelatedField( many=True, slug_field="department_name", allow_null=True, required=False, queryset=Department.objects.all() ) user = UserSerializer(many=False) nationality = NationalitySerializer(many=True, required=False) class Meta: model = Profile fields = ( 'user', 'full_name', 'father_name', 'blood_group', 'personal_email', 'employee_id', 'dob', 'current_address', 'permanent_address', 'country', 'state', 'city', 'zip_code', 'roles', 'departments', 'nationality', . . . ) def create(self, validated_data): _roles = validated_data.pop('roles') _departments = validated_data.pop('departments') _nationalities = validated_data.pop('nationality', None) user_data = validated_data.pop("user") profile_data = { //Here profile_avatar should go "full_name": f"{user_data.get('first_name')} {user_data.get('last_name')}", "father_name": validated_data.get("father_name"), "dob": validated_data.get("dob"), "personal_email": validated_data.get("personal_email"), "current_address": validated_data.get("current_address"), "permanent_address": validated_data.get("permanent_address"), "country": validated_data.get("country"), … -
module 'accounts.views' has no attribute 'signup'
File "/Users/work/Projects/blog/myblog/urls.py", line 22, in <module> path('post/<int:pk>/signup/', views.signup, name="signup"), AttributeError: module 'accounts.views' has no attribute 'signup' I am trying to do a registration by mail using this guide https://shafikshaon.medium.com/user-registration-with-email-verification-in-django-8aeff5ce498d myblog/views.py import json from urllib import request from django.views import View from django.views.generic import ListView, DetailView from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.urls import reverse_lazy from .models import Post, Comment from .forms import CommentForm from django.contrib.auth import get_user_model from django.contrib.auth.models import User from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.shortcuts import get_current_site from django.core.mail import EmailMessage from django.http import HttpResponse from django.shortcuts import render from django.template.loader import render_to_string from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode UserModel = get_user_model() from .forms import SignUpForm from .tokens import account_activation_token def signup(request): if request.method == 'GET': return render(request, 'signup.html') if request.method == 'POST': form = SignUpForm(request.POST) # print(form.errors.as_data()) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() current_site = get_current_site(request) mail_subject = 'Activate your account.' message = render_to_string('acc_active_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': default_token_generator.make_token(user), }) to_email = form.cleaned_data.get('email') email = EmailMessage( mail_subject, message, to=[to_email] ) email.send() return HttpResponse('Please confirm your email address to complete the registration') else: form = SignUpForm() return render(request, 'signup.html', {'form': form}) def activate(request, uidb64, token): try: uid … -
save() got an unexpected keyword argument, but i didn't change save method
save() got an unexpected keyword argument 'link' I read that error can appear when change save() method, but i didn't change it. My model: class Article(models.Model): link = models.CharField(max_length=50) title = models.CharField(max_length=50) author = models.CharField(max_length=20) body = models.CharField(max_length=5000) It is line where error: Article.save(link=title, title=title, author=author, body=body) -
Using a Python dictionary with multiple values, how can you output the data in a table with Jinja's for loops?
I am using Django to make an API request for current standings in a league table. I would like to display this data as a table in HTML. Here is the code I am using in views.py to make the Python dictionary. # Receive the json response response = json.loads(connection.getresponse().read().decode()) # Declare the dict to use current_table = {"position": [], "team":[], "points":[]} # Loop over 20 times as there are 20 teams in the league for x in range(20): team = response["standings"][0]["table"][x]["team"]["name"] points = response["standings"][0]["table"][x]["points"] current_table["position"].append(x + 1) current_table["team"].append(team) current_table["points"].append(points) return render(request, "predict/index.html", { "table": current_table, }) The raw output of the dict in the terminal and with {{ table }} using jinja is {'position': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 'team': ['Manchester City FC', 'Manchester United FC', 'Liverpool FC', 'Chelsea FC', 'Leicester City FC', 'West Ham United FC', 'Tottenham Hotspur FC', 'Arsenal FC', 'Leeds United FC', 'Everton FC', 'Aston Villa FC', 'Newcastle United FC', 'Wolverhampton Wanderers FC', 'Crystal Palace FC', 'Southampton FC', 'Brighton & Hove Albion FC', 'Burnley FC', 'Fulham FC', 'West Bromwich Albion FC', 'Sheffield United FC'], 'points': [86, 74, 69, 67, 66, 65, … -
Is there a Django plugin for Pycharm/Intellij?
I am working on a blog in django.So is there any Plugin for Pycharm or Intellij idea for django like VS code has? -
Django: sqlite3.OperationalError: no such table: auth_user and django.db.utils.OperationalError: no such table: auth_user
I am trying to create a new login ID in django. I have deleted the database file but it is still showing two errors: sqlite3.OperationalError: no such table: auth_user django.db.utils.OperationalError: no such table: auth_user I have tried doing makemigrations, migrate, makemigrations appname, migrate appname, migrate --run-syncdb, and migrate --database=database-name. But even after doing those, it still shows the same errors. Here is the console screen: (django_ai) C:\gsData\Workspace\venv\django_ai\src>python manage.py createsuperuser C:\gsData\Workspace\venv\django_ai\src Closest Word: Error in the try statement. Random Restart: Error in the try statement. 2021-06-12 16:16:09.640665: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-06-12 16:16:09.641185: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. List Trainer: [####################] 100% Traceback (most recent call last): File "C:\gsData\Workspace\venv\django_ai\lib\site-packages\django\db\backends\utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "C:\gsData\Workspace\venv\django_ai\lib\site-packages\django\db\backends\sqlite3\base.py", line 423, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: auth_user The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\gsData\Workspace\venv\django_ai\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line utility.execute() File "C:\gsData\Workspace\venv\django_ai\lib\site-packages\django\core\management\__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\gsData\Workspace\venv\django_ai\lib\site-packages\django\core\management\base.py", line 354, in … -
Django Exception: 'TemplateDoesNotExist at /'
I'm new to Django and trying to convert a HTML template to Django project. This is my directory structure: . └── MyProject ├── db.sqlite3 ├── main │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── migrations │ │ ├── __init__.py │ │ └── __pycache__ │ │ └── __init__.cpython-38.pyc │ ├── models.py │ ├── __pycache__ │ │ ├── admin.cpython-38.pyc │ │ ├── apps.cpython-38.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── models.cpython-38.pyc │ │ ├── urls.cpython-38.pyc │ │ └── views.cpython-38.pyc │ ├── static │ │ ├── assets │ │ │ ├── css │ │ │ │ ├── bootstrap.css │ │ │ │ ├── framework.css │ │ │ │ ├── framework-rtl.css │ │ │ │ ├── icons.css │ │ │ │ ├── night-mode.css │ │ │ │ ├── style.css │ │ │ │ └── style-rtl.css │ │ │ ├── images │ │ │ │ ├── 1920x1080 │ │ │ │ │ ├── img1.html │ │ │ │ │ ├── img2.html │ │ │ │ │ └── img3.html │ │ │ │ ├── avatars │ │ │ │ │ ├── avatar-1.jpg │ │ │ │ │ ├── avatar-2.jpg │ │ │ │ │ ├── avatar-3.jpg │ │ │ │ │ ├── avatar-4.jpg … -
DoesNotExist at /addToCart/1 User matching query does not exist
D:\DjangoDemos\venv\lib\site-packages\django\core\handlers\exception.py, line 47, in inner response = await sync_to_async(response_for_exception, thread_sensitive=False)(request, exc) return response return inner else: @wraps(get_response) def inner(request): try: response = get_response(request) … except Exception as exc: response = response_for_exception(request, exc) return response return inner ▶ Local vars D:\DjangoDemos\venv\lib\site-packages\django\core\handlers\base.py, line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) … ▶ Local vars D:\DjangoDemos\CartApp\views.py, line 15, in addToCart user = User.objects.get(id=uid) … ▶ Local vars D:\DjangoDemos\venv\lib\site-packages\django\db\models\manager.py, line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) … ▶ Local vars D:\DjangoDemos\venv\lib\site-packages\django\db\models\query.py, line 435, in get raise self.model.DoesNotExist( … ▶ Local vars -
django-allauth signup() missing 1 required positional argument: 'model'
As you can imagine i'm new to django. İ tried to use allauth package for signup-in issues. After studying bunch of basic tutorials etc. the basic configuration started to function just fine but i needed custom signup process for my project. So i started to dig more and implemented this topic to my code -- [1]: django-allauth: custom user generates IntegrityError at /accounts/signup/ (custom fields are nulled or lost) After the implementation i started to debug various issues caused by django-version difference but eventually i ve got the following error: TypeError at /accounts/signup/ signup() missing 1 required positional argument: 'model' Request Method: POST Request URL: http://localhost:8000/accounts/signup/ Django Version: 3.2.3 Exception Type: TypeError Exception Value: signup() missing 1 required positional argument: 'model' the topics and pastebin links that i've found are not working anymore. thats why i'm stucked with this error. i think im missing something basic but cant figure it out. Here are my model-form-settings and adapters below: models.py from djmoney.models.fields import MoneyField from django.db import models from django.contrib.auth.models import User from django_countries.fields import CountryField from phonenumber_field.modelfields import PhoneNumberField from django.dispatch import receiver from django.db.models.signals import post_save from django.contrib.auth.models import AbstractUser from django.conf import settings class CtrackUser(AbstractUser): date_of_birth = models.DateField(help_text='YYYY-MM-DD … -
curl: (3) Port number ended with '.'
curl: (3) Port number ended with '.' (env) (base) 192:core prashantsagar$ curl -X POST -d "client_id=CTrbHZNtiS2VrbN9iVaVzPRHU13sHdHZd6bbMoKZclient_secret=YQ0gtl7UXAJZK596bPetswWYYYyiG8Zq1zZcTytvs1f0t3cPMX2d0fTJbgNVq9eZ3qOvDTL0MekujuHvkaeiFn5ALjQ7yBKO3XYJWzXKQ4vqA4670krGm6KXf6wc2F33grant_type=password&username=sagar@fmail.com.com&password=sagar" http://localhost:127.0.0.1:8000/auth/token/ curl: (3) Port number ended with '.' -
I am trying to deploy django application using heroku but getting error?
Build is successdul and it is producing application error, i have set up host name and debug=False as suggested but it is still causing error in opening the browser window, i am new to heroku so please suggest what needs to be done to make it work my settings.py """ Django settings for djangoTut project. Generated by 'django-admin startproject' using Django 3.2.4. For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent print(BASE_DIR) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = mysecretkey # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['djangoblog-project.herokuapp.com'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog.apps.BlogConfig', 'users.apps.UsersConfig', 'crispy_forms', ] 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', ] ROOT_URLCONF = 'djangoTut.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 = 'djangoTut.wsgi.application' …