Categories
Mastering Development

Django sqlite3 OperationalError near “WHERE”: syntax error

I am trying to query an sqlite database with custom sql in django and when I run the query I get OperationalError at /production/Libre-Badge-Demo-Template/ near “WHERE”: syntax error I have heard talk of django’s sqlite engine being unable to insert multiple parameters but I’m not sure what to make of that. here is the query […]

Categories
Mastering Development

How do I configure my model such that my generated Django migration doesn’t result in an error?

I’m using Django and Python 3.7. When I run my command to generate a migration … (venv) localhost:web davea$ python manage.py makemigrations maps Migrations for ‘maps’: maps/migrations/0003_auto_20200416_1017.py – Alter field name on cooptype – Alter unique_together for cooptype (0 constraint(s)) The generated migration looks like … # Generated by Django 2.0 on 2020-04-16 15:17 from […]

Categories
Mastering Development

ProgrammingError at /admin/auth/user/1/change/

*Cant add user to group *Cant add permission to a group or user I already used pgAdmin and django shell but same throwing this error ProgrammingError at /admin/auth/user/1/change/ The whole traceback: Traceback Switch to copy-and-paste view C:\Users\User\Envs\work\lib\site-packages\django\db\backends\utils.py in _execute return self.cursor.execute(sql, params) … Local vars The above exception (syntax error at or near “ON” LINE […]

Categories
User Help

OperationalError at /admin/products/product/add/ no such table: main.auth_user__old DJANGO [closed]

main.auth_user__old in django tutorial going through mosh created a web server.When saving some polls or products or set i get this error instead of going to be saved on the site. Heres the error OperationalError at /admin/products/product/add/ no such table: main.auth_user__old Request Method: POST Request URL: http://127.0.0.1:8000/admin/products/product/add/ Django Version: 2.1 Exception Type: OperationalError Exception Value: […]

Categories
Development

Unclear errors when trying to save data while overriding default ‘create’ method

Tried to write custom create method for my model, but run into some unclear errors. Here is my code: # models.py: class ItemModel(models.Model): item_id = models.CharField(max_length=10, primary_key=True) name = models.CharField(max_length=40) active = models.BooleanField(default=True) def __str__(self): return self.item_id class ItemVersion(models.Model): item_ver_id = models.CharField(max_length=13, primary_key=True) item_ver = models.TextField() config = models.TextField() model = models.ForeignKey(ItemModel, on_delete=models.CASCADE, default=0) session_id […]

Categories
Development

How to fix UnicodeDecodeError in Django REST Framework?

I want to show ProductImageSerializer in the browsable API. But I got this error: UnicodeDecodeError at /api/product_images/ ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte Unicode error hint The string that could not be encoded/decoded was: ����� Here’s my models.py: class ProductImage(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) image = models.ImageField(upload_to=’product_images’, width_field=None, height_field=None, […]

Categories
Database Development Django

Why django trying to create migration table when my purpose is just to read existing oracle database

My purpose is to connect to oracle database and run query in order to populate those results on a web page. But when I try to run python manage.py migrate I am getting below error. Even when I use option –fake-initial or –fake same error. I dont want to create any table. I just made […]

Categories
Development Django

How can I serialize list with an object relation produced from queryset TruncYear in Django 1.11

I manage to get time series data with TruncYear/TruncMonth/TruncDay/etc like below from Tracking table. However the data for the venue just produce the venue_id. I would like to have that serialized so that it returns the “name” from the relation Venue table. I am using Django 1.11 a postgres 9.4 Here is my time series […]

Categories
Development Django

How can I serialize list with an object relation produced from queryset TruncYear in Django 1.11

I manage to get time series data with TruncYear/TruncMonth/TruncDay/etc like below from Tracking table. However the data for the venue just produce the venue_id. I would like to have that serialized so that it returns the “name” from the relation Venue table. I am using Django 1.11 a postgres 9.4 Here is my time series […]

Categories
Database Development

Django Test “database table is locked”

In my Django project, I have a view that when a user posts a zip file, it will respond immediately back and then process the data in the background with the help of threading. The view works fine in normal test, but when I run the Django’s test it fails with a database table is […]