Re: serving over either 80 or 443

2017-07-19 Thread James Schneider
On Jul 19, 2017 1:56 PM, "Larry Martell"  wrote:

This is probably not strictly a Django question, but I'm hoping
someone here has had to solve this before.

We have a django app that is sometimes deployed in an environment with
SSL and talks over port 443, and other times is deployed in a non-SSL
environment and talks over port 80.  In our templates we serve CSS and
JS files with this: href="https://0.0.0.0:443/...; When running over
port 80 that does not work. Is there a way to tell in the template if
we are using port 80 or 443 and adjust the href accordingly?


IMO this shouldn't be something you are determining on every request, it's
a waste. You should either:

A. Use relative URL's as Francois mentioned (if the request is against the
same server). Only use absolute URL's of you need to contact a server with
a different name.

B. Use a custom setting in settings.py for each customer that specifies
like RESOURCE_PREFIX = 'https:///' and then use a template context
processor to automatically populate all of your template contexts with it.
Then it's just a matter of referencing the variable in the template
combined with whatever path you need. They are stupid easy to write:

https://docs.djangoproject.com/en/1.11/ref/templates/api/#writing-your-own-context-processors

C. Strongly encourage all of your customers to convert everything to use
TLS, especially if any sort of credentials or sensitive data are involved.
There's really no excuse anymore with the advent of LetsEncrypt.

-James

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXefa4vHjXtqt94sWyrvKu%2BJucj_%2BgvVyD_kf-jw7LDug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Mike Morris

On 07/19/2017 06:20 PM, Vijay Khemlani wrote:

I'm guessing he's using the mathfilters package

https://github.com/dbrgn/django-mathfilters


Arggghhh... my ignorance is showing! I hope I included an "I'm new here" 
disclaimer in the original post!!!

Anyway, never heard of it, I'll take a look!

Thank You Vijay!


--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd06d501-0603-e62e-a34d-01ae014c912d%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Vijay Khemlani
I'm guessing he's using the mathfilters package

https://github.com/dbrgn/django-mathfilters

On Wed, Jul 19, 2017 at 7:28 PM, Mike Morris  wrote:

> Of course, if they're integers you could implement the "mul" as a loop of
> "add"s... clumsy, but would work.
>
> On 07/19/2017 03:39 PM, Mike Morris wrote:
>
> I am a newbie, but I think the answer is that you can't do that in the
> template - instead, calculate the number in the view and pass it to the
> template in the context dictionary.
>
> I think it's a design philosophy of Django Template Language to not
> support this as it muddies the border between data and presentation.
> They've obviously made some exceptions for the really common/easy use cases
> - like "|add"
>
> There are other template languages that do support that of course; if its
> important enough you could look at changing the template engine...
>
>
>
>
> On 07/18/2017 07:21 PM, sum abiut wrote:
>
> Hi,
> needed direction maths filters on django templates. for example how to you
> perform this on a template.
>
> a*b +b*c
>
> i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point me
> to right direction.
>
> cheers,
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAPCf-y648sfPwKJWLmRtcx6tfC_PZP6RP6PjUvCmzRKVfOH%3DSg%
> 40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0ff382b8-ecfa-e1ab-43f4-f47bcde5b274%40musicplace.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/735d3169-5d8f-dfb7-84cf-ba87a490573d%40musicplace.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei0QOWrZheHH0FC4JLD929pbhVFS9TrL%2Buhf2%2BDK1nymdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Mike Morris
Of course, if they're integers you could implement the "mul" as a loop 
of "add"s... clumsy, but would work.



On 07/19/2017 03:39 PM, Mike Morris wrote:


I am a newbie, but I think the answer is that you can't do that in the 
template - instead, calculate the number in the view and pass it to 
the template in the context dictionary.


I think it's a design philosophy of Django Template Language to not 
support this as it muddies the border between data and presentation. 
They've obviously made some exceptions for the really common/easy use 
cases - like "|add"


There are other template languages that do support that of course; if 
its important enough you could look at changing the template engine...





On 07/18/2017 07:21 PM, sum abiut wrote:

Hi,
needed direction maths filters on django templates. for example how 
to you perform this on a template.


