How write advance Django ORM query

2017-07-20 Thread Foridur Kayes Shawon
https://stackoverflow.com/questions/45145257/how-write-advance-django-orm-query

-- 
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/2f6fb109-a6c1-4f51-9260-cfd7d0aa19ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Find variables marked for translations

2017-07-20 Thread Mike Dewhirst
My plan (not commenced yet) is to use an on-line translation API. I just 
googled "on-line translation api" and see there are quite a few options.


On 20/07/2017 9:38 PM, prabhakar shanmugam wrote:

Hi all,

I am translating a message which is a variable. The variable is 
dynamic text. It can be from any source like third party api or from 
the request get/post of user, meaning we won't know the text to be 
translated.


So at run time when the actual value of the variable is received, and 
when django tries to look for a translation in the po/mo file, I want 
to log that, django searched for the message in the msgid's but didn't 
find one.


Is this possible. Which django function does the job of actually 
looking for the word to be translated.


|
defsome_view(request):
trans1 =ugettext("this will surely get translated")
trans2 =ugettext(some_variable)
|


when the view is run I will get the value of some_variable. But since 
I don't have that in the django.po / .mo file, it wont translate. That 
is fine and understood, but I want to log the actual value of 
some_variable when the view runs. With the log, I would translate them 
later on leisurely.


Hope I have explained it clearly.

--
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/50dea20f-9d7e-45ee-92c6-4a58925c78b1%40googlegroups.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/44f434e8-2047-8a11-1b68-2b83f9472060%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


It's possible to cache entire model

2017-07-20 Thread Fellipe Henrique
Hi guys,

I need to cache entire model, not a query, not a view.. entire model.. so,
any query using these model will use the cache..

Can I do that using django cache?

regards

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

-- 
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/CAF1jwZH1%2B7ErXX0c-ugAAA0UC4S8tT%2BDM72OME6UgO3JX4Xvqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User accessibility to multiple versions of an app.

2017-07-20 Thread James Schneider
On Thu, Jul 20, 2017 at 11:34 AM,  wrote:

> Thanks James.  I'm working with Data Labels =].  Give me a minute to go
> over my project to see which of the two design patterns would best suit my
> needs.  I really appreciate the long and in-depth response.  Will get back
> to you after some analysis.
>
> K
>

I would also highly recommend the book Fluent Python, which discusses these
two design patterns in detail with comparative examples, among a myriad of
other topics that made me realize I'm a terrible programmer.

-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%2BciXZZSqWCmwSfOnScM5F5uOGmvThP%3D6DE2cmmVFAHopC%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User accessibility to multiple versions of an app.

2017-07-20 Thread James Schneider
On Thu, Jul 20, 2017 at 11:23 AM, m1chael  wrote:

> James, you rock dude. lol
>

Yeah, apparently I got a bit excited.

-- 
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%2BciWm6F-huL5864srYUE2uEZFQd06%2BU7BCOCb%3DWa%2BeyKHjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User accessibility to multiple versions of an app.

2017-07-20 Thread pieceofkayk2718
Thanks James.  I'm working with Data Labels =].  Give me a minute to go 
over my project to see which of the two design patterns would best suit my 
needs.  I really appreciate the long and in-depth response.  Will get back 
to you after some analysis.

K

-- 
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/18d1f1f7-5d5b-41d8-8d72-45f89d796d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User accessibility to multiple versions of an app.

2017-07-20 Thread m1chael
James, you rock dude. lol

On Thu, Jul 20, 2017 at 2:20 PM, James Schneider 
wrote:

