|
I'm working on designing a new model for storing the results from BadELF. Currently it is very similar to the PopulationAnalysis model, but it doesn't inherit from StaticEnergy because I'm expecting most users interested in the code will want to run their DFT calculations using their own settings (eventually I'll add back a workflow that runs the DFT/BadELF and saves to the StaticEnergy and BadELF tables). I've also altered my BadELF workflow to directly return the desired data rather than writing an ACF.dat file like the PopulationAnalysis model currently uses. The new BadElfAnalysis model that I've made is relatively simple, basically just inheriting from the Structure and Calculation models and adding a few columns. Still, I'm running into an error when I run I'll also note that this error doesn't occur if I delete the contents of the simmate/website/migrations folder, but the generated database doesn't seem to work properly. I got an error when trying to convert a django query to a database and also when trying to view the database with a DB browser. @jacksund any ideas? │ /home/sweav/anaconda3/envs/simmate_dev/lib/python3.11/site-packages/django/db/backends/utils.py: │
│ 87 in _execute │
│ │
│ 84 │ │ with self.db.wrap_database_errors: │
│ 85 │ │ │ if params is None: │
│ 86 │ │ │ │ # params default might be backend specific. │
│ ❱ 87 │ │ │ │ return self.cursor.execute(sql) │
│ 88 │ │ │ else: │
│ 89 │ │ │ │ return self.cursor.execute(sql, params) │
│ 90 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ ignored_wrapper_args = ( │ │
│ │ │ False, │ │
│ │ │ { │ │
│ │ │ │ 'connection': <DatabaseWrapper vendor='sqlite' │ │
│ │ alias='default'>, │ │
│ │ │ │ 'cursor': <django.db.backends.utils.CursorWrapper object at │ │
│ │ 0x7fde9c41d9d0> │ │
│ │ │ } │ │
│ │ ) │ │
│ │ params = None │ │
│ │ self = <django.db.backends.utils.CursorWrapper object at 0x7fde9c41d9d0> │ │
│ │ sql = 'CREATE TABLE "warrenapp_badelfanalysis" ("id" integer NOT NULL │ │
│ │ PRIMARY KEY AUTOI'+1571 │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sweav/anaconda3/envs/simmate_dev/lib/python3.11/site-packages/django/db/backends/sqlite3/b │
│ ase.py:355 in execute │
│ │
│ 352 │ │
│ 353 │ def execute(self, query, params=None): │
│ 354 │ │ if params is None: │
│ ❱ 355 │ │ │ return Database.Cursor.execute(self, query) │
│ 356 │ │ query = self.convert_query(query) │
│ 357 │ │ return Database.Cursor.execute(self, query, params) │
│ 358 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ params = None │ │
│ │ query = 'CREATE TABLE "warrenapp_badelfanalysis" ("id" integer NOT NULL PRIMARY KEY │ │
│ │ AUTOI'+1571 │ │
│ │ self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7fde9c637f50> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OperationalError: near "None": syntax error |
Replies: 1 comment 1 reply
|
you going to be frustrated with this one 🤣 🤣 The error is because of this line: algorithm = table_column.CharField(blank=True, null=True)Django requires that you set a To fix it, just add a # OPTION 1
algorithm = table_column.CharField(blank=True, null=True, max_length=100)
# OPTION 2
algorithm = table_column.TextField(blank=True, null=True)[[ EDIT: as @SWeav02 mentioned, make sure you clear your old migrations too ]] Django could be better with the error message here, but I'm guessing it is vague because the error isn't database specific |
you going to be frustrated with this one 🤣 🤣
The error is because of this line:
Django requires that you set a
max_lengthforCharFields -- and an error is only raised for some databases (see their docs on it). Postgres is the one database wheremax_lengthis optional.To fix it, just add a
max_lengthOR you can just switch toTextFieldwhere there is no limit:[[ EDIT: as @SWeav02 mentioned, make sure you clear your old migrations too ]]
Django could be better with the error mes…