O'Reilly logo
  • Sean Brady thinks this is interesting:

Then type the following lines:

>>> from django.contrib.auth.models import User
>>> from blog.models import Post
>>> user = User.objects.get(username='admin')
>>> Post.objects.create(title='One more post',
                    slug='one-more-post',
                    body='Post body.',
                    author=user)
>>> post.save()

Let's analyze what this code does. First, we retrieve the user object that has the username admin:

user = User.objects.get(username='admin')

The get() me...

From

Cover of Django By Example

Note

Calling a reference from a foreign field.