From 9dfdcf86befecad3b638df03273719c5ada90a45 Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Tue, 19 Oct 2010 00:11:51 +0000 Subject: [1.2.X] Fixed #14426 -- Removed "mysite" import statements from examples that might teach people "bad habits" in regards to creating reusable apps. Thanks to idahogray for assisting with the patch (and sorry for forgetting the attribution in the patch on trunk). Backport of [14270] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14271 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/intro/overview.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docs/intro') diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt index 0c47e59e14..34572a6c80 100644 --- a/docs/intro/overview.txt +++ b/docs/intro/overview.txt @@ -21,7 +21,8 @@ code. The :doc:`data-model syntax ` offers many rich ways of representing your models -- so far, it's been solving two years' worth of -database-schema problems. Here's a quick example:: +database-schema problems. Here's a quick example, which might be saved in +the file ``mysite/news/models.py``:: class Reporter(models.Model): full_name = models.CharField(max_length=70) @@ -57,7 +58,8 @@ Enjoy the free API With that, you've got a free, and rich, :doc:`Python API ` to access your data. The API is created on the fly, no code generation necessary:: - >>> from mysite.models import Reporter, Article + # Import the models we created from our "news" app + >>> from news.models import Reporter, Article # No reporters are in the system yet. >>> Reporter.objects.all() @@ -177,9 +179,9 @@ example above:: from django.conf.urls.defaults import * urlpatterns = patterns('', - (r'^articles/(\d{4})/$', 'mysite.views.year_archive'), - (r'^articles/(\d{4})/(\d{2})/$', 'mysite.views.month_archive'), - (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'mysite.views.article_detail'), + (r'^articles/(\d{4})/$', 'news.views.year_archive'), + (r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'), + (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'), ) The code above maps URLs, as simple regular expressions, to the location of @@ -195,7 +197,7 @@ is a simple Python function. Each view gets passed a request object -- which contains request metadata -- and the values captured in the regex. For example, if a user requested the URL "/articles/2005/05/39323/", Django -would call the function ``mysite.views.article_detail(request, +would call the function ``news.views.article_detail(request, '2005', '05', '39323')``. Write your views -- cgit v1.3