2009-11-20 08:59:38 +08:00
|
|
|
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': """
|
2009-11-05 19:57:28 +08:00
|
|
|
>>> 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
|
|
|
|
|
2009-11-20 08:59:38 +08:00
|
|
|
# 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
|
|
|
|
|
|
|
|
"""}
|
2009-11-05 19:57:28 +08:00
|
|
|
|
|
|
|
|