Code

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#18146 closed Bug (needsinfo)

Exception during form validation

Reported by: richard.o.dodd@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal Keywords: model, manage, validation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

An exception with unhelpful message occurs when the following model is validated

from django.db import models

class a(models.Model):
    pass

class b(models.Model):
    c_a = models.ManyToManyField(a)

Maybe it would be more neat to return an error in the validation.
Haven't checked in newer versions, could someone try to replicate it.

Attachments (0)

Change History (3)

comment:1 Changed 2 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

I don't know what is meant by "the following model is validated". I don't know which of the two following models is meant, not what, specifically, is meant by "validated". Models are validated when various management commands are run, and they must pass in order for the database tables to be created by syncdb; these models both pass that validation. Possibly something about creating model instances is meant. But lacking details on what exactly is wrong with the creation attempt and what exactly the confusing exception that result is, I have no clue what might be done to improve the situation. The models work as I would expect in a Python shell (I uppercased the model names):

Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from ttt.models import A, B
>>> aaa = A()
>>> aaa.save()
>>> bbb = B()
>>> bbb.save()
>>> bbb.c_a.add(aaa)
>>> bbb.c_a.all()
[<A: A object>]
>>> aaa.b_set.all()
[<B: B object>]
>>> b2 = B.objects.create()
>>> aaa.b_set.add(b2)
>>> aaa.b_set.all()
[<B: B object>, <B: B object>]
>>> bbb.c_a.all()
[<A: A object>]
>>>

In order to evaluate if we could improve whatever happens in whatever error situation was encountered, we need specific details on how the error was encountered and what exactly it was (ideally post the traceback of the exception).

Version 0, edited 2 years ago by kmtracey (next)

comment:2 Changed 2 years ago by anonymous

Hi, the problem came when creating an app, setting the models as above and running python manage.py validate
Maybe it has been fixed I am using 1.3.

comment:3 Changed 2 years ago by anonymous

Edit: re-ran the manage.py validate and it validated no probs, must have been something else in my code, or a database table name clash or something. Please leave 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.