Refs #23919 -- Removed python_2_unicode_compatible decorator usage

This commit is contained in:
Claude Paroz 2016-11-19 21:54:19 +01:00
parent d7b9aaa366
commit f3c43ad1fd
160 changed files with 23 additions and 757 deletions

View file

@ -1,5 +1,4 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Event(models.Model):
@ -27,7 +26,6 @@ class Band(models.Model):
genres = models.ManyToManyField(Genre)
@python_2_unicode_compatible
class Musician(models.Model):
name = models.CharField(max_length=30)
@ -35,7 +33,6 @@ class Musician(models.Model):
return self.name
@python_2_unicode_compatible
class Group(models.Model):
name = models.CharField(max_length=30)
members = models.ManyToManyField(Musician, through='Membership')

View file

@ -5,14 +5,12 @@ Tests of ModelAdmin system checks logic.
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Album(models.Model):
title = models.CharField(max_length=150)
@python_2_unicode_compatible
class Song(models.Model):
title = models.CharField(max_length=150)
album = models.ForeignKey(Album, models.CASCADE)

View file

@ -4,10 +4,8 @@ from django.contrib import admin
from django.db import models
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Action(models.Model):
name = models.CharField(max_length=50, primary_key=True)
description = models.CharField(max_length=70)

View file

@ -4,10 +4,8 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Book(models.Model):
title = models.CharField(max_length=50)
year = models.PositiveIntegerField(null=True, blank=True)
@ -39,7 +37,6 @@ class Book(models.Model):
return self.title
@python_2_unicode_compatible
class Department(models.Model):
code = models.CharField(max_length=4, unique=True)
description = models.CharField(max_length=50, blank=True, null=True)
@ -48,7 +45,6 @@ class Department(models.Model):
return self.description
@python_2_unicode_compatible
class Employee(models.Model):
department = models.ForeignKey(Department, models.CASCADE, to_field="code")
name = models.CharField(max_length=100)
@ -57,7 +53,6 @@ class Employee(models.Model):
return self.name
@python_2_unicode_compatible
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(ContentType, models.CASCADE, related_name='tagged_items')
@ -68,7 +63,6 @@ class TaggedItem(models.Model):
return self.tag
@python_2_unicode_compatible
class Bookmark(models.Model):
url = models.URLField()
tags = GenericRelation(TaggedItem)

View file

@ -6,10 +6,8 @@ import random
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Parent(models.Model):
name = models.CharField(max_length=50)
@ -17,7 +15,6 @@ class Parent(models.Model):
return self.name
@python_2_unicode_compatible
class Teacher(models.Model):
name = models.CharField(max_length=50)
@ -25,7 +22,6 @@ class Teacher(models.Model):
return self.name
@python_2_unicode_compatible
class Child(models.Model):
name = models.CharField(max_length=50)
teacher = models.ForeignKey(Teacher, models.CASCADE)

View file

@ -1,10 +1,8 @@
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
@python_2_unicode_compatible
class Site(models.Model):
domain = models.CharField(max_length=100)
@ -34,7 +32,6 @@ class ArticleProxy(Article):
proxy = True
@python_2_unicode_compatible
class Count(models.Model):
num = models.PositiveSmallIntegerField()
parent = models.ForeignKey('self', models.CASCADE, null=True)

View file

@ -11,10 +11,8 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Section(models.Model):
"""
A simple section that links to articles, to test linking to related items
@ -33,7 +31,6 @@ class Section(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
"""
A simple article to test admin views. Test backwards compatibility.
@ -59,7 +56,6 @@ class Article(models.Model):
model_year_reversed.short_description = ''
@python_2_unicode_compatible
class Book(models.Model):
"""
A simple book that has chapters.
@ -70,7 +66,6 @@ class Book(models.Model):
return self.name
@python_2_unicode_compatible
class Promo(models.Model):
name = models.CharField(max_length=100, verbose_name='¿Name?')
book = models.ForeignKey(Book, models.CASCADE)
@ -79,7 +74,6 @@ class Promo(models.Model):
return self.name
@python_2_unicode_compatible
class Chapter(models.Model):
title = models.CharField(max_length=100, verbose_name='¿Title?')
content = models.TextField()
@ -93,7 +87,6 @@ class Chapter(models.Model):
verbose_name = '¿Chapter?'
@python_2_unicode_compatible
class ChapterXtra1(models.Model):
chap = models.OneToOneField(Chapter, models.CASCADE, verbose_name='¿Chap?')
xtra = models.CharField(max_length=100, verbose_name='¿Xtra?')
@ -102,7 +95,6 @@ class ChapterXtra1(models.Model):
return '¿Xtra1: %s' % self.xtra
@python_2_unicode_compatible
class ChapterXtra2(models.Model):
chap = models.OneToOneField(Chapter, models.CASCADE, verbose_name='¿Chap?')
xtra = models.CharField(max_length=100, verbose_name='¿Xtra?')
@ -120,7 +112,6 @@ class CustomArticle(models.Model):
date = models.DateTimeField()
@python_2_unicode_compatible
class ModelWithStringPrimaryKey(models.Model):
string_pk = models.CharField(max_length=255, primary_key=True)
@ -131,7 +122,6 @@ class ModelWithStringPrimaryKey(models.Model):
return '/dummy/%s/' % self.string_pk
@python_2_unicode_compatible
class Color(models.Model):
value = models.CharField(max_length=10)
warm = models.BooleanField(default=False)
@ -146,7 +136,6 @@ class Color2(Color):
proxy = True
@python_2_unicode_compatible
class Thing(models.Model):
title = models.CharField(max_length=20)
color = models.ForeignKey(Color, models.CASCADE, limit_choices_to={'warm': True})
@ -156,7 +145,6 @@ class Thing(models.Model):
return self.title
@python_2_unicode_compatible
class Actor(models.Model):
name = models.CharField(max_length=50)
age = models.IntegerField()
@ -166,7 +154,6 @@ class Actor(models.Model):
return self.name
@python_2_unicode_compatible
class Inquisition(models.Model):
expected = models.BooleanField(default=False)
leader = models.ForeignKey(Actor, models.CASCADE)
@ -176,7 +163,6 @@ class Inquisition(models.Model):
return "by %s from %s" % (self.leader, self.country)
@python_2_unicode_compatible
class Sketch(models.Model):
title = models.CharField(max_length=100)
inquisition = models.ForeignKey(
@ -213,7 +199,6 @@ def today_callable_q():
return models.Q(last_action__gte=datetime.datetime.today())
@python_2_unicode_compatible
class Character(models.Model):
username = models.CharField(max_length=100)
last_action = models.DateTimeField()
@ -222,7 +207,6 @@ class Character(models.Model):
return self.username
@python_2_unicode_compatible
class StumpJoke(models.Model):
variation = models.CharField(max_length=100)
most_recently_fooled = models.ForeignKey(
@ -248,7 +232,6 @@ class Fabric(models.Model):
surface = models.CharField(max_length=20, choices=NG_CHOICES)
@python_2_unicode_compatible
class Person(models.Model):
GENDER_CHOICES = (
(1, "Male"),
@ -263,7 +246,6 @@ class Person(models.Model):
return self.name
@python_2_unicode_compatible
class Persona(models.Model):
"""
A simple persona associated with accounts, to test inlining of related
@ -275,7 +257,6 @@ class Persona(models.Model):
return self.name
@python_2_unicode_compatible
class Account(models.Model):
"""
A simple, generic account encapsulating the information shared by all
@ -299,7 +280,6 @@ class BarAccount(Account):
servicename = 'bar'
@python_2_unicode_compatible
class Subscriber(models.Model):
name = models.CharField(blank=False, max_length=80)
email = models.EmailField(blank=False, max_length=175)
@ -349,7 +329,6 @@ class Child(models.Model):
raise ValidationError('invalid')
@python_2_unicode_compatible
class EmptyModel(models.Model):
def __str__(self):
return "Primary key = %s" % self.id
@ -433,7 +412,6 @@ class FancyDoodad(Doodad):
expensive = models.BooleanField(default=True)
@python_2_unicode_compatible
class Category(models.Model):
collector = models.ForeignKey(Collector, models.CASCADE)
order = models.PositiveIntegerField()
@ -489,7 +467,6 @@ class FieldOverridePost(Post):
proxy = True
@python_2_unicode_compatible
class Gadget(models.Model):
name = models.CharField(max_length=100)
@ -497,7 +474,6 @@ class Gadget(models.Model):
return self.name
@python_2_unicode_compatible
class Villain(models.Model):
name = models.CharField(max_length=100)
@ -509,7 +485,6 @@ class SuperVillain(Villain):
pass
@python_2_unicode_compatible
class FunkyTag(models.Model):
"Because we all know there's only one real use case for GFKs."
name = models.CharField(max_length=25)
@ -521,7 +496,6 @@ class FunkyTag(models.Model):
return self.name
@python_2_unicode_compatible
class Plot(models.Model):
name = models.CharField(max_length=100)
team_leader = models.ForeignKey(Villain, models.CASCADE, related_name='lead_plots')
@ -532,7 +506,6 @@ class Plot(models.Model):
return self.name
@python_2_unicode_compatible
class PlotDetails(models.Model):
details = models.CharField(max_length=100)
plot = models.OneToOneField(Plot, models.CASCADE, null=True, blank=True)
@ -546,7 +519,6 @@ class PlotProxy(Plot):
proxy = True
@python_2_unicode_compatible
class SecretHideout(models.Model):
""" Secret! Not registered with the admin! """
location = models.CharField(max_length=100)
@ -556,7 +528,6 @@ class SecretHideout(models.Model):
return self.location
@python_2_unicode_compatible
class SuperSecretHideout(models.Model):
""" Secret! Not registered with the admin! """
location = models.CharField(max_length=100)
@ -566,7 +537,6 @@ class SuperSecretHideout(models.Model):
return self.location
@python_2_unicode_compatible
class Bookmark(models.Model):
name = models.CharField(max_length=60)
tag = GenericRelation(FunkyTag, related_query_name='bookmark')
@ -575,7 +545,6 @@ class Bookmark(models.Model):
return self.name
@python_2_unicode_compatible
class CyclicOne(models.Model):
name = models.CharField(max_length=25)
two = models.ForeignKey('CyclicTwo', models.CASCADE)
@ -584,7 +553,6 @@ class CyclicOne(models.Model):
return self.name
@python_2_unicode_compatible
class CyclicTwo(models.Model):
name = models.CharField(max_length=25)
one = models.ForeignKey(CyclicOne, models.CASCADE)
@ -593,7 +561,6 @@ class CyclicTwo(models.Model):
return self.name
@python_2_unicode_compatible
class Topping(models.Model):
name = models.CharField(max_length=20)
@ -625,7 +592,6 @@ class Question(models.Model):
posted = models.DateField(default=datetime.date.today)
@python_2_unicode_compatible
class Answer(models.Model):
question = models.ForeignKey(Question, models.PROTECT)
answer = models.CharField(max_length=20)
@ -660,7 +626,6 @@ class FoodDelivery(models.Model):
unique_together = (("driver", "restaurant"),)
@python_2_unicode_compatible
class CoverLetter(models.Model):
author = models.CharField(max_length=30)
date_written = models.DateField(null=True, blank=True)
@ -679,7 +644,6 @@ class ShortMessage(models.Model):
timestamp = models.DateTimeField(null=True, blank=True)
@python_2_unicode_compatible
class Telegram(models.Model):
title = models.CharField(max_length=30)
date_sent = models.DateField(null=True, blank=True)
@ -745,7 +709,6 @@ class AdminOrderedCallable(models.Model):
stuff = models.CharField(max_length=200)
@python_2_unicode_compatible
class Report(models.Model):
title = models.CharField(max_length=100)

View file

@ -1,13 +1,11 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class MyFileField(models.FileField):
pass
@python_2_unicode_compatible
class Member(models.Model):
name = models.CharField(max_length=100)
birthdate = models.DateTimeField(blank=True, null=True)
@ -18,7 +16,6 @@ class Member(models.Model):
return self.name
@python_2_unicode_compatible
class Band(models.Model):
name = models.CharField(max_length=100)
style = models.CharField(max_length=20)
@ -28,7 +25,6 @@ class Band(models.Model):
return self.name
@python_2_unicode_compatible
class Album(models.Model):
band = models.ForeignKey(Band, models.CASCADE)
name = models.CharField(max_length=100)
@ -44,7 +40,6 @@ class HiddenInventoryManager(models.Manager):
return super(HiddenInventoryManager, self).get_queryset().filter(hidden=False)
@python_2_unicode_compatible
class Inventory(models.Model):
barcode = models.PositiveIntegerField(unique=True)
parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True)
@ -79,7 +74,6 @@ class Event(models.Model):
min_age = models.IntegerField(blank=True, null=True)
@python_2_unicode_compatible
class Car(models.Model):
owner = models.ForeignKey(User, models.CASCADE)
make = models.CharField(max_length=30)
@ -134,7 +128,6 @@ class Advisor(models.Model):
companies = models.ManyToManyField(Company)
@python_2_unicode_compatible
class Student(models.Model):
name = models.CharField(max_length=255)
@ -145,7 +138,6 @@ class Student(models.Model):
ordering = ('name',)
@python_2_unicode_compatible
class School(models.Model):
name = models.CharField(max_length=255)
students = models.ManyToManyField(Student, related_name='current_schools')
@ -155,7 +147,6 @@ class School(models.Model):
return self.name
@python_2_unicode_compatible
class Profile(models.Model):
user = models.ForeignKey('auth.User', models.CASCADE, to_field='username')

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
@ -12,7 +10,6 @@ class Author(models.Model):
return self.name
@python_2_unicode_compatible
class Publisher(models.Model):
name = models.CharField(max_length=255)
num_awards = models.IntegerField()
@ -22,7 +19,6 @@ class Publisher(models.Model):
return self.name
@python_2_unicode_compatible
class Book(models.Model):
isbn = models.CharField(max_length=9)
name = models.CharField(max_length=255)
@ -38,7 +34,6 @@ class Book(models.Model):
return self.name
@python_2_unicode_compatible
class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)

View file

@ -3,10 +3,8 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
@ -16,7 +14,6 @@ class Author(models.Model):
return self.name
@python_2_unicode_compatible
class Publisher(models.Model):
name = models.CharField(max_length=255)
num_awards = models.IntegerField()
@ -32,7 +29,6 @@ class ItemTag(models.Model):
content_object = GenericForeignKey('content_type', 'object_id')
@python_2_unicode_compatible
class Book(models.Model):
isbn = models.CharField(max_length=9)
name = models.CharField(max_length=255)
@ -52,7 +48,6 @@ class Book(models.Model):
return self.name
@python_2_unicode_compatible
class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)
@ -83,7 +78,6 @@ class WithManualPK(models.Model):
id = models.IntegerField(primary_key=True)
@python_2_unicode_compatible
class HardbackBook(Book):
weight = models.FloatField()

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
@ -12,7 +10,6 @@ class Author(models.Model):
return self.name
@python_2_unicode_compatible
class Publisher(models.Model):
name = models.CharField(max_length=255)
num_awards = models.IntegerField()
@ -21,7 +18,6 @@ class Publisher(models.Model):
return self.name
@python_2_unicode_compatible
class Book(models.Model):
isbn = models.CharField(max_length=9)
name = models.CharField(max_length=255)
@ -37,7 +33,6 @@ class Book(models.Model):
return self.name
@python_2_unicode_compatible
class Store(models.Model):
name = models.CharField(max_length=255)
books = models.ManyToManyField(Book)
@ -48,7 +43,6 @@ class Store(models.Model):
return self.name
@python_2_unicode_compatible
class DepartmentStore(Store):
chain = models.CharField(max_length=255)
@ -56,7 +50,6 @@ class DepartmentStore(Store):
return '%s - %s ' % (self.chain, self.name)
@python_2_unicode_compatible
class Employee(models.Model):
# The order of these fields matter, do not change. Certain backends
# rely on field ordering to perform database conversions, and this
@ -72,7 +65,6 @@ class Employee(models.Model):
return '%s %s' % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Company(models.Model):
name = models.CharField(max_length=200)
motto = models.CharField(max_length=200, null=True, blank=True)
@ -85,7 +77,6 @@ class Company(models.Model):
)
@python_2_unicode_compatible
class Ticket(models.Model):
active_at = models.DateTimeField()
duration = models.DurationField()

View file

@ -5,7 +5,6 @@ includes everything that is needed to interact with the ModelBackend.
"""
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from .custom_user import CustomUserManager, RemoveGroupsAndPermissions
@ -19,7 +18,6 @@ class CustomPermissionsUserManager(CustomUserManager):
with RemoveGroupsAndPermissions():
@python_2_unicode_compatible
class CustomPermissionsUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(verbose_name='email address', max_length=255, unique=True)
date_of_birth = models.DateField()

