Questions tagged [django-shell]
78 questions
0
votes
0 answers
Insert using bulk_create fails with an ValueError of a field name
It is definitely different from this question.
In my question the problem is that it is showing ValueError for a field that doesn't even exist
this is my model in which i am doing bulk insert
class Seats(models.Model):
seat_no =…

rand0mb0t
- 124
- 1
- 13
0
votes
1 answer
unique_together does not work in Django shell
I have below model:
class Property(models.Model):
job = models.ForeignKey(Job, on_delete=models.CASCADE)
app = models.ForeignKey(App, on_delete=models.CASCADE)
name = models.CharField(max_length=120)
value =…

user2567728
- 31
- 4
0
votes
1 answer
Grab file from Desktop in Django Shell
I have an app named cars inside my Django project that has a utils.py file that contains various utility methods used by the application. One of them (grab_new_models) is used to process a CSV file that's normally picked up via a periodic tasks…

Splashlin
- 7,225
- 12
- 46
- 50
0
votes
1 answer
writing a script to enter multiple items into model fields in django shell
I'm still very new to programming and I'm worried that I'm barking up the wrong tree. I'm trying to write a multiple choice quiz app. I have 5000 different words and their definitions. I've made two dictionaries. One with the word definitions and…

Bill Gilroy
- 1
- 2
0
votes
1 answer
Django difficulty in displaying the data(count)
Im new to django and trying to learn with building a forum
my model
class Subject(models.Model):
name=models.CharField(max_length=128)
created=models.DateTimeField('Created Date')
def __str__(self):
return self.name
class…

spidy
- 269
- 2
- 13
0
votes
1 answer
Django db query not behaving the same way in views.py and shell
I am trying to generate a query for which I get the expected result in django shell, but for the same query, I am getting an error that the attribute for the model does not exist.
First the shell:
>>> from dbaccess.models import *
>>>…

Roy
- 59
- 6
0
votes
1 answer
Change Primary Key field to unique field
When setting up my database structure, I was stupid enough to set a field called "student_id" as "primary_key=True" for my Student class. I only realised much later that there are (rare) occasions where it is necessary to change said "student_id".…

Tobi
- 351
- 1
- 2
- 20
0
votes
1 answer
Python Script not running from django shell
I'm running a Python script from the Django shell. It was working fine until I added a main() function. Now it does not work. When I execute the script, nothing happens (no errors or anything). What am I doing wrong?
From the Django shell, I execute…

steph
- 701
- 2
- 10
- 30
0
votes
1 answer
How to copy register with DetailView and get pk (Django)
Consider my template:
entry_detail.html
0
votes
1 answer
Strange behaviour Django shell and iPython
I was doing some stuff in the Django console and I realized that the global variables are not recognized inside the lambda expression, for example if you execute the following code inside a python or even inside an iPython console it works…

Victor Castillo Torres
- 10,581
- 7
- 40
- 50
0
votes
0 answers
Copy registers ManyToOne in Django
See my model
https://github.com/rg3915/vendas/blob/master/vendas_project/vendas/models.py#L117-L157
and see my gist
https://gist.github.com/rg3915/9c2c0d6b9db0a5e6e6e1
This gist copy the registers of SaleDetail to new SaleDetail. I have a field…

Regis Santos
- 3,469
- 8
- 43
- 65
0
votes
1 answer
Execute Django shell command as cron
I'm try to Execute Django shell command as cron,
I have some queries and objects tasks to search and read and write using the models and queries of my django app.
How can I execute this 1 or 2 times a day?
For example, how can I run these queries…

Softsofter
- 345
- 1
- 3
- 13
0
votes
1 answer
Run a django shell in batch file with script
I wanna ask how to make a "python manage.py shell" and add a "from myapp.model import Contact c = Contact.objects.all().count() print c". Is this possible in a batch file?

Nethan
- 251
- 1
- 6
- 18
0
votes
1 answer
`&` character in database password gives error with django dbshell
I'm using an & ampersand sign in my database password in Django. The settings.py file looks like this :
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.mysql',
'NAME' : 'testdb',
'USER' : 'user1',
…

user
- 17,781
- 20
- 98
- 124
0
votes
0 answers
Django does not retrieve anything from database when using interactive shell
I don't understand what could be the problem of this kind of error. I have 4 apps in my Django project. Each app contains multiple models. I am able to retrieve data from all models expect 1 in the python interactive shell.
Also, in my Form, it…

Akshay
- 329
- 1
- 7
- 19