Stack Overflow » Django
69 FOLLOWERS
Stack Overflow is the largest, most trusted online community for developers to learn, share their programming knowledge, and build their careers.
Stack Overflow » Django
30m ago
When we are uploading the files to azure storage via django, it's adding underscore if space or special characters are there in the filename and it's disturbing the functionality. Is there anyway we can ignore it or change it. I tried multiple suggestions but it's not working like custom storage options. If i'm trying the custom storage options, it's not uploading in blob storage but it's uploading project folder. Refer the code below i tried in custom storage,
from django.core.files.storage import FileSystemStorage
class CustomStorage(FileSystemStorage):
def _save(self, name, content ..read more
Stack Overflow » Django
30m ago
I am building a real-time chatroom using htmx connect with webstocket in Django, when I try to send a message, the message is not showing and I am getting this error in the terminal "HTTP GET /?csrfmiddlewaretoken=frNekEsvdZ6jdJp7gYMF7pvXpnO11m3J3vOpJ7XCsAKLogIBuUpuKizmufpWRKxN&body=hi+aneeb 200 [0.04, 127.0.0.1:54773]" here my asgi.py file:
import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter,URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from channels.auth import AuthMiddlewareStack
os.environ.setdef ..read more
Stack Overflow » Django
2h ago
I am building a voice bot using Twilio and Django. I have set up an outbound call with media streaming, which is working fine. However, I want to implement voice activity detection so that if the customer interrupts while the voice bot is speaking, the bot stops speaking immediately. I am looking for guidance on how to achieve this using Twilio's Media Streams feature
I have set up media streaming for the Twilio outbound call using the verb in the TwiML response. This is my view:
'''python class StartOutboundCallingView(APIView):
client = Client(sid, token)
def post(self, request, format=Non ..read more
Stack Overflow » Django
6h ago
I currently am working on a django project for a discord bot. the issue that I am trying to resolve is that I cannot seem to query the data for one of my models.
A piece of information that has been unclear to me that I am sure caused this issue was a series of migration issues I had trying to update my Character model with new relationships to the InventoryInstance model in a seperate app.
when I boot up a django shell_plus session - I get this error when trying to query the Character Model:
located in inventory.models
In [1]: Character.objects.all()
Out[1]: OperationalError: no such column ..read more
Stack Overflow » Django
6h ago
I have a method in my API that handles the sync operations with the company's ERP. This method is called once every 30 minutes by a script I made to ensure that everything will be always up date. However, if someone wants, they also can make a request to the endpoint by themselves, but they also need to be informed if the operation is currently processing or not
So, my solution is: I keep a flag on the database and set it to true when the transaction ongoing and false when it ends, so my application will check it and proceed/stop based on this condition
There's just one problem: as I'm keeping ..read more
Stack Overflow » Django
8h ago
I can't understand why I'm getting an error. I've tried different approaches, but I still encounter an issue with consumers.py. What's the problem, and what am I doing wrong?
messaging_users/routing.py
from django.urls import path
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from messaging_users import consumers
websocket_urlpatterns = [
path('ws/messaging_users/', consumers.ChatConsumer.as_asgi()),
]
application = ProtocolTypeRouter({
'websocket': AuthMiddlewareStack(
URLRouter(
websocket_urlpatterns ..read more
Stack Overflow » Django
11h ago
class MultipleFileInput(forms.ClearableFileInput):
"""
Work around for `widget=forms.ClearableFileInput(attrs={'multiple': True})`
>> `widget=MultipleFileInput(attrs={'multiple': True})`
"""
input_text = 'Select'
clear_checkbox_label = 'Clear'
initial_text = 'Current'
allow_multiple_selected = True
class UserUploadForm(forms.ModelForm):
file = forms.FileField(
widget=MultipleFileInput(attrs={'multiple': True}),
required=True,
validators=[FileExtensionValidator(allowed_extensions=['csv'])],
)
class Meta:
model = UserUpload
fields = ['file ..read more
Stack Overflow » Django
12h ago
I am trying to build a Dashboard with Django... I wish to filter the dashboard with category, month and Year. The dataFrame is coming from python code than I am adding the charts with JS.
I don't know how to proceed to be able to filter it as I want.
views.py:
def get_expense_api_data(request, *args, **kwargs):
sort_order = ['January','February','March','April','May','June','July','August','September','October','November','December']
exp_df = pd.DataFrame(Expenses.objects.filter(user=request.user).all().values('date_created', 'amount'))
categories = dict()
if exp_df.empty ..read more
Stack Overflow » Django
12h ago
I published my Django project into github and I had a lot of variables that stored in .env for secure.
And when anyone clone that project and migrate its not reading variables in my .env file that saved in .gitignore.
is there any solution without showing these value of the variables, or it's ok and no danger to show this info?
```
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
SECRET_KEY = os.getenv('SECRET_KEY')
CURRENT_HOST = os.getenv('CURRENT_HOST')
DATABASE_NAME = os.getenv('DATABASE_NAME')
DATABASE_USER = os.getenv('DATABASE_USER')
DATABASE_PASSWORD ..read more
Stack Overflow » Django
12h ago
I've got a (django) app, that displays a page with videojs-record, with ability to record something and send to backend. In general both recording and sending works fine. But - after recording there is a button to send (button with id=submit), and the click there works sometimes immediately, sometimes, I need to click it two or three times, to make it work. After sending, the button is hidden, and another one is showed to move to next question. And the behaviour is similar - it works sometimes, and sometimes needs to be clicked couple of times. I've no idea how to debug it...
{{questionText ..read more