a*b +b*c

i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please 
point me to right direction.


cheers,
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y648sfPwKJWLmRtcx6tfC_PZP6RP6PjUvCmzRKVfOH%3DSg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ff382b8-ecfa-e1ab-43f4-f47bcde5b274%40musicplace.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/735d3169-5d8f-dfb7-84cf-ba87a490573d%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Mike Morris
I am a newbie, but I think the answer is that you can't do that in the 
template - instead, calculate the number in the view and pass it to the 
template in the context dictionary.


I think it's a design philosophy of Django Template Language to not 
support this as it muddies the border between data and presentation. 
They've obviously made some exceptions for the really common/easy use 
cases - like "|add"


There are other template languages that do support that of course; if 
its important enough you could look at changing the template engine...





On 07/18/2017 07:21 PM, sum abiut wrote:

Hi,
needed direction maths filters on django templates. for example how to 
you perform this on a template.


a*b +b*c

i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point 
me to right direction.


cheers,
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y648sfPwKJWLmRtcx6tfC_PZP6RP6PjUvCmzRKVfOH%3DSg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ff382b8-ecfa-e1ab-43f4-f47bcde5b274%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving over either 80 or 443

2017-07-19 Thread François Schiettecatte
This tells you whether the request is secure or not:


https://docs.djangoproject.com/en/1.11/ref/request-response/#django.http.HttpRequest.is_secure

You could set a flag in the context you pass your templates.

And what about stripping 'https://0.0.0.0:443/‘ from the url, just use 
‘/static/file.css'

François


> On Jul 19, 2017, at 1:55 PM, Larry Martell  wrote:
> 
> This is probably not strictly a Django question, but I'm hoping
> someone here has had to solve this before.
> 
> We have a django app that is sometimes deployed in an environment with
> SSL and talks over port 443, and other times is deployed in a non-SSL
> environment and talks over port 80.  In our templates we serve CSS and
> JS files with this: href="https://0.0.0.0:443/...; When running over
> port 80 that does not work. Is there a way to tell in the template if
> we are using port 80 or 443 and adjust the href accordingly?
> 
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CACwCsY61p7F%3DH5BYR3tKnFpDE6mdW%2BSV_QsJVHY%3DvsZDa2Yk6Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DF79CE98-280F-4AC0-B98F-328871055365%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


serving over either 80 or 443

2017-07-19 Thread Larry Martell
This is probably not strictly a Django question, but I'm hoping
someone here has had to solve this before.

We have a django app that is sometimes deployed in an environment with
SSL and talks over port 443, and other times is deployed in a non-SSL
environment and talks over port 80.  In our templates we serve CSS and
JS files with this: href="https://0.0.0.0:443/...; When running over
port 80 that does not work. Is there a way to tell in the template if
we are using port 80 or 443 and adjust the href accordingly?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY61p7F%3DH5BYR3tKnFpDE6mdW%2BSV_QsJVHY%3DvsZDa2Yk6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fluent interface on custom methods of custom Queryset class

2017-07-19 Thread Felippe Raposo
Hey Fabio, according to the Django documentation
 the
right way would be:

ProcedureManager = models.Manager.from_queryset(ProcedureQuerySet)

class Procedure(models.Model):
start_date = models.DateTimeField()
end_date = models.DateTimeField(null=True)
is_active = models.BooleanField(default=True)

objects = ProcedureManager()

or

class Procedure(models.Model):
start_date = models.DateTimeField()
end_date = models.DateTimeField(null=True)
is_active = models.BooleanField(default=True)

objects = models.Manager.from_queryset(ProcedureQuerySet)()


Warmly,
Felippe Raposo


2017-07-19 11:50 GMT-03:00 Fabio C. Barrionuevo da Luz :

