Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How do you get the max value for a foreign key value in models.py file?
This is my html file {% for member in member_list %} {% for batting in batting_list %} {% if member.id == batting.member.id %} {{ batting }} <br> {{ batting.match.id }} <br> {{ batting.runs }} <br> <hr> {% endif %} {% endfor %} {% endfor %} This is my models.py file class Member(models.Model): name = models.CharField(max_length=40, default='') def __str__(self): return str(self.name) class Batting(models.Model): member = models.ForeignKey(Member, on_delete=models.CASCADE, default='') runs = models.IntegerField(blank=True, null=True) match = models.ForeignKey(Match, on_delete=models.CASCADE, default='') def __str__(self): return str('{0} {1} scored {2} runs'.format(self.member, self.match.date, self.runs)) I am trying to figure out how I show the max runs for a member x in the html file. Currently I have been able to do it for the whole Batting table but not for the individual member! Any help please -
The DAL function "select2" has already been registered
I see a weird bug in while I want to use autocomplete dropdown. I am using a django-autocomplete-light which loads values using ajax. It works perfectly on localhost but after deploying on AWS EC2 instance it raises the following error: autocomplete_light.min.js:1 The DAL function "select2" has already been registered. yl.registerFunction @ autocomplete_light.min.js:1 I have some doubts that this is something related to the jQuery file loading. after collectstatic order I have these files in static folder: admin app autocomplete_light ckeditor django_tinymce js tinymce vendor I guess there is a conflict in autocomplete_light new version( which probably loads min.js) and ckeditor. By the way, tinymce can be deleted as I am not using anymore(just for saying). Please let me know If you have some solution for this problem -
Use an external database in Django app on Heroku
I am trying to deploy a Django REST API on Heroku. Normally I wouldn't have any issues with this but for this app, I am using a legacy database that exists on AWS. Is it possible for me to continue to use this remote database after deploying Django to Heroku? I have the database credentials all set up in settings.py so I would assume that it should work but I am not sure. -
REST API with Django Admin
I am building an API-first app with the Django REST framework, so it has no html views at all and uses only token-based authentication. At the same time, I would like to make use of the Django admin interface, which is no problem, but I am worried about the performance costs as it depends on a lot of apps (sessions, standard auth, messages, csrf, etc.), that are not needed in the main app, but will run on every request. Is there a way to set admin-specific middlewares to run only on the admin interface? I know I can subclass them and raise MiddlewareNotUsed on all requests except ones going to the admin site, but maybe there is some build-in or well-known solution to this? -
How to increase the number of likes in Django using Ajax
I need to increase +1 when any user hit the like button in Django using ajax and if click dislike the like decrement by -1 my html <form method="POST" action="{% url 'video:like' video.pk %}" id="my-like-form"> {% csrf_token %} <input type="hidden" class="likin" name="next" value="{{ request.path }}"> <button class="remove-default-btn" type="submit" id="openPopup" class="like-btn{{ request.path }}"> <i class="fa fa-thumbs-up" aria-hidden="true"><span>{{ video.likes.all.count }}</span></i> Like </button> JavaScript $("#my-like-form").submit(function(e){ e.preventDefault(); // Prevent form submission let form = $(this); let url = form.attr("action"); let res const likes = $(`.like-btn{{ request.path }}`).text(); const trimCount = parseInt(likes) $.ajax({ type: "POST", url: url, data: form.serialize(), dataType: "json", success: function(response) { selector = document.getElementsByName(response.next); if(response.liked==true){ $(selector).css("color","blue"); res = trimCount - 1 } else if(response.liked==false){ $(selector).css("color","black"); res = trimCount + 1 } } }) }) -
No Table created in Django's Admin view
I am using Django REST Framework Here is my code: models.py: class myModel(models.Model): author= models.CharField(max_length= 200) blog= models.CharField(max_length= 300 ,null= False) serializer.py: class mySerializer(serializers.ModelSerializer): class Meta: model = myModel fields = '__all__' views.py: class CreateShipment(generics.CreateAPIView): queryset = myModel.objects.all() serializer_class = mySerializer class ListShipments(generics.ListAPIView): queryset = myModel.objects.all() serializer_class = mySerializer class RetrieveShipment(generics.RetrieveAPIView): queryset= myModel.objects.all() serializer_class= mySerializer lookup_url_kwarg= "id" class UpdateShipment(generics.UpdateAPIView): queryset = myModel serializer_class = mySerializer lookup_url_kwarg= "id" Admin Dashboard: Question I do not see any tables created, I did all the migrations and all the CRUD api endpoints are working. However, when I log onto the admin dashboard I do not see any tables created. -
Django-poll with a choice of several options
I just can't figure out the situation, since I have little experience in django, perhaps this question is too simple but not for me. I wrote a survey with the ability to choose one option, but I do not know how to add the option of a text response, an answer not only with a choice of one option, an answer with a choice of several options modesl.py class Poll(models.Model): title = models.CharField(max_length=200) question = models.TextField() option_one = models.CharField(max_length=50) option_two = models.CharField(max_length=50) option_three = models.CharField(max_length=50) option_input = models.CharField(max_length=50, null=True, blank=True) option_one_count = models.IntegerField(default=0) option_two_count = models.IntegerField(default=0) option_three_count = models.IntegerField(default=0) active_from = models.DateTimeField(auto_now_add=True, null=True) active_for = models.IntegerField(default=0) views.py def create(request): if request.method == 'POST': form = CreatePollForm(request.POST) if form.is_valid(): form.save() return redirect ('home') else: form = CreatePollForm() context = {'form':form} return render(request, 'poll/create.html', context) def vote(request, poll_id): poll = Poll.objects.get(pk=poll_id) if request.method == 'POST': if poll.is_active: selected_option = request.POST['poll'] if selected_option == 'option1': poll.option_one_count += 1 elif selected_option == 'option2': poll.option_two_count += 1 elif selected_option == 'option3': poll.option_three_count += 1 else: return HttpResponse(400, 'Invalid form') poll.save() return redirect('results', poll.id) else: messages.info(request, 'The poll is closed') context = {'poll':poll} return render(request, 'poll/vote.html', context) def results(request,poll_id): poll = Poll.objects.get(pk=poll_id) context = {'poll':poll} return … -
Can we use multiple themes properly in a django template
Well , I'm used one main theme and from which i'm extending all other templates and I have loaded all css and js files in the base.html template. But I want to add new thing which i have seen in another theme so I just downloaded that theme and load their files as well in base.html , Now the both themes js and css mixed up and messed up the all template , Well then i used the second approach which is mentioned below: {% load static %} {% extend 'base.html' %} #THEME ONE CSS AND JS WILL BE LOADED IN THE CONTENT BLOCK I GUESS! {% block content %} desire content from theme one {% endblock content %} {% block theme_two %} {% inclued 'theme_two_css.html'%} desire content from theme two {% inclued 'theme_two_js.html'%} {% endblock theme_two %} By this approch , the results was same... -
Got a `TypeError` when calling `Profile.objects.create()` in CreateAPIView. Django-Rest-Framework
Full Error: TypeError at /photos/user_profile/ Got a TypeError when calling Profile.objects.create(). This may be because you have a writable field on the serializer class that is not a valid argument to Profile.objects.create(). You may need to make the field read-only, or override the ProfileSerializers.create() method to handle this correctly. Original exception was: Traceback (most recent call last): File "C:\Users...\lib\site-packages\rest_framework\serializers.py", line 939, in create instance = ModelClass._default_manager.create(**validated_data) File "C:\Users...\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\Users...\lib\site-packages\django\db\models\query.py", line 447, in create obj.save(force_insert=True, using=self.db) TypeError: save() got an unexpected keyword argument 'force_insert' serializers.py: class ProfileSerializers(serializers.ModelSerializer): class Meta: model = Profile exclude = ['overall_pr','following','followers'] views.py: class ProfileView(CreateAPIView): queryset = Profile.objects.all() serializer_class = ProfileSerializers permission_classes = (IsAuthenticated,) parser_classes = (MultiPartParser,) models.py: class Profile(models.Model): user = models.OneToOneField(to = User,on_delete=models.CASCADE,related_name='userProfile') full_name = models.CharField(max_length=30) public_name = models.CharField(null=True,max_length=30, blank=True,help_text="This name use in video's comment section") bio = models.CharField(max_length=500,null=True,blank=True) profile_pic = models.ImageField(upload_to = 'profile_pic',null=True,blank=True) phone_number = models.IntegerField(null = True,blank=True) country = models.CharField(max_length=20) gender = models.CharField(max_length=10,null=True,blank=True) followers = models.ManyToManyField('self',blank=True,related_name='user_followers',symmetrical=False) following = models.ManyToManyField('self',blank=True,related_name='user_following',symmetrical=False) private_account = models.BooleanField(default = True) overall_pr = models.IntegerField(default = 0,null=True,blank=True,help_text="This contain overall pr(%) of all photos related this profile!!") created_date = models.DateTimeField(auto_now_add=True) I applied related questions solution but still not solved my problem.. Please help where … -
TemplateDoesNotExist on Heroku but works on local server
I am new to django and Heroku. I followed a tutorial on creating a webpage with multiple pages extending on a base page and hosted it on Heroku, it worked. I decided to add a new page with an image (with URL source), and followed the same steps as I did in the tutorial. However, the new page, and only the new page results in "TemplateDoesNotExist". pages app directory C:. │ db.sqlite3 │ manage.py │ Pipfile │ Pipfile.lock │ Procfile │ ├───config │ asgi.py │ settings.py │ urls.py │ wsgi.py │ __init__.py │ ├───pages │ │ admin.py │ │ apps.py │ │ models.py │ │ tests.py │ │ urls.py │ │ views.py │ │ __init__.py │ │ │ └───migrations │ __init__.py │ └───templates about.html base.html hello.html home.html base.html <header> <a href="{% url 'home' %}">Home</a> | <a href="{% url 'about' %}">About</a> | <a href="{% url 'hello' %}">Click Me</a> </header> {% block content %} {% endblock content %} hello.html {% extends 'base.html' %} {% block content %} <h1> Hello</h1> <body> <img src="https://www.rd.com/wp-content/uploads/2019/05/American-shorthair-cat.jpg", width = 320, height = 240.25> </body> {% endblock content %} settings.py from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent … -
How To Style Choose File Button in Django Forms
I have a form where users can upload files. But the button is kind of bland. It's a default html button. Do you have any way I can style that button using django forms? This is the forms.py file class FileReaderForm(forms.ModelForm): class Meta: model = FileReaderModel fields = ['file'] # I want this file(button) to be styled This is my models.py file class FileReaderModel(models.Model): file_name = models.CharField(max_length=100) file = models.FileField() file_body = models.TextField() date_read = models.DateTimeField(default=timezone.now) class Meta: ordering = ['-date_read'] verbose_name_plural = "FileReaderModel" def __str__(self): return str(self.file_name) + " File" -
Psicopg2 not installing on Mac M1
The problem is that psicopg2 isn't installing inside a Virtual Env for a project running with Python and Django on a Mac M1. Django-heroku is trying to install that dependency but is not working on M1. Thanks! -
django contact us form with file upload
Trying to make a "contact us form" on a website using django. Everything works as it should I get a email with "Name: Email: Catagory: Comments: " now I'm trying to make it so people can upload a picture or document of the problem there having. views.py from django.shortcuts import render, redirect from django.core.mail import EmailMessage from django.conf import settings from .forms import ContactForm from django.template.loader import get_template def home(request): if request.method == 'POST' : form = ContactForm(request.POST, request.FILES) if form.is_valid(): name = request.POST.get('name') email = request.POST.get('email') catagory = request.POST.get('catagory') comments = request.POST.get('comments') request.FILES['attach'] template= get_template('contact_template.txt') context = { 'name': name, 'email': email, 'catagory': catagory, 'attach': attach, 'comments': comments } content = template.render(context) email = EmailMessage( catagory, content, 'support@btcz.rocks', ['support@btcz.rocks'], attach.attach(), headers = {'Reply-to': email} ) email.send() return render(request, 'thanks.html') forms.py from django import forms from .models import catagory class ContactForm(forms.Form): name = forms.CharField(label='Your name', required = True, max_length=100) email = forms.EmailField(required=True) catagory = forms.ChoiceField(choices = catagory,) #choices in models.py attach = forms.FileField(required=False, widget = forms.FileInput) comments = forms.CharField(max_length=300, widget=forms.Textarea, required=True,) -
what is the proper way to deal an insert with onetone field? DJANGO
I am pretty new with Django , and I would like to insert an ID based on the modelA data to be inserted, and categorize the data from modelB , but I think this is not the right way to do it. how can I do it via signals or any other way to do it? class ModelA(models.Model): name = models.CharField(max_length=60) class ModelB(models.Model): [..] model_a_name = models.OneToOneField(ModelA, on_delete=models.CASCADE) # standalone domain = ModelA.objects.filter(name=data['domain']).first() model_b_obj = { "_name": data['_name'], "id": data['id'], "_url": data['url'], "_name": data['_name'], # data['domain'] } ModelB.objects.get_or_create(**model_b_obj) -
How to stream video to more than one client using Django development server
I am trying to stream video to multiple browsers using opencv and django on a raspberry pi. In the code I share below, I am able to see my video stream on a different computer which is great, but when another computer tries to access the stream it just gets a blank screen. If I close the stream on the first computer, the second computer will now be able to access it. So my question is, is this due to my code, or is this due to a limitation of the django development server, and I need to use gunicorn/nginix or similar production level? I am hoping I am just missing something in the code... #views.py class VideoCamera(object): def __init__(self): self.video = cv2.VideoCapture(0) def __del__(self): self.video.release() def get_frame(self): ret,image = self.video.read() ret,jpeg = cv2.imencode('.jpg',image) return jpeg.tobytes() def gen(camera): while True: frame = camera.get_frame() yield(b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') @gzip.gzip_page def videoStream(request): try: return StreamingHttpResponse(gen(VideoCamera()),content_type="multipart/x-mixed- replace;boundary=frame") except HttpResponseServerError as e: print("aborted") Then my HTML is very simple for now: <img id="image" src = "http://127.0.0.0:8000/videostream/"> -
Django Graphql Auth without email field in Custom User Mode
I am trying to use graphql to authenticate my flutter app. However, my Custom User model does not have field "email" instead it has "username" I have made necessary changes but I keep getting error below 'Meta.fields' contains fields that are not defined on this FilterSet: email If I add a email field in User model , it starts to work fine, but I want to use "username" field instead. Please help #Custom User Model class User(AbstractBaseUser, PermissionsMixin): username = models.CharField(_('username'), max_length=130, unique=True) full_name = models.CharField(_('full name'), max_length=130, blank=True) is_staff = models.BooleanField(_('is_staff'), default=False) is_active = models.BooleanField(_('is_active'), default=True) date_joined = models.DateField(_("date_joined"), default=date.today) phone_number_verified = models.BooleanField(default=False) change_pw = models.BooleanField(default=True) phone_number = models.BigIntegerField(unique=True,default=create_new_ref_number()) country_code = models.IntegerField(default='91') two_factor_auth = models.BooleanField(default=False) USER_TYPE_CHOICES = ( (1, 'student'), (2, 'teacher'), (3, 'unassigned'), (4, 'teacherAdmin'), (5, 'systemadmin'), ) user_type = models.PositiveSmallIntegerField(choices=USER_TYPE_CHOICES,default=3) objects = UserManager() REQUIRED_FIELDS = ['full_name', 'phone_number', 'country_code'] USERNAME_FIELD = 'username' # e.g: "username", "email" EMAIL_FIELD = 'username' #settings.py GRAPHQL_AUTH = { 'LOGIN_ALLOWED_FIELDS': ['username'], 'REGISTER_MUTATION_FIELDS':['username'], 'REGISTER_MUTATION_FIELDS_OPTIONAL': ['phone_number',], 'UPDATE_MUTATION_FIELDS': ['full_name','phone_number',], 'USERNAME_FIELD' : ['username'], } -
headache causing AttributeError:
I am trying to get the "cart" working on my website but keep getting the following when going to "cart.html: Error: File "C:\dental\dental\website\views.py", line 32, in cart customer = request.user.customer File "C:\dental\virtual\lib\site-packages\django\utils\functional.py", line 241, in inner return func(self._wrapped, *args) AttributeError: 'User' object has no attribute 'customer' Views.py | Code: def cart(request): if request.user.is_authenticated: customer = request.user.customer order, created = Order.objects.get_or_create(customer=customer, complete=False) items = order.orderitem_set.all() else: #Empty cart for non-logged in user items = [] context = {'items':items} return render(request, 'cart.html', context) If someone can lend a hand, it would be greatly appreciated! (relatively new to coding, been learning for the better half of a year) Thank you!! -
The Loop Does Not Shows Anything In Template Django
Hello, I want to show some items in my cart template, but it doesn't show me anything. When I don't use a for loop, it works fine, but it shows me nothing when I use it for a loop. I will be appreciated it if you help me to solve it. My guess is, maybe something on my CART class is wrong, I am not sure, but it would be great if you check it out. View: from django.shortcuts import render, get_object_or_404, redirect from Products.models import Product from .forms import AddCartForm from django.views.decorators.http import require_POST from decimal import Decimal CART_SESSION_ID = 'cart' class Cart: def __init__(self, request): self.session = request.session cart_session = self.session.get(CART_SESSION_ID) if not cart_session: cart_session = self.session[CART_SESSION_ID] = {} self.cart = cart_session def add_product(self, product, quantity): product_id = str(product.id) if product_id not in self.cart: self.cart[product_id] = {'quantity': 0, 'price': str(product.price)} self.cart[product_id]['quantity'] += quantity self.save() def save(self): self.session.modified = True def __iter__(self): product_ids = self.cart.keys() products = Product.objects.filter(id__in=product_ids) cart = self.cart.copy() for product in products: cart[str(product.id)]['product'] = product for item in cart.values(): item['total_price'] = Decimal(item['price']) * item['quantity'] yield item @require_POST def add_product(request, product_id): cart = Cart(request) form = AddCartForm() if form.is_valid(): product = get_object_or_404(Product, pk=product_id) quantity = form.cleaned_data['quantity'] cart.add_product(product=product, … -
How I can increase the number of likes when the hit button using ajax
How I can increase the number of likes when the hit button using ajax, I using Django and I want to increase the number of likes when hit the like button the html <form method="POST" action="{% url 'video:like' video.pk %}" id="my-like-form"> {% csrf_token %} <input type="hidden" class="likin" name="next" value="{{ request.path }}"> <button class="remove-default-btn" type="submit" id="openPopup"> <i class="fa fa-thumbs-up" aria-hidden="true"><span>{{ video.likes.all.count }}</span></i> </button> JavaScript $("#my-like-form").submit(function(e){ e.preventDefault(); // Prevent form submission let form = $(this); let url = form.attr("action"); $.ajax({ type: "POST", url: url, data: form.serialize(), dataType: "json", success: function(response) { selector = document.getElementsByName(response.next); if(response.liked==true){ $(selector).css("color","blue"); } else if(response.liked==false){ $(selector).css("color","black"); } } }) }) -
Should Include, Scripts and tcl folders be in gitignore in a Django project?
I use the gitignore file mentioned in this related question. In my project there are 3 folders: /Lib /Scripts /tcl these three are pushed to the repository, but I feel uncomfortable about these 3 folders as if they shouldn't be pushed. Should these three folders be included in .gitignore? -
Django Rest Framework Serializer not printing nested relationship
I've got established a relationship between 2 models: Order and OrderLine. I've created serializers for both of them following the DRF documentation, yet when printing the serializer.data the nested objects don't show. Here are my models: class Order(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) session_id = models.CharField(max_length=256) class OrderLine(models.Model): order_id = models.ForeignKey(Order, on_delete=models.DO_NOTHING) product_id = models.ForeignKey(Product, on_delete=models.DO_NOTHING) price = models.DecimalField(decimal_places=2, max_digits=20) quantity = models.IntegerField() total = models.DecimalField(decimal_places=2, max_digits=20) created_at = models.DateField(auto_now_add=True) updated_at = models.DateField(auto_now=True) These are the serializers: from rest_framework import serializers from .models import Order, OrderLine class OrderLineSerializer(serializers.ModelSerializer): """ OrderLine serializer """ class Meta: model = OrderLine fields = ['product_id', 'price', 'quantity', 'total'] class OrderSerializer(serializers.ModelSerializer): """ Order serializer """ items = OrderLineSerializer(many=True, read_only=True) class Meta: model = Order fields = ['session_id', 'subtotal', 'total', 'items'] read_only_fields = ['id'] and this is the view: class OrderAPIViewSet(viewsets.ViewSet): def create(self, request): order = Order.objects.create(session_id=request.data['session_id']) for item in request.data['items']: product = Product.objects.get(pk=item['product_id']) total = Decimal(item['price'] * item['quantity']) OrderLine.objects.create( order_id=order, product_id=product, price=Decimal(item['price']), quantity=item['quantity'], total=total ) serializer = OrderSerializer(instance=order) print("HERE") print(serializer.data) return Response(status=status.HTTP_200_OK) From my REST client I'm posting the following object: { "session_id":uuid, "items": [ { "product_id": product.id, "price": 5.80, "quantity": 2, } ] } but when the print statement in the view is executed this … -
django forms import path issue
I have an annoying problem that I'm not able to solve. I'm not able to import PostForm class from path posts>forms.py and use it into accounts>views.py. When I hover on the class is saying '(import) PostForm: Any'; Any help is appreciated. posts>forms.py from django import forms from posts.models import Post class PostForm(forms.ModelForm): class Meta: model = Post fields = ['image', 'caption', ] accounts>views.py from posts.forms import PostForm @login_required def profile(request): form = PostForm() if request.method == 'POST': form = PostForm(request.POST, request.FILES) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.save() return HttpResponseRedirect(reverse('home')) return render(request, 'login/user.html', context = {'title' : 'Profile Page', 'form' : 'form'}) -
make like button in django using ajax
How I can make like button in Django using ajax my html, I need to click like button without reload the page, The ajax function didn't work <form method="POST" action="{% url 'video:like' video.pk %}"> {% csrf_token %} <input type="hidden" class="likin" name="next" value="{{ request.path }}"> <button class="remove-default-btn" type="submit"> <i class="fa fa-thumbs-up" aria-hidden="true"><span>{{ video.likes.all.count }}</span></i> </button> JavaScript $('.likin').click(function(){ $.ajax({ type: "POST", url: "{% url 'video:like' video.pk %}", data: {'content_id': $(this).attr('name'),'operation':'like_submit','csrfmiddlewaretoken': '{{ csrf_token }}'}, dataType: "json", success: function(response) { selector = document.getElementsByName(response.next); if(response.liked==true){ $(selector).css("color","blue"); } else if(response.liked==false){ $(selector).css("color","black"); } } }); }) -
Passenger application error: Internal error
I am trying to migrate my Python Django web app on hosting from the local environment. The installation went well, but at the end I do not see the starting page for Django here staging.changerz.education. In the logs I found the error and not sure what is a problem that I need to fix in my app. Please, help anyone: "error" : { "category" : "INTERNAL_ERROR", "id" : "23a01cfb", "problem_description_html" : "<p>The Phusion Passenger application server tried to start the web application. But the application itself (and not Passenger) encountered an internal error.</p><p>The stdout/stderr output of the subprocess so far is:</p><pre>Traceback (most recent call last):\n File &quot;/usr/share/passenger/helper-scripts/wsgi-loader.py&quot;, line 369, in &lt;module&gt;\n app_module = load_app()\n File &quot;/usr/share/passenger/helper-scripts/wsgi-loader.py&quot;, line 76, in load_app\n return imp.load_source(&apos;passenger_wsgi&apos;, startup_file)\n File &quot;/var/www/u1115154/data/www/staging.changerz.education/passenger_wsgi.py&quot;, line 6, in &lt;module&gt;\n from django.core.wsgi import get_wsgi_application\n File &quot;/var/www/u1115154/data/djangoenv/lib/python3.7/site-packages/django/__init__.py&quot;, line 1, in &lt;module&gt;\n from django.utils.version import get_version\n File &quot;/var/www/u1115154/data/djangoenv/lib/python3.7/site-packages/django/utils/version.py&quot;, line 71, in &lt;module&gt;\n @functools.lru_cache()\nAttributeError: &apos;module&apos; object has no attribute &apos;lru_cache&apos;\n</pre>", "solution_description_html" : "<p class=\"sole-solution\">Unfortunately, Passenger does not know how to solve this problem. Please try troubleshooting the problem by studying the <strong>error message</strong> and the <strong>diagnostics</strong> reports. You can also consult <a href=\"https://www.phusionpassenger.com/support\">the Passenger support resources</a> for help.</p>", "summary" : "The application process exited … -
No module named 'sklearn.ensemble.weight_boosting'
I have created a model with a single file field in Django where it stores a pickle ML model. Django model: class Pickle(models.Model): csv=models.FileField() In my views.py file, I am trying to predict using this pickle model. But it gives above error Views.py from django.shortcuts import render,redirect from django.contrib.auth.forms import UserCreationForm,AuthenticationForm # Create your views here. from django.contrib.auth.models import User from django.contrib.auth import login,logout,authenticate from django.db import IntegrityError from diabetes.models import Info,Pickle import os import pandas as pd #import os import seaborn as sns import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import io import base64 import pickle def predict(request): data=Pickle.objects.all()[0] model=pickle.load(open(data.csv.path,'rb')) li=[40,1,0,1,0,1,0 ,0,0,1 ,0 ,1, 0 ,1 ,1,1] ans=model.predict(li) return render(request,"diabetes/predict.html",{"answer":ans}) also, I have installed scikit-learn 0.24.1. How can I solve this error?