On Fri, Apr 17, 2009 at 1:58 AM, Horacio de Oro <[email protected]> wrote:
>
> Hi! I've a problem with Django not validating my 'CharField's. Maybe
> I'm misunderstanding the docs, and Django doesn't do this kind of
> validations?
>
> I've made a simple example. This is the model:
>
> class SimpleModelC(models.Model):
>    name=models.CharField(max_length=256)
>    image_content_type=models.CharField(max_length=32, null=False,
> blank=False)
>
> and a simple view that get a parameter from request.GET:
>
> def view_c3(request):
>    model_c=SimpleModelC()
>    model_c.name=request.GET['name']
>    model_c.save()
>    return HttpResponseRedirect("/ok/from/c3/")
>
> Doing a request to: http://localhost:8000/view_c3/?name=Peter
> I get a redirect to '/ok/from/c3/', and in the database:
>
> SELECT * from myprojects_simplemodelc;
>  id | name  | image_content_type
> ----+-------+--------------------
>  7 | Peter |
> (1 row)
>
> Since 'SimpleModelC.image_content_type' is required to be not-null and
> not-empty, shouldn't Django check for this before doing the INSERT?
> In the database, in 'image_content_type'I get a blank string.
>
> This is happening me with Django 1.0.2 and the development version of
> Django 1.1.
>

A few questions:

What database backend are you using?.

Can you see what's the actual DLL definition of the image_content_type
field? (i.e. does it contain 'NULL' or 'NON NULL').

Has the table been generated by Django itself from the model or is
it a legacy database that you've generated the models from by
introspecting it?.

-- 
Ramiro Morales
http://rmorales.net

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to