> What is the right way to make Fluent interface on custom methods of custom
> Queryset class?
>
> In other words, how to make "by_validity" work without lost previous
> filters?
>
> Procedure.objects.filter(is_active=False).by_validity()
>
>
> I've tried using q = self or q = self.query before apply
> Q(start_date__lte=start_date) & (Q(end_date=None) |
> Q(end_date__gte=end_date)) , But it did not work, I got errors.
>
> Thanks.
>
> sample code:
>
> from datetime import date, datetime, time
> from django.conf import settings
> from django.db import models
> from django.db.models import Q
>
>
> class ProcedureQuerySet(models.QuerySet):
> def by_validity(self, start_date=None, end_date=None):
> if not start_date:
> start_date = date.today()
> if start_date and not end_date:
> end_date = start_date
> if end_date < start_date:
> raise ValueError("end_date must be greater than start_date")
>
> start_date = datetime.combine(start_date, time.min)
> end_date = datetime.combine(end_date, time.max)
>
>
> q = Q(start_date__lte=start_date) & (Q(end_date=None) |
> Q(end_date__gte=end_date))
> return self.filter(q)
>
> class ProcedureManager(models.Manager.from_queryset(ProcedureQuerySet)):
> pass
>
>
> class Procedure(models.Model):
> start_date = models.DateTimeField()
> end_date = models.DateTimeField(null=True)
> is_active = models.BooleanField(default=True)
>
> objects = ProcedureManager()
>
>
>
> --
> Fábio C. Barrionuevo da Luz
> Palmas - Tocantins - Brasil - América do Sul
>
> http://pythonclub.com.br/
>
> Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
> totalmente no https://github.com/pythonclub/pythonclub.github.io .
>
> Todos são livres para publicar. É só fazer fork, escrever sua postagem e
> mandar o pull-request. Leia mais sobre como publicar em README.md e
> contributing.md.
> Regra básica de postagem:
> "Você" acha interessante? É útil para "você"? Pode ser utilizado com
> Python ou é útil para quem usa Python? Está esperando o que? Publica logo,
> que estou louco para ler...
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAPVjvMZ8vm_61M_xZ2KU4vjca4ke3d52MfgEX0LrcS0ga
> q3tKQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP6GVqiti5VmG2X3%2Bpo3aRBhbw1dUN1kQZQ8Nk%3DTn4f%2B6NWOeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Fluent interface on custom methods of custom Queryset class

2017-07-19 Thread Fabio C. Barrionuevo da Luz
What is the right way to make Fluent interface on custom methods of custom
Queryset class?

In other words, how to make "by_validity" work without lost previous
filters?

Procedure.objects.filter(is_active=False).by_validity()


I've tried using q = self or q = self.query before apply
Q(start_date__lte=start_date) & (Q(end_date=None) |
Q(end_date__gte=end_date)) , But it did not work, I got errors.

Thanks.

sample code:

from datetime import date, datetime, time
from django.conf import settings
from django.db import models
from django.db.models import Q


class ProcedureQuerySet(models.QuerySet):
def by_validity(self, start_date=None, end_date=None):
if not start_date:
start_date = date.today()
if start_date and not end_date:
end_date = start_date
if end_date < start_date:
raise ValueError("end_date must be greater than start_date")

start_date = datetime.combine(start_date, time.min)
end_date = datetime.combine(end_date, time.max)


q = Q(start_date__lte=start_date) & (Q(end_date=None) |
Q(end_date__gte=end_date))
return self.filter(q)

class ProcedureManager(models.Manager.from_queryset(ProcedureQuerySet)):
pass


class Procedure(models.Model):
start_date = models.DateTimeField()
end_date = models.DateTimeField(null=True)
is_active = models.BooleanField(default=True)

objects = ProcedureManager()



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPVjvMZ8vm_61M_xZ2KU4vjca4ke3d52MfgEX0LrcS0gaq3tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to discover which postgres vesion is in use (on 1.11)?

2017-07-19 Thread Antonis Christofides
Hello,

You can probably do something like this:

import sys

from django.db import connection

with connection.cursor() as cursor:
cursor.execute("SELECT version()")
result = cursor.fetchone()[0]

sys.stdout.write(result + '\n')

This prints out something like "PostgreSQL 9.4.12 on x86_64-unknown-linux-gnu,
compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit".

The "SELECT version()" is a PostgreSQL-specific way of getting the server
version. The rest is Django's way of executing raw SQL queries
.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com


