Django 1.11 beta 1 released
djangoproject.com
djangoproject.com
I actually recommend youtube video tutorials! Like, some will show you how to make a basic photo hosting site... a blog site, etc. Follow those once or twice, and take it from there. Best of luck!
For someone completely new to Django I'd likely recommend Tango with Django or Hello Web App
I also grew up with Django... since 0.9 but didn't really focus on web development using Django, so for me I had to pick it up again from scratch and quick. Two Scoops is a reference book at best IMO. Use it if you are really comfortable with all the basics of Django and you have done at least 6-12 months of Django regularly.
https://www.youtube.com/watch?v=oT1A1KKf0SI&list=PLxxA5z-8B2...
Beats the cost of a coding academy and has let me go at my own pace.
Also, a shameless plug, I have built a website[2] where I collect the best webdev learning resources, you can find other good Django tutorials there. Funny enough, the website itself is built based on the stuff I've learned from the Django Unchained course =)
Besides that it looks really good!
Highlights:
- better support for creating indexes on your Models with class-based indexes
- widget rendering in forms now uses the templating system instead of python
- Explicit subquery expression support via Subquery and Exists expressions.
- Long Term Support
- Last release to support Python 2
- Server side cursors for postgresI haven't looked at how it's implemented yet, but that sounds like a real godsend.
Very useful when you have an exotic templating engine for example and can't inherit the `registration/login.html` template
This should give a decent performance improvement for many websites.
https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/...
Whoosh is pure python and Haystack is a nice Django-like wrapper around search engines.
* whoosh.readthedocs.io
* haystacksearch.org
I ask because I like the sound of the fulltext search mentioned in another comment, because it would mean I don't have to install a search engine to support that feature. So I'd switch to Postgres and start using Beta 1 pretty soon, if DRF will just-work with it.
Why don't you just try it?
But wait to deploy anything to production until DRF officially supports it (which should be pretty much at launch, DRF should be working with the beta now to ensure compatibility)
Really the most important part of this release, out of all.
This is the time where enterprise companies using Python and Django really need to switch to Python 3. In fact, anyone using Ubuntu 16.04 should already find themselves going "ugh" because they needed Python 2. More reasons to push forward.
It's reasonable that volunteer developers working on an open-source project sunset old versions, and old versions of language runtimes or dependencies. Nobody wants to keep maintaining 5-year-old versions with 12-year-old dependencies when they could use their time to improve the latest version instead.
Django is one of the most "responsible" projects in this regard - having LTS releases that are maintained for three years for free. Some projects even say "you should stick with github master" for fixes :)
But it's cool that Rails has a company providing paid enterprise support after the community support ends. Their pricing is surprisingly cheap - I would expect that if an enterprise has a legacy application that must be kept "stable" and never upgraded, then they would be willing to pay $10k and upwards per month for that privilege.
Django 1.6 (the last version to support Python 2.6) is still getting unofficial support: https://github.com/beanbaginc/django
Building subqueries inside Django gives the rest of Django access to them for things like aggregation or filters.
There is definitely a benefit to querying everything the same way if you can, so that way it's easy to grep where different tables are being accessed. Cuts down on bugs, security issues, etc.
The way I define queries by using a custom language in the form of keyword arguments makes me wonder why I don't just learn SQL instead?
I would much rather do something like:
models.Foo.objects.filter(sql=my_sql_query_str)
Instead of something like: models.Foo.objects.filter(name='bar', parent__siblings__count__lt=3)
And no special abstraction on SQL in the form of special classes. Just a string of SQL that I compose with Python string formatting. SQL isn't scary. I don't see the need to try and hide it.you can already do this. the django ORM has a convenient and expressive API for a lot of very common types of queries, but lets you easily drop back into raw SQL when you have a high complexity query that you want to write by hand.
You can just add various filter conditions to a dictionary, and then unpack them into the filter as kwargs. That way you can still build up the dictionary using if/else blocks or however you would normally build up a SQL query string.
SQL isn't scary, but for simple queries the Django ORM usually a lot more legible if you take the time to learn the DSL.
sounds like an SQL injection waiting to happen
1: https://github.com/kennethreitz/records (same author as Requests)
You have to learn SQL to use the Django ORM anyways; it's required knowledge in order to be able to wield the higher level abstraction effectively. However, the way you write a lot of these things in SQL is substantially more verbose and harder to compose.
Could you give an example of something that's hard to compose with SQL? I'm sure ORMs have their advantages, I just want to understand how much benefit I could get from using one.
Book.objects.filter(author__address__country='GB')
Rather than having to manage the joins with the author and address tables yourself.For example, in SQL if I wanted to return records where an records could be found in both tables, I would use an inner join, whereas if I wanted to return all records from 'author' and any related information from 'address' (and return NULL if a suitable address entry couldn't be found) I could use a left join. Does the ORM you have in mind give you that flexibility?
It's probably worth mentioning that some SQL tools will suggest fields that can be joined on, if this is a concern.
Post.objects.prefetch_related('author__company')
Often I want to avoid joins on big tables but still need to prefetch related fields on the objects I'm fetching. Example above fetches all the authors for the returned post, and then fetches all their companies. That's two additional fetches I don't have to write. published_posts = Post.objects.filter(publish_date__gte=now())
post_count = published_posts.count()
You can't just append a COUNT to an SQL query, you'd have to write two queries, or one query that returned both. The above code produces two different queries, so it's much more composable.I use it for tacking on extra filtering terms as well:
if category:
published_posts = published_posts.filter(category=category)SELECT published_posts, COUNT(published_posts) FROM Table1 WHERE publish_date > '2017-02-20' GROUP BY published_posts
https://docs.djangoproject.com/en/1.10/ref/models/querysets/...
You write your query as a string template, and then jinjasql interpolates the variables and provides the bind parameters. Makes it easy to maintain complex queries.
Admittedly I rarely have to deal with the need for highly performant database code. But one could argue that performance problems are often better handled via caching or denormalisation (which really boil down to the same thing) than by clever work on the db side.