Restrict access to one device per user at any given time
Hi, I am trying to figure out the best way of restricting access to a given django project so that a single user can login as normal but then has to logout again if they want to access it from a different session. I am thinking just to set a flag in the userprofile table upon login and then remove the flag when the user logs out, however, I'm sure this is a prone to the situation where a user is thrown out of their session for whatever reason and the code doesn't reset the flag. In this case the user will not be able to login ever again! Is there a way to store device level details so that I can check against that sort of data - this may be a more robust solution I'm guessing. How have people tackled this and what are the things to look out for? Regards, mjh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: bound field object - dynamic forms
yes it is being passed to the template as I can access the label, choices, help_text, required items of the boundfield object... i.e., {{ issue.label }} {{ issue.choices }} {{ issue.help_text }} I can get everything it seems apart from the form object !!! {{ issue }} writes to the template: ??? On Wednesday, 5 September 2012 18:56:17 UTC+1, Amyth wrote: > > check if it is being passed to template. > > {% if issue %} > {{ issue }} > {% else %} > Issue was not passed #Debug > {% endif %} > > On Wed, Sep 5, 2012 at 8:45 PM, Mando >wrote: > >> are you passing it to the template? >> >> >> On Wednesday, September 5, 2012 7:09:57 AM UTC-5, mjh wrote: >>> >>> tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template >>> >>> any other thoughts? >>> >>> On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote: >>>> >>>> Try {{ issue.0}} and {{ issue.1}} >>>> On Sep 4, 2012 5:55 AM, "mjh" wrote: >>>> >>>>> Hi all - not sure how to show the choicefield dropdown in my template? >>>>> >>>>> Am generating a dynamic form (note: for issue in issues in forms.py) and >>>>> appending the fields to self.issue_list >>>>> >>>>> in the template I am looping over these fields ({% for issue in >>>>> form.issue_list %}) and can write out the label {{ issue.label }} but if >>>>> write out {{ issue }} I simply get the bound field object written to >>>>> template (). >>>>> >>>>> Question is how do I get the html dropdown to display in the template?? >>>>> >>>>> >>>>> >>>>> >>> forms.py >>>>> def __init__(self, item, *args, **kwargs): >>>>> super(ItemAnalysisForm, self).__init__(*args, **kwargs) >>>>> issue_choice = (('1', 'Reduced'), >>>>> ('2', 'Maintained'), >>>>> ('3', 'Increased') >>>>> ) >>>>> issues = item.issue.all() >>>>> >>>>> self.issue_list = [] >>>>> self.a_list = [] >>>>> # generate dynamic issue dropdowns... >>>>> for issue in issues: >>>>> self.fields['issue-' + str(issue.pk)] = >>>>> forms.ChoiceField(label=issue.**name <http://issue.name>, >>>>> choices=issue_choice, required=False) >>>>> self.a_list.append(self.**fields['issue-' + str(issue.pk)]) >>>>> self.issue_list.append(self.**fields['issue-' + >>>>> str(issue.pk)]) >>>>> self.fields['text'] = forms.CharField(label='text', >>>>> required=True, widget=forms.Textarea(attrs={'**rows':25,'cols':'100'})) >>>>> self.a_list.append(self.**fields['text']) >>>>> >>>>> >>>>> >>> template >>>>> {% >>>>> csrf_token %} >>>>> >>>>> Individual Issue Outcome: >>>>> >>>>> {% for issue in form.issue_list %} >>>>> >>>>> {{ issue.label }}: {{ issue }} >>>>> >>>>> {% endfor %} >>>>> >>>>> >>>>> >>>>> Comment: >>>>> >>>>> {{ form.text }} >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Django users" group. >>>>> To view this discussion on the web visit https://groups.google.com/d/* >>>>> *msg/django-users/-/**XSMbUGOJyvMJ<https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ> >>>>> . >>>>> To post to this group, send email to django...@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> django-users...@googlegroups.**com. >>>>> For more options, visit this group at http://groups.google.com/** >>>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en> >>>>> . >>>>> >>>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/up3KXt_tm2YJ. >> >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > > > -- > Thanks & Regards > > > Amyth [Admin - Techstricks] > Email - aroras@gmail.com , ad...@techstricks.com > Twitter - @a_myth_ > http://techstricks.com/ > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/H8fJ3O-vDwQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: bound field object - dynamic forms
tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template any other thoughts? On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote: > > Try {{ issue.0}} and {{ issue.1}} > On Sep 4, 2012 5:55 AM, "mjh" > > wrote: > >> Hi all - not sure how to show the choicefield dropdown in my template? >> >> Am generating a dynamic form (note: for issue in issues in forms.py) and >> appending the fields to self.issue_list >> >> in the template I am looping over these fields ({% for issue in >> form.issue_list %}) and can write out the label {{ issue.label }} but if >> write out {{ issue }} I simply get the bound field object written to >> template (). >> >> Question is how do I get the html dropdown to display in the template?? >> >> >> >> >>> forms.py >> def __init__(self, item, *args, **kwargs): >> super(ItemAnalysisForm, self).__init__(*args, **kwargs) >> issue_choice = (('1', 'Reduced'), >> ('2', 'Maintained'), >> ('3', 'Increased') >> ) >> issues = item.issue.all() >> >> self.issue_list = [] >> self.a_list = [] >> # generate dynamic issue dropdowns... >> for issue in issues: >> self.fields['issue-' + str(issue.pk)] = >> forms.ChoiceField(label=issue.name, choices=issue_choice, required=False) >> self.a_list.append(self.fields['issue-' + str(issue.pk)]) >> self.issue_list.append(self.fields['issue-' + str(issue.pk)]) >> self.fields['text'] = forms.CharField(label='text', required=True, >> widget=forms.Textarea(attrs={'rows':25,'cols':'100'})) >> self.a_list.append(self.fields['text']) >> >> >> >>> template >> {% >> csrf_token %} >> >> Individual Issue Outcome: >> >> {% for issue in form.issue_list %} >> >> {{ issue.label }}: {{ issue }} >> >> {% endfor %} >> >> >> >> Comment: >> >> {{ form.text }} >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ. >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/T4kUV4SutHkJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
bound field object - dynamic forms
Hi all - not sure how to show the choicefield dropdown in my template? Am generating a dynamic form (note: for issue in issues in forms.py) and appending the fields to self.issue_list in the template I am looping over these fields ({% for issue in form.issue_list %}) and can write out the label {{ issue.label }} but if write out {{ issue }} I simply get the bound field object written to template (). Question is how do I get the html dropdown to display in the template?? >>> forms.py def __init__(self, item, *args, **kwargs): super(ItemAnalysisForm, self).__init__(*args, **kwargs) issue_choice = (('1', 'Reduced'), ('2', 'Maintained'), ('3', 'Increased') ) issues = item.issue.all() self.issue_list = [] self.a_list = [] # generate dynamic issue dropdowns... for issue in issues: self.fields['issue-' + str(issue.pk)] = forms.ChoiceField(label=issue.name, choices=issue_choice, required=False) self.a_list.append(self.fields['issue-' + str(issue.pk)]) self.issue_list.append(self.fields['issue-' + str(issue.pk)]) self.fields['text'] = forms.CharField(label='text', required=True, widget=forms.Textarea(attrs={'rows':25,'cols':'100'})) self.a_list.append(self.fields['text']) >>> template {% csrf_token %} Individual Issue Outcome: {% for issue in form.issue_list %} {{ issue.label }}: {{ issue }} {% endfor %} Comment: {{ form.text }} -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.