#help

64 messages · Page 1 of 1 (latest)

cyan forge
#

help, when I write the dumpdata command, my Russian text is saved very strangely - 'фш эрїєщ'

lavish marshBOT
#

Hi. You'll find people are more willing to help if you provide some details about your problem. A good starting point is answering what are you trying to do, what you expect to happen and what actually happened. If your answers are something like "Login to the site. To be logged in. It doesn't work", you're not providing enough detail. If you have an error, include the full error message and the traceback. For a more thorough discussion on how to ask good technical questions see:

https://www.freecodecamp.org/news/how-to-ask-good-technical-questions/ 
cyan forge
#

I'm writing the 'python' command manage.py dumpdata product.base > db.json'

the database has a description that stores Russian sentences, and already in json they are strangely encoded in 'фш эрїєщ'

stable ingot
#

try python -Xutf8 manage.py dumpdata product.base > db.json

tall heath
#

Also are you sure you just not looking at the result with wrong encoding?

cyan forge
cyan forge
stable ingot
#

first check if the dump seems okay

cyan forge
stable ingot
#

open the json file?

cyan forge
#
[{"model": "appueu.basedatel", "pk": 1, "fields": {"name": "pizdec", "description": "╨┐╨╕╨┤╨╛╤А", "value": 2, "type": 1}}]

stable ingot
cyan forge
#

yes

stable ingot
#

but in database it looks as its supposed to be?

cyan forge
#

yes

stable ingot
#

hmm then I'm not sure, probably an encoding/decoding issue but not sure how to resolve

cyan forge
#

sadly

tall heath
#

What DB are you using?

#

Also, maybe consider not using dump? fixtures can be problematic anyway.

cyan forge
#

I need dump to restore the database if I want to add a new column to it. Are there any other ways to create a new column in the database?

sqlite3

tall heath
#

Why? No you don't need to

#

You just add it

cyan forge
#

How?

tall heath
#

makemigrations and migrate

#

done

cyan forge
#

Wait a minute, there will be a mistake

#

Traceback (most recent call last):

Exception Type: OperationalError at /admin/appueu/basedatel/1/change/
Exception Value: no such column: appueu_basedatel.coin

tall heath
#

please show the whole log and commands you run

cyan forge
#

PS C:\Users\dimat\Desktop\My Project\Django\testproject> python manage.py makemigrations
Migrations for 'appueu':
appueu\migrations\0001_initial.py
- Create model cotegory
- Create model baton
- Create model basedatel
PS C:\Users\dimat\Desktop\My Project\Django\testproject> python manage.py migrate
Operations to perform:
Apply all migrations: admin, appueu, auth, contenttypes, sessions, users
Running migrations:
No migrations to apply.

this?

tall heath
#

interesting, could you also run showmigrations command as show output. It's strange it says no migrations to apply

cyan forge
#

admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
appueu
[X] 0001_initial
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
sessions
[X] 0001_initial
users
[X] 0001_initial

tall heath
#

Ok so you have inconisistent state

#

Did you remove migration files at some moment?

cyan forge
#

No

tall heath
#

Your command from above says it creates appueu\migrations\0001_initial.py

#

But showmigrations marked 0001_initial applied

#

That's won't happen normally

#

Data you need to save is withing this app?

cyan forge
#

yes

tall heath
#

Can you for now return your models for that app to state that perfectly matches your database?

#

migrations - database going out of sync is a major problem

cyan forge
#

do I make a database before adding a new column?

tall heath
#

comment all changes in models that don't match current state of DB

tall heath
cyan forge
#

okay, so how do I add a new column to the database?

tall heath
#

You need first to return your migration files to be in sync with DB

#

otherwise problems will only get worse

cyan forge
#

I've already done it.

tall heath
#

So you have your appueu\migrations\0001_initial.py match exactly your tables?

cyan forge
#

yes

tall heath
#

and showmigrations lists it's as applied?

cyan forge
#

admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
sessions
[X] 0001_initial
users
[X] 0001_initial

tall heath
#

I don't see that app here

#

You've must have done something else

cyan forge
#

I created the modules, registered the migration command and created a database, it works.

tall heath
#

I'm not following...

#

Again deleting any files in migrations/ is very dangerous

#

but any model change is just

  1. changing models.py
  2. makemigrations
  3. migrate
#

If this gives error, you have a problem that must be solved first, not worked around

cyan forge
#

I have a database. There is data in it. In case I need to add a new column, I do not know how to do it. All I know is that you can delete and recreate the database and all the data will be deleted

stable ingot
tall heath
#

Every change to DB can (and must, usually) be done with migrations