Code vs Shell?

63 views
Skip to first unread message

roflcopterpaul

unread,
Jul 23, 2018, 11:25:52 PM7/23/18
to Django users
Hello, everyone!

I am quite the scrub, having written a few super basic apps and currently going through the Django tutorial. As I'm going through the tutorial (creating a "polls" app), I've been perplexed by something the whole time that I haven't been able to find an answer to -

Why is much of the data the users see (i.e., the questions and answers to the questions) written in the shell INSTEAD of simply being typed up in the code/text editor? I'm new, so this is coming from a place of ignorance, by why is that? It seems way more complicated and less efficient.

Also, IS there a way to change up the code so everything can be directly changed in the files themselves instead of in the shell?

Thank you very much for any insight!

Mike Dewhirst

unread,
Jul 24, 2018, 3:18:14 AM7/24/18
to Django users
On 24/07/2018 9:25 AM, roflcopterpaul wrote:
> Hello, everyone!
>
> I am quite the scrub, having written a few super basic apps and
> currently going through the Django tutorial. As I'm going through the
> tutorial (creating a "polls" app), I've been perplexed by something
> the whole time that I haven't been able to find an answer to -
>
> Why is much of the data the users see (i.e., the questions and answers
> to the questions) written in the shell INSTEAD of simply being typed
> up in the code/text editor? I'm new, so this is coming from a place of
> ignorance, by why is that? It seems way more complicated and less
> efficient.

It is an education thing. Python is an interpreter which means it can
interpret and execute code directly as well as read a script and execute
from that.

And you can enter data directly without needing to write/debug data
entry code or skipping too far ahead of basic theory to get the Admin
going.

Typing stuff in and seeing the results demonstrates things actually
working. If you believe, you don't need to do it.

Typing it in directly gives you instant feedback and that's what a lot
of people like. I've been using Python for a few years now and I still
fire up the interpreter occasionally when I'm refreshing my memory about
something I haven't used for a while. Or checking to prove something
works as it should when results make me suspect I have gotten something
wrong.

YMMV


>
> Also, IS there a way to change up the code so everything can be
> directly changed in the files themselves instead of in the shell?
>
> Thank you very much for any insight!
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/00ef1cb4-3e87-4c3d-a5c6-8811408624de%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/00ef1cb4-3e87-4c3d-a5c6-8811408624de%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

mottaz hejaze

unread,
Jul 24, 2018, 4:44:31 AM7/24/18
to django...@googlegroups.com
python is not just web , python is very general and has many other usages , so you are developing but in a pythonic way , think of the shell as your scratch paper ..

what if you want to learn a code snippet like querying the database with filters , do you have to waste time build a complete app to learn that ?!

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

C. Kirby

unread,
Jul 24, 2018, 2:17:42 PM7/24/18
to Django users
With all respect to the other answers, they don't answer what you are asking.
The documentation has you interacting with the shell because django uses a database. In order to interact with the database you have to have an instance of your app running - in this case via the shell. In a future section of the tutorial you will interact with the database via the web view of your app.
There are ways to populate the database by way of code (you can look up migrations if you would like) but the tutorial is really teaching the CRUD paradigm (Create, Read, Update, Delete) by which a user will interact with your app

roflcopterpaul

unread,
Jul 24, 2018, 4:33:56 PM7/24/18
to Django users
Thank you very much for the responses, everyone. Understanding *why* I've been having to work in the shell makes a lot more sense. Currently, my primary goal of learning Python is for web applications/websites, so I definitely want to learn how to do it all in the code itself, but I'm sure I'll learn how to do that eventually.

Thanks again!
Reply all
Reply to author
Forward
0 new messages