question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alternative to `RulesModelBase` in DRF to manage dependency on this library.

See original GitHub issue

I’m working on a Django DRF project, and while implementing the rules, I feel like inheriting from RulesModelBase creates a really heavy dependency on this library.

I’m trying to make it so that the rules dependency only affects the views, and not go all the way to the models.

From what I can gather, the views have access to the current user, and the objects. The predicates get both the user and the permission object as parameters, so it feels like it would be possible.

Has anyone dealt with similar issues than this?

https://github.com/dfunckt/django-rules#permissions-in-django-rest-framework

Of course, it also requires you to declare your models as described in Permissions in models.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sergioisidorocommented, Dec 22, 2021

Sure, I’ll post a PR for this. Actually maybe I can make 2:

  • One PR, which is the simplest, to abstract the get_permission_form_model making it overridable in the mixin
  • Another PR based on the first one with these larger changes.

We can move the discussion there as well, since it’s easier to discuss things with concrete code 😃

Thanks for taking the time and attention on this! Really appreciate it!

1reaction
dfuncktcommented, Dec 22, 2021

Okay, I totally see the use-case and agree in principle that this would be great to have but I need to spend some time to check the existing code and your proposal in more depth. If you’re keen to PR stuff in the meantime, feel free and we’ll take it from there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learning the Basics - Gradle User Manual
Dependency management in Gradle; Declaring repositories; Declaring dependencies; Understanding the difference between libraries and applications ...
Read more >
Strategies for managing Gradle dependencies - ProAndroidDev
In the life of an Android Developer, library dependencies are like heart of the project. ... Strategy 1: So let's start with the...
Read more >
Managing dependencies in Visual Studio C++ projects with ...
There are different alternatives, the first one would be using different names for the library, for example zlibd.lib for the debug one, zlib....
Read more >
sbt Reference Manual — Library Management
They are intended as a lightweight alternative to a full configuration using Ivy. Dependencies. Declaring a dependency looks like: libraryDependencies += ...
Read more >
django-rules issues and how to fix | GitAnswer
List of issues in dfunckt/django-rules projects. django-rules alternative to `RulesModelBase` in DRF to manage dependency on this library.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found