Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #219 from aericson/deprecation-19
Browse files Browse the repository at this point in the history
Address deprecations warnings from RemovedInDjango19Warning
  • Loading branch information
vandersonmota committed Apr 16, 2015
2 parents 6c45de3 + a23c5df commit 7bccad4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 7 additions & 4 deletions model_mommy/mommy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
import warnings

from django.conf import settings
from django.utils import importlib
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
import django
from django.db.models.loading import get_model
if django.VERSION >= (1, 7):
import importlib
from django.apps import apps
get_model = apps.get_model
from django.contrib.contenttypes.fields import GenericRelation
else:
from django.db.models.loading import get_model
from django.utils import importlib
from django.db.models.loading import cache
from django.contrib.contenttypes.generic import GenericRelation
from django.db.models.base import ModelBase
from django.db.models import (
CharField, EmailField, SlugField, TextField, URLField,
Expand Down Expand Up @@ -292,7 +295,7 @@ def _make(self, commit=True, **attrs):

field_value_not_defined = field.name not in model_attrs

if isinstance(field, (AutoField, generic.GenericRelation)):
if isinstance(field, (AutoField, GenericRelation)):
continue

if all([field.name not in model_attrs, field.name not in self.rel_fields, field.name not in self.attr_mapping]):
Expand Down
10 changes: 7 additions & 3 deletions test/generic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
from django.core.files.storage import FileSystemStorage

from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
if VERSION >= (1, 7):
from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey
else:
from django.contrib.contenttypes.generic import GenericRelation, GenericForeignKey

from .fields import *
from model_mommy.timezone import smart_datetime as datetime
import datetime as base_datetime
Expand Down Expand Up @@ -138,11 +142,11 @@ class DummyEmailModel(models.Model):
class DummyGenericForeignKeyModel(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
content_object = GenericForeignKey('content_type', 'object_id')


class DummyGenericRelationModel(models.Model):
relation = generic.GenericRelation(DummyGenericForeignKeyModel)
relation = GenericRelation(DummyGenericForeignKeyModel)


class DummyNullFieldsModel(models.Model):
Expand Down

0 comments on commit 7bccad4

Please sign in to comment.