Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for How to execute a Python script from the Django shell?

Current License: CC BY-SA 4.0

17 events
when toggle format what by license comment
Apr 25, 2023 at 7:32 comment added Ralph Bolton This is a great solution - you don't need the __init__.py files with Python 3.10/Django 4.1.
May 30, 2022 at 17:39 comment added Konstantin Kozirev Here is the fresh link to the docs (the one in the answer doesn't work) docs.djangoproject.com/en/4.0/howto/custom-management-commands
Feb 3, 2020 at 21:28 comment added Action Jackson For anyone having a problem with database values not being inserted correctly: this command option works far better than the first. I had an issue where string formatting wasn't working on a slug field. I wanted it to string.lower() and to replace some spaces with dashes. In a plain Python shell it worked perfectly, but not when adding to the database with the exec(...) function. Whereas this Django command worked perfectly.
S Jun 6, 2019 at 20:34 history suggested pianoJames CC BY-SA 4.0
update `handle_noargs` to `handle` as per comments and django docs
Jun 6, 2019 at 15:22 review Suggested edits
S Jun 6, 2019 at 20:34
Dec 25, 2018 at 13:11 comment added Omar Gonzales To get it to work change to def handle(self, **options): as James's comment.
Jan 9, 2018 at 9:02 review Suggested edits
Jan 9, 2018 at 9:50
Nov 29, 2017 at 10:34 comment added Mattia Paterna Interesting link here in support to this answer and the documentation.
May 5, 2017 at 9:15 comment added James As per earlier comment, for it to work for me I needed to change def handle_noargs(self, **options): to def handle(self, **options):.
Mar 14, 2017 at 15:26 history edited danodonovan CC BY-SA 3.0
NoArgsCommand deprecated, use BaseCommand
Mar 30, 2016 at 20:16 comment added Ger Again this is the best answer. Since django 1.8 NoArgsCommand is deprecated. This page gives a working example : docs.djangoproject.com/en/1.9/howto/custom-management-commands/…
Mar 9, 2016 at 20:04 history edited danodonovan CC BY-SA 3.0
added 4 characters in body
Jul 8, 2013 at 12:24 vote accept Community Bot
Jul 8, 2013 at 12:24
May 31, 2013 at 9:20 vote accept Community Bot
May 31, 2013 at 9:21
May 31, 2013 at 9:16 review Suggested edits
May 31, 2013 at 9:16
May 31, 2013 at 9:15 history edited danodonovan CC BY-SA 3.0
added 46 characters in body
May 31, 2013 at 9:10 history answered danodonovan CC BY-SA 3.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /