Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable LogEntry model #346

Open
pydanny opened this issue Jul 18, 2013 · 4 comments
Open

Customizable LogEntry model #346

pydanny opened this issue Jul 18, 2013 · 4 comments

Comments

@pydanny
Copy link
Member

pydanny commented Jul 18, 2013

This is just a thought, but it would be similar to how the new Django auth.User model works:

# Psuedo-code
class AbstractLogEntry(models.Model):

    action_time = models.DateTimeField(_('action time'), auto_now=True)
    user = models.ForeignKey(settings.AUTH_USER_MODEL)
    content_type = models.ForeignKey(ContentType, blank=True, null=True)
    object_id = models.TextField(_('object id'), blank=True, null=True)
    object_repr = models.CharField(_('object repr'), max_length=200)
    action_flag = models.PositiveSmallIntegerField(_('action flag'))
    change_message = models.TextField(_('change message'), blank=True)

    class Meta:
        abstract = True

    # snip all the methods and manager


def get_logentry_model():
    return settings.get("DJADMIN2_LOGENTRY_MODEL", "djadmin2.LogEntry")

if get_logentry_model() == "djadmin2.LogEntry":

    class LogEntry(AbstractLogEntry):
        pass

With this, developers can extend the LogEntry model to do whatever they want. We might even enable them to log to it from regular model saves via signals. The downside is this is a performance hit.

More thoughts:

  • Perhaps also allow for non-ORM records to be stored?
  • Perhaps a logging system or data store better for this many writes?
  • Could also work in a queueing system.
@pydanny
Copy link
Member Author

pydanny commented Jul 18, 2013

Needs to wait until after #290 and #306 are complete.

@AndrewIngram
Copy link
Contributor

You might want to look at how django-oscar (https://github.com/tangentlabs/django-oscar) handles model overrides, it works pretty effectively.

@douglasmiranda
Copy link
Contributor

+1 for DJADMIN2_LOGENTRY_MODEL
+1 for "Perhaps also allow for non-ORM records to be stored?"

I'm thinking.. when extending the LogEntry, sometimes I'll have to override things like ModelHistoryView, model_history.html, history.html. So, I'm just wondering if would be interesting to have some features as "extensions/plugins"? I mean, a package, so I can implement my needs and register on djangoadmin2.

It is something to consider, (worth to discuss), or am I just complicating things?

@nimish-kumar
Copy link

Is there a way to still implement this? I know it's been quite sometime (almost a decade tbh) but has this been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants