Author Picture

Kim Majali


ManyToMany Relationship

Author Avatar wrote on 08/06/2022

Model

class Sample(models.Model):
    users = models.ManyToManyField(User, blank=True) # if not blank=True it will not be required, null=True is meaningless
Read more

Select Objects in Django

Author Avatar wrote on 08/06/2022

Get first record


context['branch'] = CompanyBranch.objects.filter(company=1).first()
Read more

Django Admin Area Site’s Name, Title, Header

Author Avatar wrote on 07/06/2022

Add these at bottom of url.py of your main application, make sure that admin is imported

admin.site.site_header= "Pollster Admin"
admin.site.site_title= "Pollster Admin Area"
admin.site.index_title= "Welcome to the Pollster Admin area"
Read more

Display Model in Admin

Author Avatar wrote on 07/06/2022


    class TextContentAdmin(admin.ModelAdmin):
    list_display = ("name", "page", "en_text", "ar_text")
    list_filter = ("page",)
Read more

Admin Custom View

Author Avatar wrote on 07/06/2022

Adding models to the admin

from django.contrib import admin
from backoffice.models import *
Read more

Topics: ModelsViewsAdmin