Skip to content
Advertisement

Tag: django

Django add custom permission

I am facing the problem of adding custom permission in Django. My idea is that when authorizing a user, if it belongs to group1, only the rows of group1 are displayed, and otherwise the rows of group2. There is a group field in the database table, it contains only two values group1 and group2. In the admin panel, I created

django custom Func for specific SQL function

I’m currently performing a raw query in my database because i use the MySQL function instr. I would like to translate is into a django Func class.I’ve spend several days reading the docs, Django custom for complex Func (sql function) and Annotate SQL Function to Django ORM Queryset `FUNC` / `AGGREGATE` but i still fail to write succesfully my custom

Django list_display highest value ManyToMany Field

I want to know how I can display the “highest value” from my ManyToMany Field in the admin. This is my models.py file: In my backend, I have created different types of Degree’s, all with a “ranking”. In my case, the highest degree you can have is “Doctoral Degree”, with a rank of “6”. So if a User is creating

ordering modelchoicefield in django loses formatting

I wanted to order a list in my form view, and found this post here: How do I specify an order of values in drop-down list in a Django ModelForm? So I edited my code and added the line specialty = forms.ModelChoiceField(queryset =’…’) So then I reload the form and the widget is all smoshed and funky looking. I checked

Advertisement