Sunday, March 1, 2015

Re: Different between Object-save and form-save

Both save the user to the database, but "user_form.save()" leaves the user password in plain text (which won't work when the user tries to login later) so the password must be set correctly (user.set_password(user.password)) and then the user has to be saved again for the correct (hashed) password to be stored.

On Sun, Mar 1, 2015 at 12:57 PM, ADEWALE ADISA <solixzsystem@gmail.com> wrote:

Hi guys, pls help with little explanation on the extract below from tango tutorial. In the code, they call user_form().save() to save into database. Then latter call user.save(). Pls what's the different between the two ? Where did user.save() save to ?

from rango.forms import UserForm, UserProfileForm

def register(request):

    # A boolean value for telling the template whether the registration was successful.
    # Set to False initially. Code changes value to True when registration succeeds.
    registered = False

    # If it's a HTTP POST, we're interested in processing form data.
    if request.method == 'POST':
        # Attempt to grab information from the raw form information.
        # Note that we make use of both UserForm and UserProfileForm.
        user_form = UserForm(data=request.POST)
        profile_form = UserProfileForm(data=request.POST)

        # If the two forms are valid...
        if user_form.is_valid() and profile_form.is_valid():
            # Save the user's form data to the database.
            user = user_form.save()

            # Now we hash the password with the set_password method.
            # Once hashed, we can update the user object.
            user.set_password(user.password)
            user.save()

            # Now sort out the UserProfile instance.
            # Since we need to set the user attribute ourselves, we set commit=False.
            # This delays saving the model until we're ready to avoid integrity problems.
            profile = profile_form.save(commit=False)
            profile.user = user

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei34SRTYAxP4oaSExM2Nt-tjym4PXP2q2xuSgkkH8TV_UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Python / Django slow ? Deciding my next technological stack

if you have so many uploads that all of yours workers are busy, so maybe you need more workers...

On Sun, Mar 1, 2015 at 5:38 PM, Vijay Khemlani <vkhemlan@gmail.com> wrote:
The rest of the uWSGI / gunicorn / whatever workers are available to handle the other requests.

If there are so many uploads that all of the workers are busy then there are ways to upload files directly to Amazon S3 (for example) from the browser without going through your server.

On Sun, Mar 1, 2015 at 12:16 PM, Benj <webkoros@gmail.com> wrote:
Just a little questions guys: when a user upload a file to server, and that file is a litte big and takes 3 seconds to be uploaded... what's the proper way, if possible, not to block the entire system for these 3 seconds so the server can serve other users while the upload is taking place. Should this be done in code with things like asyncio, or server with uwsgi workers ?

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
On Tue, Feb 24, 2015 at 11:30 PM, Benj <webk...@gmail.com> wrote:
> Hi,
> i'm going to invest lots of time and energy in various web projects (mostly
> community web sites), and want to pick up a language / framework and invest
> heavily on it.
> I've spent a lot of time evaluating the various options, and narrowed my
> choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>
> I'm more attracted to Python / Django combo, because of the Python language,
> and high level framework Django. I really want to use these.
> My only concern is speed. I read that Python can't run concurrent tasks, is
> this true ? So a multi-processor with hyperthreads won't benefit the stack
> and even slow it down ?
> I have no clue how this translates in reality, but should I expect noticable
> performance difference on a same server, shall I use Python / Django than if
> I had C Sharp Asp.net ?
> I don't want to invest lots of time and efforts only to discover in the end
> that the site is slow.
> You that have real world experiences with running sites, what are your
> conclusions ?
>
>
> I expect sites to be medium traffic: could be handled by a good dedicated
> server or average cloud ressources.
>
> Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

Cheers

Tom

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei2bnQi0FxpMTtvZ1OAP%3D_Q2k0XJze06mv7vCKLc%3D%2BTikQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFWa6tK0xeAe5mHdF_A561Q1-4SGsw1pD34iPEKwY-RVs3%3D6KA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Different between Object-save and form-save

Hi guys, pls help with little explanation on the extract below from tango tutorial. In the code, they call user_form().save() to save into database. Then latter call user.save(). Pls what's the different between the two ? Where did user.save() save to ?

from rango.forms import UserForm, UserProfileForm

def register(request):

    # A boolean value for telling the template whether the registration was successful.
    # Set to False initially. Code changes value to True when registration succeeds.
    registered = False

    # If it's a HTTP POST, we're interested in processing form data.
    if request.method == 'POST':
        # Attempt to grab information from the raw form information.
        # Note that we make use of both UserForm and UserProfileForm.
        user_form = UserForm(data=request.POST)
        profile_form = UserProfileForm(data=request.POST)

        # If the two forms are valid...
        if user_form.is_valid() and profile_form.is_valid():
            # Save the user's form data to the database.
            user = user_form.save()

            # Now we hash the password with the set_password method.
            # Once hashed, we can update the user object.
            user.set_password(user.password)
            user.save()

            # Now sort out the UserProfile instance.
            # Since we need to set the user attribute ourselves, we set commit=False.
            # This delays saving the model until we're ready to avoid integrity problems.
            profile = profile_form.save(commit=False)
            profile.user = user

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Python / Django slow ? Deciding my next technological stack

The rest of the uWSGI / gunicorn / whatever workers are available to handle the other requests.

