Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing import error #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions django_faker/populator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django_faker.guessers import Name
from django.db.models.fields import *
from django.db.models import ForeignKey, ManyToManyField, OneToOneField, ImageField

from django.utils.timezone import make_aware

class FieldTypeGuesser(object):

Expand All @@ -28,9 +28,9 @@ def guessFormat(self, field):
return lambda x: generator.text(field.max_length) if field.max_length >= 5 else generator.word()
if isinstance(field, TextField): return lambda x: generator.text()

if isinstance(field, DateTimeField): return lambda x: generator.dateTime()
if isinstance(field, DateField): return lambda x: generator.date()
if isinstance(field, TimeField): return lambda x: generator.time()
if isinstance(field, DateTimeField): return lambda x: make_aware(generator.dateTime())
if isinstance(field, DateField): return lambda x: make_aware(generator.date())
if isinstance(field, TimeField): return lambda x: make_aware(generator.time())

if isinstance(field, URLField): return lambda x: generator.uri()
if isinstance(field, SlugField): return lambda x: generator.slug()
Expand Down Expand Up @@ -119,7 +119,15 @@ def __init__(self, generator):
self.entities = {}
self.quantities = {}
self.orders = []



def reset(self):
"""
:param generator: Generator
"""
self.entities = {}
self.quantities = {}
self.orders = []

def addEntity(self, model, number, customFieldFormatters=None):
"""
Expand Down
9 changes: 7 additions & 2 deletions django_faker/templatetags/fakers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from inspect import getargspec
from django import template
from django.template.base import TagHelperNode, TemplateSyntaxError, parse_bits
import django

if django.VERSION >= "1.10":
from django.template.library import TagHelperNode, TemplateSyntaxError, parse_bits
else:
from django.template.base import TagHelperNode, TemplateSyntaxError, parse_bits

register = template.Library()

Expand Down Expand Up @@ -143,4 +148,4 @@ def get_range( value ):

Instead of 3 one may use the variable set in the views
"""
return range( value )
return range( value )