Comments (5)
Just a head's up I had a similar issue. The first error:
AttributeError: 'module' object has no attribute 'extensions'
In my case was because I was testing with out setting the application context.
with app.app_context():
country = mixer.blend(Country)
The second issue:
AttributeError: Mixer (<class 'models.Country'>): 'NoneType' object has no attribute 'bases'.
Is most likely because the Country model contains a field not in the standard Sqlalchemy GenFactory. In my case (missing postgresql dialects UUID and ARRAY) this was resolved by creating a new factory for the missing fields.
def get_extents_array():
"""
Generate a random extents array
"""
return [0,1,0,1]
class SeerFactory(GenFactory):
generators = {
UUID: uuid4().__str__,
(db.ARRAY, ARRAY): get_extents_array
}
mixer = Mixer(commit=True, factory=SeerFactory)
This could be potentially made more clear in the GenFactory(mixer/ factory.py) classmethod get_fabric. If the field type doesn't exist fcls will equal None and therefore will not have a bases attribute. I'm not knowledgable enough about the code base to suggest a fix for it. But it should probably be a little more verbose about what field it doesn't have in the factory. I guess it's maybe worthwhile having and assert fcls is not None.
Offending piece of code at line 172 of factory.py.
# this will not work if fcls is None
if not func and fcls.__bases__:
func = cls.generators.get(fcls.__bases__[0])
I hope that helps.
from mixer.
I also tried the Mixer
class from mixer.backend.flask
from mixer.backend.flask import Mixer
mixer = Mixer(app, commit=True)
It gives me a new error
AttributeError: Mixer (<class 'models.Country'>): 'NoneType' object has no attribute '__bases__'
from mixer.
Hi hussaintamboli
Did you resolve the issue?
from mixer.
I ended up using just Faker instead. I'll try to reproduce this issue when I get time.
from mixer.
I think this is similar issue to the fix in pull request #80
from mixer.
Related Issues (20)
- Generate model instance with related data at once.
- Fix simple typo: anythin -> anything
- Django mixer.blend fails to populate model that has (custom) SearchVectorField HOT 1
- Please update Faker version due security issue HOT 1
- is alive? HOT 1
- No matching distribution found
- Unable to generate unique uuids HOT 1
- Django 3.2
- [Django] mixer ignores registered factories when default values present
- There should be a way to compose generators with filters
- 'ArrayField' has no attribute '_meta' HOT 3
- Incompatible with latest version of Faker (`12.1.0`) HOT 4
- Couldn't save user, original exception: 'NoneType' object has no attribute 'get_FL_names'
- Support for type annotations and TypedDict
- Mixer should respect decimal presision on SQLAlchemy models
- async support
- Don't restrict Faker to version < 12.1 HOT 6
- Add backend for Pydantic
- Is this library still being maintained? HOT 2
- Support Flask-SQLAlchemy >=3.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixer.