|
If you set null=True and default=0 on the same field, is the null=True setting ignored? I had written some of my optional fields with "blank=True, null=True, default=0", so I was going back through them and changing them.
|
# ¿ Dec 30, 2016 11:50 |
|
|
# ¿ May 15, 2024 13:55 |
|
I'll be using Django for web scraping to collect data for a business-to-business data service, mainly for business locations. Someone might be using or viewing parts of the PostgreSQL database directly. I want to make it easier to see which columns go with which table during joins or complex queries by using a custom naming convention. The default table name is appname_modelname, and Django doesn't convert the CamelCase model name convention into snake_case. Using the db_table option, the default appname_modelname for the table becomes model_name. Using the db_column option, the default field_name for the column becomes table_name_column_name. The id column becomes table_name_id. The purpose behind this convention is that during a join or complex query, or when different models have the same field names (e.g. first_name), it will make it easier to see which column goes with which table. Particularly, the foreign key will stand out. If there were a product table (using a hypothetical unrelated to the project), its column headers would be product_id, product_description, vendor_id, product_purchase_date, product_price. Is this going to cause difficulty down the line? Removing the appname_ prefix might lead to a higher chance of naming conflicts, but leaving it would make writing SQL queries take slightly longer. Looking at my PostgreSQL textbook, which uses app_name.table_name, it doesn't look like they'll be that much longer and there are always aliases Edit: Also, for naming indexes, I'll use {tablename}_{columnname(s)}_idx. This is PostgreSQL's system for default index naming, and it's used automatically behind-the-scenes when PostgreSQL creates constraints. Django shortens index names to 30 characters for compatibility with Oracle, but I'd like the names to be easier to read and more predictable, so if I accidentally break something and have to go into the DBMS, the SQL environment will feel familiar galenanorth fucked around with this message at 21:45 on Mar 12, 2023 |
# ¿ Mar 2, 2023 20:56 |
|
A few years back, I tried making a website called for adopting cats or reporting lost/found cats, called Meowseum. Unfortunately, I got sidetracked on allowing videos of cats to be uploaded, which it turns out is very complicated, and I also got sidetracked on validating and processing (e.g. automatically scaling) images, which is also very complicated. As such, the project has such a long and complicated dependency tree that it may have collapsed under its own weight. My hard drive failed, but I backed up the data. When I got a new hard drive and upgraded from Python 3.5 to Python 3.11, the project stopped working. A lot of my packages are in the directory site-packages_editable because I'd used the following command to make the packages support version control with Git. code:
I tried simply copying over site-packages and site-packages_editable, which made "import django" work in the Python shell, but I get the that led to the error code:
code:
code:
Maybe I should give up and start over. If I start fresh, I could upgrade to Django 5.0 and use React for the front-end instead of using only Django templates. I'd try much harder to avoid editing packages without having the Git repository incorporate my changes in the future. Maybe I'd run into the same problem again, so I should face this head-on by installing every package one by one and then manually copying over my old edits. I used the command code:
which I assume refers to my ExceptionRecord model for saving exception data to the database itself for debugging. I tried to migrate, and Django won't even let me migrate. I got "django.db.utils.OperationalError: near "[]": syntax error" when I ran that. I'm thinking I should just give up, and if I work on Django again, just start all over with some other idea Edit: I found out from an online chat that the django.db.utils.OperationalError exception was caused by trying to switch back to SQLite after developing with Postgres, and the page has information on switching back galenanorth fucked around with this message at 04:30 on May 13, 2024 |
# ¿ May 12, 2024 00:32 |