Questions tagged [django-database]

django-database refers to database backends that Django supports out of the box

refers to database backends that Django supports out of the box.

This tutorial help you to make application using mongodb database. enter link description here

664 questions
2
votes
1 answer

why this happening

views.py getting something else in output instead of values present in it I am trying but not gating answers please provide me some suggestions I think so error occurs in :(instance=Task) from django.shortcuts import render from django.http import…
2
votes
2 answers

Django dump : models don't validate

When I try to dump the data of my model in Django with this instruction : python manage.py dumpdata app> temp_data.json It gives the following error : Error: One or more models did not validate: asset.authpermission: "codename": CharField cannot…
Johanna
  • 1,343
  • 4
  • 25
  • 44
2
votes
0 answers

How to configure two databases with different tables in same Django app?

settings.py DATABASE_ROUTERS = ["mysite.router.CheckerRouter"] DATABASES = { "default": { "ENGINE": "sql_server.pyodbc", "NAME": "A", "USER": "user", "PASSWORD": "dummypassword", "HOST":…
2
votes
1 answer

how to copy data of a DB from one django app to another app

I have Django app, one is in local machine and other is in production server after deploying in production server i see i lost all my local data lost so I want to know how I can copy all my data from db and paste into production server so is there…
Shreyash mishra
  • 738
  • 1
  • 7
  • 30
2
votes
0 answers

loading dump.json file to a new postgres database from django

I'm switching from the default sqlite3 database to the PostgreSQL database but I'm getting an DETAIL: Key (slug)=(superadmin) already exists. error the steps i did: py manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e…
2
votes
1 answer

Amount of queries to database in Views using Django

My question is regarding best practices for querying a database in a View using Django. I want a daily count of reservations for the past 7 days. Is it okay to have something like this? (below) count_day_1 =…
Shawn
  • 67
  • 1
  • 5
2
votes
2 answers

Django ORM order by filters

Help me please with my problem. I want to get objects sorted first by one filter and then by another filter. How can I get objects with this ordering in 1 query to the DB (need for pagination)? This example shows queryset without ordering: rooms =…
2
votes
1 answer

django orm sort by foreign key occurence in another table

Suppose to have something like the following tables: class Book(models.Model): title = models.CharField(max_length=200) class Purchase(models.Model): book = models.CharField(Book, db_column="book", on_delete=models.CASCADE) date =…
2
votes
1 answer

Django: no such table: users_profile

Django noob here. Whenever I extend the base User Model, and try to access or edit the new fields, I receive the following error [... table not found]. OperationalError at /admin/users/profile/ no such table: users_profile Request Method:…
2
votes
3 answers

Django - ForeignKey issue. How many DB accesses?

I am currently using Django and my model is like this. class City(models.Model): name = models.CharField(max_length=255, primary_key=True) url = models.URLField() class Paper(models.Model): city = models.ForeignKey(City) name =…
Maqsood
  • 478
  • 6
  • 10
2
votes
1 answer

Why is django not creating a database table with 'migrate' command

I am new to Django, and for some odd reason my models are not creating a database table and am completely clueless as to why. When I run the command: "python manage.py makemigrations" I get the following shows up int he console output: Migrations…
Frank Castle
  • 335
  • 3
  • 23
2
votes
2 answers

Exporting to SPSS files in Python Django?

i need to export data to SPSS file format in Python (Django), but i can't find util information in google. Is there some way to do this? Someone has tried? thanks in advance!
eos87
  • 8,961
  • 12
  • 49
  • 77
2
votes
0 answers

How can I make Django to save users using DynamoDB?

I can't find a way to configure DynamoDB as the database for my application, apparently there is no built-in way to configure DynamoDB as the ENGINE for the project, is there a solution to bring my users to a DynamoDB table? I'm looking for a way to…
qwerty000
  • 176
  • 11
2
votes
0 answers

What django do when allow_migrate() on a database router returns false?

I'm writing a DB router to control what should be or not applied on the DB, so, implemented allow_migrate(). Here is what I did: def allow_migrate(self, db, app_label, model_name=None, **hints): if app_label == 'django_q': return db…
Mahmoud Adel
  • 1,262
  • 2
  • 13
  • 23
2
votes
0 answers

Why does Django perform UPDATE before INSERT when PK is None?

I've got a model with a UUID primary key: id = models.UUIDField( primary_key = True, default = uuid.uuid4, editable = False, null = False, blank = False, help_text = 'The unique identifier of the…