Django.fun

Questions & Answers about Django

17.09.2021
0
answers

<built-in function imread> returned NULL without setting an error in django views

i want to create a qr scanner in django.for that i have a model with a field call &quot;image&quot; and a form views.py: @login_required def scan_qr(request): if request.method == 'POST': form = QrScannerForm(request.POST,request.FILES) if form.is_valid(): scanner = form.save(commit=False) scanner.save() image …

17.09.2021
0
answers

image upload works locally, but the deployed version on heroku crashes, paartial credentials messing

i have a python/django project deployed on heroku with aws s3 image upload, I can upload the image and post them on the website locally, but the deployed version on heroku is givinig me that error PartialCredentialsError at /teams/1/add_photo Partial …

17.09.2021
1
answers

Why does django cache.set() store weird characters

When I save the string via django's cache framework from django.core.cache import cache cache.set('host_cache_key_81e44325-c046-44c6-88d7-bad7cd91ec13', &quot;&quot;brown.example.com:8006&quot;) And try to get the value out: 127.0.0.1:6379&gt; get :1:host_cache_key_81e44325-c046-44c6-88d7-bad7cd91ec13 &quot;\x80\x05\x95&amp;\x00\x00\x00\x00\x00\x00\x00\x8c\&quot;brown.example.com:8006\x94.&quot; I get some weird characters around it, why is that …

17.09.2021
0
answers

Django set formset with current user

Django 3.2.7 I have a form that contains multiple inlineformset_factory formset. For all my models, they all have a meta field call created_by. Only the main form Person's created_by is filled by current user. For all the formsets (emailfs, imagefs), …

17.09.2021
0
answers

how can I get the id of the object from Subjects model?

I want to associate a post for that certain object in the subject's model but I can't figure it out (error in views.py). Your help is appreciated for a beginner like me. models.py class Subjects(models.Model): title = models.CharField(max_length=200) slug = …

17.09.2021
0
answers

How can I pass a page param in Django url template tag?

I'm creating a simple search application. I have a model with some data, and the index page is just a search bar that search results of that model. I'm creating the form using just HTML, not a proper Django Form. …

17.09.2021
1
answers

How to know when testing? Django

i'm writing tests for a django app and i need to know whether a view is in a test. # views.py class SomeClass(View): def get(self, request): # how to know if this view is called by test? Thank you!

17.09.2021
0
answers

getting specific errors type message from HTTPError while working django +firebase

i was trying to make signup page using django and while using the ff code user = auth_.create_user_with_email_and_password(email, password) while reaching this point it throws different errors depending on user input like if user input short password less than …

17.09.2021
0
answers

How to remove buttons from CKeditor 4 in Django using settings.py

I am trying to remove buttons from CKeditor 4 toolbar from Django's settings.py file I added the following line to CKEDITOR_CONFIGS but it didn't work 'removeButtons' : ['Underline,JustifyCenter'], The CKEDITOR_CONFIGS lines: CKEDITOR_CONFIGS = { 'default': { 'skin': 'moono', # …

17.09.2021
1
answers

Djano annotate with subtract operation returns None when the subtrahend is None

My objective is to get the balance for a billing instance by subtracting the payments posted within the period. In my Billing model, I have a backlog field that contains the backlogs from previous period. The Billing model has m2m …

17.09.2021
1
answers

Python - Invalid Syntax - Why is this error being thrown?

I already know that this is going to be a trashy question, as per the SO question guidelines, but I have to keep details down to a minimum. I have a traceback, but I don't know why its throwing an …

17.09.2021
0
answers

How can I do a multi file upload in Django, allowing user to remove file upload before form submission?

I am trying to do a fairly common user requirement, allowing the user to upload multiple files in Django, and giving them the option to remove files that they may have accidentally uploaded. As far as I can tell, even …

17.09.2021
1
answers

How to make 2 way access verification in django?

I would like to improve security for access, making a 2 way access verification using a code to send to whatsapp or by using a qrcode. Is there any program or library with such a function?

17.09.2021
1
answers

Django: Why does database login every query?

In my settings.py, I have a database configured. I have a page that issues a sql query against the database defined in settings.py every 10 seconds. I have been using it for 1 year now and never had any issues …

17.09.2021
0
answers

Amazon RDS: OperationalError: (2003, "Can't connect to MySQL server on rds.amazonaws.com (110)"

I have set up a MySQL database and I'm trying to connect it with my application. But I'm getting the above error. My database settings in settings.py are as follows: DATABASES = { 'default': { 'ENGINE': config('db_engine'), 'NAME': config('db_name'), 'USER': …

17.09.2021
1
answers

calculate difference between consecutive numbers in rows af the same model

I am trying to calculate the difference between consecutive numeric values in the odometer_reading field of my model. My Models.py has fields like below: class Refuel(models.Model): vehicle = models.ForeignKey(Vehicle, blank=True, null=True, on_delete=models.SET_NULL) gaz_station = models.ForeignKey( GazStation, related_name=_(&quot;Station&quot;), …

17.09.2021
0
answers

calling from browser to phone - django

I am working on an app using Django, I want my users to call clients using the app just by clicking on the call button and then the clients receive the call on their phone, I want you to suggest …

16.09.2021
0
answers

How to save celery task to a temporary db which will then be updated to the master db

What is a good way to compare new data with old data which is updated everyday with Django ORM? Basically I have a scraper which fetches hackathons everyday (basically just a celery task) and I want the newest to be …

16.09.2021
0
answers

I am getting a pre-receive hook declined when trying to push to heroku

I am trying to push my python/django project to heroku for deplyment but I keep getting ! [remote rejected] master -&gt; master (pre-receive hook declined) . not sure why is this happening ? I have tried deleting and starting over …

16.09.2021
0
answers

import error in parallel folders python django cant be fixed with PYTHONPATH

django structure this is my django structure I am trying to import &quot;home_view&quot; function from Pages APP to main urls in &quot;Kianwoodco&quot; project these statements seem to be not working from ..Pages.views import home_view from src.Pages.views import …

1 2 3 228 229