Install & Compatibility
Where this runs
tested against v0.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
model_me
✓ from django_fake_model import model_me
✗ from django_fake_model import model_me
This quickstart demonstrates how to use the `model_me` decorator to create a temporary Django model for a specific test method. The fake model is automatically registered and unregistered, ensuring test isolation. This code snippet should be placed within a Django test file and run as part of a Django test suite.
import unittest
from django.test import TestCase
from django.db import models
from fake_model import model_me
class MyFakeModelTest(TestCase):
"""
Example demonstrating the model_me decorator for creating a temporary Django model.
To execute this test, ensure you have a Django project configured and run it
via `python manage.py test your_app_name`.
"""
@model_me('my_app', 'MyFakeModel', fields={
'name': models.CharField(max_length=255),
'value': models.IntegerField(default=0),
})
def test_create_and_query_fake_model(self, MyFakeModel):
# MyFakeModel is a temporary model class, available only within this test method
self.assertFalse(MyFakeModel.objects.exists()) # Should be empty initially
instance = MyFakeModel.objects.create(name='Test Item', value=42)
self.assertEqual(instance.name, 'Test Item')
self.assertEqual(instance.value, 42)
retrieved = MyFakeModel.objects.get(name='Test Item')
self.assertEqual(retrieved.pk, instance.pk)
self.assertEqual(retrieved.value, 42)
self.assertEqual(MyFakeModel.objects.count(), 1)
Debug
Known issues
breakingThe library has not been updated since 2017 and is likely incompatible with modern Django versions (3.x, 4.x, 5.x) and newer Python versions (3.8+). It was last officially tested with Django 1.9.fixFor newer Django projects, consider using more actively maintained alternatives like `django-dynamic-models` or manual test-model creation. If absolutely necessary, pin Django to 1.9 and Python to 3.7 or earlier.
affects: All versions (0.1.x) when used with Django > 1.9 or Python > 3.7
gotchaThe lack of active maintenance since 2017 means the library may have unpatched bugs, security vulnerabilities, or simply not function as expected with contemporary Django ecosystem components.fixCarefully evaluate the long-term implications of using an unmaintained library. For new development, prioritize actively supported tools.
affects: All versions (0.1.x)
gotchaPrior to version 0.1.3, defining and using multiple fake models within the same test context could lead to unexpected behavior or conflicts. This was fixed in 0.1.3.fixEnsure you are using version 0.1.3 or higher to reliably use multiple fake models within your tests.
affects: <0.1.3
gotchaVersion 0.1.4 specifically fixed issues related to the `fake_me` class decorator when used with `nose` tests. If you are using `fake_me` with other test runners, thoroughly test its behavior.fixUpgrade to version 0.1.4 for `nose` compatibility. For other test runners (e.g., `pytest-django`), verify functionality explicitly or consider using `model_me` which might be more robust across different setups.
affects: <0.1.4, potentially 0.1.4 with non-nose runners
Upgrade
Version history
0.1.4latest on PyPI · released Feb 8, 2016
Audit
Dependencies
DjangorequiredCore dependency for functionality; designed to be used exclusively within Django projects.