I use django 0.96. I have a simple model and I just want to add one
field to my existing model. How can I do that? I think that I can't do
that without SQL code. But unfortunely I don't know it.
Anyone could give me a example of SQL code for adding one field to one
model?
If I only have the solution to upgrade to django-cvs, how can I pass
all my data from django 0.96 models to svn django models?
Thanks in advance,
Xan.
python manage.py --settings=my_settings sql my_app
Then, run the appropriate query once you know the datatype created
when you added the column.
For example, in postgres:
ALTER TABLE myapp_mymodel ADD COLUMN mycol INT NOT NULL;
Meanwhile, I think I will try patch to 0.96 found in
http://code.djangoproject.com/wiki/SchemaEvolutionDocumentation
Thanks another time,
Xan.
> python manage.py dumpdata polls > polls.json
> python manage.py sqlclear polls > polls_drop.sql
> mysql -u root -p pypoll < polls_drop.sql
enter your password for the root user (change for your specific
username)
edit mysite/polls/models.py and add the field to the Poll model
> python manage.py syncdb
> python manage.py loaddata polls.json
Hope this helps.
On Sep 25, 2:41 pm, Xan <xancor...@gmail.com> wrote:
On Sep 26, 11:33 pm, DJango Fett <tommy.adk...@gmail.com> wrote:
> Here are the steps I would use to add a field to an existing model
> without having to write your own SQL and without the risk of getting
> your model code out of sync with your database table. This code uses
> the same objects in the Tutorial onhttp://www.djangoproject.com/documentation/0.96/tutorial01/.
> Open up a Command Prompt window and change the drive/directory to your
> project. Then do something similar to the following:
>
> > python manage.py dumpdata polls > polls.json
> > python manage.py sqlclear polls > polls_drop.sql
> > mysql -u root -p pypoll < polls_drop.sql
>
> enter your password for the root user (change for your specific
> username)
>
> edit mysite/polls/models.py and add the field to the Poll model
>
> > python manage.py syncdb
> > python manage.py loaddata polls.json
>
> Hope this helps.
Okay, but I have 0.96 version (I have no loaddata option)
But, thanks very much,
Xan.
Thank you very much for your support,
Xan.
On Sep 28, 2:48 pm, DJango Fett <tommy.adk...@gmail.com> wrote:
> I am using 0.96 version too. I tested the steps I provided before I
> posted. Check out the 0.96 documentation yourself about the loaddata
> option:http://www.djangoproject.com/documentation/0.96/django-admin/#loaddat...
It worked but I HAVE A PROBLEM:
After done it, the database have strange caracters: it displays
"Convocatòria" instead of "Convocatòria"
I presume that it's an encoding problem. How can I solve that?
Please, anwer me
Xan.
On Sep 26, 11:33 pm, DJango Fett <tommy.adk...@gmail.com> wrote:
> Here are the steps I would use to add a field to an existing model
> without having to write your own SQL and without the risk of getting
> your model code out of sync with your database table. This code uses
> the same objects in the Tutorial onhttp://www.djangoproject.com/documentation/0.96/tutorial01/.