Questions tagged [django-shell]

78 questions
3
votes
0 answers

Create dynamic model in Django 1.8

How to create Dynamic models in Django 1.8? I have done the following according to the official site: >>attrs = { 'name': models.CharField(max_length=32), '__module__': 'myapp.models' } >>person = type("ptable",…
3
votes
1 answer

Use SublimeREPL as Django shell

I am learning Django, and Django shell is a frequently used thing, but it is a bit frustrating to switch back and forth to the Terminal window. I try to use SublimeREPL-shell, but it does not work properly. For instance, I can use python manage.py…
Lelouch
  • 2,111
  • 2
  • 23
  • 33
3
votes
1 answer

Variables scope in inline django shell, vs python shell

I have problem, with strange behavior of django shell. I have this code: fields = ('name', 'description', 'long_description', 'foot_description') a = 1 dict( (field, a) for field in fields) When I run it from python shell it's give me right dict.…
whncode
  • 429
  • 3
  • 15
3
votes
2 answers

How to import a template tag in the interactive shell?

How can I import a custom template tag or filter in the interactive shell to see if the everything is working fine? I have two machines behaving differently and I don't have a clue of how to do some debugging. On the production machine I can't load…
nemesisdesign
  • 8,159
  • 12
  • 58
  • 97
2
votes
2 answers

Delete Django QuerySet objects with a duplicate value in a particular field

I have this Django model (from Django CMS): class Placeholder(models.Model): slot = models.CharField(_("slot"), max_length=50, db_index=True) default_width = models.PositiveSmallIntegerField(_("width"), null=True) I want to delete the…
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
2
votes
0 answers

Function Call in another function not working in django shell

I have a file : def fetchArticles(topic): testing() def testing(): print("testing") print("starting") fetchArticles("World") It is present in a app in django and when i run it as a standalone file using python3 xyz.py it runs perfectly fine…
2
votes
3 answers

Custom command to upload photo to Photologue from within Django shell?

I have successfully employed Photologue to present galleries of regularly-created data plot images. Of course, now that the capability has been established, an obscene number of data plots are being created and they need to be shared! Scripting the…
2
votes
3 answers

Delete all django.contrib.messages

I recently realized that a module in our Django web app was using django.contrib.messages. However, the template's context processor did not have the django.contrib.messages.context_processors.messages processor added. I'm worried that when I push…
Jedi
  • 3,088
  • 2
  • 28
  • 47
2
votes
1 answer

Unrecognized flag: '--ext' on python manage.py shell_plus --notebook

I have a Django project using Django 1.6.10 running on Mac OS X 10.10 and python 2.7. I have django_extensions and ipython[notebook] installed into my virtualenv using pip: django-extensions==1.5.0 ipython==3.1.0 However, when I try to run the…
David Watson
  • 3,394
  • 2
  • 36
  • 51
2
votes
3 answers

Pydev and Django: Shell not finding certain modules?

I am developing a Django project with PyDev in Eclipse. For a while, PyDev's Django Shell worked great. Now, it doesn't: >>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version)) C:\Python26\python.exe 2.6.4 (r264:75708, Oct 26…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
2
votes
3 answers

How to create a single-line script with two for loops, in the debugger, in python 2.7

Creating a single line for loop in the python debugger or django shell is easy: >>>> for x in (1,2,3,4):print(x); >>>> for x in Obj.objects.all():something(x); But how can I get a second for loop in there? >>>> for x in (1,2,3,4):print x;for y in…
Bryce
  • 8,313
  • 6
  • 55
  • 73
1
vote
1 answer

Django comments in shell

I'm having trouble pulling comments into my template using django comments. I'd like to test some things out in the shell - ie. pulling in an object and getting the set of comments for it - but I'm not sure how to do that. Is there away to access a…
9-bits
  • 10,395
  • 21
  • 61
  • 83
1
vote
0 answers

Partial Problem from configuration settings in `$DJANGO_SETTINGS_MODULE`

Tree Directory: . ├── Pipfile ├── Pipfile.lock ├── README.md ├── Strawberry │ ├── init.py │ ├── pycache │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── catalog │ ├── init.py │ ├── pycache │ ├── admin.py │ ├── apps.py │ ├──…
1
vote
2 answers

AttributeError: 'FieldInstanceTracker' object has no attribute 'saved_data'

Problem with a post_save signal? class Book(models.Model): room = models.ForeignKey(Room, on_delete=models.CASCADE, null=False) library = models.ForeignKey(Library, on_delete=models.CASCADE, null=False) created_at =…
Jorge
  • 105
  • 9
1
vote
2 answers

Django Shell Plus Clear History

Is there a command to clear the history of Django's Shell Plus? I did not find any hints in the documentation or by typing ?.
sevic
  • 879
  • 11
  • 36