Ticket #14426: remove_mysite_from_import.2.2.diff

File remove_mysite_from_import.2.2.diff, 8.3 KB (added by Gabriel Hurley, 14 years ago)
  • docs/intro/overview.txt

     
    2121
    2222The :doc:`data-model syntax </topics/db/models>` offers many rich ways of
    2323representing your models -- so far, it's been solving two years' worth of
    24 database-schema problems. Here's a quick example::
     24database-schema problems. Here's a quick example, which might be saved in
     25the file ``mysite/news/models.py``::
    2526
    2627    class Reporter(models.Model):
    2728        full_name = models.CharField(max_length=70)
     
    5758With that, you've got a free, and rich, :doc:`Python API </topics/db/queries>` to
    5859access your data. The API is created on the fly, no code generation necessary::
    5960
    60     >>> from mysite.models import Reporter, Article
     61    # Import the models we created from our "news" app
     62    >>> from news.models import Reporter, Article
    6163
    6264    # No reporters are in the system yet.
    6365    >>> Reporter.objects.all()
     
    177179    from django.conf.urls.defaults import *
    178180
    179181    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'),
    183185    )
    184186
    185187The code above maps URLs, as simple regular expressions, to the location of
     
    195197which contains request metadata -- and the values captured in the regex.
    196198
    197199For example, if a user requested the URL "/articles/2005/05/39323/", Django
    198 would call the function ``mysite.views.article_detail(request,
     200would call the function ``news.views.article_detail(request,
    199201'2005', '05', '39323')``.
    200202
    201203Write your views
  • docs/ref/contrib/formtools/form-wizard.txt

     
    193193arguments when you instantiate the Wizard::
    194194
    195195    from django.conf.urls.defaults import *
    196     from mysite.testapp.forms import ContactForm1, ContactForm2, ContactWizard
     196    from testapp.forms import ContactForm1, ContactForm2, ContactWizard
    197197
    198198    urlpatterns = patterns('',
    199199        (r'^contact/$', ContactWizard([ContactForm1, ContactForm2])),
  • docs/ref/contrib/sitemaps.txt

     
    9595your sitemap class might look::
    9696
    9797    from django.contrib.sitemaps import Sitemap
    98     from mysite.blog.models import Entry
     98    from blog.models import Entry
    9999
    100100    class BlogSitemap(Sitemap):
    101101        changefreq = "never"
     
    242242
    243243    from django.conf.urls.defaults import *
    244244    from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
    245     from mysite.blog.models import Entry
     245    from blog.models import Entry
    246246
    247247    info_dict = {
    248248        'queryset': Entry.objects.all(),
  • docs/topics/db/models.txt

     
    570570import the related model at the top of the model that holds your model. Then,
    571571just refer to the other model class wherever needed. For example::
    572572
    573     from mysite.geography.models import ZipCode
     573    from geography.models import ZipCode
    574574
    575575    class Restaurant(models.Model):
    576576        # ...
  • docs/topics/db/queries.txt

     
    6060
    6161Assuming models live in a file ``mysite/blog/models.py``, here's an example::
    6262
    63     >>> from mysite.blog.models import Blog
     63    >>> from blog.models import Blog
    6464    >>> b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
    6565    >>> b.save()
    6666
     
    9898field; simply assign an object of the right type to the field in question.
    9999This example updates the ``blog`` attribute of an ``Entry`` instance ``entry``::
    100100
    101     >>> from mysite.blog.models import Entry
     101    >>> from blog.models import Entry
    102102    >>> entry = Entry.objects.get(pk=1)
    103103    >>> cheese_blog = Blog.objects.get(name="Cheddar Talk")
    104104    >>> entry.blog = cheese_blog
     
    108108method on the field to add a record to the relation. This example adds the
    109109``Author`` instance ``joe`` to the ``entry`` object::
    110110
    111     >>> from mysite.blog.models import Author
     111    >>> from blog.models import Author
    112112    >>> joe = Author.objects.create(name="Joe")
    113113    >>> entry.authors.add(joe)
    114114
  • docs/topics/generic-views.txt

     
    7272
    7373    from django.conf.urls.defaults import *
    7474    from django.views.generic.simple import direct_to_template
    75     **from mysite.books.views import about_pages**
     75    **from books.views import about_pages**
    7676
    7777    urlpatterns = patterns('',
    7878        ('^about/$', direct_to_template, {
     
    152152
    153153    from django.conf.urls.defaults import *
    154154    from django.views.generic import list_detail
    155     from mysite.books.models import Publisher
     155    from books.models import Publisher
    156156
    157157    publisher_info = {
    158158        "queryset" : Publisher.objects.all(),
     
    251251
    252252.. parsed-literal::
    253253
    254     from mysite.books.models import Publisher, **Book**
     254    from books.models import Publisher, **Book**
    255255
    256256    publisher_info = {
    257257        "queryset" : Publisher.objects.all(),
     
    376376
    377377.. parsed-literal::
    378378
    379     from mysite.books.views import books_by_publisher
     379    from books.views import books_by_publisher
    380380
    381381    urlpatterns = patterns('',
    382382        (r'^publishers/$', list_detail.object_list, publisher_info),
     
    387387
    388388    from django.http import Http404
    389389    from django.views.generic import list_detail
    390     from mysite.books.models import Book, Publisher
     390    from books.models import Book, Publisher
    391391
    392392    def books_by_publisher(request, name):
    393393
     
    447447
    448448.. parsed-literal::
    449449
    450     from mysite.books.views import author_detail
     450    from books.views import author_detail
    451451
    452452    urlpatterns = patterns('',
    453453        #...
     
    457457Then we'd write our wrapper function::
    458458
    459459    import datetime
    460     from mysite.books.models import Author
     460    from books.models import Author
    461461    from django.views.generic import list_detail
    462462    from django.shortcuts import get_object_or_404
    463463
  • docs/topics/http/urls.txt

     
    338338    from django.conf.urls.defaults import *
    339339
    340340    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'),
    344344    )
    345345
    346 In this example, each view has a common prefix -- ``'mysite.news.views'``.
     346In this example, each view has a common prefix -- ``'news.views'``.
    347347Instead of typing that out for each entry in ``urlpatterns``, you can use the
    348348first argument to the ``patterns()`` function to specify a prefix to apply to
    349349each view function.
     
    352352
    353353    from django.conf.urls.defaults import *
    354354
    355     urlpatterns = patterns('mysite.news.views',
     355    urlpatterns = patterns('news.views',
    356356        (r'^articles/(\d{4})/$', 'year_archive'),
    357357        (r'^articles/(\d{4})/(\d{2})/$', 'month_archive'),
    358358        (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'article_detail'),
Back to Top