Opened 13 years ago

Closed 13 years ago

Last modified 13 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.

Change History (3)

comment:1 by Karen Tracey, 13 years ago

Resolution: needsinfo
Status: newclosed

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, nor 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).

Last edited 13 years ago by Karen Tracey (previous) (diff)

comment:2 by anonymous, 13 years ago

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 by anonymous, 13 years ago

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.

Note: See TracTickets for help on using tickets.
Back to Top