django-scaffolding

Creates placeholder data for your app
Download

django-scaffolding Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Price:
  • FREE
  • Publisher Name:
  • Simon Baechler
  • Publisher web site:
  • https://github.com/sbaechler/

django-scaffolding Tags


django-scaffolding Description

django-scaffolding is a Django app that creates placeholder data for your app.UsageCreate a scaffolds.py module within your app directory which contains the Scaffolding classes.Sample models.py:class Entry(models.Model): first_name = models.CharField('First Name', max_length=32) last_name = models.CharField('Last Name', max_length=32) comment = models.TextField('Comment') image = models.ImageField(upload_to='uploads/%Y/%m/%d', blank=True, null=True) contest = models.ForeignKey(Contest) ...Sample scaffolds.py:import scaffoldingfrom scaffolding.library.flickr import FlickrInterestingfrom myapp.models import Customerclass EntryScaffold(object): first_name = scaffolding.FirstName(max_length=32) last_name = scaffolding.LastName(max_length=32) comment = scaffolding.LoremIpsum(paragraphs=1) contest = scaffolding.ForeignKey(queryset=Contest.objects.filter(name='testcontest')) image = scaffolding.RandomInternetImage(backend=FlickrInteresting)scaffolding.register(Entry, EntryScaffold)Mind the syntax for ForeignKey fields. You can assign an integer to the field but make sure the element with the corresponding key does exist. Of course you can also assign an object to the FK field.To use the flickr library you need to have the Flickr API: http://stuvel.eu/flickrapi installed.Run the management command to create the data:manage.py scaffold myapp.MyModel 20The number stands for the amout of entries to be created.Using scaffolding in interpreter or viewsYou can try out the included classes or your own modules in the shell. All classes are generators (called Tubes) that generate the field's values. start ./manage.py shell:>>> from scaffolding import *>>> r = RandInt(min=1, max=5)>>> r.next()>>> r.next()>>> n = Name(gender='m')>>> n.next()>>> n.next()Included TubesNameGenerates a random name. can be 'male', 'female', 'm' or 'f'.LoremIpsumGenerates a Lorem Ipsum Text. The number of paragraphs is defined in paragraphs.RandIntGenerates a random integer between min and max.ForeignKeyTakes a queryset and iterates through it. Assigns the item as ForeignKeys to the field. Wraps around if there are not enough items.RandomInternetImageCreates a random image for an ImageField using an internet source. A Flickr 'Daily Interesting images' grabber is included.AlwaysTrueReturns TrueAlwaysFalseReturns FalseContribCrates a Custom Object. The backend class is the first parameter. The backend class has to inherit from Tube.FacebookTestUserCreates a Facebook User from the test users pool of the Facebook app. If there aren't enough test users new ones are automatically created. This requires the django-facebook-graph API. https://github.com/feinheit/django-facebook-graphProduct's homepage


django-scaffolding Related Software