Opened 10 years ago

Closed 10 years ago

#21531 closed Bug (invalid)

Django 1.6 forms.SlugField validation error

Reported by: 20tab Owned by: nobody
Component: Forms Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

I have a problem with SlugField.

In my model I have this field: slug = models.SlugField(_(u'Slug'), blank=True, null=True)

Adding an item through admin, django catches this error:

Django Version: 1.6
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'strip'
Exception Location: myvirtualenv/lib/python2.7/site-packages/django/forms/fields.py in clean, line 1142

Is this a bug or my fault?

I tried the same code with django 1.5.5 and it works.

Thanks

Change History (7)

comment:1 by Florian Apolloner, 10 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by Florian Apolloner, 10 years ago

Resolution: needsinfo
Severity: Release blockerNormal
Status: newclosed

I just tested against, 1.6, stable/1.6.x and master; can't reproduce it -- can you provide more information?

comment:3 by 20tab, 10 years ago

The problem is that I use django-modeltranslation and SlugField doesn't work with all languages.

This is my code:

1) models.py

from django.db import models

class News(models.Model):

title = models.CharField(max_length=250)
slug = models.SlugField(blank=True, null=True)

def unicode(self):

return self.title

2) admin.py

from django.contrib import admin

class NewsAdmin(admin.ModelAdmin):

list_display = ('title',)
prepopulated_fields = {'slug': ('title',)}

admin.site.register(News, NewsAdmin)

3) translation.py

from modeltranslation.translator import translator, TranslationOptions
from test.models import News

class NewsTranslationOptions(TranslationOptions):

fields = ('title', 'slug')

translator.register(News, NewsTranslationOptions)

Maybe I have to inform django-modeltranslation's developers and I'll do it. But maybe a simple if statement can resolve this problem.

Anyway, thank you so much.

comment:4 by 20tab, 10 years ago

Resolution: needsinfo
Status: closednew

comment:5 by anonymous, 10 years ago

It's modeltranslation related.

comment:6 by Tim Graham, 10 years ago

Then the ticket should be closed, correct?

comment:7 by Tim Graham, 10 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top