Git Product home page Git Product logo

django-model-changes's People

Contributors

ianlee1521 avatar iansprice avatar kajic avatar muriloventuroso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-model-changes's Issues

Where is version 0.15

Hello

The version on pypi is 0.15, but the latest version in this repo is 0.14, would it be possible for you to push those changes?

Thanks

Ben

Why no related fields?

I wonder why you explicitly exclude related fields (ForeignKey fields) in your current_state() method.
Could you elaborate on that? For me it's important to know whether I have a different related object (according to its ID) after the save().

Detect any changes made to a model

I have found myself in a situation where for several models say X, Y and Z, I would like to know when any change happens on them i.e. any create, update, delete. Is there any way to accomplish this using django-model-changes?

'ReverseSingleRelatedObjectDescriptor' object has no attribute 'cache_name'

Hey there,

I have integrated the app into a Model of mine. I put the ChangesMixin in front of the model description it inherits from. But I get the following error:

'ReverseSingleRelatedObjectDescriptor' object has no attribute 'cache_name'

As my Model does not contain a "cache_name", I guess the problem is from your app?

Greetings,

Tron

EDIT: Using Django 1.3

Related object in creation action

Related objects does not appear in previous_changes() method after object creation. For example, if your model has an "creator" field that references to auth.User and you set creator during creation, previous_changes() method does not show 'creator': [null, user].

To fix this problem, you could include next code in _save_state method:

    def _save_state(self, new_instance=False, event_type='save'):

        if new_instance and not self.pk:  # new instance
            self._states.append(self.new_state())
        else:
            # Pipe the pk on deletes so that a correct snapshot of the current
            # state can be taken.
            if event_type == DELETE:
                self.pk = None
            # Save current state.
            self._states.append(self.current_state())
        ...

And add the new function too:

    def new_state(self):
        """
        Returns a ``field -> None`` dict of the initial state of the instance.
        """
        field_names = set()
        [field_names.add(f.name) for f in self._meta.local_fields]
        [field_names.add(f.attname) for f in self._meta.local_fields]
        return dict([(field_name, None) for field_name in field_names])

If you are ok with that, I can make a PR to the library.

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.