django-database Questions

4

What is the difference between auto_now_add and timezone.now (as default value) for models in Django? Example: create_date = models.DateTimeField(auto_now_add=True) and create_date = models.Dat...
Supat asked 27/11, 2019 at 16:32

4

Solved

I've been evaluating django and wondered if the following is possible. I've already looked at the regular multiple database docs so please don't point me to that because this use case isn't mention...
Fer asked 5/7, 2011 at 15:41

4

Solved

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. R...
Nolasco asked 4/8, 2012 at 19:22

2

Solved

I can't figure out how to pass user object to the following serializer: class ReviewSerializer(serializers.ModelSerializer): user = UserSerializer(read_only=True) class Meta: model = Review f...

7

How can I subtract or add 100 years to a datetime field in the database in Django? The date is in database, I just want to directly update the field without retrieving it out to calculate and then...
Organo asked 3/5, 2011 at 14:36

26

Solved

Is there a way to show the SQL that Django is running while performing a query?
Chronicles asked 2/7, 2009 at 13:3

10

Solved

How can I log all SQL queries that my django application performed? I want to log everything, including SQLs from admin site. I saw this question and a FAQ answer but I still can't figure out wher...
Beane asked 7/12, 2010 at 10:45

3

Solved

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 e...
Dissatisfactory asked 6/11, 2012 at 9:59

4

Solved

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/mo...
Strunk asked 20/11, 2016 at 14:30

3

Solved

I have a model class Survey(models.Model): created_by = models.ForeignKey(User) question = models.CharField(max_length=150) active = models.NullBooleanField() def __unicode__(self): return s...
Tahr asked 16/12, 2012 at 12:21

7

Solved

Is there a way to specify that a model (or app, even) should only ever use one particular database? I am working with a legacy database that I don't want to change. I have two databases - the 'def...

7

Solved

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 = m...
Departure asked 12/1, 2010 at 18:47

4

I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell, I get the following error: CommandEr...

6

Solved

I'm new to django framework. I tried to create a simple blog by following djangogirls tutorials. Here by default, we get sqlite3 as default database Engine: DATABASES = { 'default': { 'ENGINE': '...
Casing asked 14/2, 2017 at 13:44

5

Solved

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 t...
Grams asked 4/4, 2016 at 1:37

6

I am trying to use a migrations.RunSQL Django migration to run some arbitrary SQL code. I would like to run this migration for only certain db backends (for example only for postgres). I would thi...
Syllepsis asked 3/9, 2015 at 20:6

2

Solved

I'm reading a book about coding style in Django and one thing they discuss is db_index=True. Ever since I started using Django, I've never used this function because I'm not really sure what it doe...
Strum asked 9/2, 2013 at 8:47

0

Goal Test async function with test database Problem I have async functions for Django channels and when I create data in setUp the data are not reflected in the project!!! My tests: note: these te...

4

Solved

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 e...
Jenaejenda asked 30/9, 2016 at 14:41

3

Solved

I'm following the instructions on how to handle multiple databases within one Django project from here topics/db/multi-db I've created the two routers required. They are saved as ./database_router...
Parenthesis asked 19/12, 2018 at 21:49

3

I have 2 tables products and catagories connected by foreign key. I need to update field products.new_cost using field catagories.price_markup as following: UPDATE products p INNER JOIN categories...
Cestus asked 20/9, 2012 at 18:21

3

Solved

I have a long running Python process which uses the Django ORM. It looks something like this: import django from django.db import connection from my_app import models def my_process(): django....
Griseofulvin asked 30/8, 2016 at 1:27

3

Solved

Here is the problem: I have a model like this: class UserBook(models.Model): user = models.ForeignKey(User) book = models.ForeignKey(Book) is_active = models.BooleanField(default=False) clas...
Frivol asked 10/5, 2013 at 3:6

2

Look at this Django ORM code: my_instance = MyModel() my_instance.some_related_object = OtherModel.objects.using('other_db').get(id) At this point, in the second line, Django will throw an error...
Certificate asked 8/10, 2015 at 8:48

2

Solved

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 fu...
Finalize asked 12/11, 2010 at 14:42

© 2022 - 2024 — McMap. All rights reserved.