lundi 29 septembre 2014

Django error_messages not working in my model but works in my view?


Vote count:

0




So i'm simply trying to pass out my own custom error which works in my view here below:



from django.shortcuts import render
from django.http import HttpResponse
from TasksManager.models i`enter code here`mport Supervisor, Developer
from django import forms

class someView(forms.Form):
error_name = {'required':'You must type a name !','invalid':'Wrong format.'}
name = forms.CharField(label="Name", max_length=30, error_messages=error_name)


but when i try to do it in a model it just ignores the custom error_message i'm passing through to it and uses djangos built in error_message code below:



from django.db import models`enter code here`

class someModel(models.Model):
error_name = {'required':'You must type a name !','invalid':'Wrong format.'}
name = models.CharField(max_length=50, verbose_name="Name", error_messages=error_name)


What could i do to make this work in my model(how do i make my 2nd block of code work)?



asked 41 secs ago







Django error_messages not working in my model but works in my view?

Aucun commentaire:

Enregistrer un commentaire