I have a django project created with django 4.0.
I'm new to djnago, so if I'm asking a silly question, please forgive me!
I can't figure out a way by which I can edit a record in my model through the admin panel.
Below is the model Products that has some products added. Suppose I want to edit the fields' data (eg. Name of product), then how can I achieve that from the admin panel itself?
The admin panel is just showing to delete the selected record currently.
Below is the code that is present in the admin.py
file:
from django.contrib import admin
from .models import (
Customer, Product, Cart, OrderPlaced
)
@admin.register(Customer)
class CustomerModelAdmin(admin.ModelAdmin):
list_display = ['id', 'user', 'name', 'locality', 'city', 'zipcode',
'state']
@admin.register(Product)
class ProductModelAdmin(admin.ModelAdmin):
list_display = ['id', 'title', 'selling_price', 'discounted_price',
'description', 'brand', 'category', 'product_image']
@admin.register(Cart)
class CartModelAdmin(admin.ModelAdmin):
list_display = ['id', 'user', 'product', 'quantity']
@admin.register(OrderPlaced)
class OrderPlacedModelAdmin(admin.ModelAdmin):
list_display = ['id', 'user', 'customer', 'product', 'quantity',
'ordered_date', 'status']
Thanks in advance!
CodePudding user response:
Click on the numbers on the Id column, those are the hyperlinks for the edit page. It will take you to the page where you can edit the model.
If you want to change the link to some other field you can do that by specifying link_display_fields=['your fields']