Sunday, May 22, 2011

Re: how to solve this issue: "DatabaseError at /admin/myapp, no such column: myapp.myvar"

No, I don't think so, first I edit my Model like this:

in model.py:
Class UeSetting(model.Model):
title =
models.CharField('title',max_length=11,unique=True)
changetime =
models.DateTimeField('changetime',auto_now_add=True)

def __unicode__(self):
return self.title

class BtsSetting(models.Model):
title =
models.CharField('title',max_length=11,unique=True)
changetime =
models.DateTimeField('changetime',auto_now_add=True)

def __unicode__(self):
return self.title

class CheSetting(models.Model):
title =
models.CharField('title',max_length=11,unique=True)
changetime =
models.DateTimeField('changetime',auto_now_add=True)

def __unicode__(self):
return self.title

In the same time edit admin.py:

class
UeSettingAdmin(admin.ModelAdmin):
list_display = ['title',
'changetime']
ordering =
['changetime']
search_fields = ('title',
'changetime')
class
BtsSettingAdmin(admin.ModelAdmin):
list_display = ['title',
'changetime']
ordering =
['changetime']
search_fields = ('title', 'changetime')
class
CheSettingAdmin(admin.ModelAdmin):
list_display = ['title',
'changetime']
ordering =
['changetime']
search_fields = ('title', 'changetime')


admin.site.register(models.UeSetting,
UeSettingAdmin)
admin.site.register(models.BtsSetting,
BtsSettingAdmin)
admin.site.register(models.CheSetting, CheSettingAdmin)

then I use command lik this:
#python mange.py syncdb
#python mange.py runserver


at last, when I click the BtsSetting CheSetting in web browser are ok
to show, but only when I click UeSetting, the browser will show this
error:

DatabaseError at /adminaddress/uesetting
no such column: address_uesetting.changetime

I have tried to run "mange.py syncdb" many time, but nothing change.

FYI, my setting in batabase is :
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': './data.db', # Or path to database
file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for
default. Not used with sqlite3.
}
}

On 5月21日, 下午10时18分, brad <bkmontgom...@gmail.com> wrote:
> It sounds like you may have created your Models, run "mange.py syncdb", then
> added another field to your Model.
>
> Remember, syncdb doesn't add new columns in your table when you add a new
> field to an existing model.  If this app is still in development, you can
> drop the whole table corresponding to that model and run syncdb again.
>
> You should also consider looking at south (http://south.aeracode.org/). It
> provides migration tools that let you add columns to existing models via a
> managment command.
>
> - Brad

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

No comments:

Post a Comment