Django

College Event Registration Website

CampusConnect Introduction and Setup Configuring settings file for template, static and media files Setting up Tailwind Creating Custom User Model Creating Super User for CampusConnect Registering Custom User Model Search and Filter for User Model Serving Media Files During Development Categorizing Departments Linking Department with HOD Creating Abstract Model for Event Creating Model for Workshop Customizing Admin Page for Workshop Update in Model AbstractEvent Adding Instructor for Workshop Instructor Model Admin Page Adding Poster Field in Abstract Event Providing Access to HOD Access Update for HOD Restricting HOD Access to Particular Department AbstractEvent On Spot Registration Field Creating Workshop Object Creating and Linking Home Page Displaying Workshop on Home Page Styling Home Page Adding Workshop Detail Page Link Workshop Detail Page Workshop Detail Page Styling Workshop Instructor Details Workshop Detail Contact Contact Admin Page Many to Many Field for Contact Displaying Contact on Workshop Detail Page Adding Title for Workshop Detail Page Adding Gallery for Workshop Workshop Gallery Admin Page Displaying Gallery Images on Website Through Context Displaying Gallery Images on Website through template tags Authentication for users User Registration User Registration Submission Logout Functionality For User Login Functionality for User Model For Workshop Registration Workshop Registration Admin Page Register Workshop Function Register Button in Workshop Page Validations Before Workshop Registration Workshop Registration Closed Validaiton User Already Registered for Workshop Validation Workshop Registration Report From Admin Page Export using Library in Django Admin Extending Abstract Event for Hackathons

Customizing Admin Page for Workshop

In order to customize the admin page for workshop models, we can add filters and search fields, along with that during adding of a new Workshop and editing of the same, we can group particular fields to get a better view and category of fields in the admin page.

Open the event/admin.py file and make the following changes :

from django.contrib import admin
from .models import Workshop, AbstractEvent

class AbstractEventAdmin(admin.ModelAdmin):
    list_display = ('name', 'year', 'event_type', 'start_date', 'end_date', 'registration_start_date', 'registration_end_date')
    search_fields = ['name', 'year']
    list_filter = ['event_type', 'start_date', 'end_date', 'registration_start_date', 'registration_end_date']
    autocomplete_fields = ['department']
    prepopulated_fields = {'slug': ('name',)}

@admin.register(Workshop)
class WorkshopAdmin(AbstractEventAdmin):
    list_display = ('workshop_title', 'venue',)+AbstractEventAdmin.list_display
    search_fields = AbstractEventAdmin.search_fields + ['workshop_title', 'venue']
    fieldsets = (
        ('Basic Information', {
            'fields': ('name', 'slug','year', 'website_link', 'mail_id', )
        }),
        ('Workshop Details', {
            'fields': ('workshop_title', 'venue', 'target_audience', 'event_type', "department",)
        }),
        ('Dates', {
            'fields': ('start_date', 'end_date', 'registration_start_date', 'registration_end_date',)
        }),
    )

After doing this, the admin page will look like this, alt textalt textalt text

As you can see, the fields have been grouped together in categories. Also the slug field has been given as prepopulated_fields along with name, So as the name field is typed, the corresponding slug field value will also be updated for the same.

In the further sections, we would try adding workshops through admin access and Hod's access.