How to sync admin interface with DB

113 views
Skip to first unread message

Timothy Wu

unread,
May 5, 2008, 11:42:22 AM5/5/08
to django...@googlegroups.com
Hi,

I am having a big trouble. For some reason I've messed things up and admin interface is showing a table that I already dropped by accessing mysql client directly (oh no...should I not do that?).

I don't know exactly how I got to that state. I first created the table, then I decided to change some field name as well as adding new ones. Then I couldn't populate the table with a script I was using, because that syncdb command does't quite sync when you're changing the field names. So I ended up dropping the table using the mysql client and re-created it by syncing it again. I was able to populate the table, but the admin interface was having problem, it was still expecting the old table columns. =/

Actually, it's worse than this. I don't know how I does it but all the sudden the admin interface was not able to log-on with the original username. (Now the username for mysql client and the username for the admin interface is not the same..wans't it the same before?!) I must either be very confused or mess it up somehow, or both. Is there a way to bring everything back to a clean slate? I am just starting out my models.py so I can afford to start the Django app all-over. (I do not want to restart the project, however, since I'm on a shared host and that was already generated on sigh-up through its interface, which I am not familiar with yet)

Timothy


jonknee

unread,
May 5, 2008, 3:33:45 PM5/5/08
to Django users
> I was able to populate the table, but the admin interface was having
> problem, it was still expecting the old table columns. =/

Sounds like you need to update your Django models.

Timothy Wu

unread,
May 5, 2008, 9:56:46 PM5/5/08
to django...@googlegroups.com

I ran manage.py reset appname.  All the problems I describe still remain. The admin interface is still having problems.

Martin Diers

unread,
May 5, 2008, 11:37:27 PM5/5/08
to django...@googlegroups.com

On May 5, 2008, at 8:56 PM, Timothy Wu wrote:
> Sounds like you need to update your Django models.
>
> I ran manage.py reset appname. All the problems I describe still
> remain. The admin interface is still having problems.
>

No, resetting the app will not help if your models.py file still
contains models for the tables you no longer need.

In fact, resetting the app would have re-created the tables you no
longer want, because they were still contained in your model. You will
need to delete them from the model, end then drop the tables from our
database yet again, or run reset once more.

--
Martin Diers

Timothy Wu

unread,
May 6, 2008, 12:56:21 AM5/6/08
to django...@googlegroups.com
I'm sorry, could someone gives me a clarification?

Maybe I should describe it more clearly. My models.py and my database ARE in sync and they're with the tables and the fields I want. It's the admin interface that's out of sync, it's showing a table not existing in the database and mode, and when I tried to edit that table in the admin interface it will say:

Something's wrong with your database installation. Make sure the appropriate database tables have been created, and make sure the database is readable by the appropriate user.

What I am hoping to do is just to start the admin interface all over from scratch (in a clean slate) as if I've never used it, including creating the user account.

Does django offer a facility to doing that?

Martin Diers

unread,
May 6, 2008, 1:25:07 AM5/6/08
to django...@googlegroups.com

On May 5, 2008, at 11:56 PM, Timothy Wu wrote:

>
> I'm sorry, could someone gives me a clarification?
>
> Maybe I should describe it more clearly. My models.py and my
> database ARE in sync and they're with the tables and the fields I
> want. It's the admin interface that's out of sync, it's showing a
> table not existing in the database and mode, and when I tried to
> edit that table in the admin interface it will say:
>
> Something's wrong with your database installation. Make sure the
> appropriate database tables have been created, and make sure the
> database is readable by the appropriate user.
>
> What I am hoping to do is just to start the admin interface all over
> from scratch (in a clean slate) as if I've never used it, including
> creating the user account.
>
> Does django offer a facility to doing that?
>

The Admin is created on the fly. There is nothing for it to restart
from scratch. Are you running the Django development server (the one
that defaults to localhost:8000) or are you running this under another
web server, like Apache? If you are using Apache + mod_python then you
must restart Apache after changing any code.

Timothy Wu

unread,
May 6, 2008, 1:42:45 AM5/6/08
to django...@googlegroups.com
On Tue, May 6, 2008 at 1:25 PM, Martin Diers <mar...@diers.us> wrote:
The Admin is created on the fly. There is nothing for it to restart
from scratch. Are you running the Django development server (the one
that defaults to localhost:8000) or are you running this under another
web server, like Apache? If you are using Apache + mod_python then you
must restart Apache after changing any code.

Oh! Thanks. I am using mod_python. That fix the problem. =)
Reply all
Reply to author
Forward
0 new messages