GithubHelp home page GithubHelp logo

areski / django-dilla Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 441 KB

django model content generator [clone of http://gitweb.codeendeavor.com/?p=dilla.git;a=summary]

Home Page: http://gitweb.codeendeavor.com/?p=dilla.git;a=summary

Python 100.00%

django-dilla's Introduction

Dilla is a command that populates your database with randomized data. You'll need install dilla as an app in the django 
settings file.

Examples:
1. Generate data for all models in an app
   >>python manage.py dilla app_name

2. Generate data for all models in all apps listed
   >>python manage.py dilla app_name app_name

3. Generate data for all models in all apps listed (an alternative to #2)
   >>python manage.py dilla -a app_name -a app_name

4. Generate data for supplied models, in the supplied apps
   >>python manage.py dilla -a app_name -m ModelName

5. Addition to #4, generate data for multiple models
   >>python manage.py dilla -a app_name -m ModelName -m AnotherModelName

** The order of app names and model names are important, if a model has
   a ForeignKey to another model, but there isn't data available yet
   in the foregn table, problems occur.

** When using -a or -m, you don't need to use full python path.

You configure your models with some information for dilla. Here's some examples:

--models.py:--

class DillaController():
  #(Optional) this defines the order of how models are populated. (Fixes cross ForeignKey problems)
  models=('UserProfile','Venue','Event','Genre','Artist')

class Event(models.Model):
  venue=models.ForeignKey('Venue')
  artists=models.ManyToManyField('Artist')
  date=models.DateTimeField(blank=False,null=False)
  showtime=models.TimeField(blank=False,null=False)
  doortime=models.TimeField(blank=False,null=False)
  covercharge=models.DecimalField(decimal_places=2,max_digits=7)
  created_at=antaresia_models.ModelCommons.created_at()
  updated_on=antaresia_models.ModelCommons.updated_on()
  #usual Dilla meta class
  class Dilla():
    skip_model=False
    generate_images=False
    image_fields=None
    resolution="1024x768" #if images, this resolution
    resolutions=('300x340','200x190','100x10','200x90') #if images, use a random resolution from this tuple
    field_extras={ #field extras are for defining custom dilla behavior per field
      'fieldname':{
        'generator':None, #can point to a callable, which must return the desired value. If this is a string, it looks 
        for a method in the dilla.py file.
        'generator_wants_extras':False, #whether or not to pass this "field extra" hash item to the callable
        'random_values':("word","yes","no","1"), #choose a random value from this tuple
        'resolution':'1024x768', #if images, use this image size for this field
        'resolutions':('300x340','200x190','100x10','200x90'), #if images, use a random size from this tuple
        'max':10, #for many to many fields, the maximum associated objects will be 10, so it will take a range like: 
        Model.objects.all().order_by("?")[0:random.randrange(0,max)]
        'spaces':False, #if Char/TextField, whether or not to allow spaces
        'word_count':1, #if Char/TextField, the number of words to generate
        'word_range':(3,7), #a range of words to generate (3-7 words)
        'paragraph_count:1, #if TextField, the number of paragraphs to generate
        'paragraph_range':(3,5), #a range of paragraphs to generate (3 - 5 paragraphs)
        'integer_range':(0,2), #a range for any integer type field 
        (IntegerField,SmallIntegerField,PositiveInteger,PositiveSmallInteger)
        'day_delta': 5, #The day delta to generate the date, minus today
		'hour_delta': 24, #The day delta to generate the date, minus the current hour
        #TODO:'digits_only':True, #if Char/TextField, but want numbers only
        #TODO:'digit_range:(30,400), #a range for digit only creation (default range is (0,9999))
        #TODO:'digit_ranges':((0,20),(30,300)), #chooses random range from this tuple.
        #TODO:'digits_for_words':False|True (Default:False) #generates lipsum words, but then replaces each word with 
        numbers. (like a sentance of numbers)
      },
      'anotherfieldname':{...}
    }
    
    

django-dilla's People

Contributors

areski avatar tvon avatar

Stargazers

Oleg Dolya avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.