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

Field Lookups

You can use Field Lookups in Django to make specific where clauses. They are keywords that represent specific SQL keywords. All Field Lookups must be specificied with the fieldname, followed by 2 underscores (__) characters, and the field lookup keyword. For example, to get the Persons whose name starts with J, you can give like this :

Person.objects.filter(first_name__startswith='J').values()

alt text The SQL query for the above code will be as following :

SELECT * FROM Person WHERE first_name LIKE 'J%';

Other Field Lookups for reference :

Field Lookup Description
exact Matches the exact value of the field.
iexact Case-insensitive exact match.
contains Matches a substring within the field value.
icontains Case-insensitive substring match.
startswith Matches values that start with a given substring.
istartswith Case-insensitive startswith match.
endswith Matches values that end with a given substring.
iendswith Case-insensitive endswith match.
in Checks if a value is in a list of values.
gt Matches values greater than a specified value.
gte Matches values greater than or equal to a specified value.
lt Matches values less than a specified value.
lte Matches values less than or equal to a specified value.
isnull Matches NULL values or non-NULL values.
range Matches values within a specified range.
year Matches records based on the year portion of a date field.
month Matches records based on the month portion of a date field.
day Matches records based on the day portion of a date field.
week_day Matches records based on the day of the week.
regex Matches values using a regular expression pattern.
iregex Case-insensitive regex match.

These are the different Field Lookup Keywords that can be used to select only particular rows from a model.