GithubHelp home page GithubHelp logo

vikingco / django-states2 Goto Github PK

View Code? Open in Web Editor NEW
131.0 131.0 41.0 268 KB

State machine for django models.

Home Page: https://github.com/vikingco/django-states2

Makefile 0.55% Python 99.45%

django-states2's People

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  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  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-states2's Issues

Log transitions

I am new to your product and I don't know if this is a issue within the documentation, my know-how of django or something else.

I am creating a class Process, which is a StateModel. Within this class I have a subclass, Machine(StateMachine). Within this class log_transitions is default True. See code below as current situation.

class Process(StateModel):
    applicant = models.IntegerField(null=True, blank=True,
        verbose_name=_("applicant"))

    class Meta:
        app_label = 'testing_process'
        verbose_name = _('process')
        verbose_name_plural = _('processes')

    class Machine(StateMachine):
        # possible states
        class initiated(StateDefinition):
            description = _('process initiated')
            initial = True

        class process_started(StateDefinition):
            description = _('process started')

        #state transitions
        class request_offer(StateTransition):
            from_state = "initiated"
            to_state = "process_started"
            description = _("Start up the process")

I am testing this class with the following lines

from testing_process.models.process import Process
proc, c = Process.objects.get_or_create(applicant=1)
proc.make_transition('request_offer')

I get the following error; DatabaseError:
(1146, "Table 'testing_process.models_processstatelog' doesn't exist")

But when with syncdb the table isn't created. It isn't either shown with sqlall. States2 is in my requirements.txt, placed within my setting in INSTALLED_APPS. I solved it temporary with log_transitions = False, but I ofcourse want to log my transitions.

Adminsite handle with the wrong Machine

Environment:


Request Method: POST
Request URL: http://cent.os:8000/admin/device/phone/add/