>
>
> On Thu, Jul 20, 2017 at 8:44 AM,  wrote:
>
>> Hey, I've been running into issues trying to figure out how a user could
>> be able to access multiple versions of an app.  Here is the following
>> example:
>>
>> I have an app named ANNA.  ANNA is used to build labels and these labels
>> are dependent upon different standards that come out.  For example, we have
>> standard 1700, standard 1800, standard 1900.  The DjangoProject website has
>> a bottom corner button that allows you to go to different versions of the
>> django docs.  I would like to implement that into ANNA, however I've come
>> across a number of problems.  So ANNA has the following app structure:
>>
>>
> Those buttons refer to different releases of the same application. They
> really are just shortcuts to a folder path that points at the particular
> release:
>
> https://docs.djangoproject.com/en/1.7/
> https://docs.djangoproject.com/en/1.11/
> https://docs.djangoproject.com/en/dev/
>
> I haven't investigated, but I'm guessing that each of those URL paths map
> back to a directory containing a full release of the Django docs at the
> appropriate version.
>
> my_project
>>  - ANNA
>>  - build(development)
>>  - search (development)
>>
>> I have tried to implement this versioning by the following partition
>>
>> *PARTITION 1*
>>
>> my_project
>> - ANNA
>> - build   (development)
>> - search (development)
>> - build1700
>> - search1700
>> - build1800
>> - search1800
>> - build1900
>> - search1900
>>
>> Unfortunately, the models used in all versions of build are the same
>> across the board, and Django's reverse lookup for these models is giving me
>> issues.  For instance if I have a label model in build, I will also have a
>> label model in build1700, build1800, etc.  So I have to change the model
>> names for each version, which means I have to change all of the business
>> code to be version specific -- and I really do not want to do that since
>> our label standards are also in development and change quite rapidly (like
>> every four months right now).  The versions are also similar enough to
>> where when a new one comes out, I would like to be able to pretty much copy
>> and paste the last version's code into the new version's code and make my
>> changes like so.
>>
>>
> Has anyone ever had to do anything like this or have any ideas of how to
>> go about it?
>>
>
> Disclaimer: I'm obviously not familiar with your application or workflow,
> so take this with a grain of salt. My assumption is that you are creating
> output for something like shipping labels that have to follow particular
> formatting standards. If not, clarity via a brief overview of what your app
> does would be helpful.
>
> The abbreviated version of what I have below is "I highly doubt you need
> separate apps, but rather a single app with a better model design to
> support multiple label/build types."
>
>
> It appears you are creating a separate application for each label type. In
> doing so, I'm assuming that you are copying the code from another "version"
> (presumably development) and then modifying the entire application
> accordingly. From what I gather, the work being performed in each "version"
> is very similar with only a few minor differences (standard number, label
> size, address placement, font used, etc.). If that is the case, the
> versioning scheme you've developed is very inefficient and difficult to
> maintain.
>
> I would recommend that you examine the workflow processes from a much
> broader view. For example, to print a label, you would need to know it's
> total size, type (water resistant, semi-gloss, etc.), printable area, and
> so on. Presumably all of your labels have common attributes like these
> (don't think about specific values at this point).
>
> Gather all of those common attributes for handy reference. In addition,
> generate a list of unique attributes specific to a label type (perhaps a
> built-in RFID tag ID that only higher-end labels have or something like
> that).
>
> Now the fun/tricky part. There are two design patterns I see to address
> your design.
>
> First pattern:
>
> Generate an abstract model that contains all of the common attributes that
> most or all of your labels will have. This could be things like standard
> number, size, weight, etc. You would then create regular models that
> inherit from your new abstract model. Each of these models would either
> contain no new fields (if everything they need is contained in the abstract
> model), or would add the label-specific fields in. Things like the standard
> number can be made available via class-level attributes (ie standard_number
> = 1700) or via a common function defined in the abstract model that each
> regular model can override if necessary. Here's how I would handle the
> standard number:
>
> class AbstractLabel(models.Mod

Re: User accessibility to multiple versions of an app.

2017-07-20 Thread James Schneider
On Thu, Jul 20, 2017 at 8:44 AM,  wrote:

> Hey, I've been running into issues trying to figure out how a user could
> be able to access multiple versions of an app.  Here is the following
> example:
>
> I have an app named ANNA.  ANNA is used to build labels and these labels
> are dependent upon different standards that come out.  For example, we have
> standard 1700, standard 1800, standard 1900.  The DjangoProject website has
> a bottom corner button that allows you to go to different versions of the
> django docs.  I would like to implement that into ANNA, however I've come
> across a number of problems.  So ANNA has the following app structure:
>
>
Those buttons refer to different releases of the same application. They
really are just shortcuts to a folder path that points at the particular
release:

https://docs.djangoproject.com/en/1.7/
https://docs.djangoproject.com/en/1.11/
https://docs.djangoproject.com/en/dev/

I haven't investigated, but I'm guessing that each of those URL paths map
back to a directory containing a full release of the Django docs at the
appropriate version.

my_project
>  - ANNA
>  - build(development)
>  - search (development)
>
> I have tried to implement this versioning by the following partition
>
> *PARTITION 1*
>
> my_project
> - ANNA
> - build   (development)
> - search (development)
> - build1700
> - search1700
> - build1800
> - search1800
> - build1900
> - search1900
>
> Unfortunately, the models used in all versions of build are the same
> across the board, and Django's reverse lookup for these models is giving me
> issues.  For instance if I have a label model in build, I will also have a
> label model in build1700, build1800, etc.  So I have to change the model
> names for each version, which means I have to change all of the business
> code to be version specific -- and I really do not want to do that since
> our label standards are also in development and change quite rapidly (like
> every four months right now).  The versions are also similar enough to
> where when a new one comes out, I would like to be able to pretty much copy
> and paste the last version's code into the new version's code and make my
> changes like so.
>
>
Has anyone ever had to do anything like this or have any ideas of how to go
> about it?
>

Disclaimer: I'm obviously not familiar with your application or workflow,
so take this with a grain of salt. My assumption is that you are creating
output for something like shipping labels that have to follow particular
formatting standards. If not, clarity via a brief overview of what your app
does would be helpful.

The abbreviated version of what I have below is "I highly doubt you need
separate apps, but rather a single app with a better model design to
support multiple label/build types."


It appears you are creating a separate application for each label type. In
doing so, I'm assuming that you are copying the code from another "version"
(presumably development) and then modifying the entire application
accordingly. From what I gather, the work being performed in each "version"
is very similar with only a few minor differences (standard number, label
size, address placement, font used, etc.). If that is the case, the
versioning scheme you've developed is very inefficient and difficult to
maintain.

I would recommend that you examine the workflow processes from a much
broader view. For example, to print a label, you would need to know it's
total size, type (water resistant, semi-gloss, etc.), printable area, and
so on. Presumably all of your labels have common attributes like these
(don't think about specific values at this point).

Gather all of those common attributes for handy reference. In addition,
generate a list of unique attributes specific to a label type (perhaps a
built-in RFID tag ID that only higher-end labels have or something like
that).

Now the fun/tricky part. There are two design patterns I see to address
your design.

First pattern:

Generate an abstract model that contains all of the common attributes that
most or all of your labels will have. This could be things like standard
number, size, weight, etc. You would then create regular models that
inherit from your new abstract model. Each of these models would either
contain no new fields (if everything they need is contained in the abstract
model), or would add the label-specific fields in. Things like the standard
number can be made available via class-level attributes (ie standard_number
= 1700) or via a common function defined in the abstract model that each
regular model can override if necessary. Here's how I would handle the
standard number:

class AbstractLabel(models.Model):

_standard_number = None

size_horizontal = models.FloatField...
size_vertical = models.FloatField...
other fields

def get_standard_number(self):
return getattr(self, '_standard_number', None)

# You can also 

Re: New to django

2017-07-20 Thread dkushwah5
Thanx Stefano :) 

On Wednesday, July 19, 2017 at 7:19:08 PM UTC+5:30, Stefano Probst wrote:
>
> 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/50aa7f23-851b-4554-b014-ec812c7d1d1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


User accessibility to multiple versions of an app.

2017-07-20 Thread pieceofkayk2718
Hey, I've been running into issues trying to figure out how a user could be 
able to access multiple versions of an app.  Here is the following example:

I have an app named ANNA.  ANNA is used to build labels and these labels 
are dependent upon different standards that come out.  For example, we have 
standard 1700, standard 1800, standard 1900.  The DjangoProject website has 
a bottom corner button that allows you to go to different versions of the 
django docs.  I would like to implement that into ANNA, however I've come 
across a number of problems.  So ANNA has the following app structure:

my_project
 - ANNA
 - build(development)
 - search (development)

I have tried to implement this versioning by the following partition

*PARTITION 1*

my_project
- ANNA
- build   (development)
- search (development)
- build1700
- search1700
- build1800
- search1800
- build1900
- search1900

Unfortunately, the models used in all versions of build are the same across 
the board, and Django's reverse lookup for these models is giving me 
issues.  For instance if I have a label model in build, I will also have a 
label model in build1700, build1800, etc.  So I have to change the model 
names for each version, which means I have to change all of the business 
code to be version specific -- and I really do not want to do that since 
our label standards are also in development and change quite rapidly (like 
every four months right now).  The versions are also similar enough to 
where when a new one comes out, I would like to be able to pretty much copy 
and paste the last version's code into the new version's code and make my 
changes like so.

Has anyone ever had to do anything like this or have any ideas of how to go 
about it? 

Also, below is my current callback.


Unhandled exception in thread started by 
> Traceback (most recent call last):
>   File "/usr/lib64/python2.7/site-packages/django/utils/autoreload.py", 
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/usr/lib64/python2.7/site-packages/django/core/management/commands/runserver.py",
>  
> line 125, in inner_run
> self.check(display_num_errors=True)
>   File 
> "/usr/lib64/python2.7/site-packages/django/core/management/base.py", line 
> 405, in check
> raise SystemCheckError(msg)
> django.core.management.base.SystemCheckError: SystemCheckError: System 
> check identified some issues:
>
> ERRORS:
> build1700.Bundle.user: (fields.E304) Reverse accessor for 'Bundle.user' 
> clashes with reverse accessor for 'Bundle.user'.
> HINT: Add or change a related_name argument to the definition for 
> 'Bundle.user' or 'Bundle.user'.
> build.Bundle.user: (fields.E304) Reverse accessor for 'Bundle.user' 
> clashes with reverse accessor for 'Bundle.user'.
> HINT: Add or change a related_name argument to the definition for 
> 'Bundle.user' or 'Bundle.user'.
>
>

-- 
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/4ae70d15-12a3-44bd-9dfe-7666eab9e658%40googlegroups.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-20 Thread Tim Graham
You can use:

>>> from django.db import connection
>>> connection.pg_version
90507

On Wednesday, July 19, 2017 at 6:15:29 AM UTC-4, HM 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. 
>
> -- 
> 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/0b735664-8a28-4f1e-be39-224b478924eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Find variables marked for translations

2017-07-20 Thread prabhakar shanmugam
Hi all,

I am translating a message which is a variable. The variable is dynamic 
text. It can be from any source like third party api or from the request 
get/post of user, meaning we won't know the text to be translated.

So at run time when the actual value of the variable is received, and when 
django tries to look for a translation in the po/mo file, I want to log 
that, django searched for the message in the msgid's but didn't find one. 

Is this possible. Which django function does the job of actually looking 
for the word to be translated.

def some_view(request):
trans1 = ugettext("this will surely get translated")
trans2 = ugettext(some_variable)


when the view is run I will get the value of some_variable. But since I 
don't have that in the django.po / .mo file, it wont translate. That is 
fine and understood, but I want to log the actual value of some_variable 
when the view runs. With the log, I would translate them later on leisurely.

Hope I have explained it clearly.

-- 
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/50dea20f-9d7e-45ee-92c6-4a58925c78b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ModelForm with field subset saving all fields

2017-07-20 Thread Cristina Botez
I'm using a view that combines 2 forms (which were split in order to 
facilitate reuse and to separate concerns). The model instance I am sending 
to both is the same, so when one form sets the new values on the instance, 
the other can see them. The problem is that when the first form is saved, 
the changes made through the second form are also committed. Functionally, 
this is not a problem, but I also generate some historical records and 
expect to have 2 different historical records generated after these 
modifications - or in any case, I expect the fields to be grouped based on 
this separation. (Background: the records are generated by a *post_save* 
signal receiver).

My expectation was that updating an instance via a form will only update 
the set of fields specified in *ModelForm.Meta.fields*, not all the fields 
of the instance. It would also make a lot more sense in case the model has 
TextFields not included in the form being saved.
I know I could just call *super().save(commit=False)* and then just save 
the instance using the update_fields parameter, but I think this 
functionality should come out of the box.

My question is: Are there any considerations that I'm not aware of to 
prevent saving the instance with the *update_fields* set to 
*ModelForm.Meta.fields* in the base implementation of *ModelForm*?

-- 
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/8a5dcfee-a8b6-4821-9107-e16485086a7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving over either 80 or 443

2017-07-20 Thread Larry Martell
On Thu, Jul 20, 2017 at 1:27 AM, James Schneider
 wrote:
>
>
> 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.

See my reply to Francois.

> 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.

I agree, but I cannot control what my customers do.

-- 
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/CACwCsY4qbWU_8SsSgoRUN-Vkw2%2BD3Mhqfg8K5jptd329jcnN_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving over either 80 or 443

2017-07-20 Thread Larry Martell
On Wed, Jul 19, 2017 at 5:14 PM, François Schiettecatte
 wrote:
> 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

Thanks I did not know about that.


> 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'

For most of the static files we do that. But we have one thing where
we generate a PDF from the HTML. We call render_to_string and then
pass the HTML into wkhtmltopdf. Only for that case do we need the
'https://0.0.0.0:443/' - without that the PDF does not render
properly. It works over 443, but when on a different non-SSL port it
does not work. That is the case I am trying to solve.

>> 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/CACwCsY4GeGtiHUnZN2aV_Z7i%3D38g5YCR8uQVBcoeTkxj8Ha7ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-20 Thread Vijay Khemlani
Don't worry, I only knew about the project because I use it in a small part
of an application that can't execute computations on the view

On Wed, Jul 19, 2017 at 10:02 PM, Mike Morris  wrote:

> 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/ms
> gid/django-users/bd06d501-0603-e62e-a34d-01ae014c912d%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/CALn3ei1cU2%2BBX0%3DVTVLbJApB6aAWnmaFhJ%2BjdDHc5iaCQKSAzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: serving over either 80 or 443

2017-07-20 Thread 'Tom Evans' via Django users
On Wed, Jul 19, 2017 at 9: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?
>

For links within the same site, use relative URLs.

For resources on other sites, use protocol relative URLs, like:

  //www.foo.com/foo/bar

The resource will be loaded using whatever protocol the page
requesting it was loaded with.

Cheers

Tom

-- 
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/CAFHbX1K%2BaQvuok00OGfa5duMK1UGLvXR_us0AfP5joEgUm%3Dvdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple DB - Accessing another app's table/model?

2017-07-20 Thread miguel vfx
appA is on project A.
appB is on project B.

--


As it turns out, migrate names the tables as [app]_[model_name] and thus 
with different app names on different projects, I was initially accessing 
the table migrate --database=created.

To access the table on another server, match the table names on both 
database servers by using in models.py:

class Meta:
app_label = [app1_this]
db_table = [app_another]_[model_name]

If someone else has a better solution, please let me know.


On Wednesday, July 19, 2017 at 12:21:53 AM UTC+8, Avraham Serour wrote:
>
> import the Model and query it.
>
> from appB.models import Table
> Table.objects.all()
>
>
> On Tue, Jul 18, 2017 at 6:01 PM, miguel vfx  > wrote:
>
>> Hello,
>>
>> After following through the documentation, I was able to query data from 
>> another database. However, I was only able to access the table of the same 
>> app name. How can I query data from a different app name?
>>
>> For example:
>> appA has a model client_data. It's table name in the app_db database is 
>> appA_client_data.
>>
>> In appB, I created the same model then when I query the data from appA, I 
>> get zero results because it's querying data from appB_client_data in 
>> appA_db.
>>
>> How do I query client_data table/model of appA_db from appB (Both are on 
>> different projects)
>>
>> Thank you for your time.
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/d7e05187-a93d-4b81-88f6-caeb652780b4%40googlegroups.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/9a873486-dedd-4051-8bb1-2100d737f035%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.