Ticket #14426: remove_mysite_from_import.2.2.diff
File remove_mysite_from_import.2.2.diff, 8.3 KB (added by , 14 years ago) |
---|
-
docs/intro/overview.txt
21 21 22 22 The :doc:`data-model syntax </topics/db/models>` offers many rich ways of 23 23 representing your models -- so far, it's been solving two years' worth of 24 database-schema problems. Here's a quick example:: 24 database-schema problems. Here's a quick example, which might be saved in 25 the file ``mysite/news/models.py``:: 25 26 26 27 class Reporter(models.Model): 27 28 full_name = models.CharField(max_length=70) … … 57 58 With that, you've got a free, and rich, :doc:`Python API </topics/db/queries>` to 58 59 access your data. The API is created on the fly, no code generation necessary:: 59 60 60 >>> from mysite.models import Reporter, Article 61 # Import the models we created from our "news" app 62 >>> from news.models import Reporter, Article 61 63 62 64 # No reporters are in the system yet. 63 65 >>> Reporter.objects.all() … … 177 179 from django.conf.urls.defaults import * 178 180 179 181 urlpatterns = patterns('', 180 (r'^articles/(\d{4})/$', ' mysite.views.year_archive'),181 (r'^articles/(\d{4})/(\d{2})/$', ' mysite.views.month_archive'),182 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', ' mysite.views.article_detail'),182 (r'^articles/(\d{4})/$', 'news.views.year_archive'), 183 (r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'), 184 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'), 183 185 ) 184 186 185 187 The code above maps URLs, as simple regular expressions, to the location of … … 195 197 which contains request metadata -- and the values captured in the regex. 196 198 197 199 For example, if a user requested the URL "/articles/2005/05/39323/", Django 198 would call the function `` mysite.views.article_detail(request,200 would call the function ``news.views.article_detail(request, 199 201 '2005', '05', '39323')``. 200 202 201 203 Write your views -
docs/ref/contrib/formtools/form-wizard.txt
193 193 arguments when you instantiate the Wizard:: 194 194 195 195 from django.conf.urls.defaults import * 196 from mysite.testapp.forms import ContactForm1, ContactForm2, ContactWizard196 from testapp.forms import ContactForm1, ContactForm2, ContactWizard 197 197 198 198 urlpatterns = patterns('', 199 199 (r'^contact/$', ContactWizard([ContactForm1, ContactForm2])), -
docs/ref/contrib/sitemaps.txt
95 95 your sitemap class might look:: 96 96 97 97 from django.contrib.sitemaps import Sitemap 98 from mysite.blog.models import Entry98 from blog.models import Entry 99 99 100 100 class BlogSitemap(Sitemap): 101 101 changefreq = "never" … … 242 242 243 243 from django.conf.urls.defaults import * 244 244 from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap 245 from mysite.blog.models import Entry245 from blog.models import Entry 246 246 247 247 info_dict = { 248 248 'queryset': Entry.objects.all(), -
docs/topics/db/models.txt
570 570 import the related model at the top of the model that holds your model. Then, 571 571 just refer to the other model class wherever needed. For example:: 572 572 573 from mysite.geography.models import ZipCode573 from geography.models import ZipCode 574 574 575 575 class Restaurant(models.Model): 576 576 # ... -
docs/topics/db/queries.txt
60 60 61 61 Assuming models live in a file ``mysite/blog/models.py``, here's an example:: 62 62 63 >>> from mysite.blog.models import Blog63 >>> from blog.models import Blog 64 64 >>> b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.') 65 65 >>> b.save() 66 66 … … 98 98 field; simply assign an object of the right type to the field in question. 99 99 This example updates the ``blog`` attribute of an ``Entry`` instance ``entry``:: 100 100 101 >>> from mysite.blog.models import Entry101 >>> from blog.models import Entry 102 102 >>> entry = Entry.objects.get(pk=1) 103 103 >>> cheese_blog = Blog.objects.get(name="Cheddar Talk") 104 104 >>> entry.blog = cheese_blog … … 108 108 method on the field to add a record to the relation. This example adds the 109 109 ``Author`` instance ``joe`` to the ``entry`` object:: 110 110 111 >>> from mysite.blog.models import Author111 >>> from blog.models import Author 112 112 >>> joe = Author.objects.create(name="Joe") 113 113 >>> entry.authors.add(joe) 114 114 -
docs/topics/generic-views.txt
72 72 73 73 from django.conf.urls.defaults import * 74 74 from django.views.generic.simple import direct_to_template 75 **from mysite.books.views import about_pages**75 **from books.views import about_pages** 76 76 77 77 urlpatterns = patterns('', 78 78 ('^about/$', direct_to_template, { … … 152 152 153 153 from django.conf.urls.defaults import * 154 154 from django.views.generic import list_detail 155 from mysite.books.models import Publisher155 from books.models import Publisher 156 156 157 157 publisher_info = { 158 158 "queryset" : Publisher.objects.all(), … … 251 251 252 252 .. parsed-literal:: 253 253 254 from mysite.books.models import Publisher, **Book**254 from books.models import Publisher, **Book** 255 255 256 256 publisher_info = { 257 257 "queryset" : Publisher.objects.all(), … … 376 376 377 377 .. parsed-literal:: 378 378 379 from mysite.books.views import books_by_publisher379 from books.views import books_by_publisher 380 380 381 381 urlpatterns = patterns('', 382 382 (r'^publishers/$', list_detail.object_list, publisher_info), … … 387 387 388 388 from django.http import Http404 389 389 from django.views.generic import list_detail 390 from mysite.books.models import Book, Publisher390 from books.models import Book, Publisher 391 391 392 392 def books_by_publisher(request, name): 393 393 … … 447 447 448 448 .. parsed-literal:: 449 449 450 from mysite.books.views import author_detail450 from books.views import author_detail 451 451 452 452 urlpatterns = patterns('', 453 453 #... … … 457 457 Then we'd write our wrapper function:: 458 458 459 459 import datetime 460 from mysite.books.models import Author460 from books.models import Author 461 461 from django.views.generic import list_detail 462 462 from django.shortcuts import get_object_or_404 463 463 -
docs/topics/http/urls.txt
338 338 from django.conf.urls.defaults import * 339 339 340 340 urlpatterns = patterns('', 341 (r'^articles/(\d{4})/$', ' mysite.news.views.year_archive'),342 (r'^articles/(\d{4})/(\d{2})/$', ' mysite.news.views.month_archive'),343 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', ' mysite.news.views.article_detail'),341 (r'^articles/(\d{4})/$', 'news.views.year_archive'), 342 (r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'), 343 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'), 344 344 ) 345 345 346 In this example, each view has a common prefix -- ``' mysite.news.views'``.346 In this example, each view has a common prefix -- ``'news.views'``. 347 347 Instead of typing that out for each entry in ``urlpatterns``, you can use the 348 348 first argument to the ``patterns()`` function to specify a prefix to apply to 349 349 each view function. … … 352 352 353 353 from django.conf.urls.defaults import * 354 354 355 urlpatterns = patterns(' mysite.news.views',355 urlpatterns = patterns('news.views', 356 356 (r'^articles/(\d{4})/$', 'year_archive'), 357 357 (r'^articles/(\d{4})/(\d{2})/$', 'month_archive'), 358 358 (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'article_detail'),