Exemple #1
0
    def handle(self, *args, **options):
        print options
        populator = Faker.getPopulator()

        populator.addEntity(Trader, options['traders'])
        populator.addEntity(Transaction, options['transactions'])

        insertedPks = populator.execute()
Exemple #2
0
 def handle(self, *args, **options):
     populator = Faker.getPopulator()
     print 'Start'
     owner = User.objects.get(pk=1)
     populator.addEntity(Course, 5, {'owner': owner})
     insertedPks = populator.execute()
     print insertedPks
     print 'Fineshed '
Exemple #3
0
class Populator(self):
	populator = Faker.getPopulator()

	populator.addEntity(Language, 5)
	populator.addEntity(Competence, 10)
	populator.addEntity(Exercise, 10)
	populator.addEntity(Category, 5)
	populator.addEntity(Subcategory, 30)

	insertedPks = populator.execute()
Exemple #4
0
def populate_news(**kwargs):
	if settings.DEBUG:
		News.objects.all().delete()

		populator = Faker.getPopulator()
		populator.addEntity(News, 23, {
				'link': lambda x: populator.generator.url()
			})

		populator.execute()
		print("Populated sample news data..")
Exemple #5
0
def do_or_fake_filter(value, formatter):
    """
    call a faker if value is None
    uses:

        {{ myint|or_fake:'randomInt' }}

    """
    if not value:
        value = Faker.getGenerator().format(formatter)
    return value
Exemple #6
0
def do_or_fake_filter( value, formatter ):
    """
    call a faker if value is None
    uses:

        {{ myint|or_fake:'randomInt' }}

    """
    if not value:
        value = Faker.getGenerator().format( formatter )
    return value
Exemple #7
0
def do_fake_filter(formatter, arg=None):
    """
    call a faker format
    uses:

        {{ 'randomElement'|fake:mylist }}
        {% if 'boolean'|fake:30 %} .. {% endif %}
        {% for word in 'words'|fake:times %}{{ word }}\n{% endfor %}

    """
    args = []
    if not arg is None: args.append(arg)
    return Faker.getGenerator().format(formatter, *args)
Exemple #8
0
def do_fake(formatter, *args, **kwargs):
    """
        call a faker format
        uses:

            {% fake "formatterName" *args **kwargs as myvar %}
            {{ myvar }}

        or:
            {% fake 'name' %}

        """
    return Faker.getGenerator().format(formatter, *args, **kwargs)
Exemple #9
0
def do_fake_filter( formatter, arg=None ):
    """
    call a faker format
    uses:

        {{ 'randomElement'|fake:mylist }}
        {% if 'boolean'|fake:30 %} .. {% endif %}
        {% for word in 'words'|fake:times %}{{ word }}\n{% endfor %}

    """
    args = []
    if not arg is None: args.append(arg)
    return Faker.getGenerator().format( formatter, *args )
Exemple #10
0
def do_fake( formatter, *args, **kwargs ):
    """
        call a faker format
        uses:

            {% fake "formatterName" *args **kwargs as myvar %}
            {{ myvar }}

        or:
            {% fake 'name' %}

        """
    return Faker.getGenerator().format( formatter, *args, **kwargs )
Exemple #11
0
    def handle(self, *args, **options):
        BlogCategory.objects.all().delete()
        print 'start'
        from django_faker import Faker
        populator = Faker.getPopulator()

        
        populator.addEntity(BlogCategory,5)
        insertedPks = populator.execute()
        print insertedPks
        #import pdb; pdb.set_trace()
        for i,d in insertedPks:
            print i,d
        
        
        

        print 'Done' 
Exemple #12
0
#!/usr/bin/env python
import random
import datetime

from django_faker import Faker

populator = Faker.getPopulator(locale='en-gb')

from domain.achievement.models import Intention, Measurement

populator.addEntity(
    Intention, 100, {
        'action': lambda x: 18,
        'intention_text': populator.faker.sentence(),
        'intended_metric': lambda x: random.choice([i
                                                    for i in range(10, 100)]),
        'enjoyable_aspects': populator.faker.sentence(),
        'created_date': datetime.datetime.now(),
        'updated_date': datetime.datetime.now()
    })
retval = populator.execute()
print retval
	def handle(self, *args, **options):
		populator = Faker.getPopulator()
		populator.addEntity(Challenge, 27)
		insertedPks = populator.execute()
		print(insertedPks)
Exemple #14
0
from django_faker import Faker
# this Populator is only a function thats return a django_faker.populator.Populator instance
# correctly initialized with a faker.generator.Generator instance, configured as above
populator = Faker.getPopulator()

from presence.models import *
populator.addEntity(Jours_cours, 5)

insertedPks = populator.execute()