Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15688 closed Uncategorized (duplicate)

unique_for_date validation doesn't run with admin readonly_fields

Reported by: jacob Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords: admin readonly_fields unique_for unique_for_date
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:

Description

Model:

import datetime
from django.db import models

class Entry(models.Model):
   title = models.CharField(max_length=255)
   slug = models.SlugField(unique_for_date='created')
   created = models.DateField(default=datetime.date.today)

Admin:

from django.contrib import admin
from .models import Entry

admin.site.register(Entry, readonly_fields=['created'])

With this, I'm able to create multiple entries with the same created date. If I remove created field from readonly_fieldsvalidation fires as expected.

Also see this django-users thread reporting something similar with auto_now and editable=False.

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by anonymous

  • Resolution set to duplicate
  • Status changed from new to closed

readonly fields are excluded, so I believe the problem here is the same as #13091.

comment:2 Changed 3 years ago by lukeplant

  • Resolution changed from duplicate to fixed

In [16095]:

Fixed #15688 - Generic views should provide a HEAD implementation

Thanks to j4mie for the report and patch!

comment:3 Changed 3 years ago by lukeplant

  • Easy pickings unset
  • Resolution fixed deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to Uncategorized

Doh, that commit message was meant for #15668.

comment:4 Changed 3 years ago by lukeplant

  • Resolution set to duplicate
  • Status changed from reopened to closed

comment:5 Changed 3 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.