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

TypeError: Field.__init__() got an unexpected keyword argument 'max_lenght'

from django.db import models class Coustomer (models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=100) locality = models.CharField(max_lenght=150) zipcode= models.IntegerField() state =…
-1
votes
1 answer

OperationalError at /admin/ route of django project

Hey I work with django framework I had the error OperationalError. I have two classes with the same fields: class Student(models.Model): user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) id =…
-1
votes
1 answer

How can I get information about the logged-in user in a Django application?

How can I get information about the logged-in user in a Django application? What I want to do is get the user information from Logged-in user and put additional information and store in a database(models.py). So in views.py: def…
Shreyansh Dash
  • 147
  • 1
  • 1
  • 9
-1
votes
1 answer

Annotate count of related related filtered objects

I have these models: class Shop(..): category = ForeignKey... class Product(..): shop = ForeignKey... category = ForeignKey... is_active = BooleanField... class Category(..): name = ... I need to annotate the number of active…
-1
votes
2 answers

Django 3.1, I'm NOT getting RelatedObjectDoesNotExist error for User and Profile models

as the title reads I'm NOT getting the RelatedObjectDoesNotExist error in Django 3.1(Latest Release) I'm not using signals. I create a superuser using the (python manage.py createsuperuser) command, which, as expected, does not create a…
-1
votes
1 answer

Django: Does .count() force the queryset evaluation

I want to pass a queryset which involves counting rows to a function without calling the database right away. For example, the following queryset is lazy and does not access the database until it is evaluated: queryset = MyModel.objects.all() I…
-1
votes
1 answer

Can no longer drop database and reapply migrations in Django?

Throughout writting my app many times I have had to delete my database and re run my migrations. This has always worked by simply deleteing the database file then just running manage.py migrate . However now when I try to do this, I get an error…
-1
votes
1 answer

How to give database name in runtime and migrate all changes to it

How to migrate changes in a database who's name is user defined. i tried giving data = request.data cursor = connection.cursor() cursor.execute("create database " + data["database"]) DATABASES["default"]["NAME"] =…
-1
votes
1 answer

Do custom template tags cause a database query?

I am using 5 - 6 custom template tags. Each one of them is similar to the following: @register.filter(name = 'time_left') def time_left(obj): if not obj: return -1 if not obj.has_offer_expired(): return obj.time_left() …
-1
votes
1 answer

DJANGO 2.0 Displaying Data from the database

i am new to django and i am unable to get to print to the html page.How do you display the information retrieved from the database into a blank html page? blank.hml

Classes Added

{% for i in classInfo %}

{{ i.label }}

{%…
Tahmid
  • 1
  • 1
-1
votes
2 answers

Django Image is not saving in database

I'm trying to upload a user photo and show it in homepage. problem 1 : When i upload an image from admin section it gets saved in database but it doesn't show up in 'homepage.html'. Problem 2 : When i try to upload an image using 'profile.html'…
jef
  • 23
  • 2
  • 6
-1
votes
1 answer

Django - Remove object from database after day

I want to remove object after one day. Here is part of my code: data = models.DateField(null=True) So for example value of data field is 10.10.2017 And I want to remove it in 11.10.2017 Thanks for help !
xaos_xv
  • 759
  • 1
  • 10
  • 27
-1
votes
1 answer

USE Raw SQL in Django

I recently migrated from PHP to django. I am creating a project which works on django.. I am used to write custom sql in php and hence i want to use raw() to filter results from my database in django. However i am not able to fully understand how…
DJ RAXITH
  • 13
  • 2
-1
votes
1 answer

Page loading is very slow - how to properly optimize?

I'm working on a big page with different product statistics. I use there multiple charts, tables etc. It takes for example 5 seconds to load the page. This is a very simplified models.py EDIT For example, OccurencesTable contains this…
Milano
  • 18,048
  • 37
  • 153
  • 353
-1
votes
2 answers

Replicate Production Django Database to Local Foreman Server

I would like to have a local copy of the data in the Django database to facilitate offline development. The production version is hosted by Heroku; the data is stored in a Postgres database and I am using foreman locally with the default mysqlite…
Peter H
  • 83
  • 1
  • 6
1 2 3
44
45