Code

Opened 6 years ago

Closed 6 years ago

#7451 closed (worksforme)

edit_inline with CharField truncates result and cause error: string index out of range

Reported by: rudyryk <alexey.rudy@…> Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: alexey.rudy@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'm using revision 7631, latest for now.

When using edit_inline, only first symbol from CharField is saved! This error occurs when creating new object.

And when editing existing object, error 'string index out of range' occurs.

Models are taken from tutorial. See traceback and code below.

Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views\decorators.py" in _checklogin
  62.             return view_func(request, *args, **kwargs)
File "C:\Python25\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views\main.py" in change_stage
  338.             new_object = manipulator.save(new_data)
File "C:\Python25\Lib\site-packages\django\db\models\manipulators.py" in save
  166.                         if rel_new_data[related.opts.pk.name][0]:

Exception Type: IndexError at /admin/my_hello/poll/1/
Exception Value: string index out of range
from django.db import models
import datetime

# Create your models here.

class Poll(models.Model):
        question = models.CharField(max_length=200)
        pub_date = models.DateTimeField('date published')
        class Admin:
                pass
        def __unicode__(self):
                return self.question

class Choice(models.Model):
        poll = models.ForeignKey(Poll, edit_inline=models.TABULAR, num_in_admin=3)
        choice = models.CharField(max_length=200, core=True)
        class Admin:
                pass    
        def __unicode__(self):
                return self.choice

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by rudyryk <alexey.rudy@…>

  • Cc alexey.rudy@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by ramiro

  • Resolution set to worksforme
  • Status changed from new to closed

I can't reproduce this, also using r7631 with the sqlite3 backend and using exactly the same models.py file. Please post this report to the dango-users list or the #django IRC channel with additional details.

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.