Django Version: 1.6.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'south',
 'device',
 'webapp',
 'django_states')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  432.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  198.             return view(request, *args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  29.             return bound_func(*args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  25.                 return func(self, *args2, **kwargs2)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
  371.                 return func(*args, **kwargs)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
  1133.                 self.log_addition(request, new_object)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in log_addition
  599.             object_repr=force_text(object),
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django/utils/encoding.py" in force_text
  100.                 s = s.__unicode__()
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django_states/models.py" in new_unicode
  48.                 return '%s (%s)' % (old_unicode(self), self.Machine.get_state(self.state).description)
File "/home/meng/.virtualenvs/DEVICEMANAGER/local/lib/python2.7/site-packages/django_states/models.py" in __unicode__
  89.         return 'State: ' + self.state

Exception Type: AttributeError at /admin/device/phone/add/
Exception Value: 'Phone' object has no attribute 'state'

models.py

class Phone(StateModel):
    status = StateField(machine=PhoneStatusStateMachine)

admin.py

class PhoneAdmin(admin.ModelAdmin):
    pass
admin.site.register(Phone, PhoneAdmin)

Django 1.6 - TransactionManagementError

The following code will raise a TransactionManagementError when;
a handler in a transition raises an exception, and the make_transisition is in a transaction.atomic

# model_methods.py: line 205-209
except Exception, e:
    if _state_log_model:
        # main reason, this will raise error, you won't see 'e'
        transition_log.make_transition('fail')
    raise

Cause: trying to save something in database after an exception, which isn't 'protected' anymore by transaction block.

Maintenance state

As @nielsvanoch just updated the maintenance state of the project to unmaintained, I was wondering whether some people are still using it.
If so, and Niels can transfer pypi ownership of the name, I would take up maintenance and make sure it works on at least the current Django versions.

More complete Docs/Demo

It would be better to have a working example that includes all the implemented functions.
Just a long term goal I suppose. It can be tough working out from source code how everything is supposed to fit together for un demonstrated parts with thin documentation.

PyPI releases

The latest django-states on PyPI is version 1.5.1, uploaded on 2013-02-07. Is it possible to make upload an update @jonathanslenders ?

test_transition

Great app, I was looking for something like it for a while. Thanks a whole bunch!
One small suggestion:
instead of returning True on
object.get_state_info().test_transition('transition_name', user)
it would probably better to return state_info instance, so the call can be chained:

try:
    object.get_state_info().test_transition('transition_name', user).make_transition('transition_name', user)
except States2Exception as e: 
    raise ValidationError("Cannot changes state because %s" % e) 

instead of:

try:
    if object.get_state_info().test_transition('transition_name', user):
        object.get_state_info().make_transition('transition_name', user)
except States2Exception as e: 
    raise ValidationError("Cannot changes state because %s" % e) 

This way it is type consistent (test_transition never returns False anyhow), it is more DRY and by chaining calls like that we could also eliminate failed transition logs in a more concise way.

I would submit a pull request myself, but it is literally a one line change:
from True to si_self in model_methods.
More over this change wouldn't break any existing code, since si_self would still evaluate to True.

What do you guys think?

Possible transitions

Found a small bug. possible_transitions in models.py called the property possible_transitions in the model_methods.py as a function, which made it call the returned generator.

Hereby the diff, if necessary.

@@ -125,7 +125,7 @@ class StateModel(models.Model):

         :returns: list of transitions which can be made from the current state
         """
-        return self.get_state_info().possible_transitions()
+        return self.get_state_info().possible_transitions

     @classmethod
     def get_state_model_name(self):

no_state_validation defaults to True?

In fields.py, when overriding "save" with "new_save" method, if no_state_validation is not found in kwargs it defaults to True, resulting in skipping initial state handler.

Is this the desired behaviour?

Data truncated for column 'to_state' at row 1

This error is caused by logging state transitions

The state field in my model allows 64 chars

attrs['state'] = StateField(max_length=64, default='0',
                                        verbose_name=_('state id'),
                                        machine=attrs['Machine'])

But the logging allows states of max 32 chars

from_state = models.CharField(max_length=32,
                                      choices=get_state_choices())
to_state = models.CharField(max_length=32,
                                      choices=get_state_choices())

Transition with multiple from_state

From what I understand about this package it seems that if I have a state that can be transitioned to from multiple other states I would need to have an individual transition for each combinations of from_state and to_state.

For example I have a deleted stated that can be transition to from either new or draft. Is there a better way other than one transition per pair of states?

AttributeError: 'Process' object has no attribute 'all_transitions'

Hi there,

I get an AttributeError: 'Process' object has no attribute 'all_transitions', I tried to find the error myself, but I failed to understand the whole structure.

Some extra information about the creation of the error.

>>> from module.models import Process
>>> p = Process.objects.get(id=2)
>>> p
<Process: Process 2 (proces gestart)>
>>> p.state_description
u'proces gestart'
>>> p.state_transitions.all()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/peterpul/VirtualEnvs/lp_traject/src/states2/states2/models.py", line 100, in state_transitions
    return self.get_state_transitions()
  File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 11, in _curried
    return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
  File "/Users/peterpul/VirtualEnvs/lp_traject/src/states2/states2/model_methods.py", line 19, in get_STATE_transitions
    return self.all_transitions.all()
AttributeError: 'Process' object has no attribute 'all_transitions'

Where

class Process(StateModel):
    """ ofcourse some attributes """

    class Meta:
        app_label = 'module'
        verbose_name = _('process')
        verbose_name_plural = _('processes')

    class Machine(StateMachine):
        log_transitions = True

        class initiated(StateDefinition):
            description = _('process initiated')
            initial = True

        class process_started(StateDefinition):
            description = _('process started')

        class start_process(StateTransition):
            from_state = "initiated"
            to_state = "process_started"
            description = _("Start up the process")

        """Followed by some more states and transitions""""

Edit;
Maybe interesting too;

>>> Process.state_transitions
<property object at 0x10baebfc8>

Django 1.9.4: demo model fails, StateMachine has no attribute 'states'

Trying to run the the demo with Purchase model from readme.
python manange.py makemigrations ends with error:

File "django_states\machine.py", line 275, in get_state_choices
return [(k, cls.states[k].description) for k in cls.states.keys()] AttributeError: type object 'PurchaseSateMachine' has no attribute 'states'

Aren't class some_state (StateDefinition) inside class PurchaseStateMachine supposed to be states?

AttributeError while raising Exception "TransitionCannotStart"

If you are using another name than state for your StateField, the TransitionCannotStart Exception raises AttributeError, because instance.state is not defined

https://github.com/vikingco/django-states2/blob/master/django_states/exceptions.py#L46

class TransitionCannotStart(TransitionException):
    def __init__(self, instance, transition):
        TransitionException.__init__(self, "Transition '%s' on %s cannot start in the state '%s'" %
                    (transition, instance.__class__.__name__, instance.state))

Access to all states while defining transitions

Or to state groups.

I'd like to be able to define a transition thusly:

class my_transition(StateTransition):
from_states = [my_state_group]

or

class my_transition(StateTransition):
from_states = all_states() - set([some_state_to_exclude])

South problem

Hallo guys!

Thanks for such an elegant application!
Unfortunately I can't make a south migration in my case.

django-states version: 1.5.0
south-verion: 0.7.6

My Django model class looks like:

from django_extensions.db.models import TimeStampedModel
from django_states.models import StateMachine, StateDefinition, StateTransition
from django_states.models import StateModel
...
class Product(StateModel, TimeStampedModel):
'''
Product model object
'''
...

# states machine
class ProductStateMachine(StateMachine):
    log_transitions = True

    # product states        
    ...

    # transitions        
    ....

Machine = ProductStateMachine

south schema migration (schemamigration app_name --auto) says:
! Cannot freeze field 'app_name.productstatelog.state'
! (this field has class django_states.fields.StateField)
! Cannot freeze field 'app_name.product.state'
! (this field has class django_states.fields.StateField)

! South cannot introspect some fields; this is probably because they are custom
! fields. If they worked in 0.6 or below, this is because we have removed the
! models parser (it often broke things).
! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

Any help is appreciated! Thank you!

Admin Actions not working

Admin actions fail to execute correctly when run from the state object list view.

Im not able to tell how to fix this or Id be posting a pull request. But either its broken in 1.5 or we need some more documentation on how to use the admin functions so i can see where I went wrong implementing this.

I've followed the instructions as far as settign up the admin.py goes, heres the reveleant portions from my admin.py

class ResourceOfferLegalAgreementAdmin(admin.ModelAdmin):
    import pdb; pdb.set_trace()
    actions = ResourceOfferLegalAgreement.Machine.get_admin_actions()

admin.site.register(
    ResourceOfferLegalAgreement,
    ResourceOfferLegalAgreementAdmin
)

This is the section of machine.py that is breaking and driving me nuts. Ive spent 3 days going over this section of code trying to work out what I have done wrong or what is broken.

    @classmethod
    def get_admin_actions(cls, field_name='state'):
        """
        Creates a list of actions for use in the Django Admin.
        """
        actions = []

        def create_action(transition_name):
            def action(modeladmin, request, queryset):
                # Dry run first
                for o in queryset:
                    get_STATE_info = getattr(o, 'get_%s_info' % field_name)
                    try:
                        get_STATE_info.test_transition(transition_name, request.user)
                    except TransitionException, e:
                        modeladmin.message_user(request, 'ERROR: %s on: %s' % (e.message, unicode(o)))
                        return

                # Make actual transitions
                for o in queryset:
                    get_STATE_info = getattr(o, 'get_%s_info' % field_name)
                    get_STATE_info.make_transition(transition_name, request.user)

                # Feeback
                modeladmin.message_user(request, 'State changed for %s objects.' % len(queryset))

            action.short_description = unicode(cls.transitions[transition_name])
            action.__name__ = 'state_transition_%s' % transition_name
            return action

        for t in cls.transitions.keys():
            actions.append(create_action(t))

        return actions

When I set some pdb breakpoints and walk through the sequence of events when trying to perform an admin action i get the following chain of events. It starts with the line

for o in queryset:

after the comment "# Dry run first"

I step down through the execution and test repeatedly at each stage for the ability to perform *var.test_transition on any variables at that level of the stack. Then after reaching the line that causes the stack dump I step the debugger through a few more lines of generic django 1.5 code before telling the debugger to continue which as it has passed through all my set breakpoints, causes it to execute & print out the Traceback you see at the end of the PDB session.

> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(250)action()
-> for o in queryset:
(Pdb) queryset[0]
<ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>
(Pdb) temp = queryset[0]
(Pdb) dir(temp)
['DoesNotExist', 'Machine', 'Meta', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__metaclass__', u'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__', '__weakref__', '_base_manager', '_default_manager', '_deferred', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_get_unique_checks', '_meta', '_perform_date_checks', '_perform_unique_checks', '_set_pk_val', '_state', '_state_log_model', 'can_make_transition', 'clean', 'clean_fields', 'date_error_message', 'delete', 'full_clean', 'get_public_state_transitions', 'get_state_choices', 'get_state_display', 'get_state_info', 'get_state_machine', 'get_state_model_name', 'get_state_transitions', 'id', 'is_initial_state', 'make_transition', 'objects', 'offeringUser', 'offeringUserAgreesToTerms', 'offeringUser_id', 'pk', 'possible_transitions', 'prepare_database_save', 'projectRepresentative', 'projectRepresentativeAgreesToTerms', 'projectRepresentative_id', 'public_transitions', 'resourceoffer_set', 'save', 'save_base', 'serializable_value', 'state', 'state_description', 'state_history', 'state_transitions', 'test_transition', 'unique_error_message', 'validate_unique']
(Pdb) temp.state_description()
*** TypeError: 'unicode' object is not callable
(Pdb) temp.state_description
u'The legal agreement has been proposed to both parties.'
(Pdb) temp.state_transitions
[]
(Pdb) temp.state
u'proposed'
(Pdb) temp.save
<bound method ResourceOfferLegalAgreement.new_save of <ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>>
(Pdb) temp
<ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>
(Pdb) temp.possible_transitions
<generator object possible_transitions at 0x108cfe370>
(Pdb) [x.get_name() for x in temp.possible_transitions]
['proposal_acceptance']
(Pdb) temp.test_transition
<bound method ResourceOfferLegalAgreement.test_transition of <ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>>
(Pdb) s
--Call--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/db/models/query.py(97)__iter__()
-> def __iter__(self):
(Pdb) r
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/db/models/query.py(108)__iter__()-><generat...08cfe820>
-> return self._result_iter()
(Pdb) r
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(251)action()
-> get_STATE_info = getattr(o, 'get_%s_info' % field_name)
(Pdb) print o
State: proposed (The legal agreement has been proposed to both parties.)
(Pdb) o.test_transition
<bound method ResourceOfferLegalAgreement.test_transition of <ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>>
(Pdb) o.possible_transitions
<generator object possible_transitions at 0x108cfe2d0>
(Pdb) s
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(252)action()
-> pdb.set_trace()
(Pdb) 
--Call--
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py(1250)set_trace()
-> def set_trace():
(Pdb) r
--Return--
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py(1251)set_trace()->None
-> Pdb().set_trace(sys._getframe().f_back)
(Pdb) r
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(253)action()
-> try:
(Pdb) s
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(254)action()
-> pdb.set_trace()
(Pdb) s
--Call--
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py(1250)set_trace()
-> def set_trace():
(Pdb) r
--Return--
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py(1251)set_trace()->None
-> Pdb().set_trace(sys._getframe().f_back)
(Pdb) r
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(255)action()
-> get_STATE_info.test_transition(transition_name, request.user)
(Pdb) print get_STATE_info
<bound method ResourceOfferLegalAgreement._curried of <ResourceOfferLegalAgreement: State: proposed (The legal agreement has been proposed to both parties.)>>
(Pdb) print request.user
root
(Pdb) print transition_name
proposal_acceptance
(Pdb) print get_STATE_info.test_transition(transition_name, request.user)
*** AttributeError: 'function' object has no attribute 'test_transition'
(Pdb) print get_STATE_info.test_transition()
*** AttributeError: 'function' object has no attribute 'test_transition'
(Pdb) print get_STATE_info.test_transition()
*** AttributeError: 'function' object has no attribute 'test_transition'
(Pdb) s
AttributeError: "'function' object has no attribute 'test_transition'"
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(255)action()
-> get_STATE_info.test_transition(transition_name, request.user)
(Pdb) s
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(256)action()
-> except TransitionException, e:
(Pdb) s
--Call--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/db/models/query.py(118)_result_iter()
-> yield self._result_cache[pos]
(Pdb) s
GeneratorExit: None
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/db/models/query.py(118)_result_iter()
-> yield self._result_cache[pos]
(Pdb) r
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/db/models/query.py(118)_result_iter()->None
-> yield self._result_cache[pos]
(Pdb) r
--Return--
> /Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py(256)action()->None
-> except TransitionException, e:
(Pdb) s
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py(960)response_action()
-> response = func(self, request, queryset)
(Pdb) s
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py(960)response_action()->None
-> response = func(self, request, queryset)
(Pdb) s
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py(1205)changelist_view()
-> response = self.response_action(request, queryset=cl.get_query_set(request))
(Pdb) r
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py(1205)changelist_view()->None
-> response = self.response_action(request, queryset=cl.get_query_set(request))
(Pdb) r
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(21)bound_func()
-> return func(self, *args2, **kwargs2)
(Pdb) r
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(21)bound_func()->None
-> return func(self, *args2, **kwargs2)
(Pdb) 
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(91)_wrapped_view()
-> response = view_func(request, *args, **kwargs)
(Pdb) 
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(97)_wrapped_view()->None
-> raise
(Pdb) 
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(25)_wrapper()
-> return bound_func(*args, **kwargs)
(Pdb) 
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py(25)_wrapper()->None
-> return bound_func(*args, **kwargs)
(Pdb)
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/sites.py(202)inner()
-> return view(request, *args, **kwargs)
(Pdb)
--Return--
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/sites.py(202)inner()->None
-> return view(request, *args, **kwargs)
(Pdb)
AttributeError: Attribut...ition'",)
> /Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/views/decorators/cache.py(89)_wrapped_view_func()
-> response = view_func(request, *args, **kwargs)
(Pdb) c
ERROR:base:handle_uncaught_exception:212: Internal Server Error: /admin/resources/resourceofferlegalagreement/
Traceback (most recent call last):
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py", line 372, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 202, in inner
return view(request, *args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/utils/decorators.py", line 21, in bound_func
return func(self, *args2, **kwargs2)
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1205, in changelist_view
response = self.response_action(request, queryset=cl.get_query_set(request))
File "/Users/me/.virtualenvs/site1env/lib/python2.7/site-packages/django/contrib/admin/options.py", line 960, in response_action
response = func(self, request, queryset)
File "/Users/me/Dev/mydjangoproject/backend/prj/django_states/machine.py", line 255, in action
get_STATE_info.test_transition(transition_name, request.user)
AttributeError: 'function' object has no attribute 'test_transition'

Update pypi release

Hi :)

Could you create a new pypi release (version update) for django-states2 (master)? At VikingCo that is the current version we're working with, and since it is stable, it would be preferable to have a tag with a new pypi release.

Thanks in advance

Update code on pypi.python.org

The version of 1.6.1 on pypi still has the warning on model_method line 4,
however the code on Github says it's fixed.

PLZ update the code to pypi to fix this annoying warning, thx

make_transition on unsaved fails

Problem:

If I have log_transitions = True in my state machine, and then make_transition on an unsaved model object, we crash since 'self' (model object) doesn't have an id but an id is assumed here:
model_methods.py, method make_transition, line 151:
_state_log_model.objects.create(
on=self,

Discussion:
Perhaps we could have an explicit exception for this case, stating that the object needs an id/to be saved beforehand.

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.