Code Monkey home page Code Monkey logo

Comments (11)

sonus21 avatar sonus21 commented on June 6, 2024

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.

AlanParente avatar AlanParente commented on June 6, 2024

from error-tracker.

sonus21 avatar sonus21 commented on June 6, 2024

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.

AlanParente avatar AlanParente commented on June 6, 2024

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.

sonus21 avatar sonus21 commented on June 6, 2024

Can you please share the MyErrorModel class definition? It seems you're using ForeignKey to track similar error via self reference.

from error-tracker.

AlanParente avatar AlanParente commented on June 6, 2024

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.

sonus21 avatar sonus21 commented on June 6, 2024

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.

AlanParente avatar AlanParente commented on June 6, 2024

Thank you, Sonu!

from error-tracker.

AlanParente avatar AlanParente commented on June 6, 2024

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:

  1. 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.

  2. 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.

  3. 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.

sonus21 avatar sonus21 commented on June 6, 2024

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.

sonus21 avatar sonus21 commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.