mirror of
https://github.com/django/django.git
synced 2024-12-23 09:36:06 +00:00
660f9086f1
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11755 bcc190cf-cafb-0310-a4f2-bffc1f526a37
56 lines
1.2 KiB
Python
56 lines
1.2 KiB
Python
from django.db import models
|
|
|
|
class Advertisment(models.Model):
|
|
customer = models.CharField(max_length=100)
|
|
publications = models.ManyToManyField("model_package.Publication", null=True, blank=True)
|
|
|
|
class Meta:
|
|
app_label = 'model_package'
|
|
|
|
__test__ = {'API_TESTS': """
|
|
>>> from models.publication import Publication
|
|
>>> from models.article import Article
|
|
>>> from django.contrib.auth.views import Site
|
|
|
|
>>> p = Publication(title="FooBar")
|
|
>>> p.save()
|
|
>>> p
|
|
<Publication: Publication object>
|
|
|
|
>>> from django.contrib.sites.models import Site
|
|
>>> current_site = Site.objects.get_current()
|
|
>>> current_site
|
|
<Site: example.com>
|
|
|
|
# Regression for #12168: models split into subpackages still get M2M tables
|
|
|
|
>>> a = Article(headline="a foo headline")
|
|
>>> a.save()
|
|
>>> a.publications.add(p)
|
|
>>> a.sites.add(current_site)
|
|
|
|
>>> a = Article.objects.get(id=1)
|
|
>>> a
|
|
<Article: Article object>
|
|
>>> a.id
|
|
1
|
|
>>> a.sites.count()
|
|
1
|
|
|
|
# Regression for #12248 - Models can exist in the test package, too
|
|
|
|
>>> ad = Advertisment(customer="Lawrence Journal-World")
|
|
>>> ad.save()
|
|
>>> ad.publications.add(p)
|
|
|
|
>>> ad = Advertisment.objects.get(id=1)
|
|
>>> ad
|
|
<Advertisment: Advertisment object>
|
|
|
|
>>> ad.publications.count()
|
|
1
|
|
|
|
"""}
|
|
|
|
|