On 2017-07-19 13:14, Hanne Moa wrote:
> When https://code.djangoproject.com/ticket/18332 lands (No generic way
> to get database backend version) this will be trivial but I need a
> solution for this now: How can I find out which version of postgres is
> in use?
>
> I need it thanks to JSONField. 9.6 has support for it but older
> postgresqls don't, and I'd like to then use a third-party
> json-in-TextField solution instead.
>
> A model with a django.contrib.postgres.fields.JSONField cannot be
> migrated on posgresqls older than 9.4. (We run 9.3 and I need this
> project to run on >=9.3) You get 'django.db.utils.ProgrammingError:
> type "jsonb" does not exist'. At that point it's a little late
> swapping out the import.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06844f40-13ea-6345-eb01-fddf1421fd3f%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to django

2017-07-19 Thread Stefano Probst
Hi!

New to Django? Read the Getting started 
.

Am Mittwoch, 19. Juli 2017 13:04:50 UTC+2 schrieb dkushwah5:
>
> I want to connect my bootstrap website with django's database. Please tell 
> me how to do it.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/639bb6be-c112-42da-a5c5-f6831ac31770%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


permission denied for relation gallery_image

2017-07-19 Thread Samuel Muiruri
I made a mistake and overwrote the Django server's settings file with the
local version and I lost the database settings for postgresql I have setup
a new user and when I tried to reload the site again I get an error from
one of the models as permission denied for relation gallery_image

if I try this command from the shell

from gallery.models import Image

I get back

ProgrammingError: permission denied for relation gallery_image


-- 

Best Regards,

Samuel Muiruri.

Web Designer | +254 738 940064

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJZFZXpmFF%3DuGvQm7Ubo44TWFA4%3Dt26OS288x%3DZ5CXBQLU6ATw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


url path got static ,can't execute other project files

2017-07-19 Thread Kesava Knights
I had downloaded a django file from github , and executed the file and 
working properly in browser UI. but later  tried to execute another project 
file which is in another directory , url path got fixed to previous 
executed file and it same for any other project files except the first 
executed file.Plzz help me to get rid of  static path .. 



https://github.com/axelpale/minimal-django-file-upload-example.git 

I cloned the above link file from github.. 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/745a4203-df44-408f-b445-b37bd17c5222%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Vijay Khemlani
Also I guess mathfilters just executes left-to-right

so

a|mul:b|add:b|mul:c

is (((a * b) + b) * c)

On Wed, Jul 19, 2017 at 1:50 AM, James Schneider 
wrote:

>
>
> On Jul 18, 2017 7:21 PM, "sum abiut"  wrote:
>
> Hi,
> needed direction maths filters on django templates. for example how to you
> perform this on a template.
>
> a*b +b*c
>
> i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point me
> to right direction.
>
>
> I wouldn't do any sort of advanced math in the template. It should be
> completed in the view and added to the template context, then referenced as
> a template variable. The template processor has no concept of the order of
> operations in math.
>
> -James
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciWfni0w6XZmfqrjnsrTLiWZLh0N
> Wu9ye%2BA_Cm0NDb6x3A%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei3eX0FOfV2aNMZJbNawsW1ywVRn%2BLKb86V_23uXW9cisQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New to django

2017-07-19 Thread dkushwah5
I want to connect my bootstrap website with django's database. Please tell 
me how to do it.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a7ea1e2-f004-4fef-b808-a254b3b46b68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to discover which postgres vesion is in use (on 1.11)?

2017-07-19 Thread Hanne Moa
When https://code.djangoproject.com/ticket/18332 lands (No generic way
to get database backend version) this will be trivial but I need a
solution for this now: How can I find out which version of postgres is
in use?

I need it thanks to JSONField. 9.6 has support for it but older
postgresqls don't, and I'd like to then use a third-party
json-in-TextField solution instead.

A model with a django.contrib.postgres.fields.JSONField cannot be
migrated on posgresqls older than 9.4. (We run 9.3 and I need this
project to run on >=9.3) You get 'django.db.utils.ProgrammingError:
type "jsonb" does not exist'. At that point it's a little late
swapping out the import.

-- 
HM

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACQ%3DrrekauCT-2HVHb7t-WtFxmp5Bq8mRTnThj%2Bb6AURP1b%3Dng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.