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

django: automatically detect CRUD changes done on database

I'm building an application(log) which stores the CRUD operations done on database.Is there any way to detect the CRUD operations directly?
2
votes
1 answer

Django: How do I perform database introspection with multiple databases?

I have code that works for getting models and fields from a Django database. However, it only works on the default database. This function wants a database name, and I'd like to get the tables and fields for that database. def…
Jason Champion
  • 2,670
  • 4
  • 35
  • 55
2
votes
1 answer

Django database migration: merging two fields into one

Say I have a model that represents a product from my company. Each product a product number (ex. 5928523), as well as a boolean representing whether or not it is an experimental product. class Product(models.Model): product_number =…
2
votes
2 answers

How do I delete an object in a django relation (While keeping all related objects)?

I have the following model: One name (Char) Many one (ForeignKey,blank=True,null=True) title (Char) I want to delete a One instance and all related objects should loose their relation to the One instance. At the moment my code looks…
niklasfi
  • 15,245
  • 7
  • 40
  • 54
2
votes
2 answers

Django creating a DateTimeField(auto_now_add) on a populated table

I decided to add a created = Models.DateTimeField(auto_now_add = True) field to a model which already has objects instantiated (without created field of course), and I saved them as initial_data So now when I run syncdb, I get the error…
jeff
  • 13,055
  • 29
  • 78
  • 136
2
votes
1 answer

Want to add another field to form and database django

I tried adding another field (pin) in forms.py and models.py The error i got was "FieldError at /student/signup/ Cannot resolve keyword 'pin' into field. Choices are: date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser,…
2
votes
0 answers

Using F() expressions with lookup of position from a list to update objects

I have 4 BaseReward objects, that have a default ordering of (rank, id) in Meta class. My aim is to update the objects such that I preserve their relative rankings, but give them unique ranks starting from 1, Originally: | id | rank…
dowjones123
  • 3,695
  • 5
  • 40
  • 83
2
votes
1 answer

Django multiple DB how to write router

I've got two DB, I've written a router.py that correctly manage write and read, but if the read db the default is down I cannot access also the write db getting the class TestRouter(object): def db_for_read(self, model, **hints): if…
user2239318
  • 2,578
  • 7
  • 28
  • 50
2
votes
1 answer

Models does not create tables when synched

I have some django models for my extended users profile. Problem is that this code does not create tables when syncdb is used (simply nothing happens. No validation errors). Why is that happening? (Also those models give import error elsewhere)…
crivateos
  • 925
  • 3
  • 10
  • 19
2
votes
1 answer

In Django-Rest-Framework how can I make all requests, except GET, transactional?

According to Django's documentation I can set ATOMIC_REQUESTS to make all requests atomic. It also states that I'm able to selectively turn it off on a "per-View" basis, not "per-View-function". But it isn't clear if the GET method would also be…
2
votes
1 answer

Accidentally deleted my django south migration directory

I accidentally deleted the South migrations directory for one of my Django apps. This directory was not under git. So now there are migrations in the database that are not present on the disk. Some pointers on how I can recover from this will be…
zaphod
  • 2,045
  • 1
  • 14
  • 18
2
votes
2 answers

Django 1.8 OperationalError: No such column

I just wanted to add a field on a model. class Categories(models.Model): #this IDUnique = models.IntegerField(max_length=11, blank=True, null=True) IDParent = models.IntegerField(max_length=11, blank=True, null=True) Name =…
2
votes
0 answers

How can I limit the number of queries when retrieving all related objects from multiple models?

Lets say I have this model: class MyLogModel(models.Model): log_stuff = models.CharField(max_length) class MoreLogModel(models.Model): word = models.CharField(max_length) my_log_model = models.ForeignKey(MyLogModel,…
JasonTS
  • 2,479
  • 4
  • 32
  • 48
2
votes
2 answers

Django importing Models from template

In my django project, I have a base.html from which all my templates {% extends 'base.html' %}. In that base template I want to do this to a list of all my algorithms. {% for algorithm in algorithms %} # list them out as links in nav bar {%…
2
votes
2 answers

Where to store key/value data in django app

I need to store dynamic (will change every day/hour) value in django app. Value will be generated every day, and I will need access to this key:value from all views in the application. I don't want to store it in some model object instance, it…
dease
  • 2,975
  • 13
  • 39
  • 75