Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #34140 -- Format python code blocks in documentation files under docs/releases #16487

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/ref/urlresolvers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ If the URL accepts arguments, you may pass them in ``args``. For example::
def myview(request):
return HttpResponseRedirect(reverse('arch-summary', args=[1945]))

You can also pass ``kwargs`` instead of ``args``. For example::
You can also pass ``kwargs`` instead of ``args``. For example:

.. code-block:: pycon

>>> reverse('admin:app_list', kwargs={'app_label': 'auth'})
'/admin/auth/'
Expand Down Expand Up @@ -65,7 +67,9 @@ use for reversing. By default, the root URLconf for the current thread is used.
.. note::

The string returned by ``reverse()`` is already
:ref:`urlquoted <uri-and-iri-handling>`. For example::
:ref:`urlquoted <uri-and-iri-handling>`. For example:

.. code-block:: pycon

>>> reverse('cities', args=['Orléans'])
'.../Orl%C3%A9ans/'
Expand Down
22 changes: 8 additions & 14 deletions docs/releases/0.96.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ slashes one level.
For example, this used to work::

# Find text containing a single backslash
MyModel.objects.filter(text__contains='\\\\')
MyModel.objects.filter(text__contains="\\\\")

The above is now incorrect, and should be rewritten as::

# Find text containing a single backslash
MyModel.objects.filter(text__contains='\\')
MyModel.objects.filter(text__contains="\\")

Removed ENABLE_PSYCO setting
----------------------------
Expand Down Expand Up @@ -145,8 +145,8 @@ There are three elements to this transition:
rushing to fix your code after the fact. Just change your
import statements like this::

from django import forms # 0.95-style
from django import oldforms as forms # 0.96-style
from django import forms # 0.95-style
from django import oldforms as forms # 0.96-style

* The next official release of Django will move the current
``django.newforms`` to ``django.forms``. This will be a
Expand All @@ -173,18 +173,14 @@ natural use of URLconfs. For example, this URLconf::

from django.conf.urls.defaults import *

urlpatterns = patterns('',
('^myview/$', 'mysite.myapp.views.myview')
)
urlpatterns = patterns("", ("^myview/$", "mysite.myapp.views.myview"))

can now be rewritten as::

from django.conf.urls.defaults import *
from mysite.myapp.views import myview

urlpatterns = patterns('',
('^myview/$', myview)
)
urlpatterns = patterns("", ("^myview/$", myview))

One useful application of this can be seen when using decorators; this
change allows you to apply decorators to views *in your
Expand All @@ -197,12 +193,10 @@ easily::
from mysite.myapp.models import MyModel

info = {
"queryset" : MyModel.objects.all(),
"queryset": MyModel.objects.all(),
}

urlpatterns = patterns('',
('^myview/$', login_required(object_list), info)
)
urlpatterns = patterns("", ("^myview/$", login_required(object_list), info))

Note that both syntaxes (strings and callables) are valid, and will continue to
be valid for the foreseeable future.
Expand Down
68 changes: 38 additions & 30 deletions docs/releases/1.0-porting-guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ Old (0.96) ``models.py``::
class Author(models.Model):
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)
slug = models.CharField(maxlength=60, prepopulate_from=('first_name', 'last_name'))
slug = models.CharField(maxlength=60, prepopulate_from=("first_name", "last_name"))

class Admin:
list_display = ['first_name', 'last_name']
list_display = ["first_name", "last_name"]

def __str__(self):
return '%s %s' % (self.first_name, self.last_name)
return "%s %s" % (self.first_name, self.last_name)

New (1.0) ``models.py``::

Expand All @@ -108,18 +108,18 @@ New (1.0) ``models.py``::
slug = models.CharField(max_length=60)

def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)
return "%s %s" % (self.first_name, self.last_name)

New (1.0) ``admin.py``::

from django.contrib import admin
from models import Author


class AuthorAdmin(admin.ModelAdmin):
list_display = ['first_name', 'last_name']
prepopulated_fields = {
'slug': ('first_name', 'last_name')
}
list_display = ["first_name", "last_name"]
prepopulated_fields = {"slug": ("first_name", "last_name")}


admin.site.register(Author, AuthorAdmin)

Expand Down Expand Up @@ -149,6 +149,7 @@ Old (0.96)::
class Parent(models.Model):
...


class Child(models.Model):
parent = models.ForeignKey(Parent, edit_inline=models.STACKED, num_in_admin=3)

Expand All @@ -159,10 +160,12 @@ New (1.0)::
model = Child
extra = 3


class ParentAdmin(admin.ModelAdmin):
model = Parent
inlines = [ChildInline]


admin.site.register(Parent, ParentAdmin)

See :ref:`admin-inlines` for more details.
Expand All @@ -179,29 +182,29 @@ Old (0.96)::
...

class Admin:
fields = (
(None, {'fields': ('foo','bar')}),
)
fields = ((None, {"fields": ("foo", "bar")}),)


class ModelTwo(models.Model):
...

class Admin:
fields = (
('group1', {'fields': ('foo','bar'), 'classes': 'collapse'}),
('group2', {'fields': ('spam','eggs'), 'classes': 'collapse wide'}),
("group1", {"fields": ("foo", "bar"), "classes": "collapse"}),
("group2", {"fields": ("spam", "eggs"), "classes": "collapse wide"}),
)


New (1.0)::

class ModelOneAdmin(admin.ModelAdmin):
fields = ('foo', 'bar')
fields = ("foo", "bar")


class ModelTwoAdmin(admin.ModelAdmin):
fieldsets = (
('group1', {'fields': ('foo','bar'), 'classes': 'collapse'}),
('group2', {'fields': ('spam','eggs'), 'classes': 'collapse wide'}),
("group1", {"fields": ("foo", "bar"), "classes": "collapse"}),
("group2", {"fields": ("spam", "eggs"), "classes": "collapse wide"}),
)


Expand All @@ -227,9 +230,9 @@ Old (0.96) ``urls.py``::

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),

urlpatterns = patterns(
"",
(r"^admin/", include("django.contrib.admin.urls")),
# ... the rest of your URLs here ...
)

Expand All @@ -239,11 +242,12 @@ New (1.0) ``urls.py``::

# The next two lines enable the admin and load each admin.py file:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),
admin.autodiscover()

urlpatterns = patterns(
"",
(r"^admin/(.*)", admin.site.root),
# ... the rest of your URLs here ...
)

Expand Down Expand Up @@ -284,7 +288,7 @@ syntax no longer works.
Thus, in a view like::

def my_view(request):
f = request.FILES['file_field_name']
f = request.FILES["file_field_name"]
...

...you'd need to make the following changes:
Expand Down Expand Up @@ -465,12 +469,12 @@ it is assumed you deliberately wanted to catch that pattern.
For most people, this won't require any changes. Some people, though, have URL
patterns that look like this::

r'/some_prefix/(.*)$'
r"/some_prefix/(.*)$"

Previously, those patterns would have been redirected to have a trailing
slash. If you always want a slash on such URLs, rewrite the pattern as::

r'/some_prefix/(.*/)$'
r"/some_prefix/(.*/)$"

Smaller model changes
---------------------
Expand Down Expand Up @@ -513,6 +517,7 @@ New (1.0)::

import datetime


class Article(models.Model):
title = models.CharField(max_length=100)
published = models.DateField(default=datetime.datetime.now)
Expand Down Expand Up @@ -649,13 +654,14 @@ Testing
Old (0.96)::

from django.test import Client

c = Client()
c.login('/path/to/login','myuser','mypassword')
c.login("/path/to/login", "myuser", "mypassword")

New (1.0)::

# ... same as above, but then:
c.login(username='myuser', password='mypassword')
c.login(username="myuser", password="mypassword")

Management commands
-------------------
Expand All @@ -670,14 +676,16 @@ Calls to management services in your code now need to use
load_data::

from django.core import management

management.flush(verbosity=0, interactive=False)
management.load_data(['test_data'], verbosity=0)
management.load_data(["test_data"], verbosity=0)

...you'll need to change this code to read::

from django.core import management
management.call_command('flush', verbosity=0, interactive=False)
management.call_command('loaddata', 'test_data', verbosity=0)

management.call_command("flush", verbosity=0, interactive=False)
management.call_command("loaddata", "test_data", verbosity=0)

Subcommands must now precede options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 4 additions & 1 deletion docs/releases/1.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,11 @@ models like the following are **not valid**::
name = models.CharField(max_length=10)
other_value = models.IntegerField(unique=True)


class Child(Parent):
father = models.OneToOneField(Parent, primary_key=True, to_field="other_value", parent_link=True)
father = models.OneToOneField(
Parent, primary_key=True, to_field="other_value", parent_link=True
)
value = models.IntegerField()

This bug will be fixed in the next release of Django.
Expand Down
12 changes: 8 additions & 4 deletions docs/releases/1.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ differences as a result of this change.
However, **users on 64-bit platforms may experience some problems** using the
``reset`` management command. Prior to this change, 64-bit platforms
would generate a 64-bit, 16 character digest in the constraint name; for
example::
example:

.. code-block:: sql

ALTER TABLE myapp_sometable ADD CONSTRAINT object_id_refs_id_5e8f10c132091d1e FOREIGN KEY ...

Following this change, all platforms, regardless of word size, will generate a
32-bit, 8 character digest in the constraint name; for example::
32-bit, 8 character digest in the constraint name; for example:

.. code-block:: sql

ALTER TABLE myapp_sometable ADD CONSTRAINT object_id_refs_id_32091d1e FOREIGN KEY ...

Expand Down Expand Up @@ -156,11 +160,11 @@ One feature has been marked as deprecated in Django 1.1:
* You should no longer use ``AdminSite.root()`` to register that admin
views. That is, if your URLconf contains the line::

(r'^admin/(.*)', admin.site.root),
(r"^admin/(.*)", admin.site.root),

You should change it to read::

(r'^admin/', include(admin.site.urls)),
(r"^admin/", include(admin.site.urls)),

You should begin to remove use of this feature from your code immediately.

Expand Down