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

Search and Filter for User Model

On the users page there would be a UI like this. alt textSince there is only one user, there is no problem in selecting the user and editing it. Consider a scenario where there would be thousands of users. At that case it becomes difficult to select a particular user. To make this task easy search fields and filters can be added in the admin page for more easy access.

In the admin code, the filter fields needs to be specified as follows :

list_filter = ['is_active', 'is_staff', 'is_superuser', 'role']

This allows to select particular filters based on the requirement. alt text Similarly search fields can also be added.

search_fields = ['email', 'first_name', 'last_name']

Adding this will add a search bar and it would search for each of the fields and returns only if the text contains in any one of the fields : alt text By doing this, search and filter fields can be added inside the admin panel. Also the display of which content to be displayed can be edited. You can specify which fields you want to display instead of just displaying a single column.

list_display = ['email', 'first_name', 'mobile_number', 'profile_photo']

alt textNow, it will display the fields specified inside the list_display in the admin class.

For now, if you click the profile photo path, it will show a page like this. alt text You will see how to correct this in the next section.