In that case you can create an abstract model class and use that instead of
models.Model:
class MyModel(models.Model):
class Meta:
abstract = True
class DoesNotExist(Exception):
pass
On Wed, Aug 19, 2009 at 1:22 PM, Idan Gazit <[email protected]> wrote:
>
> Yes, and then I also need to import that class into every place that I
> want to use it, no?
>
> The benefit of making it part of the model is that any place I'm using
> it, I already have the exception handy:
>
> try:
> # ... do some things
> m = MyModel(foo=bar, baz=bling)
> m.save()
> except MyModel.FrobNotAllowed:
> # handle the exception...
>
> It's not a big deal but I figured that emulating the framework isn't a
> bad idea.
>
> On Aug 19, 5:03 pm, Joshua Russo <[email protected]> wrote:
> > All you really need is:
> >
> > class DoesNotExist(Exception):
> > pass
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---