Tuesday, June 28, 2016

Re: AUTH_PASSWORD_VALIDATORS not used when creating new users?

Even when I use User.objects.create_user() I am still not required to use a strong password. Considering that createsuperuser and changepassword are management commands, it seems odd that require a password that conforms with AUTH_PASSWORD_VALIDATORS there, but not with a function I would use in production code.

On Tuesday, June 28, 2016 at 10:00:06 PM UTC-4, Tim Graham wrote:
Validation happens in the management commands (createsuperuser, changepassword) as well as the user creation forms. We assume that if you're creating a user using the command line, you know what you're doing. If you want to open a documentation ticket, we could add a note about this.

On Monday, June 27, 2016 at 9:29:56 PM UTC-4, Farhan Khan wrote:
Hi all,

I set the AUTH_PASSWORD_VALIDATORS variable to the standard set here: https://docs.djangoproject.com/en/1.9/topics/auth/passwords/#enabling-password-validation. When I use the `createsuperuser` function in manage.py, my password must conform to the validators. But when I use User.objects.create_user() or the user.set_password() methods, the AUTH_PASSWORD_VALIDATORS is not used. I can literally set my password to 'a' and its accepted.

Is this a bug? It seems like the validators should be used when creating a new user or setting the password.
Is is there an alternative method to validate the password prior to creation?

I am using Django 1.9.7

Thanks!
---
Farhan Khan
PGP Fingerprint: 4A78 F071 5CB6 E771 B8D6 3910 F371 FE22 3B20 B21B

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e44a9871-0aeb-4cc4-96ec-a9866e6d6f74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Serving static files

The concerns about needing a separate server are likely overblown. In particular, Whitenoise is a popular solution for static file serving using Python. See its FAQ: http://whitenoise.evans.io/en/stable/#isn-t-serving-static-files-from-python-horribly-inefficient

On Tuesday, June 28, 2016 at 9:59:26 PM UTC-4, Ankush Thakur wrote:
Thanks but I'm afraid I wasn't able to grasp the point of that article. Could you break it down for me, please? 

~~Ankush

On Monday, June 27, 2016 at 10:07:43 PM UTC+5:30, ludovic coues wrote:
It's not that the framework will come to an halt. It's that a server
serving static file directly would be an order of magnitude faster.

https://unix4lyfe.org/time/hn.html is a nice article on how server
react to heavy load when serving static file.

2016-06-27 18:26 GMT+02:00 Ankush Thakur <ankush....@gmail.com>:
> I keep hearing in the docs and in tutorials that frameworks are horrible
> when it comes to service static files. In production, also, one needs to set
> up another dedicated server to serve static files.
>
> I'm wondering why. What is so special about serving static files that a
> framework comes to a halt, even though the same framework can happily serve
> thousands of requests per hour?
>
> Regards,
> Ankush Thakur
>
> --
> 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/CALX%3DrKLw_nMxZz7xeC0N%3D5Zwn0Q0eZnV_GFGkdwmP-%3DabtPMUQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c2f1699e-9bfc-43f4-a858-a54a256cec1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How by help Python generate random image with vector figures.

This probably isn't the best place to ask since it isn't Django related.

On Tuesday, June 28, 2016 at 6:16:20 AM UTC-4, Seti Volkylany wrote:
I need a pure python module from PyPI without additional packages on my OS.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/610ae409-f8f3-48ad-8855-cd31bfa13f2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: AUTH_PASSWORD_VALIDATORS not used when creating new users?

Validation happens in the management commands (createsuperuser, changepassword) as well as the user creation forms. We assume that if you're creating a user using the command line, you know what you're doing. If you want to open a documentation ticket, we could add a note about this.

On Monday, June 27, 2016 at 9:29:56 PM UTC-4, Farhan Khan wrote:
Hi all,

I set the AUTH_PASSWORD_VALIDATORS variable to the standard set here: https://docs.djangoproject.com/en/1.9/topics/auth/passwords/#enabling-password-validation. When I use the `createsuperuser` function in manage.py, my password must conform to the validators. But when I use User.objects.create_user() or the user.set_password() methods, the AUTH_PASSWORD_VALIDATORS is not used. I can literally set my password to 'a' and its accepted.

