Code

Opened 8 years ago

Closed 22 months 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',)}),
		)

Attachments (0)

Change History (13)

comment:1 Changed 8 years ago by ubernostrum

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 8 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 8 years ago by ubernostrum

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 8 years ago by adrian

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

Duplicate of #289.

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

  • Resolution duplicate deleted
  • Status changed from closed to reopened

#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 8 years ago by adrian

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

Duplicate of #289.

comment:7 Changed 3 years ago by anonymous

  • Easy pickings unset
  • UI/UX unset

comment:8 Changed 22 months ago by anonymous

  • Resolution duplicate deleted
  • Status changed from closed to reopened

comment:9 Changed 22 months ago by anonymous

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

comment:10 Changed 22 months ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:11 Changed 22 months ago by anonymous

  • Owner changed from adrian to anonymous
  • Status changed from reopened to new

comment:12 Changed 22 months ago by anonymous

  • Status changed from new to assigned

comment:13 Changed 22 months ago by claudep

  • Resolution set to fixed
  • Status changed from assigned to closed

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.