View file

@ -3,7 +3,6 @@ from django.contrib.auth.models import (
PermissionsMixin, UserManager,
)
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# The custom user uses email as the unique identifier, and requires
@ -33,7 +32,6 @@ class CustomUserManager(BaseUserManager):
return u
@python_2_unicode_compatible
class CustomUser(AbstractBaseUser):
email = models.EmailField(verbose_name='email address', max_length=255, unique=True)
is_active = models.BooleanField(default=True)

View file

@ -3,10 +3,8 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Square(models.Model):
root = models.IntegerField()
square = models.PositiveIntegerField()
@ -15,7 +13,6 @@ class Square(models.Model):
return "%s ** 2 == %s" % (self.root, self.square)
@python_2_unicode_compatible
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
@ -52,7 +49,6 @@ class Post(models.Model):
db_table = 'CaseSensitive_Post'
@python_2_unicode_compatible
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -66,7 +62,6 @@ class ReporterProxy(Reporter):
proxy = True
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
@ -82,7 +77,6 @@ class Article(models.Model):
return self.headline
@python_2_unicode_compatible
class Item(models.Model):
name = models.CharField(max_length=30)
date = models.DateField()
@ -93,7 +87,6 @@ class Item(models.Model):
return self.name
@python_2_unicode_compatible
class Object(models.Model):
related_objects = models.ManyToManyField("self", db_constraint=False, symmetrical=False)
@ -101,7 +94,6 @@ class Object(models.Model):
return str(self.id)
@python_2_unicode_compatible
class ObjectReference(models.Model):
obj = models.ForeignKey(Object, models.CASCADE, db_constraint=False)

View file

@ -4,10 +4,8 @@ Bare-bones model
This is a basic model with only two non-primary-key fields.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
@ -25,7 +23,6 @@ class ArticleSelectOnSave(Article):
select_on_save = True
@python_2_unicode_compatible
class SelfRef(models.Model):
selfref = models.ForeignKey(
'self',

View file

@ -10,7 +10,6 @@ field. This method returns the "human-readable" value of the field.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
GENDER_CHOICES = (
('M', 'Male'),
@ -18,7 +17,6 @@ GENDER_CHOICES = (
)
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=20)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)

View file

@ -4,11 +4,9 @@ from django.contrib.contenttypes.fields import (
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import SiteManager
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.http import urlquote
@python_2_unicode_compatible
class Site(models.Model):
domain = models.CharField(max_length=100)
objects = SiteManager()
@ -17,7 +15,6 @@ class Site(models.Model):
return self.domain
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
@ -28,7 +25,6 @@ class Author(models.Model):
return '/authors/%s/' % self.id
@python_2_unicode_compatible
class Article(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
@ -39,7 +35,6 @@ class Article(models.Model):
return self.title
@python_2_unicode_compatible
class SchemeIncludedURL(models.Model):
url = models.URLField(max_length=100)
@ -59,7 +54,6 @@ class ProxyModel(ConcreteModel):
proxy = True
@python_2_unicode_compatible
class FooWithoutUrl(models.Model):
"""
Fake model not defining ``get_absolute_url`` for
@ -95,7 +89,6 @@ class Question(models.Model):
answer_set = GenericRelation('Answer')
@python_2_unicode_compatible
class Answer(models.Model):
text = models.CharField(max_length=200)
content_type = models.ForeignKey(ContentType, models.CASCADE)
@ -109,7 +102,6 @@ class Answer(models.Model):
return self.text
@python_2_unicode_compatible
class Post(models.Model):
"""An ordered tag on an item."""
title = models.CharField(max_length=200)
@ -125,7 +117,6 @@ class Post(models.Model):
return self.title
@python_2_unicode_compatible
class ModelWithNullFKToSite(models.Model):
title = models.CharField(max_length=200)
site = models.ForeignKey(Site, null=True, on_delete=models.CASCADE)

View file

@ -16,10 +16,8 @@ from the default generated name, use the ``db_table`` parameter on the
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
Author_ID = models.AutoField(primary_key=True, db_column='Author ID')
first_name = models.CharField(max_length=30, db_column='firstname')
@ -33,7 +31,6 @@ class Author(models.Model):
ordering = ('last_name', 'first_name')
@python_2_unicode_compatible
class Article(models.Model):
Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
headline = models.CharField(max_length=100)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=20)
age = models.IntegerField(null=True)
@ -17,7 +15,6 @@ class Article(models.Model):
author = models.ForeignKey(Author, on_delete=models.CASCADE)
@python_2_unicode_compatible
class MySQLUnixTimestamp(models.Model):
timestamp = models.PositiveIntegerField()

View file

@ -13,7 +13,6 @@ from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class PersonManager(models.Manager):
@ -86,7 +85,6 @@ class BoringPeopleManager(models.Manager):
return super(BoringPeopleManager, self).get_queryset().filter(fun=False)
@python_2_unicode_compatible
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -109,7 +107,6 @@ class Person(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class FunPerson(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -130,7 +127,6 @@ class FunPerson(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Book(models.Model):
title = models.CharField(max_length=50)
author = models.CharField(max_length=30)
@ -158,7 +154,6 @@ class FastCarManager(models.Manager):
return super(FastCarManager, self).get_queryset().filter(top_speed__gt=150)
@python_2_unicode_compatible
class Car(models.Model):
name = models.CharField(max_length=10)
mileage = models.IntegerField()
@ -187,7 +182,6 @@ class RestrictedManager(models.Manager):
return super(RestrictedManager, self).get_queryset().filter(is_public=True)
@python_2_unicode_compatible
class RelatedModel(models.Model):
name = models.CharField(max_length=50)
@ -195,7 +189,6 @@ class RelatedModel(models.Model):
return self.name
@python_2_unicode_compatible
class RestrictedModel(models.Model):
name = models.CharField(max_length=50)
is_public = models.BooleanField(default=False)
@ -208,7 +201,6 @@ class RestrictedModel(models.Model):
return self.name
@python_2_unicode_compatible
class OneToOneRestrictedModel(models.Model):
name = models.CharField(max_length=50)
is_public = models.BooleanField(default=False)

View file

@ -7,10 +7,8 @@ Any method you add to a model will be available to instances.
import datetime
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()

View file

@ -3,10 +3,8 @@ import string
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class MyWrapper(object):
def __init__(self, value):
self.value = value

View file

@ -6,12 +6,10 @@ this behavior by explicitly adding ``primary_key=True`` to a field.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from .fields import MyAutoField
@python_2_unicode_compatible
class Employee(models.Model):
employee_code = models.IntegerField(primary_key=True, db_column='code')
first_name = models.CharField(max_length=20)
@ -24,7 +22,6 @@ class Employee(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Business(models.Model):
name = models.CharField(max_length=20, primary_key=True)
employees = models.ManyToManyField(Employee)
@ -36,7 +33,6 @@ class Business(models.Model):
return self.name
@python_2_unicode_compatible
class Bar(models.Model):
id = MyAutoField(primary_key=True, db_index=True)

View file

@ -4,10 +4,8 @@ types, which in the past were problematic for some database backends.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Donut(models.Model):
name = models.CharField(max_length=100)
is_frosted = models.BooleanField(default=False)

View file

@ -1,9 +1,7 @@
from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
title = models.CharField(max_length=100)
pub_date = models.DateField()
@ -15,7 +13,6 @@ class Article(models.Model):
return self.title
@python_2_unicode_compatible
class Comment(models.Model):
article = models.ForeignKey(Article, models.CASCADE, related_name="comments")
text = models.TextField()

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
title = models.CharField(max_length=100)
pub_date = models.DateTimeField()
@ -14,7 +12,6 @@ class Article(models.Model):
return self.title
@python_2_unicode_compatible
class Comment(models.Model):
article = models.ForeignKey(Article, models.CASCADE, related_name="comments")
text = models.TextField()

View file

@ -2,10 +2,8 @@
Tests for built in Function expressions.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=50)
alias = models.CharField(max_length=50, null=True, blank=True)
@ -16,7 +14,6 @@ class Author(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
authors = models.ManyToManyField(Author, related_name='articles')
title = models.CharField(max_length=50)
@ -31,7 +28,6 @@ class Article(models.Model):
return self.title
@python_2_unicode_compatible
class Fan(models.Model):
name = models.CharField(max_length=50)
age = models.PositiveSmallIntegerField(default=30)
@ -41,7 +37,6 @@ class Fan(models.Model):
return self.name
@python_2_unicode_compatible
class DTModel(models.Model):
name = models.CharField(max_length=32)
start_datetime = models.DateTimeField(null=True, blank=True)

View file

@ -3,7 +3,6 @@ Tests for defer() and only().
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Secondary(models.Model):
@ -11,7 +10,6 @@ class Secondary(models.Model):
second = models.CharField(max_length=50)
@python_2_unicode_compatible
class Primary(models.Model):
name = models.CharField(max_length=50)
value = models.CharField(max_length=50)

View file

@ -3,10 +3,8 @@ Regression tests for defer() / only() behavior.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Item(models.Model):
name = models.CharField(max_length=15)
text = models.TextField(default="xyzzy")
@ -31,7 +29,6 @@ class Child(models.Model):
value = models.IntegerField()
@python_2_unicode_compatible
class Leaf(models.Model):
name = models.CharField(max_length=10)
child = models.ForeignKey(Child, models.CASCADE)
@ -52,7 +49,6 @@ class Proxy(Item):
proxy = True
@python_2_unicode_compatible
class SimpleItem(models.Model):
name = models.CharField(max_length=15)
value = models.IntegerField()

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class R(models.Model):
is_default = models.BooleanField(default=False)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Tag(models.Model):
name = models.CharField(max_length=10)
parent = models.ForeignKey(
@ -20,7 +18,6 @@ class Tag(models.Model):
return self.name
@python_2_unicode_compatible
class Celebrity(models.Model):
name = models.CharField("Name", max_length=20)
greatest_fan = models.ForeignKey(
@ -38,7 +35,6 @@ class Fan(models.Model):
fan_of = models.ForeignKey(Celebrity, models.CASCADE)
@python_2_unicode_compatible
class Staff(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50)
@ -50,7 +46,6 @@ class Staff(models.Model):
return self.name
@python_2_unicode_compatible
class StaffTag(models.Model):
staff = models.ForeignKey(Staff, models.CASCADE)
tag = models.ForeignKey(Tag, models.CASCADE)

View file

@ -3,10 +3,8 @@ Tests for F() query expression syntax.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Employee(models.Model):
firstname = models.CharField(max_length=50)
lastname = models.CharField(max_length=50)
@ -16,7 +14,6 @@ class Employee(models.Model):
return '%s %s' % (self.firstname, self.lastname)
@python_2_unicode_compatible
class Company(models.Model):
name = models.CharField(max_length=100)
num_employees = models.PositiveIntegerField()
@ -35,7 +32,6 @@ class Company(models.Model):
return self.name
@python_2_unicode_compatible
class Number(models.Model):
integer = models.BigIntegerField(db_column='the_integer')
float = models.FloatField(null=True, db_column='the_float')
@ -59,7 +55,6 @@ class Experiment(models.Model):
return self.end - self.start
@python_2_unicode_compatible
class Result(models.Model):
experiment = models.ForeignKey(Experiment, models.CASCADE)
result_time = models.DateTimeField()
@ -68,7 +63,6 @@ class Result(models.Model):
return "Result at %s" % self.result_time
@python_2_unicode_compatible
class Time(models.Model):
time = models.TimeField(null=True)
@ -76,7 +70,6 @@ class Time(models.Model):
return "%s" % self.time
@python_2_unicode_compatible
class SimulationRun(models.Model):
start = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+')
end = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+')
@ -86,7 +79,6 @@ class SimulationRun(models.Model):
return "%s (%s to %s)" % (self.midpoint, self.start, self.end)
@python_2_unicode_compatible
class UUID(models.Model):
uuid = models.UUIDField(null=True)

View file

@ -1,5 +1,4 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
try:
from PIL import Image
@ -7,7 +6,6 @@ except ImportError:
Image = None
@python_2_unicode_compatible
class CaseTestModel(models.Model):
integer = models.IntegerField()
integer2 = models.IntegerField(null=True)
@ -42,7 +40,6 @@ class CaseTestModel(models.Model):
return "%i, %s" % (self.integer, self.string)
@python_2_unicode_compatible
class O2OCaseTestModel(models.Model):
o2o = models.OneToOneField(CaseTestModel, models.CASCADE, related_name='o2o_rel')
integer = models.IntegerField()
@ -51,7 +48,6 @@ class O2OCaseTestModel(models.Model):
return "%i, %s" % (self.id, self.o2o)
@python_2_unicode_compatible
class FKCaseTestModel(models.Model):
fk = models.ForeignKey(CaseTestModel, models.CASCADE, related_name='fk_rel')
integer = models.IntegerField()
@ -60,7 +56,6 @@ class FKCaseTestModel(models.Model):
return "%i, %s" % (self.id, self.fk)
@python_2_unicode_compatible
class Client(models.Model):
REGULAR = 'R'
GOLD = 'G'

View file

@ -3,10 +3,8 @@ import datetime
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class RevisionableModel(models.Model):
base = models.ForeignKey('self', models.SET_NULL, null=True)
title = models.CharField(blank=True, max_length=255)
@ -34,7 +32,6 @@ class Order(models.Model):
text = models.TextField()
@python_2_unicode_compatible
class TestObject(models.Model):
first = models.CharField(max_length=20)
second = models.CharField(max_length=20)

View file

@ -12,10 +12,8 @@ field.
from datetime import datetime
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField(default=datetime.now)

View file

@ -14,10 +14,8 @@ from django.contrib.auth.models import Permission
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Category(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
@ -29,7 +27,6 @@ class Category(models.Model):
ordering = ('title',)
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
@ -41,7 +38,6 @@ class Article(models.Model):
ordering = ('-pub_date', 'headline')
@python_2_unicode_compatible
class Blog(models.Model):
name = models.CharField(max_length=100)
featured = models.ForeignKey(Article, models.CASCADE, related_name='fixtures_featured_set')
@ -52,7 +48,6 @@ class Blog(models.Model):
return self.name
@python_2_unicode_compatible
class Tag(models.Model):
name = models.CharField(max_length=100)
tagged_type = models.ForeignKey(ContentType, models.CASCADE, related_name="fixtures_tag_set")
@ -69,7 +64,6 @@ class PersonManager(models.Manager):
return self.get(name=name)
@python_2_unicode_compatible
class Person(models.Model):
objects = PersonManager()
name = models.CharField(max_length=100)
@ -99,7 +93,6 @@ class ProxySpy(Spy):
proxy = True
@python_2_unicode_compatible
class Visa(models.Model):
person = models.ForeignKey(Person, models.CASCADE)
permissions = models.ManyToManyField(Permission, blank=True)
@ -109,7 +102,6 @@ class Visa(models.Model):
', '.join(p.name for p in self.permissions.all()))
@python_2_unicode_compatible
class Book(models.Model):
name = models.CharField(max_length=100)
authors = models.ManyToManyField(Person)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()

View file

@ -1,10 +1,8 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Animal(models.Model):
name = models.CharField(max_length=150)
latin_name = models.CharField(max_length=150)
@ -26,7 +24,6 @@ class Plant(models.Model):
db_table = "Fixtures_regress_plant"
@python_2_unicode_compatible
class Stuff(models.Model):
name = models.CharField(max_length=20, null=True)
owner = models.ForeignKey(User, models.SET_NULL, null=True)
@ -80,7 +77,6 @@ class Feature(CommonFeature):
# Models to regression test #11428
@python_2_unicode_compatible
class Widget(models.Model):
name = models.CharField(max_length=255)
@ -102,7 +98,6 @@ class TestManager(models.Manager):
return self.get(name=key)
@python_2_unicode_compatible
class Store(models.Model):
objects = TestManager()
name = models.CharField(max_length=255)
@ -118,7 +113,6 @@ class Store(models.Model):
return (self.name,)
@python_2_unicode_compatible
class Person(models.Model):
objects = TestManager()
name = models.CharField(max_length=255)
@ -136,7 +130,6 @@ class Person(models.Model):
natural_key.dependencies = ['fixtures_regress.store']
@python_2_unicode_compatible
class Book(models.Model):
name = models.CharField(max_length=255)
author = models.ForeignKey(Person, models.CASCADE)
@ -158,7 +151,6 @@ class NKManager(models.Manager):
return self.get(data=data)
@python_2_unicode_compatible
class NKChild(Parent):
data = models.CharField(max_length=10, unique=True)
objects = NKManager()
@ -170,7 +162,6 @@ class NKChild(Parent):
return 'NKChild %s:%s' % (self.name, self.data)
@python_2_unicode_compatible
class RefToNKChild(models.Model):
text = models.CharField(max_length=10)
nk_fk = models.ForeignKey(NKChild, models.CASCADE, related_name='ref_fks')
@ -250,7 +241,6 @@ class M2MToSelf(models.Model):
parent = models.ManyToManyField("self", blank=True)
@python_2_unicode_compatible
class BaseNKModel(models.Model):
"""
Base model with a natural_key and a manager with `get_by_natural_key`

View file

@ -1,6 +1,5 @@
from django.db import models
from django.db.models.fields.related import ForwardManyToOneDescriptor
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language
@ -49,7 +48,6 @@ class ActiveTranslationFieldWithQ(ActiveTranslationField):
return models.Q(lang=get_language())
@python_2_unicode_compatible
class Article(models.Model):
active_translation = ActiveTranslationField(
'ArticleTranslation',

View file

@ -4,7 +4,6 @@ from django.db.models.fields.related import (
)
from django.db.models.lookups import StartsWith
from django.db.models.query_utils import PathInfo
from django.utils.encoding import python_2_unicode_compatible
class CustomForeignObjectRel(ForeignObjectRel):
@ -78,7 +77,6 @@ class BrokenContainsRelation(StartsWithRelation):
return None
@python_2_unicode_compatible
class SlugPage(models.Model):
slug = models.CharField(max_length=20, unique=True)
descendants = StartsWithRelation(

View file

@ -1,10 +1,8 @@
import datetime
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Country(models.Model):
# Table Column Fields
name = models.CharField(max_length=50)
@ -13,7 +11,6 @@ class Country(models.Model):
return self.name
@python_2_unicode_compatible
class Person(models.Model):
# Table Column Fields
name = models.CharField(max_length=128)
@ -35,7 +32,6 @@ class Person(models.Model):
return self.name
@python_2_unicode_compatible
class Group(models.Model):
# Table Column Fields
name = models.CharField(max_length=128)
@ -49,7 +45,6 @@ class Group(models.Model):
return self.name
@python_2_unicode_compatible
class Membership(models.Model):
# Table Column Fields
membership_country = models.ForeignKey(Country, models.CASCADE)

View file

@ -4,7 +4,6 @@ import tempfile
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
callable_default_counter = itertools.count()
@ -55,7 +54,6 @@ class ChoiceModel(models.Model):
null=True)
@python_2_unicode_compatible
class ChoiceOptionModel(models.Model):
"""Destination for ChoiceFieldModel's ForeignKey.
Can't reuse ChoiceModel because error_message tests require that it have no instances."""
@ -132,7 +130,6 @@ class FileModel(models.Model):
file = models.FileField(storage=temp_storage, upload_to='tests')
@python_2_unicode_compatible
class Group(models.Model):
name = models.CharField(max_length=10)

View file

@ -8,7 +8,6 @@ from django.forms import (
)
from django.template import Context, Template
from django.test import SimpleTestCase, TestCase
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
from ..models import ChoiceModel
@ -216,7 +215,6 @@ class FormsErrorMessagesTestCase(SimpleTestCase, AssertFormErrorsMixin):
def clean(self):
raise ValidationError("I like to be awkward.")
@python_2_unicode_compatible
class CustomErrorList(utils.ErrorList):
def __str__(self):
return self.as_divs()

View file

@ -21,7 +21,7 @@ from django.template import Context, Template
from django.test import SimpleTestCase
from django.test.utils import str_prefix
from django.utils.datastructures import MultiValueDict
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.encoding import force_text
from django.utils.html import format_html
from django.utils.safestring import SafeData, mark_safe
@ -3375,7 +3375,6 @@ Good luck picking a username that doesn&#39;t already exist.</p>
)
def test_errorlist_override(self):
@python_2_unicode_compatible
class DivErrorList(ErrorList):
def __str__(self):
return self.as_divs()

View file

@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError
from django.forms.utils import ErrorDict, ErrorList, flatatt
from django.test import SimpleTestCase
from django.utils import six
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy
@ -101,7 +101,6 @@ class FormsUtilsTestCase(SimpleTestCase):
'</ul>'
)
@python_2_unicode_compatible
class VeryBadError:
def __str__(self):
return "A very bad error."

View file

@ -1,11 +1,9 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import ClearableFileInput
from django.utils.encoding import python_2_unicode_compatible
from .base import WidgetTest
@python_2_unicode_compatible
class FakeFieldFile(object):
"""
Quacks like a FieldFile (has a .url and unicode representation), but
@ -39,7 +37,6 @@ class ClearableFileInputTest(WidgetTest):
A ClearableFileInput should escape name, filename, and URL
when rendering HTML (#15182).
"""
@python_2_unicode_compatible
class StrangeFieldFile(object):
url = "something?chapter=1&sect=2&copy=3&lang=en"
@ -110,7 +107,6 @@ class ClearableFileInputTest(WidgetTest):
A ClearableFileInput should not mask exceptions produced while
checking that it has a value.
"""
@python_2_unicode_compatible
class FailingURLFieldFile(object):
@property
def url(self):
@ -123,7 +119,6 @@ class ClearableFileInputTest(WidgetTest):
self.widget.render('myfile', FailingURLFieldFile())
def test_url_as_property(self):
@python_2_unicode_compatible
class URLFieldFile(object):
@property
def url(self):
@ -136,7 +131,6 @@ class ClearableFileInputTest(WidgetTest):
self.assertInHTML('<a href="https://www.python.org/">value</a>', html)
def test_return_false_if_url_does_not_exists(self):
@python_2_unicode_compatible
class NoURLFieldFile(object):
def __str__(self):
return 'value'

View file

@ -1,7 +1,6 @@
import decimal
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Cash(decimal.Decimal):
@ -24,7 +23,6 @@ class CashField(models.DecimalField):
return cash
@python_2_unicode_compatible
class CashModel(models.Model):
cash = CashField()

View file

@ -3,7 +3,6 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Episode(models.Model):
@ -12,7 +11,6 @@ class Episode(models.Model):
author = models.CharField(max_length=100, blank=True)
@python_2_unicode_compatible
class Media(models.Model):
"""
Media that can associated to any object.

View file

@ -14,10 +14,8 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class TaggedItem(models.Model):
"""A tag on an item."""
tag = models.SlugField()
@ -46,7 +44,6 @@ class AbstractComparison(models.Model):
first_obj = GenericForeignKey(ct_field="content_type1", fk_field="object_id1")
@python_2_unicode_compatible
class Comparison(AbstractComparison):
"""
A model that tests having multiple GenericForeignKeys. One is defined
@ -61,7 +58,6 @@ class Comparison(AbstractComparison):
return "%s is %s than %s" % (self.first_obj, self.comparative, self.other_obj)
@python_2_unicode_compatible
class Animal(models.Model):
common_name = models.CharField(max_length=150)
latin_name = models.CharField(max_length=150)
@ -75,7 +71,6 @@ class Animal(models.Model):
return self.common_name
@python_2_unicode_compatible
class Vegetable(models.Model):
name = models.CharField(max_length=150)
is_yucky = models.BooleanField(default=True)
@ -90,7 +85,6 @@ class Carrot(Vegetable):
pass
@python_2_unicode_compatible
class Mineral(models.Model):
name = models.CharField(max_length=150)
hardness = models.PositiveSmallIntegerField()

View file

@ -4,14 +4,12 @@ from django.contrib.contenttypes.fields import (
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models.deletion import ProtectedError
from django.utils.encoding import python_2_unicode_compatible
__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
'Contact', 'Organization', 'Note', 'Company')
@python_2_unicode_compatible
class Link(models.Model):
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
@ -21,7 +19,6 @@ class Link(models.Model):
return "Link to %s id=%s" % (self.content_type, self.object_id)
@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=100)
links = GenericRelation(Link)
@ -30,13 +27,11 @@ class Place(models.Model):
return "Place: %s" % self.name
@python_2_unicode_compatible
class Restaurant(Place):
def __str__(self):
return "Restaurant: %s" % self.name
@python_2_unicode_compatible
class Address(models.Model):
street = models.CharField(max_length=80)
city = models.CharField(max_length=50)
@ -50,7 +45,6 @@ class Address(models.Model):
return '%s %s, %s %s' % (self.street, self.city, self.state, self.zipcode)
@python_2_unicode_compatible
class Person(models.Model):
account = models.IntegerField(primary_key=True)
name = models.CharField(max_length=128)
@ -99,7 +93,6 @@ class Organization(models.Model):
contacts = models.ManyToManyField(Contact, related_name='organizations')
@python_2_unicode_compatible
class Company(models.Model):
name = models.CharField(max_length=100)
links = GenericRelation(Link)
@ -113,7 +106,6 @@ class Developer(models.Model):
name = models.CharField(max_length=15)
@python_2_unicode_compatible
class Team(models.Model):
name = models.CharField(max_length=15)
members = models.ManyToManyField(Developer)

View file

@ -2,10 +2,8 @@ from django.db import models
from django.db.models import QuerySet
from django.db.models.manager import BaseManager
from django.urls import reverse
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Artist(models.Model):
name = models.CharField(max_length=100)
@ -21,7 +19,6 @@ class Artist(models.Model):
return reverse('artist_detail', kwargs={'pk': self.id})
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField()
@ -41,7 +38,6 @@ class DoesNotExistQuerySet(QuerySet):
DoesNotExistBookManager = BaseManager.from_queryset(DoesNotExistQuerySet)
@python_2_unicode_compatible
class Book(models.Model):
name = models.CharField(max_length=300)
slug = models.SlugField()

View file

@ -11,10 +11,8 @@ performing a ``filter()`` lookup and raising a ``Http404`` exception if a
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=50)
@ -27,7 +25,6 @@ class ArticleManager(models.Manager):
return super(ArticleManager, self).get_queryset().filter(authors__name__icontains='sir')
@python_2_unicode_compatible
class Article(models.Model):
authors = models.ManyToManyField(Author)
title = models.CharField(max_length=50)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Person(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)

View file

@ -1,10 +1,8 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
from ..utils import gisfield_may_be_null
@python_2_unicode_compatible
class NamedModel(models.Model):
name = models.CharField(max_length=30)

View file

@ -1,8 +1,6 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class NamedModel(models.Model):
name = models.CharField(max_length=30)

View file

@ -1,10 +1,8 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
from ..admin import admin
@python_2_unicode_compatible
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()

View file

@ -1,10 +1,8 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
from ..utils import gisfield_may_be_null
@python_2_unicode_compatible
class NamedModel(models.Model):
name = models.CharField(max_length=30)

View file

@ -1,8 +1,6 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class NamedModel(models.Model):
name = models.CharField(max_length=30)

View file

@ -1,8 +1,6 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class NamedModel(models.Model):
name = models.CharField(max_length=25)

View file

@ -1,5 +1,4 @@
from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
class SimpleModel(models.Model):
@ -8,7 +7,6 @@ class SimpleModel(models.Model):
required_db_features = ['gis_enabled']
@python_2_unicode_compatible
class Location(SimpleModel):
point = models.PointField()
@ -16,7 +14,6 @@ class Location(SimpleModel):
return self.point.wkt
@python_2_unicode_compatible
class City(SimpleModel):
name = models.CharField(max_length=50)
state = models.CharField(max_length=2)
@ -35,7 +32,6 @@ class DirectoryEntry(SimpleModel):
location = models.ForeignKey(AugmentedLocation, models.CASCADE)
@python_2_unicode_compatible
class Parcel(SimpleModel):
name = models.CharField(max_length=30)
city = models.ForeignKey(City, models.CASCADE)

View file

@ -1,5 +1,4 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class School(models.Model):
@ -17,7 +16,6 @@ class Child(models.Model):
name = models.CharField(max_length=100)
@python_2_unicode_compatible
class Poet(models.Model):
name = models.CharField(max_length=100)
@ -25,7 +23,6 @@ class Poet(models.Model):
return self.name
@python_2_unicode_compatible
class Poem(models.Model):
poet = models.ForeignKey(Poet, models.CASCADE)
name = models.CharField(max_length=100)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class City(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=50)
@ -11,7 +9,6 @@ class City(models.Model):
return self.name
@python_2_unicode_compatible
class District(models.Model):
city = models.ForeignKey(City, models.CASCADE, primary_key=True)
name = models.CharField(max_length=50)
@ -20,7 +17,6 @@ class District(models.Model):
return self.name
@python_2_unicode_compatible
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -36,7 +32,6 @@ class Reporter(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()

View file

@ -6,7 +6,6 @@ This demonstrates features of the database API.
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class Alarm(models.Model):
@ -24,7 +23,6 @@ class Author(models.Model):
ordering = ('name', )
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
@ -45,7 +43,6 @@ class Tag(models.Model):
ordering = ('name', )
@python_2_unicode_compatible
class Season(models.Model):
year = models.PositiveSmallIntegerField()
gt = models.IntegerField(null=True, blank=True)
@ -54,7 +51,6 @@ class Season(models.Model):
return six.text_type(self.year)
@python_2_unicode_compatible
class Game(models.Model):
season = models.ForeignKey(Season, models.CASCADE, related_name='games')
home = models.CharField(max_length=100)
@ -64,7 +60,6 @@ class Game(models.Model):
return "%s at %s" % (self.away, self.home)
@python_2_unicode_compatible
class Player(models.Model):
name = models.CharField(max_length=100)
games = models.ManyToManyField(Game, related_name='players')

View file

@ -5,14 +5,12 @@ Make sure to set ``related_name`` if you use relationships to the same table.
"""
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class User(models.Model):
username = models.CharField(max_length=20)
@python_2_unicode_compatible
class Issue(models.Model):
num = models.IntegerField()
cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc')

View file

@ -10,10 +10,8 @@ field, which specifies the ``Reporter``'s position for the given article
(e.g. "Staff writer").
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -22,7 +20,6 @@ class Reporter(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
@ -31,7 +28,6 @@ class Article(models.Model):
return self.headline
@python_2_unicode_compatible
class Writer(models.Model):
reporter = models.ForeignKey(Reporter, models.CASCADE)
article = models.ForeignKey(Article, models.CASCADE)

View file

@ -8,10 +8,8 @@ Set ``related_name`` to designate what the reverse relationship is called.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Category(models.Model):
name = models.CharField(max_length=20)
@ -22,7 +20,6 @@ class Category(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=50)
pub_date = models.DateTimeField()

View file

@ -17,10 +17,8 @@ appropriate.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=20)
friends = models.ManyToManyField('self')

View file

@ -1,11 +1,9 @@
from django.contrib.auth import models as auth
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# No related name is needed here, since symmetrical relations are not
# explicitly reversible.
@python_2_unicode_compatible
class SelfRefer(models.Model):
name = models.CharField(max_length=10)
references = models.ManyToManyField('self')
@ -15,7 +13,6 @@ class SelfRefer(models.Model):
return self.name
@python_2_unicode_compatible
class Tag(models.Model):
name = models.CharField(max_length=10)
@ -24,7 +21,6 @@ class Tag(models.Model):
# Regression for #11956 -- a many to many to the base class
@python_2_unicode_compatible
class TagCollection(Tag):
tags = models.ManyToManyField(Tag, related_name='tag_collections')
@ -34,7 +30,6 @@ class TagCollection(Tag):
# A related_name is required on one of the ManyToManyField entries here because
# they are both addressable as reverse relations from Tag.
@python_2_unicode_compatible
class Entry(models.Model):
name = models.CharField(max_length=10)
topics = models.ManyToManyField(Tag)
@ -54,7 +49,6 @@ class SelfReferChildSibling(SelfRefer):
# Many-to-Many relation between models, where one of the PK's isn't an Autofield
@python_2_unicode_compatible
class Line(models.Model):
name = models.CharField(max_length=100)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Part(models.Model):
name = models.CharField(max_length=20)
@ -13,7 +11,6 @@ class Part(models.Model):
return self.name
@python_2_unicode_compatible
class Car(models.Model):
name = models.CharField(max_length=20)
default_parts = models.ManyToManyField(Part)
@ -30,7 +27,6 @@ class SportsCar(Car):
price = models.IntegerField()
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=20)
fans = models.ManyToManyField('self', related_name='idols', symmetrical=False)

