How to: Django development and debugging

169 views
Skip to first unread message

Don Thilaka Jayamanne

unread,
Oct 20, 2016, 8:30:45 PM10/20/16
to Django users
Hi Everyone, I'm the author of a Python plugin for the VS Code editor (https://github.com/DonJayamanne/pythonVSCode). Basically it provides intellisense, code navigation, debugging (django, multi threads, etc), data science and the like.

When it comes to debugging django applications, today the extension disables (doesn't support) live reloading of django applications.

I'm thinking of having a look at this particular area. Before I do so, I'd like to get an idea of how developers actually develop and debug django applications.

Most of the people i've spoken to say they develop as follows:
- Fire up the django application with live reload 
- Start codeing
- Test in the browser
- Very rarely would they debug an application
- i.e. majority of the time they don't launch the application in debug mode 

How do you work on django applications?

Antonis Christofides

unread,
Oct 21, 2016, 1:48:37 AM10/21/16
to django...@googlegroups.com

- Very rarely would they debug an application
- i.e. majority of the time they don't launch the application in debug mode 

By "debug mode" I guess you mean stepping into the code, stopping at breakpoints, etc. I wouldn't say I do it rarely, I do it quite often. I add "import ipdb; ipdb.set_trace()" in the code, at the place I want it to stop, and then I can step and so on. It sucks when you compare it to great debuggers (I have experience in Delphi and I'm missing the debugger much when I program in Python), but it's better than nothing. I've heard PyCharm's decent in that, but I haven't tried it (yet).

Antonis Christofides
http://djangodeployment.com
--
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.
To post to this group, send email to 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/249e5555-3721-40a6-a351-99eb33ae1f77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Muizudeen Kusimo

unread,
Oct 21, 2016, 2:56:43 PM10/21/16
to Django users
Hello Folks,

PyCharm makes debugging Django (and other Python) applications very easy. Some of the features which are very helpful include:
  1. Ability to choose specific Python Interpreter you want to run the code base against. Useful if you use virtualenv and need to test your code in different Python versions
  2. Standard debugging tools - Step Into, Step Over, Step Out, Watches
  3. Support for debugging other Python libraries tied to your Django application e.g. Lettuce BDD tests, Unit Tests e.t.c
It's definitely worth a try as you can get a lot from the Community Edition

Regards

Mike Dewhirst

