mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Renamed key.py to keygen.py
This commit is contained in:
		| @@ -1,4 +1,8 @@ | |||||||
| # Generate a SECRET_KEY file | """ | ||||||
|  | Module keygen | ||||||
|  | ============= | ||||||
|  | This module generates a Django SECRET_KEY file to be used by manage.py | ||||||
|  | """ | ||||||
| 
 | 
 | ||||||
| import random | import random | ||||||
| import string | import string | ||||||
| @@ -10,9 +14,16 @@ KEY_FN = 'secret_key.txt' | |||||||
| KEY_DIR = os.path.dirname(os.path.realpath(__file__)) | KEY_DIR = os.path.dirname(os.path.realpath(__file__)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def generate_key(): | def generate_key(length=50): | ||||||
|  |     """ | ||||||
|  |     Generate a random string | ||||||
|  | 
 | ||||||
|  |     :param length: Number of characters in returned string (default=50) | ||||||
|  |     :returns: Randomized secret key string | ||||||
|  |     """ | ||||||
|  | 
 | ||||||
|     options = string.digits + string.ascii_letters + string.punctuation |     options = string.digits + string.ascii_letters + string.punctuation | ||||||
|     key = ''.join([random.choice(options) for i in range(50)]) |     key = ''.join([random.choice(options) for i in range(length)]) | ||||||
|     return key |     return key | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
		Reference in New Issue
	
	Block a user