-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreload-module-when-using-django-shell.html
147 lines (135 loc) · 7.61 KB
/
reload-module-when-using-django-shell.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Han" />
<meta name="copyright" content="Han" />
<meta property="og:type" content="article" />
<meta name="twitter:card" content="summary">
<meta name="keywords" content="django, python, tech, " />
<meta property="og:title" content="Reload module when using Django shell "/>
<meta property="og:url" content="http://blog.hehan.net/reload-module-when-using-django-shell.html" />
<meta property="og:description" content="Issue The annoying part of using django shell is that: Once you changed the source code, you need restart the shell and enter the code again. Solution Use django-extensions in the project and with shell_plus, there is a better expirence using django shell, although it's not the best, anyway ..." />
<meta property="og:site_name" content="Note Everything" />
<meta property="og:article:author" content="Han" />
<meta property="og:article:published_time" content="2015-06-05T10:57:00+08:00" />
<meta name="twitter:title" content="Reload module when using Django shell ">
<meta name="twitter:description" content="Issue The annoying part of using django shell is that: Once you changed the source code, you need restart the shell and enter the code again. Solution Use django-extensions in the project and with shell_plus, there is a better expirence using django shell, although it's not the best, anyway ...">
<title>Reload module when using Django shell · Note Everything
</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://blog.hehan.net/theme/css/pygments.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://blog.hehan.net/theme/tipuesearch/tipuesearch.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://blog.hehan.net/theme/css/elegant.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://blog.hehan.net/theme/css/custom.css" media="screen">
<link href="http://blog.hehan.net/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Note Everything - Full Atom Feed" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-43074617-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="content-sans-footer">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://blog.hehan.net/"><span class=site-name>Note Everything</span></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right top-menu">
<li ><a href="http://blog.hehan.net">Home</a></li>
<li ><a href="http://blog.hehan.net/categories.html">Categories</a></li>
<li ><a href="http://blog.hehan.net/tags.html">Tags</a></li>
<li ><a href="http://blog.hehan.net/archives.html">Archives</a></li>
<li><form class="navbar-search" action="http://blog.hehan.net/search.html" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10">
<article>
<div class="row-fluid">
<header class="page-header span10 offset2">
<h1><a href="http://blog.hehan.net/reload-module-when-using-django-shell.html"> Reload module when using Django shell </a></h1>
</header>
</div>
<div class="row-fluid">
<div class="span8 offset2 article-content">
<h3>Issue</h3>
<p>The annoying part of using django shell is that:</p>
<blockquote>
<p>Once you changed the source code, you need restart the shell and enter the code again.</p>
</blockquote>
<h3>Solution</h3>
<p>Use <code>django-extensions</code> in the project and with <code>shell_plus</code>, there is a better expirence using django shell, although<br />
it's not the best, anyway it's much better.</p>
<pre><code># python manage.py shell_plus --notebook
</code></pre>
<p>The above command would open a notebook on your browser, write your code in a cell.<br />
When you changed your module, just click <code>Kernel > Restart</code>, and rerun the code.</p>
<p>Done! Happy django.</p>
<hr/>
</div>
<section>
<div class="span2" style="float:right;font-size:0.9em;">
<h4>Published</h4>
<time pubdate="pubdate" datetime="2015-06-05T10:57:00+08:00">2015-06-05</time>
<h4>Category</h4>
<a class="category-link" href="http://blog.hehan.net/categories.html#tech-ref">tech</a>
<h4>Tags</h4>
<ul class="list-of-tags tags-in-article">
<li><a href="http://blog.hehan.net/tags.html#django-ref">django
<span>6</span>
</a></li>
<li><a href="http://blog.hehan.net/tags.html#python-ref">python
<span>15</span>
</a></li>
</ul>
<h4>Contact</h4>
<a href="#" title="My You can add links in your config file Profile" class="sidebar-social-links" target="_blank">
<i class="fa fa-you can add links in your config file sidebar-social-links"></i></a>
<a href="#" title="My Another social link Profile" class="sidebar-social-links" target="_blank">
<i class="fa fa-another social link sidebar-social-links"></i></a>
</div>
</section>
</div>
</article>
</div>
<div class="span1"></div>
</div>
</div>
<div id="push"></div>
</div>
<footer>
<div id="footer">
<ul class="footer-content">
<li class="elegant-power">Powered by <a href="http://getpelican.com/" title="Pelican Home Page">Pelican</a>. Theme: <a href="http://oncrashreboot.com/pelican-elegant" title="Theme Elegant Home Page">Elegant</a> by <a href="http://oncrashreboot.com" title="Talha Mansoor Home Page">Talha Mansoor</a></li>
</ul>
</div>
</footer> <script src="http://code.jquery.com/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script>
function validateForm(query)
{
return (query.length > 0);
}
</script>
</body>
<!-- Theme: Elegant built for Pelican
License : http://oncrashreboot.com/pelican-elegant -->
</html>