All Projects → kakulukia → django-undeletable

kakulukia / django-undeletable

Licence: MIT license
undeletable Django models

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to django-undeletable

shadow
Shadow dom support for Vue
Stars: ✭ 46 (+253.85%)
Mutual labels:  shadow
ElegantData
像操作Room一样操作 SharedPreferences 和 File 文件.
Stars: ✭ 18 (+38.46%)
Mutual labels:  db
planar proj shadows
Demo of Planar Projected Shadows in regl
Stars: ✭ 31 (+138.46%)
Mutual labels:  shadow
react-native-shadow-2
Cross-platform shadow for React Native. Supports Android, iOS, Web and Expo.
Stars: ✭ 442 (+3300%)
Mutual labels:  shadow
react-native-image-blur-shadow
A React Native Image component with Blur Drop Shadows,100% JavaScript, 0 dependency component. Supports Android, iOS and Web. A light weight <Image/> component for your react native project.
Stars: ✭ 80 (+515.38%)
Mutual labels:  shadow
db-command
Performs basic database operations using credentials stored in wp-config.php.
Stars: ✭ 65 (+400%)
Mutual labels:  db
ngrest-db
Simple ORM to use with ngrest
Stars: ✭ 27 (+107.69%)
Mutual labels:  db
shadow-nix
Supporting Shadow under NixOS
Stars: ✭ 15 (+15.38%)
Mutual labels:  shadow
dbclient
데이터배이스 관리 / 자동 메일링 / Admin 자동화 / Database IDE Tool. SQL Development Helper. Support DBMS Oracle/Mysql/MS-SQL
Stars: ✭ 35 (+169.23%)
Mutual labels:  db
dbx4fb
dbExpress driver for Firebird
Stars: ✭ 22 (+69.23%)
Mutual labels:  db
unitdb
Fast specialized time-series database for IoT, real-time internet connected devices and AI analytics.
Stars: ✭ 97 (+646.15%)
Mutual labels:  db
Part-DB
Open Source Electronic Parts Database using PHP and MySQL
Stars: ✭ 143 (+1000%)
Mutual labels:  db
MeowDB.js
Database in JSON (Node.JS Library)
Stars: ✭ 12 (-7.69%)
Mutual labels:  db
compat-db
A browser API compatibility database
Stars: ✭ 61 (+369.23%)
Mutual labels:  db
Android-SGTextView
同时带字体描边 渐变 阴影的TextView - both have stroker, gradient and shadow TextView
Stars: ✭ 18 (+38.46%)
Mutual labels:  shadow
XLocalizer
Localizer package for Asp.Net Core web applications, powered by online translation and auto resource creating.
Stars: ✭ 103 (+692.31%)
Mutual labels:  db
tevere
🏞 Decentralized DB over IPFS
Stars: ✭ 57 (+338.46%)
Mutual labels:  db
db-rest
A clean REST API wrapping around the Deutsche Bahn API.
Stars: ✭ 40 (+207.69%)
Mutual labels:  db
sqlmetrics
Prometheus metrics for Go database/sql via VictoriaMetrics/metrics
Stars: ✭ 21 (+61.54%)
Mutual labels:  db
DeepShadowMap
Real-Time Deep Shadow Maps for Unity3D
Stars: ✭ 36 (+176.92%)
Mutual labels:  shadow

django-undeletable BuildStatus Coverage

I have run into dozens of situations where data got deleted by accident or somebody wanted to know when something got deleted or changed, so this little module will prevent accidents and you will always be able to reverse the situation or to identify why that little bug deleted exactly this set of data. And even if somebody from marketing all in a sudden wants to know what was in those temporary shopping baskets that should have been deleted already - you will be able to answer those questions! I never had the problem of too much data - it was always the missing data, the missing creation and modification timestamps that makes your job harder than it has to be.

So here is the answer to all that. Nothing will be deleted anymore and you will know when X got created, changed or deleted. Django Undeletable provides a BaseModel with useful default attributes to keep track of your data. The custom DataManager keeps track of deleted and live data. You can also keep stuff hidden from the public while displaying that data to some chosen customers (like beta testers).

Installation

Install django-undeletable

pip install django-undeletable

When using this package, all your models should extend from BaseModel instead of django.db.models.Model. Take a look at the additional NamedModel as to how its done.

class NamedModel(BaseModel):
    name = models.CharField(_('Name'), max_length=150, db_index=True)

    class Meta(BaseModel.Meta):
        ordering = ['name']
        abstract = True

Extending the Meta class from BaseModel.Meta is important for Django 2.0+ otherwise you will experience your related QuerySets to not be managed by a DataManager but by Djangos default manager instead including deleted data.

For a fully working QuerySet and Manager relation which share methods, you should create your managers the following way:

class BookQuerySet(DataQuerySet):
    def not_null(self):
        return self.filter(author__isnull=False)


class CoverBook(Book):
    data = DataManager.from_queryset(BookQuerySet)()

This way you can do CoverBook.data.all().nut_null() and CoverBook.data.nut_null() otherwise you will have to define the methods twice or face errors in one of the previous calls.

Features

While inheriting from BaseModel you get the following advantages:

  • Your models have created, modified and deleted DateTime attributes
  • The data queryset shall always tell you which ones of your models are undeletable or from 3rd party modules - but the main reason for using data is that im lazy and prefer typing data instead of objects :)
  • Since quite some modules don't respect a models default manager and just use 'objects', data is mirrored to objects to not run into any trouble
  • You have the option to hide specific data from the public while using visible() instead of all()
  • since its quite common, this package also includes the above NamedModel and a customized User Model that you should copy to your codebase and remove the abstract = True line to have undeletable users
  • The included abstract User class features an EMAIL_OVERRIDE_ADDRESS setting that can be used to not actually email real users on a development system :)

Running Tests

Does the code actually work?

make init
make test

Credits

Tools used in rendering this package:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].