I have a site which is joomla 2.5 version. I have used chronoform. I have configured chronoform mail with field values like Nombre{Nombre}.But the mail is going in spam and in the body I am getting like below..
Nombre {Nombre}
Apellido {Apellido}
Ciudad {Ciudad}
Telefono {Telefono}
Correo electrónico {Correo electronico}
Mensaje {Mensaje}
I am not getting the values of {Nombre} etc.
You need to make sure that the field name is declared in chronoforms.
If you go into your form and click on the wizard (if you used the wizard) - you'll see your form fields. Click to edit your form field and your options window will appear.
You will see 'Label Text', 'Field Name', 'Field Default Value', etc.
You MUST fill in the field name for each of them in order to get their values into the email. So for example Nombre would be:
Label Text: Nombre:
Field Name: Nombre
Then you could do "Nombre: {Nombre}" in your email template to get the value.
Related
The basic problem is that I can't use the key-value-argument
field_variable_name__isnull=True/False
or
field_variable_name=None
when the field_variable_name contains spaces or hyphens (e.g. 'This is my field variable name', or 'This-is-another-one').
I looked up how to filter a models.object-list with 'varname__isnull=True', but didn't find a solution for the case that a name containing a space-character was given:
In my views.py I have the following function:
def currenttodos(request):
todos = Todo.objects.filter(user=request.user, time_completed__isnull=True)
return render(request, 'todo/currenttodos.html', {'todos': todos})
The model Todo in the models.py - file comprises the following field:
time_completed = models.DateTimeField(null=True, blank=True)
This way it works, but actually I wanted to call the time_completed - field differently, for example "Completion time" using the name-parameter:
time_completed = models.DateTimeField(null=True, blank=True, name="Completion time")
Now, the problem is that I can't use the __isnull - parameter since the name contains a space.
All of the following examples don't work:
todos = Todo.objects.filter(user=request.user, Completion time__isnull=True)
todos = Todo.objects.filter(user=request.user, "Completion time"__isnull=True)
todos = Todo.objects.filter(user=request.user, "Completion time"=None)
etc.
How can I make this work for names containing spaces or hyphens?
Here is a link to a similar post:
Filtering for empty or NULL names in a queryset
Basically, this user wanted to be able to exclude instances that were null or blank. As you can see there are several options to do this. My preferred approach is to chain together the filter criteria as to me it is more straightforward and easy to understand however you have some options.
You could delete the name argument. It is not necessary. django will create a field with label of the attribute time_completed but you just filter like this
todos = Todo.objects.filter(user=request.user, time_completed__isnull=True)
I am using QuerySelectField in many pages in a Flask app and it is working fine. Except in one route where I keep getting the message "not a valid choice" when I submit the form.
Yet, the dropdown menu is populated correctly and a choice is indeed selected in it. When I print() the field data, I get a "None" so there seems to be the problem since even if we select a choice, the form seems to pass "None" as the result. Any idea why?
The field is set as:
buy_pc = QuerySelectField('Punch-cards',query_factory=getPunchcards,get_label='label')
Here is the full form:
def getPunchcards():
return Punchcard.query
class Add_participants(Form):
member_name = StringField('Type the tribe\'s member full name:', validators=[DataRequired()])
choice = RadioField('Registration mode',validators=[DataRequired()],choices=[('season_pass','Season Pass'),
('punchcard', 'Punch-card'),
('free_pass','Using a free pass'),
('old_punchcard','Using old punch-card'),
('dropin','Drop-in'),
('checked','Use another member punch-card')])
dropin_ammount = IntegerField('Drop-in ammount',validators=[NumberRange(min=0,max=25,message='Please '
'enter an amount btw 0 and 25')],default=10)
add_note = BooleanField('Add a note to the member profile')
note_content = TextAreaField()
other_punchcard = StringField('Type the tribe\'s member full name:')
buy_pc = QuerySelectField('Punch-cards',query_factory=getPunchcards,get_label='label')
submit = SubmitField('Add')
I am working on a Django project where in a model file I have a field called 'status' which is a choice field.
STATUS_CHOICES = (
(StudentProfileStatus.NEW, _('New')),
(StudentProfileStatus.IMPORTED, _('Imported')),
(StudentProfileStatus.MISSING_INFORMATION, _('Missing Information')),
(StudentProfileStatus.INTERVIEW_SCHEDULED, _('Interview scheduled')),
(StudentProfileStatus.REJECTED, _('Rejected')),
(StudentProfileStatus.ACCEPTED, _('Accepted into Pool')),
(StudentProfileStatus.PAUSED, _('Paused')),
(StudentProfileStatus.OUTBOARDED, _('Outboarded'))
status = models.CharField(
_('Status'),
max_length=50,
choices=STATUS_CHOICES,
default=StudentProfileStatus.default()
)
I am sending an auto generated email as soon as 'Accepted into pool' choice option is selected by the admin for the first time.I am using post_save signal for that.Now in case an admin selects another choice option for e.g. 'Paused',saves it but later again reverts back to the 'Accepted into the pool' choice I don't want the mail to be sent out again.Is there any way where I can get all previous saved values for the 'status' field and check if 'Accepted into Pool' was already saved before so that there is no need to send out the mail again? One possible option which I could think of is django-revisions.
if I have a model that has two model choice fields, is there a way to make the choice set of the second field dependent on what is chosen in the first. Example, if given the following code, the User chooses APPLE for the "company" field — can the code be configured such that the User is presented ONLY the APPLE DIV_CHOICES for his "division" field choices?
CMP_CHOICES ('Apple', 'Apple Computers'),
('MS', 'Microsoft Inc.'),
APPLE DIV_CHOICES ( 'Desktop', 'Desktop'),
( 'iOS', 'iOS'),
( 'AS', 'AppStore'),
MS DIV_CHOICES ( 'Windows', 'Windows'),
( 'Longhorn', 'Longhorn'),
( 'Mobile', 'Mobile'),
class Contact(models.Model)
first_name = models.CharField(max_length=64, …)
last_name = models.CharField(max_length=64, …)
company = models.CharField(max_length=100, choices=CMP_CHOICES)
division = models.CharField(max_length=100, choices=DIV_CHOICES)
....
No. Choices must be all choices that are ever possible. However, you may use JavaScript on your form to limit the choices based on the first selection, but not on the model itself.
There are lots of ways to go about this which will depend on whether you are using the django admin or your own custom code but out of the box it won't work - everything in the form is selectable by default.
You will end up do this at the form level and template level, not in the model. You could create a django form wizard to show the form in multiple stages. Alternatively you could use javascript to only show the APPLE/MS field after the CMP field has been selected. You could get fancier and do some ajax to dynamically load the APPLE/MS field after the CMP has been selected and validated.
In a template for a view I would like to use the name of a field and not just the value.
So for example if I have this:
class Test(models.Model):
name = models.CharField(max_length=2, verbose_name = 'Your name')
age = models.PositiveSmallIntegerField(max_length=3)
I would like to be able to do {{ name.get_field_name_display }} which will result in either the field's name or the verbose name if it is specified; like the way it is done in the admin and forms. Imagine using it like this in the template:
{{name.get_field_name_display}}: {{name}}.
{{age.get_field_name_display}}: {{age}}.
Which would result in, for example:
Your name: John. Age: 16.
where 'Your name' is the field verbose name, 'Age' is the field name and 'John' and 16 are the values.
Could anyone tell me if this is possible and how it is done?
Not easily.