Opened 10 years ago

Closed 4 years ago

#2169 closed defect (fixed)

"Please correct the error below." With No Shown Errors

Reported by: tyson@… Owned by: anonymous
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When a class has a field that isn't shown in the admin interface but must not be blank, it's impossible to add a new one. You get a cryptic "Please correct the error below." message with no shown errors. The error message should probably say something about a hidden field.

Here's a sample model to reproduce this bug:

class Foo(models.Model):
	title = models.CharField(maxlength=100)
	url = models.URLField()

	class Admin:
		fields = (
			(None, {'fields': ('title',)}),
		)

Change History (13)

comment:1 Changed 10 years ago by James Bennett

The problem with solving this is in the way Django decouples its components. For the manipulator system (which is where the error message comes from) to know that a field was left blank because it wasn't ever shown in a page, the manipulator would effectively have to know the contents of the template which was rendered for the previous request, and there's simply no way for it to know that -- not only are manipulators decoupled from the template system, HTTP itself is stateless, so solving this completely would invlve the (IMHO) too-extreme step of trying to store information about the previous request in the session.

It may end up being that the only solution we can offer is a clear warning to make sure you have the admin display all of your required fields, and add an item to the "common pitfalls" section of the wiki about this if it's not there already.

comment:2 Changed 10 years ago by mir@…

Hmm, I'd consider this an error in the model. manage.py validate could throw an error when there are required fields that are not in the Admin.fields list..

comment:3 Changed 10 years ago by James Bennett

That would solve it for the admin, but not for pages generated from a manipulator, which may include all the required fields in the manipulator, or might not show all those fields in the template; in that case, there would once again be an error with no apparent error message.

comment:4 Changed 10 years ago by Adrian Holovaty

Resolution: duplicate
Status: newclosed

Duplicate of #289.

comment:5 Changed 10 years ago by Tyson Tate <tyson@…>

Resolution: duplicate
Status: closedreopened

#289 was closed because Adrian didn't like the patch (I think - he didn't really leave an explanation on the "wontfix" change). I don't think this should be closed if it hasn't been fixed. Please let me know if I'm in the wrong here, but I really feel telling people there's an error without telling them where is like saying "There's a fire someplace on Earth, go put it out!"

comment:6 Changed 10 years ago by Adrian Holovaty

Resolution: duplicate
Status: reopenedclosed

Duplicate of #289.

comment:7 Changed 5 years ago by anonymous

Easy pickings: unset
UI/UX: unset

comment:8 Changed 4 years ago by anonymous

Resolution: duplicate
Status: closedreopened

comment:9 Changed 4 years ago by anonymous

Resolution: fixed
Status: reopenedclosed

comment:10 Changed 4 years ago by anonymous

Resolution: fixed
Status: closedreopened

comment:11 Changed 4 years ago by anonymous

Owner: changed from Adrian Holovaty to anonymous
Status: reopenednew

comment:12 Changed 4 years ago by anonymous

Status: newassigned

comment:13 Changed 4 years ago by Claude Paroz

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top