@@ -30,8 +30,8 @@ statement to retrieve every row in the USERS table where the
3030 SELECT * FROM USERS WHERE zip_code=94107;
3131
3232
33- The equivalent Django ORM query would instead look like the following Python
34- code:
33+ The equivalent [ Django ORM] ( /django-orm.html ) query would instead look like
34+ the following Python code:
3535
3636 # obtain everyone in the 94107 zip code and assign to users variable
3737 users = Users.objects.filter(zip_code=94107)
@@ -135,7 +135,7 @@ There are numerous ORM implementations written in Python, including
135135
1361361 . [ SQLAlchemy] ( /sqlalchemy.html )
1371371 . [ Peewee] ( /peewee.html )
138- 1 . [ The Django ORM] ( https://docs.djangoproject.com/en/1.8/topics/db/ )
138+ 1 . [ The Django ORM] ( /django-orm.html )
1391391 . [ PonyORM] ( http://ponyorm.com/ )
1401401 . [ SQLObject] ( http://sqlobject.org/ )
141141
@@ -147,8 +147,8 @@ ORMs below.
147147
148148### Django's ORM
149149The [ Django] ( /django.html ) web framework comes with
150- its own built-in object-relational mapping module, generally referred to
151- as "the Django ORM" or "Django's ORM".
150+ [ its own built-in object-relational mapping module] ( /django-orm.html ) ,
151+ generally referred to as "the Django ORM" or "Django's ORM".
152152
153153[ Django's ORM] ( https://docs.djangoproject.com/en/dev/topics/db/ ) works well
154154for simple and medium-complexity database operations. However, there are often
@@ -157,11 +157,10 @@ writing straight SQL or using [SQLAlchemy](http://www.sqlalchemy.org/).
157157
158158It is technically possible to drop down to SQL but it ties the queries to a
159159specific database implementation. The ORM is coupled closely with Django so
160- replacing the default ORM with SQLAlchemy is currently a hack workaround. Note
161- though that some of the Django core committers believe it is only a matter of
162- time before the default ORM is replaced with SQLAlchemy. It will be a large
163- effort to get that working though so it's likely to come in
164- [ Django 1.9 or later] ( https://github.com/mattmakai/fullstackpython.com/issues/48 ) .
160+ replacing the default ORM with SQLAlchemy is currently a hack workaround.
161+ Note though it is possible that swappable ORM backends will be possible
162+ in the future as it is now possible to change the
163+ [ template engine] ( /template-engines.html ) for rendering output in Django.
165164
166165Since the majority of Django projects are tied to the default ORM, it is
167166best to read up on advanced use cases and tools for doing your best work
@@ -270,75 +269,8 @@ pages.
270269
271270
272271### Django ORM resources
273- * [ Django models, encapsulation and data integrity] ( http://www.dabapps.com/blog/django-models-and-encapsulation/ )
274- is a detailed article by Tom Christie on encapsulating Django models for
275- data integrity.
276-
277- * [ Django Debug Toolbar] ( http://django-debug-toolbar.readthedocs.org/en/1.2/ )
278- is a powerful Django ORM database query inspection tool. Highly recommended
279- during development to ensure you're writing reasonable query code.
280- [ Django Silk] ( http://mtford.co.uk/blog/2/ ) is another inspection tool and
281- has capabilities to do more than just SQL inspection.
282-
283- * [ Making a specific Django app faster] ( http://reinout.vanrees.org/weblog/2014/05/06/making-faster.html )
284- is a Django performance blog post with some tips on measuring performance
285- and optimizing based on the measured results.
286-
287- * [ Why I Hate the Django ORM] ( https://speakerdeck.com/alex/why-i-hate-the-django-orm )
288- is Alex Gaynor's overview of the bad designs decisions, some of which he
289- made, while building the Django ORM.
290-
291- * [ Going Beyond Django ORM with Postgres] ( https://speakerdeck.com/craigkerstiens/going-beyond-django-orm-with-postgres )
292- is specific to using PostgreSQL with Django.
293-
294- * [ Migrating a Django app from MySQL to PostgreSQL] ( http://www.calazan.com/migrating-django-app-from-mysql-to-postgresql/ )
295- is a quick look at how to move from MySQL to PostgreSQL. However, my guess
296- is that any Django app that's been running for awhile on one
297- [ relational database] ( /databases.html ) will require a lot more work to
298- port over to another backend even with the power of the ORM.
299-
300- * [ Django Model Descriptors] ( http://blog.kevinastone.com/django-model-descriptors.html )
301- discusses and shows how to incorporate business logic into Django models
302- to reduce complexity from the views and make the code easier to reuse across
303- separate views.
304-
305- * [ Supporting both Django 1.7 and South] ( http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/ )
306- explains the difficulty of supporting Django 1.7 and maintaining South
307- migrations for Django 1.6 then goes into how it can be done.
308-
309- * [ Adding basic search to your Django site] ( https://www.calazan.com/adding-basic-search-to-your-django-site/ )
310- shows how to write generic queries that'll allow you to provide site
311- search via the Django ORM without relying on another tool like
312- ElasticSearch. This is great for small sites before you scale them up with
313- a more robust search engine.
314-
315- * [ How to use Django's Proxy Models] ( https://www.wellfireinteractive.com/blog/using-django-proxy-models )
316- is a solid post on a Django ORM concept that doesn't frequently get a lot
317- of love or explanation.
318-
319- * [ Tightening Django Admin Logins] ( http://tech.marksblogg.com/django-admin-logins.html )
320- shows you how to log authentication failures, create an IP addresses white
321- list and combine fail2ban with the authentication failures list.
322-
323- * [ Django Migrations - a Primer] ( https://realpython.com/blog/python/django-migrations-a-primer/ )
324- takes you through the new migrations system integrated in the Django core as of Django 1.7, looking specifically at a solid workflow that you can use for creating and applying migrations.
325-
326- * [ Django 1.7: Database Migrations Done Right] ( https://markusholtermann.eu/2014/09/django-17-database-migrations-done-right/ )
327- explains why South was not directly integrated into Django, how migrations
328- are built and shows how backwards migrations work.
329-
330- * [ Squashing and optimizing migrations in Django] ( http://www.rkblog.rk.edu.pl/w/p/squashing-and-optimizing-migrations-django/ )
331- shows a simple example with code for how to use the migrations integrated
332- into Django 1.7.
333-
334- * [ Sorting querysets with NULLs in Django] ( https://www.isotoma.com/blog/2015/11/23/sorting-querysets-with-nulls-in-django/ )
335- shows what to do if you're struggling with the common issue of sorting
336- columns that contain NULL values.
337-
338- * [ Best Practices working with Django models in Python] ( http://steelkiwi.com/blog/best-practices-working-django-models-python/ )
339- has a ton of great advice on proper model naming conventions, quirks to
340- avoid with ` ForeignKey ` field relationships, handling IDs and many other
341- edge cases that come up when frequently working with Django's ORM.
272+ A curated list of resources can be found on the dedicated
273+ [ Django ORM resources] ( /django-orm.html ) page.
342274
343275
344276### Pony ORM resources
0 commit comments