Comments (11)
Hi Alan
Not sure, If I understand your question correctly. If you want to use custom model than you need to implement all abstract methods.
Please see the default one
https://github.com/sonus21/error-tracker/blob/master/error_tracker/django/models.py
from error-tracker.
from error-tracker.
Got it, the current error_tracker Django model is swappable that means you can extend this model with your custom one and swap with that something like this.
from error_tracker.django.models import ErrorModel
class MyErrorModel(ErrorModel):
# add your code here
Now you should set APP_ERROR_DB_MODEL
in settings.py like we do for User
model.
from error-tracker.
Yes, I did that early but this is what I get:
monitoring.MyErrorModel.errormodel_ptr: (fields.E301) Field defines a relation with the model 'error_tracker.ErrorModel', which has been swapped out.
HINT: Update the relation to point at 'settings.APP_ERROR_DB_MODEL'.
from error-tracker.
Can you please share the MyErrorModel class definition? It seems you're using ForeignKey to track similar error via self reference.
from error-tracker.
I am not. I tried a lot of things already.
from error_tracker.django.models import ErrorModel
class MyErrorModel(ErrorModel):
pass
On setttings.py:
APP_ERROR_DB_MODEL = 'monitoring.MyErrorModel'
from error-tracker.
It seems you can't extend model directly, we need to make ErrorModel as Abstract, this change has been done, i'll release this shortly via d699840
from error-tracker.
Thank you, Sonu!
from error-tracker.
Thank you, Sonu. I am able to extend it now using your last revision. If you allow me I want to give you three suggestions:
-
You are setting the db_name in the Meta options, if someone wants to reuse the model into their app they will probably expect the table to have the name as 'myapp_mymodelname' instead of 'exceptions'. Of course, if you update the documentation telling to include into their Meta options db_table = None this will be OK.
-
Maybe some of the people needs to explicitly have a id as PK in their models, in this case they will add the id field and declare the hash field without the primary_key attribute, my case due distributed databases. In this case they will get an error because when you seek for a entry into the exceptions table you are using pk field, instead of hash:
return cls.objects.get(pk=rhash)
Instead of:
return cls.objects.get(hash=rhash)
Not sure how about this in Flask. -
Options to see the Exception table as a admin page.
If you want I can do a pull request with the item 2 and 3 so you can see it.
from error-tracker.
Hi Alan
- Point 1 makes sense
- Point 2 can break compatibility, your idea seems fine.
- Point 3 can be done easily via admin.py file [But I think the developer can register their own model via admin.py ]
from error-tracker.
Version 2.0.0 has been released, it has the changes for point 1 and 2. I'm closing this issue, please open it if you see.
from error-tracker.
Related Issues (13)
- Protect Django views (and probably Flask too)
- Error: ModuleNotFoundError: No module named 'flask HOT 2
- Change break migrations HOT 1
- Error on warnings library HOT 1
- Simplify error reporting
- How to Suppress warnings for Default Options HOT 1
- UserWarning: APP_ERROR_DB_MODEL is not set using default model HOT 1
- NotificationMixin not working Without set APP_ERROR_RECIPIENT_EMAIL and APP_ERROR_EMAIL_SENDER HOT 5
- All variables in traceback are `None` HOT 4
- Add support for Django REST Framework
- Record all errors (do not overwrite) HOT 4
- Reduce dependencies? HOT 3
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 error-tracker.