Soma
Results .objects.aggregate(max(student))
Soma
So take avg instead of max
James
So take avg instead of max
result = Results.objects.values('student').annotate(Avg('marks')) i tried to do this but i fail to get the name by using a foreign key
....
Hloo anyone know about isoft it training
....
They were fake or not
Soma
Any one say how to customise models?
kritikos
James
James
kritikos
kritikos
kritikos
James
hop you add related name to student foreign key in your Result Model
class Results(models.Model):
student = models.ForeignKey(Student, related_name='results', on_delete=models.RESTRICT)
entry = models.ForeignKey(Entry,on_delete=models.SET_NULL, null=True)
subject_name = models.CharField(max_length=20)
marks = models.FloatField()
remarks = models.CharField(max_length=255, null=True)
R_OU
class Product(models.Model):
category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='product')
title = models.CharField(max_length=255)
description = models.TextField(blank=True)
price = models.DecimalField(default=0, max_digits=100000, decimal_places=1)
price_before_offer = models.DecimalField(default=0, max_digits=100000, decimal_places=1)
def offer_maker(self):
amount = 2
jj = self.price * amount
return Product(price_before_offer=jj).save()
<< Why my code is not save in the database >>
kritikos
James
kritikos
James
R_OU
Dami_codr
Sanji
S
df= df.replace({np.nan:None}) this line is not replacing my entire df with none. Suggestions please
Dami_codr
Karan
Django complete Tutorials
.. ...
Atul
Guys I need one suggestion, I belong to Data Analyst background (BI). Want to learn web developement. Django or React, not able to decide. 😞
Enigma
can anyone tell me what is the name of the widget that numbericinput has in forms inputs
Enigma
that you can make the number goes up and down by clicking it
Enigma
i cant send the pic :(
Enigma
the name is spinners
how can i disable them in my forms |:
Anonymous
Enigma
Tsogi
hey guys. do you use free templates? how do you use them? just copy-paste to your project and edit until nececary?
laurel
Hello bro, I stuck in my project, where I am creating API for college management system. I have a Teacher table that is OnetoOne related with User table. I want that any teacher and view and update any teacher details. For that I created a group of "teacher" in Group table and give permission for "can update teacher ". I add teacher to that group. But when I go to update teacher detail It says you don't have permission. It work when I give "can change User" person to teacher. I used JWT for authentication and DjangoModelPermisson as permission class
Harsh
Can anyone help me out
I am making a Django+ React app and i want to render images in my component , i am using the webpack for loading all the JS files , can anyone help me out as to how to load the image using file loader and using the public url generated
Zelo
Panji
Hello anyone try using raw query with multiple table joined and returned as json?
Panji
I have a problem to return json from rawquery
Doragonsureiyā
Doragonsureiyā
Hello anyone try using raw query with multiple table joined and returned as json?
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
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like:
- https://del.dog
- https://dpaste.org
- https://linkode.org
- https://hastebin.com
- https://bin.kv2.dev
If you posted a wall of text, go back and delete it.
Panji
Sorry
Karina Fernanda
Hello all,
Karina Fernanda
I have a question, can somebody provide any feedback please?
Doragonsureiyā
I have a question, can somebody provide any feedback please?
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
Karina Fernanda
This is a file with the questions:
Karina Fernanda
https://docs.google.com/presentation/d/1fPqMcr6LW1JiTHrbb8UwZ53FvPxjWZX-dpAUBCqiIU8/edit?usp=sharing
Nico
Hello gyes! (sorry if I will bad to speak english)
.. in general I want to create one general Model "Photo" with different fields (...) AND fields:
object_id = models.IntegerField()
object_type = models.CharField()
for relations with different models.
and create several different Models.
each of them will be some type for object_type field in Model "Photo".
and each of them will have a method:
def get_photos(self):
return Photo.objects.filter(object_type='...', object_id=self.pk)
and everything works well for lazy requests
but if i want to make greedy request(i.e. get nested objects ahead of time without using get_photo () method)..
i don't know how to do ORM query..
Maxim
Maxim
Panji
Can someone helps to solve my error here?https://pastebin.com/hjBVV4Bv
Panji
here updated link with model https://pastebin.com/wtf5aJj4
Harish
A model 'C' has its data given in the form of Fixtures. Many models are dependent on this model through both FK & M2M.
Now, in Develop, it has some pk for particular object, while in Prod, for that pk, some different object is set, causing Fixture inconsistency in pk's.
To resolve this, in (test db),
1. I tried to alter the schema of child table of C with "ON UPDATE CASCADE" in psql using this https://stackoverflow.com/questions/25973576/updating-primary-keys-in-postgresql., since Django doesn't have on_update=models.CASCADE.
3. I then updated the pk of 'C' objects with the one having in development, in order to avoid Unique constraint failed error, (at this moment, update reflected in Child model) & then reloaded the fixture, it was fine.
Some Side effect of this change resulted in "some_model_id_seq" got its value replaced with new one ( because of my Fixture pk change )
My queries are :
1. Is this way the correct to do ?, If so, it won't cause any serious issues ( because of changing pk )?
2. I tried in only one child of C, but there are many more children models of C. So, for them also, I should do manually or any other quick way ?
3. For Child model having M2M, I tried to same Operation in the "Join Table", since that has FK to Parent, it works as expected. Is that ok to do, or any other special change required for it?
4. Is there any other way to solve this ? I'm thinking of having env specific Fixtures ( for Prod, 1 fixture , for Dev, different fixture ). But, it's too much of thing to do..
Changing primary keys is definitely a bad idea, but I don't have any other choice to maintain consistency of 'C' across all env's..
Sorry for the wall of text, since I need to clearly explain what my problem is.
Anyone please help on this..
Maxim
or separate - idk - I am not a native English speaker
Nico
i found))
thank you all for your help. The issue was resolved using GenericForeignKey. And with DRF serializers, everything is worked)
p.s.
this approach has its drawbacks in terms of database structure, etc., but about that later))
Karina Fernanda
may i write in PM?
Hi Maxim, yes. I'll create a new prívate group
Willian
Hi,
ValueError: Django can only handle ASGI/HTTP connections, not websocket.
Willian
Could some angel help me enable this websocket
maverick
James
Hello i need some help please
I how should i calculate the average of marks for each student. And store the remarks with either fail or pass based on the entry level cutting point. If the average is less than cutting point then the remarks will be Fail.
My models.
Entry(id, level, cutting point).
Results(subject name, marks, remarks, entry_id, student_id).
Any one who can help me please
_karimoff_1904
Hi my friends . Which hosting is the best one for central asia or over the world
Deleted
https://stackoverflow.com/questions/68901044/save-data-in-editable-table-to-database
Kaushal
is it possible to shake the screen on some error with css ?
Amit
Hello guys
Amit
Can anyone help me?
How can i join two tables using ORM?
In two tables i don't have any foreign key
Amit
Thanks in advance
Amit
Amit
Amit
Use AJAX call
How? Can you please help
Actually I'm a Fresher so
Sanjarbek
User=sardor
Group=www-data
WorkingDirectory=/home/sardor/BuxoroITS
ExecStart=/home/sardor/BuxoroITS/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
config.wsgi:application
which is this User
Rahul
I am looking for Django Developer from India to help me with a product, possible partner/co-founder. Interested candidates whatsapp me at wa.me/919814776655