Relative Content

Tag Archive for pythonmysqldjango

How to add the evey objects to Many-to-Many relationship model

class MyUserGroup(BaseModel): my_user_types = m.ManyToManyField(‘MyUserType’,blank=True) I have this models which has the many-to-many relation ship to type. Now I want to give the every MyUserType objects to this model such as muy = MyUserType() muy.save() muy.my_user_types.add(MyUserType.objects.all()) However this shows the error like this, TypeError: Field ‘id’ expected a number but got <SafeDeleteQueryset [<MyUserType:A>, <MyUserType: B>, […]

Django-MySQL remote connection trouble

I was trying to connect my app with a remote MySQL database (usually obtained from our hosting through cPanel) and encountered this error. Can anyone help me out? I’m stuck here. Does Django really allow remote MySQL connections?

DJANGO Compute number of hours the user spend per day

I have Clocking table in database. I wanted to count the users’ time spend per day. For example 2024-03-21, user 1 spend 6.8 hours, the next day he spend n number of hours and so on ([‘6.8’, ‘n’, … ‘n’])

Django: Change Datatable by input value

I have an input field where the user can input specific ‘year’, and it will show all related rows. It’s not the search function that I want, this one is different. There are multiple rows that has the same information, so if I use the search bar, it won’t give me rows from other ‘year’. So all the info in my datatable will depend on what is in the input field. I’m not sure if you get what I mean. Is there any links or tutorials you can recommend to me?