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

Editing Fields in List

The Admin page in django, allows a user to edit the fields value while being displayed in the list without explicitly going to another page and updating it.

This can be done by adding the following code in the ModelAdmin :

list_editable = ('description',)

alt text Here, the description can be edited and clicking the save button will make the respective updates in the database, But the title cannot be edited.

If both title and description are added in the list_editable variable, then it will be possible to edit both the fields.

list_editable = ('title','description',)

But the addition of this code, will lead to an error which will be like this alt text

<class 'notesapp.admin.NoteAdmin'>: (admin.E124) The value of 'list_editable[0]' refers to the first field in 'list_display' ('title'), which cannot be used unless 'list_display_links' is set.

It states that, the value that takes acts as a link to give its detailed view, cannot be added inside the list_editable option. If that should be made editable, then we will need to create some other field value to be given as link, and that should be the first value in the list_display variable.

This can be done as follows :

list_display = ('pk','title', 'description')
list_editable = ('title','description',)

alt textHere pk refers to the primary key field of the object, and it is used to act as a link for the model in the admin page.