Alex
https://dpaste.org/crz9
So, it is acltually classical x y problem. You don't need background tasking here. Instead you need to learn how to work with DBs. And how they function at all.
Alex
https://dpaste.org/crz9
I think you should consider refactoring your code with bulk create/update https://docs.djangoproject.com/en/3.2/ref/models/querysets/#bulk-create
Joseph
Please when debug is false my images from the database don't appear but static files do and when debug is true all comes Please any help so the media images appear
Finose
Css files not loading in website
Beekaaash
How do You load css file in html page
Beekaaash
Send code first
Doragonsureiyā
Css files not loading in website
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions
Beekaaash
Load static first in the page
Beekaaash
Then give path in start with static
Beekaaash
If you send code then exactly we can say where you do wrong else how can we say bro there is many things need to do in page
Finose
i know
Finose
i have done everything upto my knowledge
Finose
actually css files are showing in website debug controll (i mean in the network section)
Finose
which code file i need to send settings.py or my website templates
John
Why Django replaces all spaces with underscores while uploading files?
Finose
Send code first
<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">
Alex
No
then show the code where occurs
John
then show the code where occurs
It is default behavior when you upload file to model FileField
Firdavs
It doesn't work if I write a function to the data I received in ajax, it only works if I type it into onclick, it reads the function I wrote
Anonymous
how to form user token in django api ?please some one help me
Charly
you were running elastic search locally? If you get connection refused is that the elastic server is not running
Charly
but you said its docker so it can't be on localhost
Charly
I already did
Charly
can work separatelly but you need to use the correct addres
Charly
then use machine IP not localhost
Charly
do you know what is a IP?
Charly
local network machine one
Charly
I understand your issue, you don't understand the solution
Charly
So instead of using localhost:9200 to refer to elsatci server you need to use the local network machine ip, for example 192.168.1.2:9200
Jasurbek
Who can help me with WebSpace.uz DIrect Admin to create python application for django project
Charly
Who can help me with WebSpace.uz DIrect Admin to create python application for django project
I don't know what that website is, please explain, but pytohn or django projects are created in your computer
cj
Im using djongo, which is giving error
then read the article Doragon sent to you
Fzn9
How can i link Django rest with html template?
Charly
How can i link Django rest with html template?
yo don't, django templates are supposed to be used with views directly, if you are using rest framwork is because you are going to use javascript to query the API
Arnol
Dear team, have you already integrated Django with rest fw and angular?, Do you have any reference about this back and frontend frameworks?
Charly
Arnol
Ok ok
Arnol
Thanks dear Charly. So I have to create as well as always in Angular Services.ts to connect what I receive from the back in Json callback?
Charly
Thanks dear Charly. So I have to create as well as always in Angular Services.ts to connect what I receive from the back in Json callback?
I'd say yes but not sure this is a Django group, questions about angular have no room here
Arnol
Ok. Thanks
Anonymous
How do you retrieve the pk of a model whose pk is a UUID field with the default value set to django.contrib.postgres.functions.RandomUUID accessing model.id or model.pk simply returns RandomUUID
Yusuf
Hello everyone.. I want to ask how to display the results of Many to Many in the HTML template? I want to display a type of case connected in the kasus.pmi table I try to use a forloop but it can't. {% for jenis_kasus in case.pmi.jenis_kasus.all %} {{ jenis_kasus }} {% endFor%} Note: jenis kasus = type case
Roy Cyril
hi everyone, anyone know the reason Faker not randomizing whenever i execute it in a Factory? i'm using factory-boy (latest version) and uses this code product=factory.random.random.choice(['item1','item2','item3','item4']) to generate random value for a field, it randomly generate whenever i run it in the shell, but if i generate using create_batch of factory-boy, it doesnt seem to generate randomise values. any tips how this works, should i seed the random generator first.
Roy Cyril
searched it in the docs but still not working.
Rohan
Just use the model manager and get id
Anonymous
In no case you should call randomuuid yourself, let the database handle it
I have to provide a default value for the field since its a primary key. Weird how django returns no uuid after save but if you get the instance again using something like`.first()` this instance would have the UUID. While this works, there is no way to be sure that it would be the record we expect it to be. model.refresh_from_db throws a DoesNotExist exception
Anonymous
and yes its after calling save if anyone is wondering
P
Anyone worked on Django app. I am facing issue with multiple request, so how to tackle with this? In brief, if at a time more than 1 user makes a request then it won't work.
R_OU
does django-q work on Window 10?
Doragonsureiyā
Anyone worked on Django app. I am facing issue with multiple request, so how to tackle with this? In brief, if at a time more than 1 user makes a request then it won't work.
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase
Vxvek
I need to make dictionary in django template like keys in heading as row and there values as columns.. I tired a lot but I'm getting as key and values in one row
...
Hello. How do the same in DRF… _______________________ views.py class AnswerView(CreateView): … def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs[choice] = Choice.objects.filter( question=Question.objects.get(pk=self.kwargs[„pk“]) return kwargs __________________ forms.py class AnswerForm(ModelForm): class Meta: … fields = [ … „answer_choice“, ] def __init(self, choice, *args, **kwargs): super().__init__(*args, **kwargs) self.fields[„answer_choice“].queryset = choice ________________________________________ with this I get certain fields from the model p.s. I use Google translator (from Russian)
...
You can start from: https://www.django-rest-framework.org/api-guide/generic-views/ https://www.django-rest-framework.org/api-guide/serializers/
Yes, of course I first searched the documentation, but unfortunately everything I tried to do didn't work.
Alex
Or do you suggest looking more?
it is just a set of links you should start from.
...
Yes, of course you are right .. you still need to look .... despite the fact that the documentation is made very intelligibly ... apparently I missed it. thanks anyway
Roy Cyril
Hello, anyone know how to access fields in a factory-boy factory class, for example i have title=factory.Faker., and i have another field called slug which converts title to it slug form, now, i have a problem accessing the title's random generated value. how can i access title to generate a slug from it? any idea how to do this
Dishant
how do i create put function method in the class TaskViewDetails(views.APIView)
Alex
how do i create put function method in the class TaskViewDetails(views.APIView)
Also learn how to ask questions https://mikeash.com/getting_answers.html
Nico
hi, I have a long-term running command in a django (ver 3.0.5) app which uses MySQL as DB backend (mysqlclient version is 2.0.3). Somewhat after 24 hours of running, I get a django.db.utils.OperationalError: (2006, 'MySQL server has gone away') exception when some of the commands want to retrieve data from the DB. I just run Model.objects.filter() commands. I've read the Django documentation for Databases, there I saw a parameter called CONN_MAX_AGE which "default value is 0, preserving the historical behavior of closing the database connection at the end of each request.". Thus, I don't understand why I'm getting such exception. I'm completely sure the MySQL server has not gone away and has been running all along. I've also tried setting it to None and the result is the same. Has anyone bumped into this and knows why is it happening?