Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Using the Django framework, I've built a user-based web application. After some time, my client requested that the application disallow creating usernames that contain users' last names.
I have two questions:
Is it possible to do this reliably, always catching someone trying to register a username containing their last name, which is also present as a sign-up field? (My understanding and experience is that users can easily subvert this and still make the username look like their last name just by adding special characters or integers.)
What would be the best way to do this?
Try creating a custom validation rule. The function (which would be a member method of a subclass of django.forms.Field) might look something like this:
def validate(self, value):
if len(re.findall(self.lastname,value)) > 0:
raise forms.ValidationError('Your username may not contain your last name.')
return value
I don't think you can accomplish this withoud knowing their last name first. For example if I can make my username:
joevasquez OR jvasquez OR vasquezj OR vasquez...
There are no rules on what constitutes someome's last name. What if someone's last name is joe? It's not like filtering swearwords.
What is the reason behind this request? If it's privacy you can inform the user, but I don't think you can stop people from using their last names.
You can simply have your app autogenerate the usernames? Or use email as username?
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
As of now i am facing some problem with field bind issue while get the response from coveo, inside the this method ToCoveoFieldName is implemented. Any one can help me on this.
Code snippet
raw.<%= ToCoveoFieldName("field Name", false)
Since you are having issues with this call, I am assuming that you might be migrating to the Coveo for Sitecore Hive Framework implementation, which mostly shifted from a back-end implementation to a front-end one for all of its major field logic.
This means that ToCoveoFieldName is not available any more on the server side. Instead, there is a JavaScript implementation of the same logic.
For instance, if you want to translate a field to the Coveo format, you can use CoveoForSitecore.Context.fields.toCoveo("field name").
I can see in your question that you are within a result template, there are already two helpers to get you either the field name or the value.
<div data-field={{= coveoFieldName("field name") }}>
and
<div>{{= coveoFieldValue("field name") }}</div>. (This one is the equivalent of calling raw[coveoFieldName("field name")])
Those helpers are explained in more details in the documentation, on the Editing the Content of a Result Template page (for version 5.0+) and Coveo Fields Resources Component page (for versions <5.0 and 4.1+).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Can I Use Django's built in auth groups as a friend list? For each user I would like to create each group and the main advantage I see is possibility of use of permissions.
If chose to use a friendship model instead of group, is it possible to add permissions to the friendship model?
Thanks
If you read here:
Beyond permissions, groups are a convenient way to categorize users to
apply some label, or extended functionality, to them. For example, you
could create a group 'Special users', and you could write code that would
do special things to those users -- such as giving them access to a
members-only portion of your site, or sending them members-only email
messages.
...
what means for me that in general you can use it applying different labels to them like "Alex friends" or "Marty friends" But do you really want to do it? Simpler is to create new model and leave Django groups for what they were supposed to.
If you create your model you can apply permissions to the instances or create your own permissions in Meta section of the model like:
class Meta:
permissions = (
('participate_contest', _('Participate Contest')),
('unparticipate_contest', _('Unparticipate Contest')),
)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to create a form that does the following: the user specifies the number of questions that they want to ask and then on the next page, the user is able to fill out the relevant details pertaining to the number of questions that they to ask. I was wondering if there is a simple way to do this using django forms?
My approach is as follows:
I use one form to record the number of questions that the user wants to ask with a general description, then when the user clicks submit/next, the next view would create a form with those number of questions; however, I'm running into a complication when trying to use this method. I want to link the first form to the second form, but not sure how to because I can't preserve any information in the view from each call.
Is there a better way of going about this problem?
You certainly can preserve information between views. Perhaps the easiest way to do this is in URL parameters; your first view can redirect to "/second_view/?number_of_questions=5" and the second view can access request.GET['number_of_questions'].
An alternative, which is particularly useful if you have a lot of data, would be to use the session; add the data to the session on submit in the first view, and pop it out in the second.
In Django 1.8, the django.contrib.formtools module was moved into a separate package, django-formtools. It includes the FormWizard, which is the standard tool you'd use to create a form that spans multiple pages and/or steps.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a competition management application that I will be hosting with heroku. Every user of the application would need certain things like an integrated registration store which also plug in the entries so that the registrants can be judged and access to all of their information after the competition to provide results. I dont know how to build this around a profile system that lets you manage your competitions so I was thinking just duplicate the app upon request with a subdomain name for each new event that wants to use it. Is this a bad idea? Should I bite the bullet and figure out how to do the whole profile thing so its one app? - if so please point me in the right direction of how. I am using django
There's no need for multiple app per User, Just one app is enough and define your model something like ...!
class Competition(models.Model):
event_name = models.CharField(max_length=200)
result = models.IntegerField()
class Registration(models.Model):
user = models.ForeignKey(User)
competition = models.ForeignKey(Completition)
Just do event Registration in localhost.com:8000/competition/event_name or Do with your own logic here.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to dynamically change the required attribute on form fields. The reason for doing this is because a user can select "Same address as previous user" yes/no.
If yes then it hides the fields on the frontend and I would want to make the fields which are required by default not required when validating / processing the modelform.
Here is a very nice discussion of this topic in general: Dynamic form requirements in Django .
If you just want to do something really simple, there are two very basic ways that I can think of:
Set the field to not be required and use a custom clean function to check that it exists when it should exist. (If you want an asterisk to appear after the field title, just use some simple javascript.)
Have two different forms--one with the field required and one without--and use javascript to display the correct form.
The first solution is obviously much simpler for exactly what you asked, but if you want to do something even slightly more complicated, you might prefer the second option.