10👍
I ran into this issue where I got the ModuleNotFoundError for a folder in my path that I wasn’t directly specifying.
I was running my test file inside PyCharm.
The fix was adding the main entry point to my test file:
if __name__ == '__main__':
unittest.main()
6👍
i figured it out after more crawling on stackO. It was a simple fix I got the idea from here:
website w/ answer
. it turns out the answer was just to change the relative import to an abolute import
In status/tests.py, the line of code had to change from:
from .models import Status
to:
from status.models import Status
I still find it weird that it threw an error but the accounts/tests.py is fine.
- [Django]-How can I avoid "Using selector: EpollSelector" log message in Django?
- [Django]-Exclude fields in Django admin for users other than superuser
- [Django]-Getting Values of QuerySet in Django
3👍
Also the test package should not have the same name as the source package. Eg:
- src
- utils
- utilities.py
- tests
- utils
- test_utilities.py
This setup can cause the error, although it depends on your PYTHONPATH and where you run the tests from. Note how there’s utils
package in both src
and test
directories. Renaming one of the packages seems to solve the problem, eg: utils
and test_utils
.
Not directly the situation that OP is facing, but I thought it’s worth mentioning.
- [Django]-Django datefield filter by weekday/weekend
- [Django]-Django: Use of DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT in settings.py?
- [Django]-How to implement FirebaseDB with a Django Web Application
- [Django]-Python (and Django) best import practices
- [Django]-Django Footer and header on each page with {% extends }
- [Django]-Naming convention for Django URL, templates, models and views
0👍
Double check you pycharm root directory also, if you did put your virtual environment to the same directory as django apps, move env file to higher hierarchy
- [Django]-Heroku, postgreSQL, django, comments, tastypie: No operator matches the given name and argument type(s). You might need to add explicit type casts
- [Django]-Serializer call is showing an TypeError: Object of type 'ListSerializer' is not JSON serializable?
- [Django]-Django JSONField inside ArrayField
0👍
So I got this error because I had an __init__.py
file in the same directory as the project root (the same directory that manage.py exists in.) This caused some wierd import issues with the tests code and caused a number of other imports of tests to fail.
- [Django]-Sending post data from angularjs to django as JSON and not as raw content
- [Django]-Django models: mutual references between two classes and impossibility to use forward declaration in python
- [Django]-Django-rest-framework returning 403 response on POST, PUT, DELETE despite AllowAny permissions