jazzband / jazzband/django-admin2
Customizable LogEntry model
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 147
- PR merge metrics
- No merged PRs in 30d
Description
This is just a thought, but it would be similar to how the new Django auth.User model works:
``` python
# 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.
Contributor guide
Research direction
No repository files, tests, or entry points are identified. Start by reviewing the proposed AbstractLogEntry and the questions about non-ORM storage, signals, performance, and queueing; done requires an agreed scope and design before implementation can begin.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100