View file

@ -1,11 +1,9 @@
from datetime import datetime
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# M2M described on one of the models
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=128)
@ -16,7 +14,6 @@ class Person(models.Model):
return self.name
@python_2_unicode_compatible
class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Membership')
@ -34,7 +31,6 @@ class Group(models.Model):
return self.name
@python_2_unicode_compatible
class Membership(models.Model):
person = models.ForeignKey(Person, models.CASCADE)
group = models.ForeignKey(Group, models.CASCADE)
@ -48,7 +44,6 @@ class Membership(models.Model):
return "%s is a member of %s" % (self.person.name, self.group.name)
@python_2_unicode_compatible
class CustomMembership(models.Model):
person = models.ForeignKey(
Person,
@ -74,7 +69,6 @@ class TestNoDefaultsOrNulls(models.Model):
nodefaultnonull = models.CharField(max_length=5)
@python_2_unicode_compatible
class PersonSelfRefM2M(models.Model):
name = models.CharField(max_length=5)
friends = models.ManyToManyField('self', through="Friendship", symmetrical=False)
@ -90,7 +84,6 @@ class Friendship(models.Model):
# Custom through link fields
@python_2_unicode_compatible
class Event(models.Model):
title = models.CharField(max_length=50)
invitees = models.ManyToManyField(
@ -110,7 +103,6 @@ class Invitation(models.Model):
invitee = models.ForeignKey(Person, models.CASCADE, related_name='invitations')
@python_2_unicode_compatible
class Employee(models.Model):
name = models.CharField(max_length=5)
subordinates = models.ManyToManyField(

View file

@ -1,10 +1,8 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# Forward declared intermediate model
@python_2_unicode_compatible
class Membership(models.Model):
person = models.ForeignKey('Person', models.CASCADE)
group = models.ForeignKey('Group', models.CASCADE)
@ -15,7 +13,6 @@ class Membership(models.Model):
# using custom id column to test ticket #11107
@python_2_unicode_compatible
class UserMembership(models.Model):
id = models.AutoField(db_column='usermembership_id', primary_key=True)
user = models.ForeignKey(User, models.CASCADE)
@ -26,7 +23,6 @@ class UserMembership(models.Model):
return "%s is a user and member of %s" % (self.user.username, self.group.name)
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=128)
@ -34,7 +30,6 @@ class Person(models.Model):
return self.name
@python_2_unicode_compatible
class Group(models.Model):
name = models.CharField(max_length=128)
# Membership object defined as a class
@ -65,7 +60,6 @@ class B(models.Model):
# Using to_field on the through model
@python_2_unicode_compatible
class Car(models.Model):
make = models.CharField(max_length=20, unique=True, null=True)
drivers = models.ManyToManyField('Driver', through='CarDriver')
@ -74,7 +68,6 @@ class Car(models.Model):
return "%s" % self.make
@python_2_unicode_compatible
class Driver(models.Model):
name = models.CharField(max_length=20, unique=True, null=True)
@ -85,7 +78,6 @@ class Driver(models.Model):
ordering = ('name',)
@python_2_unicode_compatible
class CarDriver(models.Model):
car = models.ForeignKey('Car', models.CASCADE, to_field='make')
driver = models.ForeignKey('Driver', models.CASCADE, to_field='name')

View file

@ -11,10 +11,8 @@ Set ``related_name`` to designate what the reverse relationship is called.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Category(models.Model):
name = models.CharField(max_length=20)
parent = models.ForeignKey('self', models.SET_NULL, blank=True, null=True, related_name='child_set')
@ -23,7 +21,6 @@ class Category(models.Model):
return self.name
@python_2_unicode_compatible
class Person(models.Model):
full_name = models.CharField(max_length=20)
mother = models.ForeignKey('self', models.SET_NULL, null=True, related_name='mothers_child_set')

View file

@ -7,7 +7,7 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.encoding import force_text
class OnlyFred(models.Manager):
@ -55,7 +55,6 @@ class AbstractBase3(models.Model):
abstract = True
@python_2_unicode_compatible
class Parent(models.Model):
name = models.CharField(max_length=50)
@ -68,7 +67,6 @@ class Parent(models.Model):
# Managers from base classes are inherited and, if no manager is specified
# *and* the parent has a manager specified, the first one (in the MRO) will
# become the default.
@python_2_unicode_compatible
class Child1(AbstractBase1):
data = models.CharField(max_length=25)
@ -76,7 +74,6 @@ class Child1(AbstractBase1):
return self.data
@python_2_unicode_compatible
class Child2(AbstractBase1, AbstractBase2):
data = models.CharField(max_length=25)
@ -84,7 +81,6 @@ class Child2(AbstractBase1, AbstractBase2):
return self.data
@python_2_unicode_compatible
class Child3(AbstractBase1, AbstractBase3):
data = models.CharField(max_length=25)
@ -92,7 +88,6 @@ class Child3(AbstractBase1, AbstractBase3):
return self.data
@python_2_unicode_compatible
class Child4(AbstractBase1):
data = models.CharField(max_length=25)
@ -104,7 +99,6 @@ class Child4(AbstractBase1):
return self.data
@python_2_unicode_compatible
class Child5(AbstractBase3):
name = models.CharField(max_length=25)
@ -124,7 +118,6 @@ class Child7(Parent):
# RelatedManagers
@python_2_unicode_compatible
class RelatedModel(models.Model):
test_gfk = GenericRelation('RelationModel', content_type_field='gfk_ctype', object_id_field='gfk_id')
exact = models.NullBooleanField()
@ -133,7 +126,6 @@ class RelatedModel(models.Model):
return force_text(self.pk)
@python_2_unicode_compatible
class RelationModel(models.Model):
fk = models.ForeignKey(RelatedModel, models.CASCADE, related_name='test_fk')

View file

@ -7,10 +7,8 @@ In this example, an ``Article`` can be published in multiple ``Publication``
objects, and a ``Publication`` has multiple ``Article`` objects.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Publication(models.Model):
title = models.CharField(max_length=30)
@ -21,7 +19,6 @@ class Publication(models.Model):
ordering = ('title',)
@python_2_unicode_compatible
class Tag(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=50)
@ -30,7 +27,6 @@ class Tag(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
# Assign a unicode string as name to make sure the intermediary model is

View file

@ -4,10 +4,8 @@ Many-to-one relationships
To define a many-to-one relationship, use ``ForeignKey()``.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
@ -17,7 +15,6 @@ class Reporter(models.Model):
return "%s %s" % (self.first_name, self.last_name)
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
@ -30,7 +27,6 @@ class Article(models.Model):
ordering = ('headline',)
@python_2_unicode_compatible
class City(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=50)
@ -39,7 +35,6 @@ class City(models.Model):
return self.name
@python_2_unicode_compatible
class District(models.Model):
city = models.ForeignKey(City, models.CASCADE, related_name='districts', null=True)
name = models.CharField(max_length=50)
@ -80,7 +75,6 @@ class ToFieldChild(models.Model):
# Multiple paths to the same model (#7110, #7125)
@python_2_unicode_compatible
class Category(models.Model):
name = models.CharField(max_length=20)
@ -92,7 +86,6 @@ class Record(models.Model):
category = models.ForeignKey(Category, models.CASCADE)
@python_2_unicode_compatible
class Relation(models.Model):
left = models.ForeignKey(Record, models.CASCADE, related_name='left_set')
right = models.ForeignKey(Record, models.CASCADE, related_name='right_set')

View file

@ -6,10 +6,8 @@ To define a many-to-one relationship that can have a null foreign key, use
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Reporter(models.Model):
name = models.CharField(max_length=30)
@ -17,7 +15,6 @@ class Reporter(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
reporter = models.ForeignKey(Reporter, models.SET_NULL, null=True)

View file

@ -1,7 +1,6 @@
from django.apps.registry import Apps
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class CustomModelBase(models.base.ModelBase):
@ -12,7 +11,6 @@ class ModelWithCustomBase(six.with_metaclass(CustomModelBase, models.Model)):
pass
@python_2_unicode_compatible
class UnicodeModel(models.Model):
title = models.CharField('ÚÑÍ¢ÓÐÉ', max_length=20, default='“Ðjáñgó”')

View file

@ -17,7 +17,6 @@ from django.core.files.storage import FileSystemStorage
from django.db import models
from django.utils import six
from django.utils._os import upath
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six.moves import range
temp_storage_dir = tempfile.mkdtemp()
@ -40,7 +39,6 @@ class Person(models.Model):
name = models.CharField(max_length=100)
@python_2_unicode_compatible
class Category(models.Model):
name = models.CharField(max_length=20)
slug = models.SlugField(max_length=20)
@ -53,7 +51,6 @@ class Category(models.Model):
return self.__str__()
@python_2_unicode_compatible
class Writer(models.Model):
name = models.CharField(max_length=50, help_text='Use both first and last names.')
@ -64,7 +61,6 @@ class Writer(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=50)
slug = models.SlugField()
@ -96,7 +92,6 @@ class BetterWriter(Writer):
score = models.IntegerField()
@python_2_unicode_compatible
class Publication(models.Model):
title = models.CharField(max_length=30)
date_published = models.DateField()
@ -135,7 +130,6 @@ class Author1(models.Model):
full_name = models.CharField(max_length=255)
@python_2_unicode_compatible
class WriterProfile(models.Model):
writer = models.OneToOneField(Writer, models.CASCADE, primary_key=True)
age = models.PositiveIntegerField()
@ -148,7 +142,6 @@ class Document(models.Model):
myfile = models.FileField(upload_to='unused', blank=True)
@python_2_unicode_compatible
class TextFile(models.Model):
description = models.CharField(max_length=20)
file = models.FileField(storage=temp_storage, upload_to='tests', max_length=15)
@ -177,7 +170,6 @@ try:
test_images = True
@python_2_unicode_compatible
class ImageFile(models.Model):
def custom_upload_path(self, filename):
path = self.path or 'tests'
@ -196,7 +188,6 @@ try:
def __str__(self):
return self.description
@python_2_unicode_compatible
class OptionalImageFile(models.Model):
def custom_upload_path(self, filename):
path = self.path or 'tests'
@ -220,7 +211,6 @@ class Homepage(models.Model):
url = models.URLField()
@python_2_unicode_compatible
class Product(models.Model):
slug = models.SlugField(unique=True)
@ -228,7 +218,6 @@ class Product(models.Model):
return self.slug
@python_2_unicode_compatible
class Price(models.Model):
price = models.DecimalField(max_digits=10, decimal_places=2)
quantity = models.PositiveIntegerField()
@ -253,7 +242,6 @@ class ArticleStatus(models.Model):
status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True)
@python_2_unicode_compatible
class Inventory(models.Model):
barcode = models.PositiveIntegerField(unique=True)
parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True)
@ -292,7 +280,6 @@ class DerivedBook(Book, BookXtra):
pass
@python_2_unicode_compatible
class ExplicitPK(models.Model):
key = models.CharField(max_length=20, primary_key=True)
desc = models.CharField(max_length=20, blank=True, unique=True)
@ -304,7 +291,6 @@ class ExplicitPK(models.Model):
return self.key
@python_2_unicode_compatible
class Post(models.Model):
title = models.CharField(max_length=50, unique_for_date='posted', blank=True)
slug = models.CharField(max_length=50, unique_for_year='posted', blank=True)
@ -315,7 +301,6 @@ class Post(models.Model):
return self.title
@python_2_unicode_compatible
class DateTimePost(models.Model):
title = models.CharField(max_length=50, unique_for_date='posted', blank=True)
slug = models.CharField(max_length=50, unique_for_year='posted', blank=True)
@ -330,7 +315,6 @@ class DerivedPost(Post):
pass
@python_2_unicode_compatible
class BigInt(models.Model):
biggie = models.BigIntegerField()
@ -363,7 +347,6 @@ class FlexibleDatePost(models.Model):
posted = models.DateField(blank=True, null=True)
@python_2_unicode_compatible
class Colour(models.Model):
name = models.CharField(max_length=50)

View file

@ -3,10 +3,8 @@ import uuid
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
@ -21,7 +19,6 @@ class BetterAuthor(Author):
write_speed = models.IntegerField()
@python_2_unicode_compatible
class Book(models.Model):
author = models.ForeignKey(Author, models.CASCADE)
title = models.CharField(max_length=100)
@ -40,7 +37,6 @@ class Book(models.Model):
assert self.author.name is not None
@python_2_unicode_compatible
class BookWithCustomPK(models.Model):
my_pk = models.DecimalField(max_digits=5, decimal_places=0, primary_key=True)
author = models.ForeignKey(Author, models.CASCADE)
@ -54,7 +50,6 @@ class Editor(models.Model):
name = models.CharField(max_length=100)
@python_2_unicode_compatible
class BookWithOptionalAltEditor(models.Model):
author = models.ForeignKey(Author, models.CASCADE)
# Optional secondary author
@ -70,7 +65,6 @@ class BookWithOptionalAltEditor(models.Model):
return self.title
@python_2_unicode_compatible
class AlternateBook(Book):
notes = models.CharField(max_length=100)
@ -78,7 +72,6 @@ class AlternateBook(Book):
return '%s - %s' % (self.title, self.notes)
@python_2_unicode_compatible
class AuthorMeeting(models.Model):
name = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
@ -96,7 +89,6 @@ class CustomPrimaryKey(models.Model):
# models for inheritance tests.
@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=50)
city = models.CharField(max_length=50)
@ -105,7 +97,6 @@ class Place(models.Model):
return self.name
@python_2_unicode_compatible
class Owner(models.Model):
auto_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100)
@ -122,7 +113,6 @@ class Location(models.Model):
lon = models.CharField(max_length=100)
@python_2_unicode_compatible
class OwnerProfile(models.Model):
owner = models.OneToOneField(Owner, models.CASCADE, primary_key=True)
age = models.PositiveIntegerField()
@ -131,7 +121,6 @@ class OwnerProfile(models.Model):
return "%s is %d" % (self.owner.name, self.age)
@python_2_unicode_compatible
class Restaurant(Place):
serves_pizza = models.BooleanField(default=False)
@ -139,7 +128,6 @@ class Restaurant(Place):
return self.name
@python_2_unicode_compatible
class Product(models.Model):
slug = models.SlugField(unique=True)
@ -147,7 +135,6 @@ class Product(models.Model):
return self.slug
@python_2_unicode_compatible
class Price(models.Model):
price = models.DecimalField(max_digits=10, decimal_places=2)
quantity = models.PositiveIntegerField()
@ -170,7 +157,6 @@ class ClassyMexicanRestaurant(MexicanRestaurant):
# models for testing unique_together validation when a fk is involved and
# using inlineformset_factory.
@python_2_unicode_compatible
class Repository(models.Model):
name = models.CharField(max_length=25)
@ -178,7 +164,6 @@ class Repository(models.Model):
return self.name
@python_2_unicode_compatible
class Revision(models.Model):
repository = models.ForeignKey(Repository, models.CASCADE)
revision = models.CharField(max_length=40)
@ -208,7 +193,6 @@ class Team(models.Model):
name = models.CharField(max_length=100)
@python_2_unicode_compatible
class Player(models.Model):
team = models.ForeignKey(Team, models.SET_NULL, null=True)
name = models.CharField(max_length=100)
@ -218,7 +202,6 @@ class Player(models.Model):
# Models for testing custom ModelForm save methods in formsets and inline formsets
@python_2_unicode_compatible
class Poet(models.Model):
name = models.CharField(max_length=100)
@ -226,7 +209,6 @@ class Poet(models.Model):
return self.name
@python_2_unicode_compatible
class Poem(models.Model):
poet = models.ForeignKey(Poet, models.CASCADE)
name = models.CharField(max_length=100)
@ -235,7 +217,6 @@ class Poem(models.Model):
return self.name
@python_2_unicode_compatible
class Post(models.Model):
title = models.CharField(max_length=50, unique_for_date='posted', blank=True)
slug = models.CharField(max_length=50, unique_for_year='posted', blank=True)

