Code

Opened 3 years ago

Closed 3 years ago

#16060 closed Bug (invalid)

Model entry does not get verified and no error raised

Reported by: m.vovcu@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
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:

Description

Model:

class DestMail(models.Model):

user = models.ForeignKey(User)

mail = models.EmailField()

class Meta:

unique_together = (("user", "mail"),)

def unicode(self):

return self.mail

First of all, even on the command line you can enter anything in the mail-field. No verification.

While used this code:

## user defined, mail defined

m, created = DestMail.objects.get_or_create(user=user,mail=mail)

Object got created even if it existed. Neither "unique_together" does help.

I have to check anytime something is entered if it's not blank, because even blank entries got entered. Although there is no "blank=True" directive.

Didn't seem to have that problem with previous Django release. That's all I noticed so far.

marius

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by mattmcc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed
  • Type changed from Uncategorized to Bug

Model validation does not happen automatically when you're manipulating a model object directly. See http://docs.djangoproject.com/en/1.3/ref/models/instances/#validating-objects

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.