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
19
votes
1 answer

Copy a database column into another in Django

I am writing a migration that requires me to fill a field with existing data from another field (with same type and constraints). Is it possible in Django to copy the data in a single operation? The destination column already exists when I need to…
mimo
  • 2,469
  • 2
  • 28
  • 49
18
votes
3 answers

django database delete specific number of entries

How to delete specific number of entries from the database? I did something like this EntriesToDelete=Statusmessages.objects.filter(time__lt=date)[:30000] EntriesToDelete.delete() But I get an error which says: AssertionError. Cannot use 'limit' or…
arjun
  • 2,333
  • 4
  • 21
  • 21
17
votes
3 answers

"Returning to that page might cause any action you took to be repeated" - Django

I have a form on my website, that creates an entry in database. So every time when I refresh a page I got this message first: The page that you're looking for used information that you entered. Returning to that page might cause any action you took…
Vor
  • 33,215
  • 43
  • 135
  • 193
16
votes
3 answers

Django: dynamic database file

In my Django project I have a dependency for a third party application that produces SQLite cache files in various directories with a known schema. I'd like to use Django models to access those databases, but obviously I cannot use a static…
Constantinius
  • 34,183
  • 8
  • 77
  • 85
15
votes
4 answers

django.db.migrations.exceptions.CircularDependencyError

I have a problem with Django migrations on empty DB. When I want to migrate I have a circular dependency error. Circular dependency error between two apps that related by foreign keys /firstapp/models.py class Person(models.Model): ... class…
yarsanich
  • 174
  • 1
  • 1
  • 10
14
votes
3 answers

Django ManyToMany through with multiple databases

TLTR: Django does not include database names in SQL queries, can I somehow force it to do this or is there a workaround? The long version: I have two legacy MySQL databases (Note: I have no influence on the DB layout) for which I'm creating a…
masterfloda
  • 2,908
  • 1
  • 16
  • 27
14
votes
5 answers

Django makemigrations AttributeError: 'str' object has no attribute '_meta'

I was playing with the django framework and I ran into an issue running the makemigration command. Here is a copy of the model and the stack trace it produces. I have seen a couple of posts with the same error but none has led me to resolve my…
legend
  • 197
  • 1
  • 4
  • 17
13
votes
2 answers

How do I create a new database for an existing App using Django South and set default values?

I'm working with an OS project that uses South to migrate the database. I'm building a new database from scratch and I want to make sure South is setup so I can easily update the database in the future. It seems this process should be: create the…
BryanWheelock
  • 12,146
  • 18
  • 64
  • 109
13
votes
3 answers

Django and NoSQL, any ready-to-use library?

So far Django has good integration with several RDBMS. NoSQL, schema-less and document-oriented DBMS are picking up. What's the status of integration those on-trend and fashionable DBMSes with Django? Are there any production-ready or at least…
Viet
  • 17,944
  • 33
  • 103
  • 135
13
votes
7 answers

Django Table with Million of rows

I have a project with 2 applications ( books and reader ). Books application has a table with 4 milions of rows with this fields: book_title = models.CharField(max_length=40) book_description = models.CharField(max_length=400) To avoid to query…
xRobot
  • 25,579
  • 69
  • 184
  • 304
13
votes
1 answer

Prevent Django from querying for ForeignKey options for every form in ModelFormSet

I'm building a csv import form for my Django application and want to display the to-be-imported rows in a ModelFormSet for validational purposes. Therefore I added a view to the relevant ModelAdmin which reads the lines from the csv and prints a…
jnns
  • 5,148
  • 4
  • 47
  • 74
12
votes
4 answers

Specifying Readonly access for Django.db connection object

I have a series of integration-level tests that are being run as a management command in my Django project. These tests are verifying the integrity of a large amount of weather data ingested from external sources into my database. Because I have…
12
votes
4 answers

Create Read-Only MySQL Database Connection in Django

Is it possible to add a connection to a database so when using it only select queries are allowed? Something like this would be great: DATABASES = { #can do update, insert, etc... 'default': { 'ENGINE': 'django.db.backends.mysql', …
YardenST
  • 5,119
  • 2
  • 33
  • 54
11
votes
2 answers

Where is the ON DELETE CASCADE logic being implemented in Django? (PostgreSQL is used)

I just need a confirmation for my understanding on Django's implementation of ON DELETE CASCADE from you Django experts. According to the official Django documentation: When Django deletes an object, by default it emulates the behavior of the SQL…
tamakisquare
  • 16,659
  • 26
  • 88
  • 129
11
votes
1 answer

Multiple fields to the same DB column

We are trying to speed up our app with prefetch_related. It can follow the GenericForeignKey relations, and it can go deeper with __ but unfortunately it will fail if related model do not have such field. Here is some example of model…
Igor
  • 3,129
  • 1
  • 21
  • 32
1
2
3
44 45