Is this a bug? It seems like the validators should be used when creating a new user or setting the password.
Is is there an alternative method to validate the password prior to creation?

I am using Django 1.9.7

Thanks!
---
Farhan Khan
PGP Fingerprint: 4A78 F071 5CB6 E771 B8D6 3910 F371 FE22 3B20 B21B

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e7320f01-21db-417c-b6c0-b5e0335d0508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Serving static files

Thanks but I'm afraid I wasn't able to grasp the point of that article. Could you break it down for me, please? 

~~Ankush

On Monday, June 27, 2016 at 10:07:43 PM UTC+5:30, ludovic coues wrote:
It's not that the framework will come to an halt. It's that a server
serving static file directly would be an order of magnitude faster.

https://unix4lyfe.org/time/hn.html is a nice article on how server
react to heavy load when serving static file.

2016-06-27 18:26 GMT+02:00 Ankush Thakur <ankush....@gmail.com>:
> I keep hearing in the docs and in tutorials that frameworks are horrible
> when it comes to service static files. In production, also, one needs to set
> up another dedicated server to serve static files.
>
> I'm wondering why. What is so special about serving static files that a
> framework comes to a halt, even though the same framework can happily serve
> thousands of requests per hour?
>
> Regards,
> Ankush Thakur
>
> --
> 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/CALX%3DrKLw_nMxZz7xeC0N%3D5Zwn0Q0eZnV_GFGkdwmP-%3DabtPMUQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4ee672fa-f6d8-4882-8420-ac57032e4904%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How to use password_change function from django.contrib.auth.views

You need a url() with name='password_change_done' -- instead you wrote 'change_password_done'.

On Monday, June 27, 2016 at 11:39:23 AM UTC-4, Juan Sebastian Avila Rodriguez wrote:
I tried to implement the password_change view but is not working. I only add the code below to the urls.py:

from django.contrib.auth import views as auth_views
...
url(          r'^change-password/$',          auth_views.password_change,
        name='change_password'
    ),
url(
        r'^change-password/done$',
        auth_views.password_change_done,
        name='change_password_done'
),
...

In the base.html template. Add the <a> tag with href="{% url 'change_password' %}". When I click on it. I get this error:

NoReverseMatch at /change-password/  Reverse for 'password_change_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Thank you for your 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-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/f1e91da0-4b8e-49ca-ac61-49259fb53e25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Confused about this aggregation example from the docs

'book' (the model name) is the default value of ForeignKey.related_name for the publisher field on Book.

class Book(models.Model):
    publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)

https://docs.djangoproject.com/en/stable/ref/models/fields/#django.db.models.ForeignKey.related_name

On Saturday, June 25, 2016 at 10:11:44 AM UTC-4, Ankush Thakur wrote:
On this page https://docs.djangoproject.com/en/1.9/topics/db/aggregation/ we have the following example of aggregation:

# All the following queries involve traversing the Book<->Publisher
# foreign key relationship backwards.

# Each publisher, each with a count of books as a "num_books" attribute.
>>> from django.db.models import Count
>>> pubs = Publisher.objects.annotate(num_books=Count('book'))
>>> pubs
[<Publisher BaloneyPress>, <Publisher SalamiPress>, ...]
>>> pubs[0].num_books
73

​The models used in this are as follows: 

from django.db import models

class Author(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()

class Publisher(models.Model):
    name = models.CharField(max_length=300)
    num_awards = models.IntegerField()

class Book(models.Model):
    name = models.CharField(max_length=300)
    pages = models.IntegerField()
    price = models.DecimalField(max_digits=10, decimal_places=2)
    rating = models.FloatField()
    authors = models.ManyToManyField(Author)
    publisher = models.ForeignKey(Publisher)
    pubdate = models.DateField()

class Store(models.Model):
    name = models.CharField(max_length=300)
    books = models.ManyToManyField(Book)
    registered_users = models.PositiveIntegerField()

My question is: How come something like "Publisher.objects.annotate(num_books=Count('book'))" work? The name "book" is not defined as a reverse relationship (I think it should be accessible by "book_set"). 

How is this traversal working?

Regards,
Ankush Thakur

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ee2d7cb-4247-45e0-9bb0-e5cb8013b04c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.