Rainur
I am new in django. How i authenticate user if auth.authenticate(username=username, password=password) returns None when user is not active?
Ghorz
docs.djangoproject.com
Rainur
thanks
Raja
Hi Guys .. anyone help on this requirement. How to filter dynamically selected option in same page without refresh?
Raja
Yes I think Ajax also can be used. Is there any available pip for this feature ?
Mirco
Yes I think Ajax also can be used. Is there any available pip for this feature ?
Nowadays js can do what you did with ajax by using fetch APIs But you can use ajax if u prefer
Ghorz
Yes I think Ajax also can be used. Is there any available pip for this feature ?
Sometimes try find a custom solution to simple task rather than pipping around the problem.
🤔
whats the best practice for storing constants in models? class A(models.Model): bb = 1 aa = models.Integer.... wont help because this bb wont be stored in db. But this needs to be accessed in non django app so it has to be stored in table
🤔
what do you really want to do?
create column where all rows will have one value
cj
create column where all rows will have one value
then declare the field and set a defult= value 🤷🏻‍♂️ isn't that enough for what you want to do?
cj
class A(...): bb = models.IntegerField(default=1) ...
cj
"constants" are another kind of things, for example class A(...): FOO = 'bar' aa = models.SomeField... FOO won't be stored in DB —because it's a constant, there's no sense to store it on disk—, but you can use the FOO constant later in your code accessing to it trough your model instance
Ghorz
I was trying out Django 3. Django Rest Framework spilled bunch of errors as a result of deprecated library import. I debugged the full django REST Framework. It worked fine. For those interested, I'll upload the zipped DRF to a link so you can try it out before the official DRF will be available.
Rohan
Did you squash em all in one commit?
Rohan
Yea
Bad boi
David Kilgrave
hi sorry... can you point me to the flask group?
Anonymous
There isn't any.
David Kilgrave
There isn't any.
alright, thank you
Yash
how to save django form wizrad data in database
Yash
What?
How to save that form data in database
Rohan
Using ORM
Anonymous
How to save that form data in database
https://docs.djangoproject.com/en/2.2/topics/db/ May be it can help you.
🤔
No
Yesnt
Shubham
https://dpaste.de/Egnd
Shubham
in this case
Shubham
.Display the total salary drawn by analyst working in dept no 20
Shubham
e=emp.objects.filter(job='salesman').filter(deptno=30).aggregate(Sum('sal'));
Shubham
its returning sum but what if I want name of employee
Shubham
.values('ename') isnt workin
Shubham
got it sorry silliest mistake
RafaelRS
Hello Gents. I have django site (django-acra) where i view data thru admin page. Problem is that this page counting qty of table row, which is slow for my DB (1.6 million records of 15Gb counting in 5 seconds). Is there way to change query which used to count number of records? Django uses SELECT count(*) FROM table;
Elvis
hi, one "simple" query: django its a good framework for create an erp ?
Someone
Hi, I am saving a model first and then passing the pk of the object created to a function.. In that function am trying to get the object based on the pk I passed, but I get a error Object Not Found and it is not always 40% of time am getting not found and other times it's working perfectly.. The object is already created as we saved it before calling this function.. Then how am I getting object not found error? Someone please help me to understand what would have gone wrong.
RafaelRS
need to use indexing as per your database
Indexing won't help. In postgres count works slow: https://www.citusdata.com/blog/2016/10/12/count-performance/
Anonymous
How to solve this one You are trying to add a non-nullable field in django when I referenced a foreign key in another model
Anonymous
If I give null = True It's working but every time it's gives null value. I want to store a reference id from another model to this model
Anonymous
What should I do ??
Tony
How can you add a JavaScript file to an HTML file in Django.
🤔
How can you add a JavaScript file to an HTML file in Django.
Google: How can you add a JavaScript file to an HTML file in Django.
ℕo ℕame
Why does RetrieveAPIview require "queryset" property with Model.objects.all() (by doc)? It makes a query to database and return a list of objects and then search an object in the list? Is it not easier to make a query that get 1 object?
Sergey K
Actually it constructs another query with filtering and then hits the database
ℕo ℕame
Actually it constructs another query with filtering and then hits the database
Yes? I thought .all() method doesn't create a query object and hits the db directly
Mirco
Guyz does anyone use this and setup Google OAuth2 ? I'm having some issues related whitelist domains setting that does not work Maybe someone of you have had the same issue
@Garant
Hello! Who can help with password reset via mail in django rest wramework?
Lamepic
Hello! Who can help with password reset via mail in django rest wramework?
https://wsvincent.com/django-user-authentication-tutorial-password-reset/
Sap
How can i change buy and sell orders clrs red and green trading website in django
ℕo ℕame
Do anyone have any idea why this is happening?
not clear what you mean by "get the object based on the pk i passed". Maybe because you dont create the object you want to get that based on that pk?
Someone
I guess I found the reason. It was because of my custom manager, default model manager was not on the top of it so it was giving inconsistent data.. Hence I was getting 404 even if the data was there in the DB
ℕo ℕame
No. I am first saving the object and the passing the objects PK to a celery task ..
I've not worked with celery but I know it is async... looks like your function makes query to get the object before async function save object
ℕo ℕame
Sometimes async func save the object before func gets the object. So sometimes it works
Someone
I am not saving the object in async, I am saving the object normally in class and after saving it passing the pk to the async task which is doing get object or 404..not the other way around
.
You should launch task after calling transaction.on_commit
.
Because Celery in some cases executes task before last transaction commit
Someone
Because Celery in some cases executes task before last transaction commit
Looks valid, will check doing this.. Thanks a lot
.
Looks valid, will check doing this.. Thanks a lot
From docs: There’s a race condition if the task starts executing before the transaction has been committed; The database object doesn’t exist yet! The solution is to use the on_commit callback to launch your Celery task once all transactions have been committed successfully.
.
Looks valid, will check doing this.. Thanks a lot
Example: on_commit(lambda: expand_abbreviations.delay(article.pk))
.
Launch tasks always after calling on_commit
Someone
Why do you pass the pk? Can't you pass the object itself?
Celery tasks cannot take a object as parameter