Пример #1
0
	def __init__(self, *args, **kwargs):
		"""Make any available lenses the choices."""

		kwargs.update({
			'choices': [(lens.slug, lens.make_title()) for lens in get_all_lenses()],
			'initial': get_default_lens().slug})
		super(LensChoiceField, self).__init__(*args, **kwargs)
Пример #2
0
    def __init__(self, *args, **kwargs):
        """Make any available lenses the choices."""

        kwargs.update({
            'choices':
            [(lens.slug, lens.make_title()) for lens in get_all_lenses()],
            'initial':
            get_default_lens().slug
        })
        super(LensChoiceField, self).__init__(*args, **kwargs)
Пример #3
0
	def create_for_user(self, user):
		"""Create a profile for the given user if one doesn't already exist."""

		try:
			profile = self.get(user=user)
		except UserProfile.DoesNotExist:
			profile = self.create(
								user=user,
								default_location=Location.objects.get_default(),
								default_lens=get_default_lens().slug)

		return profile