Questions tagged [django-shell]
78 questions
0
votes
1 answer
Access django dict through shell after aggregate annotate
Simple question
I am trying to get the result of an aggregate to use in my view to make a simple calculation.
I have written the following.
sms_raised = SmsBacker.objects.values('amount').annotate(Sum('amount'))
sms_raised
[{'amount': 150L,…

ApPeL
- 4,801
- 9
- 47
- 84
0
votes
1 answer
how to insert list of data into django database?
I made a list of items in string that i wanted to insert them into my Country table from shell, well wasn't successful so need some help.(i tried to add it as list and tuple but didn't work just caused more errors)
I use sqlite3…

Nicolas_Darksoul
- 99
- 8
0
votes
0 answers
Django shell can't see apps(directories with files) that are in the current working directory
I'm fairly new, trying to learn Django. I'm not sure when this issue started, or what caused it, since I used Django shell before and everything worked fine.
I've tried different approaches, one of which I saw several times - open Django project…

Friendly One
- 35
- 4
0
votes
0 answers
How to disable logging messages in Django shell?
I'm using pycharm to run my Django project and I did set some logging settings in my settings.py:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {
"require_debug_false": {
"()":…

Mehrdad HMT
- 53
- 8
0
votes
1 answer
Jupyter Notebook crashes every time there is an error
Every time there is an execution error, the Jupyter Notebook crashes without showing the error on the notebook, but showing it on the Jupyter prompt.
It forces me to restart the notebook and execute all the cells each time.
Screenshot of the…

Ibrahim Chiheb
- 1
- 2
0
votes
0 answers
Model def recepiestatus get error in django shell
im trying to solve a problem related to this eror message i get when i call a function in Django shell.
The error i get in Django shell is TypeError: can't compare datetime.datetime to datetime.date. But when i look at the code variables status…

The
- 73
- 7
0
votes
1 answer
Django shell get models object function does not work any ideas?
i have tried to look at the django documentation but cant find what i am looking for. I have a django models, and in this model i have defined som logic, the problem is that i cant get the value when i try fetching the recepie through django shell.…

The
- 73
- 7
0
votes
1 answer
Django Shell update objects value
I want to increase the prices by 30% in django shell.
models.py:
price = models.FloatField(null=True)
shell:
from product.models import Product
Product.objects.all().update(price=price*1.3)
error:
NameError: name 'price' is not defined

ibrahim demet
- 89
- 11
0
votes
0 answers
m2m_change signal not work form admin site but work from shell
I have a model
class Category(models.Model):
name = models.CharField(unique=True, max_length=45, blank=False, null=False)
perants= models.ManyToManyField('self',through="CategoryParent",symmetrical=False,blank=True)
and the CatigoryPerants…

omar nofal
- 36
- 2
0
votes
3 answers
How to fetch object with multiple levels of reverse lookup
In my project, there are three models:
class Level1(models.Model):
name = models.CharField(max_length=250)
class Level2(models.Model):
name = models.CharField(max_length=250)
level1 = models.ForeignKey(Level1,…

Bayezid Talukdar
- 1
- 2
0
votes
2 answers
How to replace/extend Django shell with Rich?
Django allows to replace its default shell with more capable ones like ipython and bpython.
Is there a way to replace/extend the default Django shell with Rich?

Den Kasyanov
- 870
- 2
- 11
- 27
0
votes
1 answer
Wrong date time getting extracted in my Django project
I am currently inserting current timestamp in my postgresdb. As shown below, the date 19th feb got inserted.
but when I got to Django shell and printed all the dates, its printing 18th feb. How can i solve this confusion.
In my settings.py, current…

Mahesh
- 1,117
- 2
- 23
- 42
0
votes
1 answer
Can't check profile model in django python shell
I am trying to run the django shell to understand what is happening to the photos when I upload them.
However when I try to filter for particular users
python manage.py shell
from django.contrib.auth.models import User
user =…

Emm
- 2,367
- 3
- 24
- 50
0
votes
2 answers
Django forms: how to show only objects associated with user in dropdown
I am a vet hospital, with class Pet and class Records. Each pet can have many records, i.e. everytime it visits the hospital it gets a new record.
At the moment, my form shows all the pets ever associated with my app (please view…

Ally Alfie
- 131
- 11
0
votes
2 answers
How can I manually edit a specific attribute in a model through Django Shell?
I recently added a created_by attribute in Store model. Since this automatically gets a current logged in user when a store is created, if I don't manually assign any user, that column will be forever null.
class Store(models.Model):
...
…

Jay P.
- 2,420
- 6
- 36
- 71