Entire Application in Django shuts down with single error

40 views
Skip to first unread message

Amit Sharma

unread,
Oct 1, 2019, 7:14:13 AM10/1/19
to Django users
I am new to Python and django , I worked on C# and php as developer earlier. My problem here is Entire Application in Django shuts down with single error.

for example i start my website with "python3 manage.py runserver 0.0.0.0:8000" example:-- i have two pages home and register
1) if i make error in register page code(register.py) , It shuts down home page too. Is there a way to prevent that as in php and C# in both one page do not effect other.
2) how to work in django with team one errors full team hangs.

3) How to work with live working websites things may become too risky.

4) can we make django development as friendly as C#, PHP  ......... and other programming language

also i am not able to find article related to this. kindly help

Aldian Fazrihady

unread,
Oct 1, 2019, 8:44:52 AM10/1/19
to django...@googlegroups.com
`runserver` is a development server to help you debug your code, so crashing is a feature.

 To use django on production/staging, please follow this guide: https://docs.djangoproject.com/en/2.2/howto/deployment/

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7d81706a-2f84-4f55-a25c-1bae726a8879%40googlegroups.com.


--
Regards,

Andréas Kühne

unread,
Oct 2, 2019, 3:49:49 AM10/2/19
to django...@googlegroups.com
Hi,

You shouldn't use runserver in production - that's not what it's for. So first read how to deploy django in production. When in production, you don't deploy code that doesn't work - so that means that you won't get this issue.

You shouldn't work on live working websites - that's not how you do it professionally. You should work locally on your machine and then update the production server WHEN everything works. Allowing someone to work live on a production server is a major issue. Like you said, you will probably crash the server when doing that. 

Django development is very friendly - as long as you work in the correct way:

1. Work on a development machine - update the changes and run your tests to make sure that everything works as expected.
2. Create a package for the website somehow (git archive, create a docker image or something like that).
2a. Test your code on a staging server.
3. Update your production server with the working code.
4. Restart the application server on the production server.

If you follow that mindset it won't be a problem when working  - and this is basically the way you should be working REGARDLESS of what framework you are using. Otherwise you will get changes done in several places - you won't know what is the latest code and so on.

The list above is a minimal list - you could of course expand on that as well.


Regards,

Andréas


--

Amit Sharma

unread,
Oct 3, 2019, 3:03:48 AM10/3/19
to Django users
Hi , 
I agree with your point and i do follow same. But what my main concern here is :--

Can we have in django that if one page has got some error than other page  do not stop working. This was only thing i want to know. Kindly help.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Mike Dewhirst

unread,
Oct 3, 2019, 5:44:36 AM10/3/19
to django...@googlegroups.com
On 3/10/2019 5:03 pm, Amit Sharma wrote:
> Hi ,
> I agree with your point and i do follow same. But what my main concern
> here is :--
>
> Can we have in django that if one page has got some error than other
> page  do not stop working. This was only thing i want to know. Kindly
> help.

It is quite reasonable for that to happen for a single user encountering
the error. Other users who do not encounter an error will keep working.

The unfortunate victim can always click the back button on the browser
to see earlier pages.

If you have your logging established to email errors to you or your dev
team you will see what is happening and be able to repair the damage.

That is the way to discover exactly where to put your try/except blocks
or more rigorous checking.

Cheers

Mike
> <letter...@gmail.com <javascript:>>:
>
> I am new to Python and django , I worked on C# and php as
> developer earlier. My problem here is Entire Application in
> Django shuts down with single error.
>
> for example i start my website with "python3 manage.py
> runserver 0.0.0.0:8000 <http://0.0.0.0:8000>" example:-- i
> have two pages home and register
> 1) if i make error in register page code(register.py) , It
> shuts down home page too. Is there a way to prevent that as in
> php and C# in both one page do not effect other.
> 2) how to work in django with team one errors full team hangs.
>
> 3) How to work with live working websites things may become
> too risky.
>
> 4) can we make django development as friendly as C#, PHP 
> ......... and other programming language
>
> also i am not able to find article related to this. kindly help
>
> --
> 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...@googlegroups.com <javascript:>.
> <https://groups.google.com/d/msgid/django-users/7d81706a-2f84-4f55-a25c-1bae726a8879%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/807cd268-aecc-45db-84b9-6d3371bb5d49%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/807cd268-aecc-45db-84b9-6d3371bb5d49%40googlegroups.com?utm_medium=email&utm_source=footer>.

Andréas Kühne

unread,
Oct 6, 2019, 12:24:18 PM10/6/19
to django...@googlegroups.com
Hi again,

I think you are a bit confused about the difference between django and a php framework. In PHP all pages are php files - and PHP has the stupid preference to try to run everything, even if there is an error (except when you have a syntax error - that will also break your php site). What you referred to in your first question was a syntax error in a python file. That doesn't compile and therefore runserver won't work. Like I said earlier - these types of errors halt the runserver. However running a django application in production, you will be running something else for serving the python files. So all files that are used for startup, need to have correct syntax. But if a view file that doesn't get run on startup doesn't have that, only the process serving the request will stop and not the entire server. 

Mostly when you run a django application you will get an error from a view file or from a html template. This will not break the entire application, but only the view for the user requesting invalid data.

So it will not break. Don't forget that Youtube and Instagram are running on django - they are developed by several thousands of developers, and it works perfectly.

Andréas


To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/807cd268-aecc-45db-84b9-6d3371bb5d49%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages