These are chat archives for django/django

Aug 2016
MinJae Kwon
Aug 31 2016 04:08
@shakib609 Although I only use social login on, but I know that login method
If user logged in site by email, you can send a unique url with unique login key (this value is generated on your application). so your application should manage the key on session with appropriate expire time (and user's email)
MinJae Kwon
Aug 31 2016 04:16
before managing the key on session, your application must verify the login key (extracted from url is sent to user email) is valid (invalid key form, expired key, ...)
Shakib Hossain
Aug 31 2016 05:25
@mingrammer Thanks. I think I get the idea.
@mingrammer Though some hints on how to generate a unique login key each time would really help.
Alexey Rogachev
Aug 31 2016 05:32
Hi guys.
I have a model form, that uses a mixin which adds some additional fields.
class EnterpriseForm(LocationMixin, forms.ModelForm):

    class Meta:
        model = Enterprise
        fields = '__all__'
and the mixin looks like this:
class LocationMixin(forms.ModelForm):
    location_required = True
    location = LocationField(required=False, label='Местоположение')
    latitude = forms.DecimalField(widget=forms.TextInput, label='Широта',
                                  validators=[MinValueValidator(-90), MaxValueValidator(90)])
    longitude = forms.DecimalField(widget=forms.TextInput, label='Долгота',
                                   validators=[MinValueValidator(-180), MaxValueValidator(180)])

    def __init__(self, *args, **kwargs):
        super(LocationMixin, self).__init__(*args, **kwargs)
        self.fields['latitude'].required = self.location_required
        self.fields['longitude'].required = self.location_required
        coordinates = getattr(self.instance, 'coordinates', '')
        if coordinates and coordinates != '{}':
            self.fields['latitude'].initial = str(coordinates[0])
            self.fields['longitude'].initial = str(coordinates[1])

    def save(self, commit=True):
        instance = super(LocationMixin, self).save(commit=False)
        latitude = self.cleaned_data.get('latitude')
        longitude = self.cleaned_data.get('longitude')
        instance.coordinates = [latitude, longitude] if latitude and longitude else '{}'
        if commit:
        return instance
I need to track changes in these models, so I decided to use this extension
However, the fields coming from mixin always marked as changed even nothing was changed at all
Any advice how to solve this?
location, latitude and longitude are not presented in DB as columns,
location is needed just to quickly find coordinates, and coordinates is stored as array (I'm using PostgreSQL)
coordinates = ArrayField(models.DecimalField(max_digits=18, decimal_places=15), default=coordinates_default, size=2,
                             editable=False, verbose_name='Координаты')
Alexey Rogachev
Aug 31 2016 05:38
Also seems like this extension ignores changes in fields where editable kwarg is set to False
Before I tried to use form.has_changed() and form.changed_data built-in Django methods / properties, faced with the same problem that I described.
MinJae Kwon
Aug 31 2016 06:39
@shakib609 The easiest way is random hash. if you use python, you can use this like
import random

hash = random.getrandbits(128)

hash_string = '%032x' % hash
Shakib Hossain
Aug 31 2016 08:06
@mingrammer Thanks a lot. It really helped.. :)
MinJae Kwon
Aug 31 2016 08:47
you're welcome.
Aug 31 2016 16:27
Hey guys
sorry to ask here but, is there a chat room for Python beginners?
MinJae Kwon
Aug 31 2016 16:36
um .. freenode #python channel?
Aug 31 2016 16:45
looking for Python developer to Capital One in NY!!!
Aug 31 2016 17:04
It is possible to show more than one model inside a ModelAdmin? I'm trying with @admin.register(A, B, C), but nothing (it shows me each model separately in the admin site)
Italo Maia
Aug 31 2016 21:14
Hello folks
any idea how can I invalidate a user session with only its session_key?
I'm trying to implement a "single session per user" feature here
Vaibhav Tulsyan
Aug 31 2016 21:17
Hello @LookUp14