If there are so many uploads that all of the workers are busy then there are ways to upload files directly to Amazon S3 (for example) from the browser without going through your server.

On Sun, Mar 1, 2015 at 12:16 PM, Benj <webkoros@gmail.com> wrote:
Just a little questions guys: when a user upload a file to server, and that file is a litte big and takes 3 seconds to be uploaded... what's the proper way, if possible, not to block the entire system for these 3 seconds so the server can serve other users while the upload is taking place. Should this be done in code with things like asyncio, or server with uwsgi workers ?

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
On Tue, Feb 24, 2015 at 11:30 PM, Benj <webk...@gmail.com> wrote:
> Hi,
> i'm going to invest lots of time and energy in various web projects (mostly
> community web sites), and want to pick up a language / framework and invest
> heavily on it.
> I've spent a lot of time evaluating the various options, and narrowed my
> choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>
> I'm more attracted to Python / Django combo, because of the Python language,
> and high level framework Django. I really want to use these.
> My only concern is speed. I read that Python can't run concurrent tasks, is
> this true ? So a multi-processor with hyperthreads won't benefit the stack
> and even slow it down ?
> I have no clue how this translates in reality, but should I expect noticable
> performance difference on a same server, shall I use Python / Django than if
> I had C Sharp Asp.net ?
> I don't want to invest lots of time and efforts only to discover in the end
> that the site is slow.
> You that have real world experiences with running sites, what are your
> conclusions ?
>
>
> I expect sites to be medium traffic: could be handled by a good dedicated
> server or average cloud ressources.
>
> Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

Cheers

Tom

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei2bnQi0FxpMTtvZ1OAP%3D_Q2k0XJze06mv7vCKLc%3D%2BTikQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Python / Django slow ? Deciding my next technological stack

Just a little questions guys: when a user upload a file to server, and that file is a litte big and takes 3 seconds to be uploaded... what's the proper way, if possible, not to block the entire system for these 3 seconds so the server can serve other users while the upload is taking place. Should this be done in code with things like asyncio, or server with uwsgi workers ?

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
On Tue, Feb 24, 2015 at 11:30 PM, Benj <webk...@gmail.com> wrote:
> Hi,
> i'm going to invest lots of time and energy in various web projects (mostly
> community web sites), and want to pick up a language / framework and invest
> heavily on it.
> I've spent a lot of time evaluating the various options, and narrowed my
> choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>
> I'm more attracted to Python / Django combo, because of the Python language,
> and high level framework Django. I really want to use these.
> My only concern is speed. I read that Python can't run concurrent tasks, is
> this true ? So a multi-processor with hyperthreads won't benefit the stack
> and even slow it down ?
> I have no clue how this translates in reality, but should I expect noticable
> performance difference on a same server, shall I use Python / Django than if
> I had C Sharp Asp.net ?
> I don't want to invest lots of time and efforts only to discover in the end
> that the site is slow.
> You that have real world experiences with running sites, what are your
> conclusions ?
>
>
> I expect sites to be medium traffic: could be handled by a good dedicated
> server or average cloud ressources.
>
> Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

Cheers

Tom

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Python / Django slow ? Deciding my next technological stack

Just a little questions guys: when a user upload a file to server, and that file is a litte big and takes 3 seconds to be uploaded... what's the proper way, if possible, not to block the entire system for these 3 seconds so the server can serve other users while the upload is taking place.

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
On Tue, Feb 24, 2015 at 11:30 PM, Benj <webk...@gmail.com> wrote:
> Hi,
> i'm going to invest lots of time and energy in various web projects (mostly
> community web sites), and want to pick up a language / framework and invest
> heavily on it.
> I've spent a lot of time evaluating the various options, and narrowed my
> choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>
> I'm more attracted to Python / Django combo, because of the Python language,
> and high level framework Django. I really want to use these.
> My only concern is speed. I read that Python can't run concurrent tasks, is
> this true ? So a multi-processor with hyperthreads won't benefit the stack
> and even slow it down ?
> I have no clue how this translates in reality, but should I expect noticable
> performance difference on a same server, shall I use Python / Django than if
> I had C Sharp Asp.net ?
> I don't want to invest lots of time and efforts only to discover in the end
> that the site is slow.
> You that have real world experiences with running sites, what are your
> conclusions ?
>
>
> I expect sites to be medium traffic: could be handled by a good dedicated
> server or average cloud ressources.
>
> Benj

Unless you are producing web-scale sites (gmail, ebay, instagram), the
speed of your website will depend more upon what you do with a
framework than the framework you choose.

If you are producing web-scale sites, then whatever framework you
choose you will need to make the right design decisions and/or
compromises.

Even with the best framework in the world, if you design the
architecture of a website poorly, the website will be slow.

Even less important than the choice of framework is the choice of
hosting container for your framework. If you ever get to the point
where the speed of your wsgi container is the thing that is holding
you back, well done, now you should spend some time looking at it.
Until then, use the way that is easiest for you.

Cheers

Tom

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e783c1f-2c44-4110-8dd9-933b489ac9ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Free Django Video Tutorials

Hi All

Just a quick shout out to all you guys learning Django!

I have a 11+ hrs FREE tutorial series to get you started here: https://mikesdjangotutorials.co.uk

Check it out, there stuff there for beginners and advanced!

Mike

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8683e896-9557-4647-9ffc-68251627228a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.