Document that ModelAdmin.prepopulated_fields only works on empty forms
ModelAdmin.prepopulated_fields auto generating works only while creating new records but not while editing them.
from django.db import models
class Item(models.Model):
title = models.CharField(max_length=200, blank=False)
slug = models.SlugField(max_length=200)
from django.contrib import admin
from .models import Item
class ItemAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Item, ItemAdmin)
Change History
(8)
Component: |
contrib.admin → Documentation
|
Summary: |
ModelAdmin.prepopulated_fields. Auto generating does not work while editing object → Document that ModelAdmin.prepopulated_fields only works on empty forms
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Bug → Cleanup/optimization
|
Owner: |
changed from nobody to James Seden Smith
|
Status: |
new → assigned
|
Owner: |
changed from James Seden Smith to Botond Béres
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
That's expected behavior --
prepopulated_fields
only works on empty forms. I think the idea is that slugs for existing objects shouldn't change since that could cause a URL to change. This could be documented.