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

Update in Model AbstractEvent

In the AbstractEvent model more two fields can be added to know the date and time at which a particular event was added as well as the the last date and time at which it was modified.

Add the following fields in AbstractEvent inside event/models.py file :

created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)

After adding these 2 fields, you will need to run the migrations in order to make the changes in the database.

python manage.py makemigrations
python manage.py migrate

alt text So after this, those fields will be recorded automatically.

In the admin page even, it can displayed and filters can be set for it.

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

This allows to keep track of events as when it were created and last modified.

Also the model field year is not required as the created_at would contain the year in which it was created. So that field also can be removed.

After removing that field from event/models.py , you would also need to remove all its references from event/admin.py and then you would need to run migrations to make the changes in the database.

python manage.py makemigrations
python manage.py migrate

alt text This would remove that field completely from the database.