View file

@ -1,5 +1,4 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class User(models.Model):
@ -40,7 +39,6 @@ class Network(models.Model):
name = models.CharField(max_length=15)
@python_2_unicode_compatible
class Host(models.Model):
network = models.ForeignKey(Network, models.CASCADE)
hostname = models.CharField(max_length=25)

View file

@ -12,7 +12,6 @@ Model inheritance exists in two varieties:
Both styles are demonstrated here.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
#
@ -20,7 +19,6 @@ from django.utils.encoding import python_2_unicode_compatible
#
@python_2_unicode_compatible
class CommonInfo(models.Model):
name = models.CharField(max_length=50)
age = models.PositiveIntegerField()
@ -52,7 +50,6 @@ class Post(models.Model):
title = models.CharField(max_length=50)
@python_2_unicode_compatible
class Attachment(models.Model):
post = models.ForeignKey(
Post,
@ -81,7 +78,6 @@ class Link(Attachment):
# Multi-table inheritance
#
@python_2_unicode_compatible
class Chef(models.Model):
name = models.CharField(max_length=50)
@ -89,7 +85,6 @@ class Chef(models.Model):
return "%s the chef" % self.name
@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
@ -106,7 +101,6 @@ class Rating(models.Model):
ordering = ['-rating']
@python_2_unicode_compatible
class Restaurant(Place, Rating):
serves_hot_dogs = models.BooleanField(default=False)
serves_pizza = models.BooleanField(default=False)
@ -119,7 +113,6 @@ class Restaurant(Place, Rating):
return "%s the restaurant" % self.name
@python_2_unicode_compatible
class ItalianRestaurant(Restaurant):
serves_gnocchi = models.BooleanField(default=False)
@ -127,7 +120,6 @@ class ItalianRestaurant(Restaurant):
return "%s the italian restaurant" % self.name
@python_2_unicode_compatible
class Supplier(Place):
customers = models.ManyToManyField(Restaurant, related_name='provider')
@ -135,7 +127,6 @@ class Supplier(Place):
return "%s the supplier" % self.name
@python_2_unicode_compatible
class ParkingLot(Place):
# An explicit link to the parent (we can control the attribute name).
parent = models.OneToOneField(Place, models.CASCADE, primary_key=True, parent_link=True)

View file

@ -1,10 +1,8 @@
import datetime
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
@ -16,7 +14,6 @@ class Place(models.Model):
return "%s the place" % self.name
@python_2_unicode_compatible
class Restaurant(Place):
serves_hot_dogs = models.BooleanField(default=False)
serves_pizza = models.BooleanField(default=False)
@ -25,7 +22,6 @@ class Restaurant(Place):
return "%s the restaurant" % self.name
@python_2_unicode_compatible
class ItalianRestaurant(Restaurant):
serves_gnocchi = models.BooleanField(default=False)
@ -33,7 +29,6 @@ class ItalianRestaurant(Restaurant):
return "%s the italian restaurant" % self.name
@python_2_unicode_compatible
class ParkingLot(Place):
# An explicit link to the parent (we can control the attribute name).
parent = models.OneToOneField(Place, models.CASCADE, primary_key=True, parent_link=True)
@ -65,7 +60,6 @@ class ParkingLot4B(Place, ParkingLot4):
pass
@python_2_unicode_compatible
class Supplier(models.Model):
name = models.CharField(max_length=50)
restaurant = models.ForeignKey(Restaurant, models.CASCADE)
@ -95,7 +89,6 @@ class SelfRefChild(SelfRefParent):
child_data = models.IntegerField()
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
@ -130,7 +123,6 @@ class QualityControl(Evaluation):
assignee = models.CharField(max_length=50)
@python_2_unicode_compatible
class BaseM(models.Model):
base_name = models.CharField(max_length=100)
@ -138,7 +130,6 @@ class BaseM(models.Model):
return self.base_name
@python_2_unicode_compatible
class DerivedM(BaseM):
customPK = models.IntegerField(primary_key=True)
derived_name = models.CharField(max_length=100)
@ -166,7 +157,6 @@ class InternalCertificationAudit(CertificationAudit):
# Abstract classes don't get m2m tables autocreated.
@python_2_unicode_compatible
class Person(models.Model):
name = models.CharField(max_length=100)
@ -177,7 +167,6 @@ class Person(models.Model):
return self.name
@python_2_unicode_compatible
class AbstractEvent(models.Model):
name = models.CharField(max_length=100)
attendees = models.ManyToManyField(Person, related_name="%(class)s_set")

View file

@ -1,5 +1,4 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
CHOICES = (
(1, 'first'),
@ -7,7 +6,6 @@ CHOICES = (
)
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
@ -38,7 +36,6 @@ class Event(models.Model):
when = models.DateTimeField()
@python_2_unicode_compatible
class Department(models.Model):
id = models.PositiveIntegerField(primary_key=True)
name = models.CharField(max_length=200)
@ -47,7 +44,6 @@ class Department(models.Model):
return self.name
@python_2_unicode_compatible
class Worker(models.Model):
department = models.ForeignKey(Department, models.CASCADE)
name = models.CharField(max_length=200)
@ -56,7 +52,6 @@ class Worker(models.Model):
return self.name
@python_2_unicode_compatible
class BrokenUnicodeMethod(models.Model):
name = models.CharField(max_length=7)

View file

@ -1,9 +1,7 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Band(models.Model):
name = models.CharField(max_length=100)
bio = models.TextField()

View file

@ -4,10 +4,8 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Review(models.Model):
source = models.CharField(max_length=100)
content_type = models.ForeignKey(ContentType, models.CASCADE)
@ -26,7 +24,6 @@ class PersonManager(models.Manager):
return self.get(name=name)
@python_2_unicode_compatible
class Person(models.Model):
objects = PersonManager()
name = models.CharField(max_length=100)
@ -52,7 +49,6 @@ class BookManager(models.Manager):
return super(BookManager, self).get_or_create(*args, **kwargs)
@python_2_unicode_compatible
class Book(models.Model):
objects = BookManager()
title = models.CharField(max_length=100)
@ -69,7 +65,6 @@ class Book(models.Model):
ordering = ('title',)
@python_2_unicode_compatible
class Pet(models.Model):
name = models.CharField(max_length=100)
owner = models.ForeignKey(Person, models.CASCADE)

View file

@ -3,7 +3,6 @@ Regression tests for proper working of ForeignKey(null=True).
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class SystemDetails(models.Model):
@ -20,7 +19,6 @@ class Forum(models.Model):
forum_name = models.CharField(max_length=32)
@python_2_unicode_compatible
class Post(models.Model):
forum = models.ForeignKey(Forum, models.SET_NULL, null=True)
title = models.CharField(max_length=32)
@ -29,7 +27,6 @@ class Post(models.Model):
return self.title
@python_2_unicode_compatible
class Comment(models.Model):
post = models.ForeignKey(Post, models.SET_NULL, null=True)
comment_text = models.CharField(max_length=250)

View file

@ -6,7 +6,6 @@ unexpected results
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# The first two models represent a very simple null FK ordering case.
@ -14,7 +13,6 @@ class Author(models.Model):
name = models.CharField(max_length=150)
@python_2_unicode_compatible
class Article(models.Model):
title = models.CharField(max_length=150)
author = models.ForeignKey(Author, models.SET_NULL, null=True)
@ -36,7 +34,6 @@ class Forum(models.Model):
forum_name = models.CharField(max_length=32)
@python_2_unicode_compatible
class Post(models.Model):
forum = models.ForeignKey(Forum, models.SET_NULL, null=True)
title = models.CharField(max_length=32)
@ -45,7 +42,6 @@ class Post(models.Model):
return self.title
@python_2_unicode_compatible
class Comment(models.Model):
post = models.ForeignKey(Post, models.SET_NULL, null=True)
comment_text = models.CharField(max_length=250)

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Poll(models.Model):
question = models.CharField(max_length=200)
@ -10,7 +8,6 @@ class Poll(models.Model):
return "Q: %s " % self.question
@python_2_unicode_compatible
class Choice(models.Model):
poll = models.ForeignKey(Poll, models.CASCADE)
choice = models.CharField(max_length=200)

View file

@ -6,10 +6,8 @@ To define a one-to-one relationship, use ``OneToOneField()``.
In this example, a ``Place`` optionally can be a ``Restaurant``.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Place(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
@ -18,7 +16,6 @@ class Place(models.Model):
return "%s the place" % self.name
@python_2_unicode_compatible
class Restaurant(models.Model):
place = models.OneToOneField(Place, models.CASCADE, primary_key=True)
serves_hot_dogs = models.BooleanField(default=False)
@ -28,7 +25,6 @@ class Restaurant(models.Model):
return "%s the restaurant" % self.place.name
@python_2_unicode_compatible
class Bar(models.Model):
place = models.OneToOneField(Place, models.CASCADE)
serves_cocktails = models.BooleanField(default=True)
@ -42,7 +38,6 @@ class UndergroundBar(models.Model):
serves_cocktails = models.BooleanField(default=True)
@python_2_unicode_compatible
class Waiter(models.Model):
restaurant = models.ForeignKey(Restaurant, models.CASCADE)
name = models.CharField(max_length=50)
@ -51,7 +46,6 @@ class Waiter(models.Model):
return "%s the waiter at %s" % (self.name, self.restaurant)
@python_2_unicode_compatible
class Favorites(models.Model):
name = models.CharField(max_length=50)
restaurants = models.ManyToManyField(Restaurant)
@ -70,7 +64,6 @@ class RelatedModel(models.Model):
name = models.CharField(max_length=50)
@python_2_unicode_compatible
class MultiModel(models.Model):
link1 = models.OneToOneField(Place, models.CASCADE)
link2 = models.OneToOneField(ManualPrimaryKey, models.CASCADE)

View file

@ -10,10 +10,8 @@ clauses using the variable ``django.db.models.Q`` (or any object with an
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=50)
pub_date = models.DateTimeField()

View file

@ -4,14 +4,12 @@ Tests for the order_with_respect_to Meta attribute.
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class Question(models.Model):
text = models.CharField(max_length=200)
@python_2_unicode_compatible
class Answer(models.Model):
text = models.CharField(max_length=200)
question = models.ForeignKey(Question, models.CASCADE)
@ -23,7 +21,6 @@ class Answer(models.Model):
return six.text_type(self.text)
@python_2_unicode_compatible
class Post(models.Model):
title = models.CharField(max_length=200)
parent = models.ForeignKey("self", models.SET_NULL, related_name="children", null=True)

View file

@ -14,7 +14,6 @@ undefined -- not random, just undefined.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Author(models.Model):
@ -24,7 +23,6 @@ class Author(models.Model):
ordering = ('-pk',)
@python_2_unicode_compatible
class Article(models.Model):
author = models.ForeignKey(Author, models.SET_NULL, null=True)
second_author = models.ForeignKey(Author, models.SET_NULL, null=True, related_name='+')

View file

@ -1,8 +1,6 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()

View file

@ -5,13 +5,11 @@ from django.contrib.contenttypes.fields import (
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
# Basic tests
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=50, unique=True)
first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors')
@ -38,7 +36,6 @@ class FavoriteAuthors(models.Model):
ordering = ['id']
@python_2_unicode_compatible
class AuthorAddress(models.Model):
author = models.ForeignKey(Author, models.CASCADE, to_field='name', related_name='addresses')
address = models.TextField()
@ -50,7 +47,6 @@ class AuthorAddress(models.Model):
return self.address
@python_2_unicode_compatible
class Book(models.Model):
title = models.CharField(max_length=255)
authors = models.ManyToManyField(Author, related_name='books')
@ -74,7 +70,6 @@ class Bio(models.Model):
books = models.ManyToManyField(Book, blank=True)
@python_2_unicode_compatible
class Reader(models.Model):
name = models.CharField(max_length=50)
books_read = models.ManyToManyField(Book, related_name='read_by')
@ -105,7 +100,6 @@ class TeacherManager(models.Manager):
return super(TeacherManager, self).get_queryset().prefetch_related('qualifications')
@python_2_unicode_compatible
class Teacher(models.Model):
name = models.CharField(max_length=50)
qualifications = models.ManyToManyField(Qualification)
@ -129,7 +123,6 @@ class Department(models.Model):
# GenericRelation/GenericForeignKey tests
@python_2_unicode_compatible
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(
@ -230,7 +223,6 @@ class Person(models.Model):
# Models for nullable FK tests
@python_2_unicode_compatible
class Employee(models.Model):
name = models.CharField(max_length=50)
boss = models.ForeignKey('self', models.SET_NULL, null=True, related_name='serfs')
@ -244,7 +236,6 @@ class Employee(models.Model):
# Ticket #19607
@python_2_unicode_compatible
class LessonEntry(models.Model):
name1 = models.CharField(max_length=200)
name2 = models.CharField(max_length=200)
@ -253,7 +244,6 @@ class LessonEntry(models.Model):
return "%s %s" % (self.name1, self.name2)
@python_2_unicode_compatible
class WordEntry(models.Model):
lesson_entry = models.ForeignKey(LessonEntry, models.CASCADE)
name = models.CharField(max_length=200)
@ -264,7 +254,6 @@ class WordEntry(models.Model):
# Ticket #21410: Regression when related_name="+"
@python_2_unicode_compatible
class Author2(models.Model):
name = models.CharField(max_length=50, unique=True)
first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors+')

View file

@ -5,7 +5,6 @@ than using a new table of their own. This allows them to act as simple proxies,
providing a modified interface to the data from the base class.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# A couple of managers for testing managing overriding in proxy model cases.
@ -21,7 +20,6 @@ class SubManager(models.Manager):
return super(SubManager, self).get_queryset().exclude(name="wilma")
@python_2_unicode_compatible
class Person(models.Model):
"""
A simple concrete base class.
@ -101,7 +99,6 @@ class LowerStatusPerson(MyPersonProxy):
objects = models.Manager()
@python_2_unicode_compatible
class User(models.Model):
name = models.CharField(max_length=100)
@ -135,7 +132,6 @@ class Country(models.Model):
name = models.CharField(max_length=50)
@python_2_unicode_compatible
class State(models.Model):
name = models.CharField(max_length=50)
country = models.ForeignKey(Country, models.CASCADE)
@ -152,7 +148,6 @@ class StateProxy(State):
# and select_related, even when mixed with model inheritance
@python_2_unicode_compatible
class BaseUser(models.Model):
name = models.CharField(max_length=255)
@ -169,7 +164,6 @@ class ProxyTrackerUser(TrackerUser):
proxy = True
@python_2_unicode_compatible
class Issue(models.Model):
summary = models.CharField(max_length=255)
assignee = models.ForeignKey(ProxyTrackerUser, models.CASCADE, related_name='issues')

View file

@ -5,7 +5,6 @@ import threading
from django.db import models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
class DumbCategory(models.Model):
@ -17,7 +16,6 @@ class ProxyCategory(DumbCategory):
proxy = True
@python_2_unicode_compatible
class NamedCategory(DumbCategory):
name = models.CharField(max_length=10)
@ -25,7 +23,6 @@ class NamedCategory(DumbCategory):
return self.name
@python_2_unicode_compatible
class Tag(models.Model):
name = models.CharField(max_length=10)
parent = models.ForeignKey(
@ -43,7 +40,6 @@ class Tag(models.Model):
return self.name
@python_2_unicode_compatible
class Note(models.Model):
note = models.CharField(max_length=100)
misc = models.CharField(max_length=10)
@ -63,7 +59,6 @@ class Note(models.Model):
self.lock = threading.Lock()
@python_2_unicode_compatible
class Annotation(models.Model):
name = models.CharField(max_length=10)
tag = models.ForeignKey(Tag, models.CASCADE)
@ -73,7 +68,6 @@ class Annotation(models.Model):
return self.name
@python_2_unicode_compatible
class ExtraInfo(models.Model):
info = models.CharField(max_length=100)
note = models.ForeignKey(Note, models.CASCADE)
@ -86,7 +80,6 @@ class ExtraInfo(models.Model):
return self.info
@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=10)
num = models.IntegerField(unique=True)
@ -99,7 +92,6 @@ class Author(models.Model):
return self.name
@python_2_unicode_compatible
class Item(models.Model):
name = models.CharField(max_length=10)
created = models.DateTimeField()
@ -115,7 +107,6 @@ class Item(models.Model):
return self.name
@python_2_unicode_compatible
class Report(models.Model):
name = models.CharField(max_length=10)
creator = models.ForeignKey(Author, models.SET_NULL, to_field='num', null=True)
@ -124,7 +115,6 @@ class Report(models.Model):
return self.name
@python_2_unicode_compatible
class Ranking(models.Model):
rank = models.IntegerField()
author = models.ForeignKey(Author, models.CASCADE)
@ -137,7 +127,6 @@ class Ranking(models.Model):
return '%d: %s' % (self.rank, self.author.name)
@python_2_unicode_compatible
class Cover(models.Model):
title = models.CharField(max_length=50)
item = models.ForeignKey(Item, models.CASCADE)
@ -149,7 +138,6 @@ class Cover(models.Model):
return self.title
@python_2_unicode_compatible
class Number(models.Model):
num = models.IntegerField()
@ -212,7 +200,6 @@ class CustomManager(models.Manager):
return qs.filter(public=True, tag__name='t1')
@python_2_unicode_compatible
class ManagedModel(models.Model):
data = models.CharField(max_length=10)
tag = models.ForeignKey(Tag, models.CASCADE)
@ -271,7 +258,6 @@ class CustomPkTag(models.Model):
# path to another model, and a return path from that model.
@python_2_unicode_compatible
class Celebrity(models.Model):
name = models.CharField("Name", max_length=20)
greatest_fan = models.ForeignKey("Fan", models.SET_NULL, null=True, unique=True)
@ -290,7 +276,6 @@ class Fan(models.Model):
# Multiple foreign keys
@python_2_unicode_compatible
class LeafA(models.Model):
data = models.CharField(max_length=10)
@ -307,7 +292,6 @@ class Join(models.Model):
b = models.ForeignKey(LeafB, models.CASCADE)
@python_2_unicode_compatible
class ReservedName(models.Model):
name = models.CharField(max_length=20)
order = models.IntegerField()
@ -318,7 +302,6 @@ class ReservedName(models.Model):
# A simpler shared-foreign-key setup that can expose some problems.
@python_2_unicode_compatible
class SharedConnection(models.Model):
data = models.CharField(max_length=10)
@ -336,7 +319,6 @@ class PointerB(models.Model):
# Multi-layer ordering
@python_2_unicode_compatible
class SingleObject(models.Model):
name = models.CharField(max_length=10)
@ -355,7 +337,6 @@ class RelatedObject(models.Model):
ordering = ['single']
@python_2_unicode_compatible
class Plaything(models.Model):
name = models.CharField(max_length=10)
others = models.ForeignKey(RelatedObject, models.SET_NULL, null=True)
@ -367,7 +348,6 @@ class Plaything(models.Model):
return self.name
@python_2_unicode_compatible
class Article(models.Model):
name = models.CharField(max_length=20)
created = models.DateTimeField()
@ -376,7 +356,6 @@ class Article(models.Model):
return self.name
@python_2_unicode_compatible
class Food(models.Model):
name = models.CharField(max_length=20, unique=True)
@ -384,7 +363,6 @@ class Food(models.Model):
return self.name
@python_2_unicode_compatible
class Eaten(models.Model):
food = models.ForeignKey(Food, models.SET_NULL, to_field="name", null=True)
meal = models.CharField(max_length=20)
@ -393,7 +371,6 @@ class Eaten(models.Model):
return "%s at %s" % (self.food, self.meal)
@python_2_unicode_compatible
class Node(models.Model):
num = models.IntegerField(unique=True)
parent = models.ForeignKey("self", models.SET_NULL, to_field="num", null=True)
@ -404,7 +381,6 @@ class Node(models.Model):
# Bug #12252
@python_2_unicode_compatible
class ObjectA(models.Model):
name = models.CharField(max_length=50)
@ -425,7 +401,6 @@ class ChildObjectA(ObjectA):
pass
@python_2_unicode_compatible
class ObjectB(models.Model):
name = models.CharField(max_length=50)
objecta = models.ForeignKey(ObjectA, models.CASCADE)
@ -440,7 +415,6 @@ class ProxyObjectB(ObjectB):
proxy = True
@python_2_unicode_compatible
class ObjectC(models.Model):
name = models.CharField(max_length=50)
objecta = models.ForeignKey(ObjectA, models.SET_NULL, null=True)
@ -451,7 +425,6 @@ class ObjectC(models.Model):
return self.name
@python_2_unicode_compatible
class SimpleCategory(models.Model):
name = models.CharField(max_length=15)
@ -459,7 +432,6 @@ class SimpleCategory(models.Model):
return self.name
@python_2_unicode_compatible
class SpecialCategory(SimpleCategory):
special_name = models.CharField(max_length=15)
@ -467,7 +439,6 @@ class SpecialCategory(SimpleCategory):
return self.name + " " + self.special_name
@python_2_unicode_compatible
class CategoryItem(models.Model):
category = models.ForeignKey(SimpleCategory, models.CASCADE)
@ -475,7 +446,6 @@ class CategoryItem(models.Model):
return "category item: " + str(self.category)
@python_2_unicode_compatible
class OneToOneCategory(models.Model):
new_name = models.CharField(max_length=15)
category = models.OneToOneField(SimpleCategory, models.CASCADE)
@ -515,7 +485,6 @@ class ModelA(models.Model):
d = models.ForeignKey(ModelD, models.CASCADE)
@python_2_unicode_compatible
class Job(models.Model):
name = models.CharField(max_length=20, unique=True)
@ -528,7 +497,6 @@ class JobResponsibilities(models.Model):
responsibility = models.ForeignKey('Responsibility', models.CASCADE, to_field='description')
@python_2_unicode_compatible
class Responsibility(models.Model):
description = models.CharField(max_length=20, unique=True)
jobs = models.ManyToManyField(Job, through=JobResponsibilities,
@ -561,7 +529,6 @@ class BaseA(models.Model):
c = models.ForeignKey(FK3, models.SET_NULL, null=True)
@python_2_unicode_compatible
class Identifier(models.Model):
name = models.CharField(max_length=100)
@ -605,7 +572,6 @@ class MyObject(models.Model):
# Models for #17600 regressions
@python_2_unicode_compatible
class Order(models.Model):
id = models.IntegerField(primary_key=True)
@ -616,7 +582,6 @@ class Order(models.Model):
return '%s' % self.pk
@python_2_unicode_compatible
class OrderItem(models.Model):
order = models.ForeignKey(Order, models.CASCADE, related_name='items')
status = models.IntegerField()
@ -632,7 +597,6 @@ class BaseUser(models.Model):
pass
@python_2_unicode_compatible
class Task(models.Model):
title = models.CharField(max_length=10)
owner = models.ForeignKey(BaseUser, models.CASCADE, related_name='owner')
@ -642,7 +606,6 @@ class Task(models.Model):
return self.title
@python_2_unicode_compatible
class Staff(models.Model):
name = models.CharField(max_length=10)
@ -650,7 +613,6 @@ class Staff(models.Model):
return self.name
@python_2_unicode_compatible
class StaffUser(BaseUser):
staff = models.OneToOneField(Staff, models.CASCADE, related_name='user')
@ -673,7 +635,6 @@ class Person(models.Model):
name = models.CharField(max_length=128)
@python_2_unicode_compatible
class Company(models.Model):
name = models.CharField(max_length=128)
employees = models.ManyToManyField(Person, related_name='employers', through='Employment')

View file

@ -8,10 +8,8 @@ reserved-name usage.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Thing(models.Model):
when = models.CharField(max_length=1, primary_key=True)
join = models.CharField(max_length=1)

View file

@ -5,10 +5,8 @@ This demonstrates the reverse lookup features of the database API.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class User(models.Model):
name = models.CharField(max_length=200)
@ -16,7 +14,6 @@ class User(models.Model):
return self.name
@python_2_unicode_compatible
class Poll(models.Model):
question = models.CharField(max_length=200)
creator = models.ForeignKey(User, models.CASCADE)
@ -25,7 +22,6 @@ class Poll(models.Model):
return self.question
@python_2_unicode_compatible
class Choice(models.Model):
name = models.CharField(max_length=100)
poll = models.ForeignKey(Poll, models.CASCADE, related_name="poll_choice")

View file

@ -5,10 +5,8 @@ To execute arbitrary code around ``save()`` and ``delete()``, just subclass
the methods.
"""
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)

View file

@ -1,6 +1,5 @@
from django.apps.registry import Apps
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
# Because we want to test creation and deletion of these as separate things,
# these models are all inserted into a separate Apps so the main test
@ -160,7 +159,6 @@ class TagUniqueRename(models.Model):
# Based on tests/reserved_names/models.py
@python_2_unicode_compatible
class Thing(models.Model):
when = models.CharField(max_length=1, primary_key=True)

Some files were not shown because too many files have changed in this diff Show more