News for hackers. Stuff that matters.
Re:My essential django package list by speg on Wednesday October 11, 2017 @09:38AM (#15449623)
Built in everything. Users, auth, admin, ORM.

Flask is the opposite: Bring Your Own Everything. It's not hard to replicate the functionality of Django but there is surely utility in having everything boxed up and ready to go.

Re:My essential django package list by jon_richards on Wednesday October 11, 2017 @11:33AM (#15450558)
Never use the built in user. Always start a project with a custom user extending abstract user.

At some point you'll want to customize the user in some way (like making the username case insensitive), and you don't want to be dealing with migration dependency conflicts when you do.

For some reason the Django team is really against any attempt to fix that. They're almost hostile in their discussion of it.

Re:My essential django package list by thraxil on Wednesday October 11, 2017 @11:49AM (#15450691)
OK. Well, I've been building Django apps since around 2007/2008. More than 50 deployed to production, many still running/maintained. Never once had a problem using the built-in user model. Do you work in some vertical that makes this a particularly common problem for you?
Re:My essential django package list by jastr on Wednesday October 11, 2017 @12:24PM (#15450934)
I don't think the parent comment is saying don't use the built-in user model. The comment is suggesting to sub-class/extend the built-in user model. So you can use much of the built-in functionality and add/change what you'd like, eg. to add a birthday field

There are obviously other ways to do this, perhaps by creating a Profile model that relates to a User.

Re:My essential django package list by jon_richards on Wednesday October 11, 2017 @12:48PM (#15451134)
Yes. Technically you should extend the abstract user model or things get real broken real fast, but that still gives you all the functionality of the built-in user model right out the gate.

The main reason is that if you ever want to change how the username works, it will be a major pain to do if you've been using the built-in user model and already run migrations.

Re:My essential django package list by jon_richards on Wednesday October 11, 2017 @12:42PM (#15451085)
You've never had to extend the user model? I suppose you could just do most extension with a model that has a 1-to-1 with users and use a proxy of the built-in model for the rest, but it seems much simpler to just start out with a user model you can customize easily.
Re:My essential django package list by thraxil on Wednesday October 11, 2017 @01:46PM (#15451606)
I create Profile's that are mapped 1-to-1 to django.contrib.auth.models.User all the time to hold additional fields. I consider that the "orthodox" approach that Django encourages.

I've even implemented "case-insensitive username" a time or two, but done it by overriding some logic in the login view rather than modifying the user model.

Re:My essential django package list by jon_richards on Thursday October 12, 2017 @01:48AM (#15455927)
That seems like a lot of trouble when you can just start out a project with a few lines of code extending abstract user. The case-insensitive username can then just be done by making the username a case-insensitive text field (admittedly only available in Postgres, but that's true for a lot of awesome Django features).

I don't mean to be mean, but your answer reminded me a lot of the last row of this comic: http://www.giantitp.com/comics/oots0050.html

Re:My essential django package list by thraxil on Thursday October 12, 2017 @05:13AM (#15456673)
But you see, I find that overriding the one little bit of view code (literally a couple lines of code) to change the one thing I want changed is by far the simpler approach rather than changing the whole structure of the user model and introducing who knows what kinds of subtle bugs elsewhere. When the requirement for "case-insensitive username" comes in, it's always turned out that all they really mean is "If someone types 'Bob' in the username field rather than 'bob', it should still work". And again, even that has been such a rare thing that I've probably spent more time writing this comment here than implementing it in code, so why overcomplicate it?
Re:My essential django package list by jon_richards on Thursday October 12, 2017 @05:32AM (#15456734)
If you change login and forget to change registration, suddenly "Bob" can't login because "bob" just signed up for the service and your login is now returning 2 users. Django puts username validation on the model field for a reason. It's better to have it all centralized.

The nice part about extending the abstract user from the start is that you can still just use it exactly like you'd use the built in user. There's no difference. It just gives you more options in the future.

It literally only takes 8 lines of code, including imports and a "pass" to do.

Re:My essential django package list by photojosh on Wednesday October 11, 2017 @10:26PM (#15455234)
Heh, wish I'd done this back in 2012 with my app. Admittedly it wasn't as easy to do back then IIRC.

Now one of my to-do-one-day jobs is rolling my UserProfile model back into a custom User subclass... would save a lot of DB queries. :)

Re:My essential django package list by andybak on Wednesday October 11, 2017 @11:04AM (#15450334)
Yes. The joy of reasonable defaults and an opinionated way of working.

Some people loathe that but it frees me to think about the customer's actual problem rather than merely tidying my pencil case.

Re:My essential django package list by philipov on Wednesday October 11, 2017 @09:42AM (#15449653)
Oh, I get it now. Thanks!