unread,
Oct 22, 2016, 10:06:36 PM10/22/16
to django...@googlegroups.com
On Thursday, October 20, 2016 at 8:30:45 PM UTC-4, Don Thilaka Jayamanne
wrote:
>
> Hi Everyone, I'm the author of a Python plugin for the VS Code
> editor (https://github.com/DonJayamanne/pythonVSCode
> <https://github.com/DonJayamanne/pythonVSCode>). Basically it
> provides intellisense, code navigation, debugging (django, multi
> threads, etc), data science and the like.
>
> When it comes to debugging django applications, today the
> extension disables (doesn't support) live reloading of django
> applications.
>

I take this to mean reload the dev server when code changes. I think
that is critical for development.
Also critical for me is the debug page delivered when settings.DEBUG is
True. I suppose that is independent of the IDE.

>
> I'm thinking of having a look at this particular area. Before I do
> so, I'd like to get an idea of how developers actually develop and
> debug django applications.
>
> Most of the people i've spoken to say they develop as follows:
> - Fire up the django application with live reloadÂ
>

No. I write a unit test (or tests) then do manage.py test
Assuming the tests fail I start coding
>
> - Start codeing
>

When the unit tests all pass

> - Test in the browser
>
Yes
>
> - Very rarely would they debug an application
>

Very rarely necessary to step through code looking at variables etc to
discover why something isn't working. My bugs are pretty obvious. I have
stepped through code but usually to see what the framework is doing for
one reason or another.

> - i.e. majority of the time they don't launch the application in
> debug modeÂ
>

Always in development

Very rarely in staging and then only temporarily to see what is going
wrong on the non-dev platform.

Never in production (same platform as staging)

>
> How do you work on django applications?
>

* Plain text editor with Python syntax highlighting to write code
* Scripted launching of manage.py with different backends, settings,
databases as required
* Commit to my own branch in svn
* Merge to trunk
* Run unit tests
* Repeat until all unit tests are working
* Commit trunk in svn
* Svn commences a Buildbot deployment on staging which succeeds if the
tests all work
* Occasionally create a production tag from trunk in svn
* Manually edit a script on production to deploy the tag

HTH

Mike

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 3:07:03 AM10/23/16
to Django users
The debugger in python extension for VS Code is comparable to PyCharms debugger. In fact it supports all of the features you have mentioned.
Please feel free to try it out:

Derek

unread,
Oct 23, 2016, 9:20:26 AM10/23/16
to Django users
Is VS Code Editor available on Linux platforms?

Luis Zárate

unread,
Oct 23, 2016, 12:40:35 PM10/23/16
to django...@googlegroups.com
I rarelly debug code with django, with external utility, just trace stack when errors appears, buy when I need it I use pydev over Aptana,  it has heap monitor, breakpoints, step by step run and other debugger functions.

One important thing is that I need to say to pydev that  run django with --no-autoreload parameter, so then works well because when I am debugging I am not coding and I can start or stop the server when I want.

I always run django in external terminal when I am coding, I really like the autoreload, I think it's better if the IDE can reload, but I really hate when Aptana is configured wrong and server never die, because I need to user $ killall python (or some like that) to stop django.

I dislike VS as IDE but, great if you want to support Django there.
> --
> 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+unsubscribe@googlegroups.com.

> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 6:56:36 PM10/23/16
to django...@googlegroups.com
@Derek, yes VS Code Editor is available on Linux platforms.
Have a look here:

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/vEKR34Oo08g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 6:59:01 PM10/23/16
to django...@googlegroups.com
@Luis Zárate 
>I dislike VS as IDE but
Any particular reason for this?

>great if you want to support Django there
Django is supported today (including template debugging). Right now i'm looking at the need for debugging with auto-reload.

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/vEKR34Oo08g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 7:06:04 PM10/23/16
to Django users
@Derek, yes VS Code Editor is available on Linux platforms.
Have a look here:

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 7:08:16 PM10/23/16
to Django users
@Luis Zárate 
>I dislike VS as IDE but
Please remember, this is Visual Studio Code (cross platform, open source, free) and not to be confused with Visual Sutdio IDE (full blown IDE runs only on Windows)

>great if you want to support Django there
Django is supported today (including template debugging). Right now i'm looking at the need for debugging with auto-reload.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Don Thilaka Jayamanne

unread,
Oct 23, 2016, 7:13:06 PM10/23/16
to Django users
Hi ,
This Python Extension too supports the features you have mentioned.
The difference is:
- Visual Studio Code is more of a lightweight and cross platform alternative (completely open source - MIT licensed).

Here are some of the features:

On Saturday, 22 October 2016 05:56:43 UTC+11, Muizudeen Kusimo wrote:

Luis Zárate

unread,
Oct 25, 2016, 10:42:05 AM10/25/16
to django...@googlegroups.com

2016-10-23 17:08 GMT-06:00 Don Thilaka Jayamanne <don.ja...@gmail.com>:
@Luis Zárate 
>I dislike VS as IDE but
Please remember, this is Visual Studio Code (cross platform, open source, free) and not to be confused with Visual Sutdio IDE (full blown IDE runs only on Windows)

Sorry I was confused, I was thinking in Microsoft Visual Studio (MVS).

I didn't test VSC, but I will.  I am looking for a IDE because Aptana is not updated for a while, so I am having compatibility issues.

33 Mb size it's like i want :) great for Debian installer.

It's any relation with MVS? because you are using the same icon and the same colors.


--
"La utopía sirve para caminar" Fernando Birri


Reply all
Reply to author
Forward
0 new messages