What does this mean? 1.0 or 1.1 ?
>>> django.VERSION
(1, 1, 1, 'final', 0)
Apologies for such a dumb question!
Is a tuple with the following fields:
"major"
The major version number of the Django release, e.g., 1 for the
1.x releases.
"minor"
The minor version number of the Django release, e.g., 0 for the
1.0.x releases, 1 for the 1.1.x release, etc.
"micro"
The micro version number of the Django release, e.g., 1 for a
release number 1.0.1, 2 for a release number 1.0.2, etc.
"release level"
A short string describing the type of release. Value will be one
of: "alpha", "beta", "rc" (for release candidates, "final".
"serial"
For situations where we do more than one release of a given level,
the incremental number of the release (e.g., 1 for "alpha 1", 3
for "beta 3", etc.).
Related
I am trying to build a checkout using the Square API. I am getting the following error:
'order.total_money.amount' must be greater than 1.
I am sending:
<cfset stFields = {
"idempotency_key": "*******-258a-402e-abb5-fee8e3d16884",
"redirect_url": "https://graftondecafundraising.org/SquareOrderComplete.cfm",
"order": {
"total_money":{
"amount": 900},
"idempotency_key": "******-258a-402e-abb5-fee8e3d16884",
"order": {
"location_id": "******C7F3RZ1S5",
"customer_id": "customer_id",
"reference_id": "reference_id"
}
},
"ask_for_shipping_address": false,
"merchant_support_email": "merchant+support#website.com",
"pre_populate_buyer_email": "example#email.com"
}
>
And the JSON Reply is showing:
Thanks in advance for any suggestions!
The issue was in CF2016 when serializing the JSON CF wasn't sending the amounts as integers even if you wrapped it as INT(#value#). In CF2018 and CF2021 serializing the JSON created the value as an integer and Square was happy. We tested the exact same code in 2016, 2018, and 2021. It failed in 2016 and worked perfectly in the newer versions.
This occurs in a lot of payment APIs, the amount is in cents, not dollars.
https://developer.squareup.com/reference/square/objects/Money
amount - integer
The amount of money, in the smallest denomination of the currency indicated by currency. For example, when currency is USD, amount is in cents. Monetary amounts can be positive or negative. See the specific field description to determine the meaning of the sign in a particular case.
Can't recall which API was integrated at a previous company, but sending amount: 0 triggered a full refund. Really need to read the docs when it involves money.
I want to know version of the default Postgres database. How to find it using Django?
Get a database connection:
from django.db import connection
And access the inner psycopg2 connection object:
print(connection.cursor().connection.server_version)
One-liner:
$ python3 manage.py shell -c "from django.db import connection; print(connection.cursor().connection.server_version)"
90504
After Postgres 10, the number is formed by multiplying the server's major version number by 10000 and adding the minor version number. For example, version 10.1 will be returned as 100001, and version 11.0 will be returned as 110000. Zero is returned if the connection is bad.
Prior to Postgres 10, the number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 8.1.5 will be returned as 80105.
Therefore, for purposes of determining feature compatibility, applications should divide the result of connection.server_version by 100 not 10000 to determine a logical major version number. In all release series, only the last two digits differ between minor releases (bug-fix releases).
Docs:
https://www.psycopg.org/docs/connection.html#connection.server_version
https://www.postgresql.org/docs/current/libpq-status.html#LIBPQ-PQSERVERVERSION
The Python range() built-in function is limited to integers.
I need a more generic function of similar signature range(start, stop, step), where start, stop and step may be of any types given that:
result of (possibly multiple) addition of step to start is defined,
both start and the result mentioned above can be compared with stop.
The function may be used (for example) to obtain a sequence of days of the year:
range(datetime.datetime(2015, 1, 1),
datetime.datetime(2016, 1, 1),
datetime.timedelta(1))
I know I can easily write such function by myself. However, I am looking for efficient existing solutions in some popular package (like numpy or scipy), working with both Python 2 and Python 3.
I have already tried to combine itertools.takewhile with itertools.count, however the latter seems to be limited to numbers.
You can do this with a simple generator. The following example works with floats, integers and datetime.
With datetime you just need to clearly specify the exact date (1 Jan 2016) not just 2016 and clearly specify the time delta (timedelta(days=1) not timedelta(1))
import datetime
def range2(start,stop,step):
value = start
while value <= stop:
yield value
value += step
for date in range2(datetime.datetime(2015,1,1),datetime.datetime(2016,1,1),datetime.timedelta(days=1)):
print(date)
As for off-the-shelf solutions there is arange in numpy but I haven't tested that with datetime.
>>> from numpy import arange
>>> arange(0.5, 5, 1.5)
array([0.5, 2.0, 3.5])
It is possible to display crosses on google chart instead of circles?
I cannot find it in the documentation.
The new pointShape option does not support crosses per say, but you can make the "star" shape look like a cross:
pointShape: {
type: 'star',
sides: 4,
inset: 0.1,
rotation: 45
},
pointSize: 16
Load the release candidate version (1.1) instead of the production version (1) to test this. This should be available in the next public release, tentatively scheduled for March 13, 2014.
I am working on a sitecore site rev 120706 DMS and main.
We are adding personas to some pages and getting unusual results with fractional values when we try to add to them using the Score(string, float) method. we have a value lead which is 0.5 due to two profiles being added to an earlier page one with a value of 1 and another with a value of 0. On a form submission we want to add one to the value and use Profile.Score("lead", 1) which replaces the .5 with a 1 instead of adding 1 to get 1.5 . When the value is 1 we are successfully getting 2.
How can we get the Score method to react in a consistent matter?
Sitecore apparently has an issue in their code with it using int.Parse instead of float.Parse
I've found place in the code where the error appears. It's in the
Sitecore.Analytics.Data.VisitProfile.Parse() method. It uses int.Parse
instead of float.Parse while reading profile values from database.
This issue was fixed in Sitecore 6.6.0 Update-4. Please see reference
number 376088 in release notes. Unfortunately, there is no easy way to
fix the code. Please consider upgrading your solution to 6.6.0
Update-4. In the meantime I would suggest to use larger score values
in your profiles, so that resulting value is always be greater than 1.
This approach works on my side. Please let us know in case you have
any troubles with that.
To resolve the issue ended up just multiplying the values we were using by 10 to avoid sitecore's int as opposed to float issue.