Kareem
Anonymous
djangochannelsrestframework
class ClientsConsumer(ListModelMixin, GenericAsyncAPIConsumer):
queryset = Clients_new.objects.all()
serializer_class = ClientsSerializer
permissions = (permissions.AllowAny,)
async def connect(self, **kwargs):
await self.model_change.subscribe()
await super().connect()
@model_observer(Clients_new)
async def model_change(self, message, observer=None, **kwargs):
await self.send_json(message)
@model_change.serializer
def model_serialize(self, instance, action, **kwargs):
return dict(data=ClientsSerializer(instance=instance).data, action=action.value)
Hello! How can I add an additional parameter (filter) that is applied via request.user ?
i need queryset = Clients_new.objects.filter(user=request.user)
Anonymous
Now the user on the site listens to all changes on the site. I want to make it listen only to the changes that helped its filter.
For example, listen only to records about dogs
Mirco
Victor
Victor
Husniddin
Hi
How do i access my server in other devices that are connected to the same network?
What i tried:
Adding the network's ip address to the allowed hosts settings in settings.py and running the server with both 0.0.0.0 and my_ip with 8000 port
Running with localhost:8000 ip address
For each case, i tried to connect it in other device using my_ip:8000 and 0.0.0.0:8000 and localhost:8000 addresses but none of them worked. The browser says the site is unreachable
Anonymous
1.) Allowed_host = ['the connect device ip address '] to get that on windows go to CMD and type ipconfig scroll to where you see ipv4 copy the numbers place after it.
2). In your Django project terminal write CMD python manage.py runserver IP addresses:8000 e.g python manage.py 193.09.83.1:8000
Anonymous
Turn on your hotspot and connect your system which your Django project is on before doing those
Husniddin
Anonymous
DM me
I
Hello, who can help me, i use django-hitcount library, if i make request from browser my hits is not incremented, but if i make request using javascript every request is incrementing + 1
Husniddin
Anonymous
Husniddin
Victor
Husniddin
Victor
Are you sure you are typing in the IP of the system that Django is running on?
Husniddin
Victor
Check if your server is behind any firewall
Husniddin
Victor
Type in ipconfig in your CMD let's see
Husniddin
Doragonsureiyā
Can't send media here
To share code or error tracebacks, use a pasting service, like:
- https://linkode.org
- https://dpaste.org
Hodonou
Good evening,
I'm trying to build an "Add to cart" functionality, is it possible without using Js?
Nishanth Siraj
Nishanth Siraj
But the page ll reload for each addtocart click
Hodonou
Ok, I see thank you
pranav
Does django require too much of python?
I've learnt basics of it or say more than that , will it be enough?
🧌
Yes
Victor
Adrian
hi all, how to get app_name from a template ?
Adrian
django 4.2+
Adrian
on django 1.9 I use {{ request.current_app }}
pranav
pranav
Adrian
M. Hossein
I am trying to create a docker file for my django project. I use python3.11.4:alpine and this is how my docker file looks:
https://dpaste.org/fmmob
when I try to run my project using docker compose and python manage.py runserver, I get this error:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "python": executable file not found in $PATH: unknown
what should i do?
Анатолий
Hosein
hello guys,,,mosh have best course for django?
Modou-dev
jahanbini01
https://dpaste.org/YH0HM
please help me
ashu
Deepak
Hi guys
I have two tables user and training
I have used user as foreign key in my training model
But i am getting lookup error
Can some one please help me here?
Karthik
Hello every one can any one please help me
when i run SQL query on postgres database
Query:
SELECT DATE(created) AS created_date, COUNT(id) AS user_count
FROM students
WHERE created >= '2014-12-19' AND created < '2014-12-31'
GROUP BY created_date LIMIT 100 OFFSET 0
Output:
"created_date" "user_count"
"2014-12-30" 9
"2014-12-29" 10
"2014-12-20" 2
"2014-12-19" 16
But when i run the equivalent Django ORM for above sql query
start_date = datetime(2014, 12, 19, tzinfo=timezone.utc)
end_date = datetime(2014, 12, 31, tzinfo=timezone.utc)
# Query to fetch users created between the date range and count for each day
users_per_day = students.objects.filter(created_on__gte=start_date, created_on__lt=end_date) \
.extra({'created_date': "DATE(created AT TIME ZONE '+05:30')"}) \ .values('created_date') \
.annotate(user_count=Count('id'))
# Prepare the response dictionary
response_data = {
'user_counts': [ {
'date': entry['created_date'].strftime('%Y-%m-%d'), 'count': entry['user_count']
} for entry in users_per_day
]}
Output:
{
"user_counts": [
{
"date": "2014-12-30",
"count": 2
},
{
"date": "2014-12-29",
"count": 17
},
{
"date": "2014-12-19",
"count": 17
}
]
why my django output is wrong ?
...
hello guys, pls help, how to pass the any word in argument for function in django views from Template?
AShM
Hello everyone!)
Please tell me the structure for the django graphql project so that it can be easily scaled.
And is there a template for graphql django cookiecutter
TonFutures 💎
Hi
How can I make a loading page?
That is, until the site information comes up, I want it to be on the loading page
By
How can I run my django project on IIS server? I have different asp php sites with plex panel installed.
Nicho
Hello guys how can i solve integrity Error
Doragonsureiyā
Erkaboy
Hi guys I have got a problem.
I have got a list of staff. When a client gives an order I send it to one of the staff, and he/she can accept or reject the order. If he/she rejects the order I should send it to another staff till one of them accepts. I should do it with a WebSocket. I need some ideas,
Thanks for any help.
Abhishek
Mohammad
hi every on
I need help
Mohammad
I have a problem, I need help
I have a quick view section for a store site. Inside the main page, when the button is clicked, the ID of that product is sent by ajax to the server and it receives and processes information in the view.
After that, this information will go to another html page which is for django render partial, I will do this with the render to string command, then I will return the ajax response with jsonresponse, and inside the html page where the data will be loaded, we have a main div, then we will use the ajax address We will find this div and I will send response.html to show it
Well, in js, I log the information that is supposed to be displayed in the html tags correctly, but when I load this html, the information is no longer there in the page, and the sections related to the information are empty, after we are in that desired page In the dtl format, the context that I sent does not recognize its name, it only recognizes media_url and static_url
I would be grateful if someone could help me solve this problem
Mohammad
I have a problem, I need help
I have a quick view section for a store site. Inside the main page, when the button is clicked, the ID of that product is sent by ajax to the server and it receives and processes information in the view.
After that, this information will go to another html page which is for django render partial, I will do this with the render to string command, then I will return the ajax response with jsonresponse, and inside the html page where the data will be loaded, we have a main div, then we will use the ajax address We will find this div and I will send response.html to show it
Well, in js, I log the information that is supposed to be displayed in the html tags correctly, but when I load this html, the information is no longer there in the page, and the sections related to the information are empty, after we are in that desired page In the dtl format, the context that I sent does not recognize its name, it only recognizes media_url and static_url
I would be grateful if someone could help me solve this problem
Anyone can not help me to solve this problem?
Anonymous
Hi need to learn Django rapidly
previously studied python
Anonymous
any good course please?
Anonymous
wish to try some sample crud please
Doragonsureiyā
any good course please?
Looking for Django tutorials? you can follow these three recommended ones:
* Official documentation and tutorial
* Tutorial from MDN
* Tutorial from django-girls
Muflone
I have a problem, I need help
I have a quick view section for a store site. Inside the main page, when the button is clicked, the ID of that product is sent by ajax to the server and it receives and processes information in the view.
After that, this information will go to another html page which is for django render partial, I will do this with the render to string command, then I will return the ajax response with jsonresponse, and inside the html page where the data will be loaded, we have a main div, then we will use the ajax address We will find this div and I will send response.html to show it
Well, in js, I log the information that is supposed to be displayed in the html tags correctly, but when I load this html, the information is no longer there in the page, and the sections related to the information are empty, after we are in that desired page In the dtl format, the context that I sent does not recognize its name, it only recognizes media_url and static_url
I would be grateful if someone could help me solve this problem
Too long and too many superfluous details and zero explaination about the issue in doing
Mohammad
Muflone
Muflone
x-yro
Hello guys i have a question. how can I transfer a variable that stores some values, transfer it from the class in which it is located to another class?
V
x-yro
Use inheritance?
when I try to use inheritance I get an error: 'AnimeDetail' object has no attribute 'api_url
M. Hossein
I want to create my apps in my project folder
How can I do this? And how to register apps this way?
Victor
I have a problem, I need help
I have a quick view section for a store site. Inside the main page, when the button is clicked, the ID of that product is sent by ajax to the server and it receives and processes information in the view.
After that, this information will go to another html page which is for django render partial, I will do this with the render to string command, then I will return the ajax response with jsonresponse, and inside the html page where the data will be loaded, we have a main div, then we will use the ajax address We will find this div and I will send response.html to show it
Well, in js, I log the information that is supposed to be displayed in the html tags correctly, but when I load this html, the information is no longer there in the page, and the sections related to the information are empty, after we are in that desired page In the dtl format, the context that I sent does not recognize its name, it only recognizes media_url and static_url
I would be grateful if someone could help me solve this problem
Perhaps some visual presentation can help to fully understand your problem
Mohammad
Victor
Nerd