Skip to content

Timestamp model field for Django ( only for Mysql )

License

Notifications You must be signed in to change notification settings

paytm/dj-myghanta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dj-myghanta

PyPI version

dj-myghanta is a Django app to allow end users to create timestamp model field for MySQL.

Installation

  • Install it through pip

    pip install dj-myghanta
    
  • Download and install manually

    git clone https://github.com/paytm/dj-myghanta.git
    cd dj-myghanta
    python setup.py install
    

Use

  • Add myghanta in your INSTALLED_APPS like

    INSTALLED_APPS = (
        ...
        'myghanta',
    )
    
  • Now import it in your models like

    from myghanta.fields import MysqlTimeStampField
    
  • Create fields like

    # auto_now_add = True creates `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
    created_at = MysqlTimestamp(auto_now_add=True)
    
    # auto_now = True creates `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    updated_at = MysqlTimestamp(auto_now=True)
    

Known Issues/ ToDo

  • Works only for Mysql . Tested on mysql 5.6, 5.7

About

Timestamp model field for Django ( only for Mysql )

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages