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
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
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
Did all This site cant be reached ERR_ADDRESS_UNREACHABLE The device which the server is running and the other device which I'm trying to access to the server are connected to the same network (WiFi)
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
Dm
Did
Victor
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
Add 0.0.0.0 to settings.ALLOWED_HOSTS e.g ALLOWED_HOSTS = ["0.0.0.0"] Run the runserver command python manage.py runserver 0.0.0.0:8000 If you are on windows type "ipconfig" (without qoutes) in your CMD Or if you are in Linux or Mac type "ifconfig" in your terminal Then copy your IP address Connect your devices to the same network On the other devices open your browser and type in {your_ip}:8000
Victor
Are you sure you are typing in the IP of the system that Django is running on?
Victor
Check if your server is behind any firewall
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
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
Eternity
Does django require too much of python? I've learnt basics of it or say more than that , will it be enough?
If you know basic things like for loops, if statements, functions and so on, you are ready. You also should have basic knowledges of OOP
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 }}
Adorilson
Can you provide some resources for OOPs in python?
For a intro: https://docs.python.org/3/tutorial/classes.html Beyond: https://docs.python.org/3/reference/datamodel.html
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?
Анатолий
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?
Maybe you should to write a full path to your executable python file inside the docker container. Because, in simple words, locally a simple "python ...." command is available because your operating system creates a "variable" for a full path to executable file and calls it "python" to use it easily. Maybe alpine distro does not do this thing automatically. (It can be a mistake 'cause I'm still learning docker features)
Hosein
hello guys,,,mosh have best course for django?
Doragonsureiyā
hello guys,,,mosh have best course for django?
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
jahanbini01
https://dpaste.org/YH0HM please help me
Charly
https://dpaste.org/YH0HM please help me
normale Formas has no save function only ModelForms
ashu
Hey guys! How to create cart system in django? Explain to me pls
You have to create model of every product in model file
Артём
You have to create model of every product in model file
Yes, I’ve dine this. In Django cart implements with sessions?
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ā
Hello guys how can i solve integrity Error
Impossible to help without details.
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
Doragonsureiyā
hi every on I need help
No one can help you until you explain your difficulties.
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
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
Mohammad
Muflone
What do u want to know about this issus I cant send file
Do your project Why can't you do that alone?
Mohammad
Do your project Why can't you do that alone?
Because final project of uni and must do it alone
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?
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?
Maxim
Perhaps some visual presentation can help to fully understand your problem
no visual presentation is allowed here this group is for programmers, not managers