Re: logging admin accesses

2023-12-19 Thread Larry Martell
I got this working. I had to add history =
HistoricalRecords(m2m_fields=[products]) to the models with the M2M
relationships. Did not see that in the docs anywhere.


On Tue, Dec 19, 2023 at 2:17 PM Larry Martell 
wrote:

> After creating the models for the m2m tables the changes to them are
> not tracked by django-simple history. Could it be that Django is not
> using the ORM to update these tables? How could it, since the models
> did not exist before I created them today. If the updates are not
> through the ORM django-simple history may not be able to see them.
>
> On Tue, Dec 19, 2023 at 8:50 AM Larry Martell 
> wrote:
> >
> > On Mon, Dec 18, 2023 at 7:23 PM Mike Dewhirst 
> wrote:
> > >
> > > On 19/12/2023 9:51 am, Larry Martell wrote:
> > >
> > > Hmmm, in my case I do not see any models for those in any of my
> models.py files. Where would I expect to find them?
> > >
> > >
> > > You have to write them yourself.
> >
> > Yeah, thanks. I know I can create them myself. I thought you were
> > saying they were already created by django.
> >
> > The best way is to run manage.py inspectdb > models.txt then extract
> > the m2m models from there. In theory and provided you follow the
> > advice at the top of the output ...
> > >
> > > # This is an auto-generated Django model module.
> > > # You'll have to do the following manually to clean this up:
> > > #   * Rearrange models' order
> > > #   * Make sure each model has one field with primary_key=True
> > > #   * Make sure each ForeignKey and OneToOneField has `on_delete` set
> to the desired behavior
> > > #   * Remove `managed = False` lines if you wish to allow Django to
> create, modify, and delete the table
> > > # Feel free to rename the models, but don't rename db_table values or
> field names.
> > > from django.db import models
> > >
> > >
> > > ... just having the model declarations should not require a migration.
> Haven't checked that myself.
> > >
> > >
> > > On Mon, Dec 18, 2023 at 5:26 PM Mike Dewhirst 
> wrote:
> > >>
> > >> Those many-to-many relations most certainly can have models and all
> of mine always do.
> > >>
> > >> It is more explicit to do so but more importantly they generally
> carry essential real-world information about the relationship itself.
> > >>
> > >> I haven't looked at django-simple history beyond deciding to roll my
> own but it may well cover m2m tables if you add the models explicitly.
> > >>
> > >>
> > >> --
> > >> (Unsigned mail from my phone)
> > >>
> > >>
> > >>
> > >>  Original message 
> > >> From: Larry Martell 
> > >> Date: 19/12/23 08:18 (GMT+10:00)
> > >> To: django-users@googlegroups.com
> > >> Subject: Re: logging admin accesses
> > >>
> > >> django-simple-history is close to what we need. The one issue I see
> > >> (so far) is that it does not support tables that are created behind
> > >> the scenes by django to handle one to many relations that do not have
> > >> models. Does anyone know how to maintain history on those?
> > >>
> > >> On Mon, Dec 18, 2023 at 2:48 PM Larry Martell <
> larry.mart...@gmail.com> wrote:
> > >> >
> > >> > No, I have not see django-simple-history - thanks for the pointer -
> will check it out.
> > >> >
> > >> > On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst <
> mi...@dewhirst.com.au> wrote:
> > >> >>
> > >> >> Just thinking about it again ... you could look at the Admin
> source to see how it is working now and perhaps find a way to include the
> missing info in a pre-save signal.
> > >> >>
> > >> >> Also, I found django-simple-history online but I suppose you have
> seen that already.
> > >> >>
> > >> >> M
> > >> >>
> > >> >> --
> > >> >> (Unsigned mail from my phone)
> > >> >>
> > >> >>
> > >> >>
> > >> >>  Original message 
> > >> >> From: Mike Dewhirst 
> > >> >> Date: 16/12/23 12:38 (GMT+10:00)
> > >> >> To: django-users@googlegroups.com
> > >> >> Subject: Re: logging admin accesses
> > >> >>
> > >> >> You seem to be 

Re: logging admin accesses

2023-12-19 Thread Larry Martell
On Mon, Dec 18, 2023 at 7:23 PM Mike Dewhirst  wrote:
>
> On 19/12/2023 9:51 am, Larry Martell wrote:
>
> Hmmm, in my case I do not see any models for those in any of my models.py 
> files. Where would I expect to find them?
>
>
> You have to write them yourself.

Yeah, thanks. I know I can create them myself. I thought you were
saying they were already created by django.

The best way is to run manage.py inspectdb > models.txt then extract
the m2m models from there. In theory and provided you follow the
advice at the top of the output ...
>
> # This is an auto-generated Django model module.
> # You'll have to do the following manually to clean this up:
> #   * Rearrange models' order
> #   * Make sure each model has one field with primary_key=True
> #   * Make sure each ForeignKey and OneToOneField has `on_delete` set to the 
> desired behavior
> #   * Remove `managed = False` lines if you wish to allow Django to create, 
> modify, and delete the table
> # Feel free to rename the models, but don't rename db_table values or field 
> names.
> from django.db import models
>
>
> ... just having the model declarations should not require a migration. 
> Haven't checked that myself.
>
>
> On Mon, Dec 18, 2023 at 5:26 PM Mike Dewhirst  wrote:
>>
>> Those many-to-many relations most certainly can have models and all of mine 
>> always do.
>>
>> It is more explicit to do so but more importantly they generally carry 
>> essential real-world information about the relationship itself.
>>
>> I haven't looked at django-simple history beyond deciding to roll my own but 
>> it may well cover m2m tables if you add the models explicitly.
>>
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Larry Martell 
>> Date: 19/12/23 08:18 (GMT+10:00)
>> To: django-users@googlegroups.com
>> Subject: Re: logging admin accesses
>>
>> django-simple-history is close to what we need. The one issue I see
>> (so far) is that it does not support tables that are created behind
>> the scenes by django to handle one to many relations that do not have
>> models. Does anyone know how to maintain history on those?
>>
>> On Mon, Dec 18, 2023 at 2:48 PM Larry Martell  
>> wrote:
>> >
>> > No, I have not see django-simple-history - thanks for the pointer - will 
>> > check it out.
>> >
>> > On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst  
>> > wrote:
>> >>
>> >> Just thinking about it again ... you could look at the Admin source to 
>> >> see how it is working now and perhaps find a way to include the missing 
>> >> info in a pre-save signal.
>> >>
>> >> Also, I found django-simple-history online but I suppose you have seen 
>> >> that already.
>> >>
>> >> M
>> >>
>> >> --
>> >> (Unsigned mail from my phone)
>> >>
>> >>
>> >>
>> >>  Original message 
>> >> From: Mike Dewhirst 
>> >> Date: 16/12/23 12:38 (GMT+10:00)
>> >> To: django-users@googlegroups.com
>> >> Subject: Re: logging admin accesses
>> >>
>> >> You seem to be asking for a full history 'system'.
>> >>
>> >> I think the Admin history exists to show a bit of history with a link to 
>> >> go back to the change form where it happened.
>> >>
>> >> Full history needs to be specified fairly carefully so it doesn't bog the 
>> >> system down. For example, every write costs a performance hit. Also, how 
>> >> resilient must it be to cope with database schema changes? How is it 
>> >> going to be used in practice? What are the benefits and are they worth 
>> >> the effort.
>> >>
>> >> I have worked through some of this in my current project and decided to 
>> >> create separate 'mirror' tables for only the critical information and 
>> >> automate data collection for others in a plain text field for archival.
>> >>
>> >> It can be quite open ended and might reward very aggressive specification.
>> >>
>> >> Cheers
>> >>
>> >> Mike
>> >>
>> >>
>> >>
>> >> --
>> >> (Unsigned mail from my phone)
>> >>
>> >>
>> >>
>> >>  Origina

Re: logging admin accesses

2023-12-18 Thread Larry Martell
django-simple-history is close to what we need. The one issue I see
(so far) is that it does not support tables that are created behind
the scenes by django to handle one to many relations that do not have
models. Does anyone know how to maintain history on those?

On Mon, Dec 18, 2023 at 2:48 PM Larry Martell  wrote:
>
> No, I have not see django-simple-history - thanks for the pointer - will 
> check it out.
>
> On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst  wrote:
>>
>> Just thinking about it again ... you could look at the Admin source to see 
>> how it is working now and perhaps find a way to include the missing info in 
>> a pre-save signal.
>>
>> Also, I found django-simple-history online but I suppose you have seen that 
>> already.
>>
>> M
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Mike Dewhirst 
>> Date: 16/12/23 12:38 (GMT+10:00)
>> To: django-users@googlegroups.com
>> Subject: Re: logging admin accesses
>>
>> You seem to be asking for a full history 'system'.
>>
>> I think the Admin history exists to show a bit of history with a link to go 
>> back to the change form where it happened.
>>
>> Full history needs to be specified fairly carefully so it doesn't bog the 
>> system down. For example, every write costs a performance hit. Also, how 
>> resilient must it be to cope with database schema changes? How is it going 
>> to be used in practice? What are the benefits and are they worth the effort.
>>
>> I have worked through some of this in my current project and decided to 
>> create separate 'mirror' tables for only the critical information and 
>> automate data collection for others in a plain text field for archival.
>>
>> It can be quite open ended and might reward very aggressive specification.
>>
>> Cheers
>>
>> Mike
>>
>>
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Larry Martell 
>> Date: 16/12/23 01:47 (GMT+10:00)
>> To: django-users@googlegroups.com
>> Subject: Re: logging admin accesses
>>
>> On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst  wrote:
>>>
>>> Top posting because of phone email client.
>>>
>>> Have you seen the Admin history? Might be already logged for you.
>>
>>
>> Thanks, this is useful, but it does not seem to be logging everything. We 
>> have a custom user admin page that updates a few models in addition to User: 
>> UserInfo, UserExtendProduct, and UserRole. If I add a new user I see this:
>>
>> +---+-+-+-+-+-+
>> | object_id | object_repr | action_flag | change_message 
>>  
>> | content_type_id | user_id |
>> +---+-+-+-+-+-+
>> | 3 | x   |   1 | [{"added": {}}, {"added": {"name": 
>> "user info", "object": "x"}}, {"added": {"name": "user extend product", 
>> "object": "x"}}] |   4 |   1 |
>> +---+-+-+-+-+-+
>>
>> It shows that a row in User, UserInfo, and UserExtendProdct were added, but 
>> it does not show what was added to the latter 2, and it does not show that 
>> rows were added to UserRole.
>>
>> When I modify a user and cause UserRole to be updated I see this:
>>
>> +---+-+-++-+-+
>> | object_id | object_repr | action_flag | change_message | content_type_id | 
>> user_id |
>> +---+-+-++-+-+
>> | 3 | x   |   2 | [] |   4 | 
>>   1 |
>> +---+-+-++-+-+
>>
>> No info about that row 

Re: logging admin accesses

2023-12-18 Thread Larry Martell
No, I have not see django-simple-history - thanks for the pointer - will
check it out.

On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst  wrote:

> Just thinking about it again ... you could look at the Admin source to see
> how it is working now and perhaps find a way to include the missing info in
> a pre-save signal.
>
> Also, I found django-simple-history online but I suppose you have seen
> that already.
>
> M
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Mike Dewhirst 
> Date: 16/12/23 12:38 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: Re: logging admin accesses
>
> You seem to be asking for a full history 'system'.
>
> I think the Admin history exists to show a bit of history with a link to
> go back to the change form where it happened.
>
> Full history needs to be specified fairly carefully so it doesn't bog the
> system down. For example, every write costs a performance hit. Also, how
> resilient must it be to cope with database schema changes? How is it going
> to be used in practice? What are the benefits and are they worth the
> effort.
>
> I have worked through some of this in my current project and decided to
> create separate 'mirror' tables for only the critical information and
> automate data collection for others in a plain text field for archival.
>
> It can be quite open ended and might reward very aggressive specification.
>
> Cheers
>
> Mike
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Larry Martell 
> Date: 16/12/23 01:47 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: Re: logging admin accesses
>
> On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst 
> wrote:
>
>> Top posting because of phone email client.
>>
>> Have you seen the Admin history? Might be already logged for you.
>>
>
> Thanks, this is useful, but it does not seem to be logging everything. We
> have a custom user admin page that updates a few models in addition to
> User: UserInfo, UserExtendProduct, and UserRole. If I add a new user I see
> this:
>
>
> +---+-+-+-+-+-+
> | object_id | object_repr | action_flag | change_message
>
>| content_type_id | user_id |
>
> +---+-+-+-+-+-+
> | 3 | x   |   1 | [{"added": {}}, {"added":
> {"name": "user info", "object": "x"}}, {"added": {"name": "user extend
> product", "object": "x"}}] |   4 |   1 |
>
> +---+-+-+-+-+-+
>
> It shows that a row in User, UserInfo, and UserExtendProdct were
> added, but it does not show what was added to the latter 2, and it does not
> show that rows were added to UserRole.
>
> When I modify a user and cause UserRole to be updated I see this:
>
>
> +---+-+-++-+-+
> | object_id | object_repr | action_flag | change_message | content_type_id
> | user_id |
>
> +---+-+-++-+-+
> | 3 | x   |   2 | [] |   4
> |   1 |
>
> +---+-+-++-+-+
>
> No info about that row being added. If I cause a row in UserRole to be
> deleted I get the exact same entry, so I cannot distinguish between an add
> and a delete and I can't see what was added or deleted.
>
> But if I cause a row in UserInfo or UserExtendProduct to be added I see
> this:
>
>
> +---+-+-+-+-+-+
> | object_id | object_repr | action_flag | change_message
>
>| content_type_id | user_id |
>
> +---+-+-+-+-+-+
> | 3 | x  

Re: logging admin accesses

2023-12-18 Thread Larry Martell
For pages under admin control, yes, we need a full system history. For
other tables what we need is more narrowly defined. I have very clear specs
on what I need to log. ATM performance is not a concern.

On Fri, Dec 15, 2023 at 8:37 PM Mike Dewhirst  wrote:

> You seem to be asking for a full history 'system'.
>
> I think the Admin history exists to show a bit of history with a link to
> go back to the change form where it happened.
>
> Full history needs to be specified fairly carefully so it doesn't bog the
> system down. For example, every write costs a performance hit. Also, how
> resilient must it be to cope with database schema changes? How is it going
> to be used in practice? What are the benefits and are they worth the
> effort.
>
> I have worked through some of this in my current project and decided to
> create separate 'mirror' tables for only the critical information and
> automate data collection for others in a plain text field for archival.
>
> It can be quite open ended and might reward very aggressive specification.
>
> Cheers
>
> Mike
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Larry Martell 
> Date: 16/12/23 01:47 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: Re: logging admin accesses
>
> On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst 
> wrote:
>
>> Top posting because of phone email client.
>>
>> Have you seen the Admin history? Might be already logged for you.
>>
>
> Thanks, this is useful, but it does not seem to be logging everything. We
> have a custom user admin page that updates a few models in addition to
> User: UserInfo, UserExtendProduct, and UserRole. If I add a new user I see
> this:
>
>
> +---+-+-+-+-+-+
> | object_id | object_repr | action_flag | change_message
>
>| content_type_id | user_id |
>
> +---+-+-+-+-+-+
> | 3 | x   |   1 | [{"added": {}}, {"added":
> {"name": "user info", "object": "x"}}, {"added": {"name": "user extend
> product", "object": "x"}}] |   4 |   1 |
>
> +---+-+-+-+-+-+
>
> It shows that a row in User, UserInfo, and UserExtendProdct were
> added, but it does not show what was added to the latter 2, and it does not
> show that rows were added to UserRole.
>
> When I modify a user and cause UserRole to be updated I see this:
>
>
> +---+-+-++-+-+
> | object_id | object_repr | action_flag | change_message | content_type_id
> | user_id |
>
> +---+-+-++-+-+
> | 3 | x   |   2 | [] |   4
> |   1 |
>
> +---+-+-++-+-+
>
> No info about that row being added. If I cause a row in UserRole to be
> deleted I get the exact same entry, so I cannot distinguish between an add
> and a delete and I can't see what was added or deleted.
>
> But if I cause a row in UserInfo or UserExtendProduct to be added I see
> this:
>
>
> +---+-+-+-+-+-+
> | object_id | object_repr | action_flag | change_message
>
>| content_type_id | user_id |
>
> +---+-+-+-+-+-+
> | 3 | x   |   1 | [{"added": {}}, {"added":
> {"name": "user info", "object": "x"}}, {"added": {"name": "user extend
> product", "object": "x"}}] |       4 |   1 |
>
> +---+-+-+--

Re: Help with DRF error

2023-12-16 Thread Larry Martell
On Sat, Dec 16, 2023 at 1:10 PM Reddy Tintaya  wrote:

> Can't you just use
> workitem = serializers.PrimaryKeyRelatedField(
> queryset=WorkItem.objects.all())
> instead of workitem_id?
>

No because workitem_id is what is sent in the request.


>
> On Sat, Dec 16, 2023 at 10:00 AM Larry Martell 
> wrote:
>
>> I have a DRF API. It is throwing an error that I have not been able to
>> fix.
>>
>> Here is my view and serializer:
>>
>> class CreateNotations(CreateAPIView):
>> permission_classes = [IsAuthenticated]
>> serializer_class = NotationListSerializer
>>
>> def post(self, request, *args, **kwargs):
>> return super().post(request, *args, **kwargs)
>>
>> class NotationListSerializer(serializers.Serializer):
>> workitem_id =
>> serializers.PrimaryKeyRelatedField(queryset=WorkItem.objects.all(),
>> source="workitem")
>> notations = NotationSerializer(many=True)
>>
>> def create(self, validated_data):
>> workitem = validated_data["workitem"]
>>
>> IncompleteAnalysis.objects.filter(workitem=workitem).delete()
>>
>> data = []
>> for notation in validated_data["notations"]:
>> data.append({
>> 'workitem': workitem,
>> 'incomplete_analysis_reason': notation["reason"],
>> 'vessel_affected': notation["vessel"],
>> 'user': self.context['request'].user,
>> 'timestamp': datetime.now().isoformat()
>> })
>>
>> return
>> IncompleteAnalysis.objects.bulk_create([IncompleteAnalysis(**d) for d in
>> data])
>>
>> The body of the request received is:
>>
>> {'workitem_id': 244, 'notations': [{'reason_id": 4, 'vessel_id': 6}]}
>>
>> It fails with this:
>>
>> AttributeError: Got AttributeError when attempting to get a value for
>> field `workitem_id` on serializer `NotationListSerializer`.
>> The serializer field might be named incorrectly and not match any
>> attribute or key on the `list` instance.
>> Original exception text was: 'list' object has no attribute 'workitem'.
>>
>> Here is the stack trace:
>>
>> ERRORdjango.request:log.py:241 Internal Server Error: /api/notations/
>> Traceback (most recent call last):
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/fields.py",
>> line 446, in get_attribute
>> return get_attribute(instance, self.source_attrs)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/fields.py",
>> line 96, in get_attribute
>> instance = getattr(instance, attr)
>> AttributeError: 'list' object has no attribute 'workitem'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/django/core/handlers/exception.py",
>> line 56, in inner
>> response = get_response(request)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/django/core/handlers/base.py",
>> line 197, in _get_response
>> response = wrapped_callback(request, *callback_args,
>> **callback_kwargs)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/django/views/decorators/csrf.py",
>> line 55, in wrapped_view
>> return view_func(*args, **kwargs)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/django/views/generic/base.py",
>> line 103, in view
>> return self.dispatch(request, *args, **kwargs)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
>> line 509, in dispatch
>> response = self.handle_exception(exc)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
>> line 469, in handle_exception
>> self.raise_uncaught_exception(exc)
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
>> line 480, in raise_uncaught_exception
>> raise exc
>>   File
>> "/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
>> line 506, in dispatch
>> response = handler(request, *args, **kwargs)
>>   File "/inst/martell/EVServer/app/CAPgraph/createevapi/views.py", line
>> 1270, in

Help with DRF error

2023-12-16 Thread Larry Martell
I have a DRF API. It is throwing an error that I have not been able to fix.

Here is my view and serializer:

class CreateNotations(CreateAPIView):
permission_classes = [IsAuthenticated]
serializer_class = NotationListSerializer

def post(self, request, *args, **kwargs):
return super().post(request, *args, **kwargs)

class NotationListSerializer(serializers.Serializer):
workitem_id =
serializers.PrimaryKeyRelatedField(queryset=WorkItem.objects.all(),
source="workitem")
notations = NotationSerializer(many=True)

def create(self, validated_data):
workitem = validated_data["workitem"]

IncompleteAnalysis.objects.filter(workitem=workitem).delete()

data = []
for notation in validated_data["notations"]:
data.append({
'workitem': workitem,
'incomplete_analysis_reason': notation["reason"],
'vessel_affected': notation["vessel"],
'user': self.context['request'].user,
'timestamp': datetime.now().isoformat()
})

return
IncompleteAnalysis.objects.bulk_create([IncompleteAnalysis(**d) for d in
data])

The body of the request received is:

{'workitem_id': 244, 'notations': [{'reason_id": 4, 'vessel_id': 6}]}

It fails with this:

AttributeError: Got AttributeError when attempting to get a value for field
`workitem_id` on serializer `NotationListSerializer`.
The serializer field might be named incorrectly and not match any attribute
or key on the `list` instance.
Original exception text was: 'list' object has no attribute 'workitem'.

Here is the stack trace:

ERRORdjango.request:log.py:241 Internal Server Error: /api/notations/
Traceback (most recent call last):
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/fields.py",
line 446, in get_attribute
return get_attribute(instance, self.source_attrs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/fields.py",
line 96, in get_attribute
instance = getattr(instance, attr)
AttributeError: 'list' object has no attribute 'workitem'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/django/core/handlers/exception.py",
line 56, in inner
response = get_response(request)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/django/core/handlers/base.py",
line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/django/views/decorators/csrf.py",
line 55, in wrapped_view
return view_func(*args, **kwargs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/django/views/generic/base.py",
line 103, in view
return self.dispatch(request, *args, **kwargs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
line 509, in dispatch
response = self.handle_exception(exc)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
line 469, in handle_exception
self.raise_uncaught_exception(exc)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
line 480, in raise_uncaught_exception
raise exc
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/views.py",
line 506, in dispatch
response = handler(request, *args, **kwargs)
  File "/inst/martell/EVServer/app/CAPgraph/createevapi/views.py", line
1270, in post
return super().post(request, *args, **kwargs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/generics.py",
line 190, in post
return self.create(request, *args, **kwargs)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/mixins.py",
line 20, in create
headers = self.get_success_headers(serializer.data)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/serializers.py",
line 555, in data
ret = super().data
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/serializers.py",
line 253, in data
self._data = self.to_representation(self.instance)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/serializers.py",
line 509, in to_representation
attribute = field.get_attribute(instance)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/relations.py",
line 190, in get_attribute
return super().get_attribute(instance)
  File
"/home/larrymartell/.local/lib/python3.8/site-packages/rest_framework/fields.py",
line 479, in get_attribute
raise type(exc)(msg)
AttributeError: Got AttributeError when attempting to get a value for field
`workitem_id` on serializer `NotationListSerializer`.
The serializer field might be named incorrectly and not match any attribute
or key on the `list` instance.
Original 

Re: logging admin accesses

2023-12-15 Thread Larry Martell
On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst  wrote:

> Top posting because of phone email client.
>
> Have you seen the Admin history? Might be already logged for you.
>

Thanks, this is useful, but it does not seem to be logging everything. We
have a custom user admin page that updates a few models in addition to
User: UserInfo, UserExtendProduct, and UserRole. If I add a new user I see
this:

+---+-+-+-+-+-+
| object_id | object_repr | action_flag | change_message

   | content_type_id | user_id |
+---+-+-+-+-+-+
| 3 | x   |   1 | [{"added": {}}, {"added":
{"name": "user info", "object": "x"}}, {"added": {"name": "user extend
product", "object": "x"}}] |   4 |   1 |
+---+-+-+-+-+-+

It shows that a row in User, UserInfo, and UserExtendProdct were added, but
it does not show what was added to the latter 2, and it does not show that
rows were added to UserRole.

When I modify a user and cause UserRole to be updated I see this:

+---+-+-++-+-+
| object_id | object_repr | action_flag | change_message | content_type_id
| user_id |
+---+-+-++-+-+
| 3 | x   |   2 | [] |   4
|   1 |
+---+-+-++-+-+

No info about that row being added. If I cause a row in UserRole to be
deleted I get the exact same entry, so I cannot distinguish between an add
and a delete and I can't see what was added or deleted.

But if I cause a row in UserInfo or UserExtendProduct to be added I see
this:

+---+-+-+-+-+-+
| object_id | object_repr | action_flag | change_message

   | content_type_id | user_id |
+---+-+-+-+-+-+
| 3 | x   |   1 | [{"added": {}}, {"added":
{"name": "user info", "object": "x"}}, {"added": {"name": "user extend
product", "object": "x"}}] |   4 |   1 |
+---+-+-+-+-+-+

Shows an add, but not what was added.

So my questions are:
-how can I get it to show the details of what was added or changed
-why are updates to UserInfo and UserExtendProduct shown, but updates to
UserRole are not?

Thanks!

 Original message 
> From: Larry Martell 
> Date: 15/12/23 06:44 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: logging admin accesses
>
> Is there a way to capture all admin changes (add, change, delete). I have
> some middleware that gets called on any admin add, change, or delete, but I
> have not figured out a way to capture specifically what was done, something
> like: model, PK, action, e.g.
>
> user, 12, change, first name changed
> user, 15, add
> user, 24, delete
>
> I am looking for something generic that will work for all models under
> admin control
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5Es5WtrMc1-WXTHUix-CyZ7G6bRNx5y1Bsv%3DG4btuAmQ%40mail.gmail.com.


Re: logging admin accesses

2023-12-14 Thread Larry Martell
On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst  wrote:

> Top posting because of phone email client.
>
> Have you seen the Admin history? Might be already logged for you.
>

Is that programically accessible? I want to record it in the database.


>  Original message ----
> From: Larry Martell 
> Date: 15/12/23 06:44 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: logging admin accesses
>
> Is there a way to capture all admin changes (add, change, delete). I have
> some middleware that gets called on any admin add, change, or delete, but I
> have not figured out a way to capture specifically what was done, something
> like: model, PK, action, e.g.
>
> user, 12, change, first name changed
> user, 15, add
> user, 24, delete
>
> I am looking for something generic that will work for all models under
> admin control.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6%3D8Ryo31JcCubHvMFn%2BU0JjDHNbcfvqp7QA2i6xYqGLw%40mail.gmail.com.


logging admin accesses

2023-12-14 Thread Larry Martell
Is there a way to capture all admin changes (add, change, delete). I have
some middleware that gets called on any admin add, change, or delete, but I
have not figured out a way to capture specifically what was done, something
like: model, PK, action, e.g.

user, 12, change, first name changed
user, 15, add
user, 24, delete

I am looking for something generic that will work for all models under
admin control.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5tDc6ZJihTJFmrmus4PG7f_HCXewN-pQr3T-WcMGG4ZA%40mail.gmail.com.


Re: auth_user' doesn't exist

2023-12-02 Thread Larry Martell
On Sat, Dec 2, 2023 at 9:00 AM Nurlanbek Musaev 
wrote:

> hello everyone
> I get an error when I do makemigrations. I tried many things. It didn't
> happen
> django.db.utils.ProgrammingError: (1146, "Table 'prodb1.auth_user' doesn't
> exist")


Have you run the initial migrations that would have created the auth
tables?

>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6-RX-gv2wuHAvFxGOLCbie2EGRRFs5Lnz0fGJ3TQQiHg%40mail.gmail.com.


Re: Management command scheduling options

2023-10-25 Thread Larry Martell
On Wed, Oct 25, 2023 at 5:35 AM Mike Dewhirst  wrote:
>
> Ahmedrufai
>
> I looked at APScheduler and like Celery it is too much of a sledgehammer for 
> my tiny problem.
>
> I ended up using cron to launch the command each day. It works perfectly.
>
> My task now is to find a way to automate establishment of that crontab entry 
> when the project is migrated to a new server.

How are new servers deployed? How many new servers will be deployed?
If it's a one off thing you are doing manually, you just have to
remember to do it. If there are many, then you should use a tool like
terraform or octopus, or something similar and have that 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5xFsBK7Joe4U6-itLv7%2BSrMQ0OyQ1VJ%3DscFvTmepsPbw%40mail.gmail.com.


uwsgi

2023-06-04 Thread Larry Martell
I normally deploy my django apps using nginx and uwsgi. I recently
found that the uwsgi mailing list is defunct, and I read this on the
uwsgi github page:

Note: The project is in maintenance mode (only bugfixes and updates
for new languages apis). Do not expect quick answers on github issues.

Are folks still deploying new apps with uwsgi, or have people switched
to Gunicorn or something else?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4h8Jc4_Cd7Vf2w-8ExjfUnu0W2i-GknCuxOznk6V_V3A%40mail.gmail.com.


Connection reset by peer on file upload if JWT expires

2023-06-02 Thread Larry Martell
We have a django app and it supports a file upload request. The entire
upload comprises multiple requests. We are authenticating with JWT and
we have logic to handle a 401 and in that case use the refresh token
to get a new access token and resend the failed request. However if
the token expires between 2 requests of the same upload the 401
response never makes it to the client. In the logs I found that before
nginx gets the response we get this error:

2023/06/02 16:23:11 [error] 1924925#1924925: *75 readv() failed (104:
Connection reset by peer) while reading upstream, client: xx.xx.xx.xx,
server: foo.com, request: "POST /api/upload/ HTTP/1.1", upstream:
"uwsgi://unix:///bar/foo/our_app/app.sock:", host: "foo.com",
referrer: "http://foo.com:8082/;

This causes the client to get an empty response body and the browser
throws a ERR_CONTENT_LENGTH_MISMATCH error. The entire upload takes
under 10 minutes and we have all the timeouts set to 100 minutes:

uwsgi_read_timeout 6000;
uwsgi_connect_timeout 6000;
uwsgi_send_timeout 6000;
send_timeout 6000;
proxy_read_timeout 6000;
proxy_send_timeout 6000;

What is causing the socket to get closed? How can I prevent that? Are
there other timeouts I could set? Any logging that I can enable to see
why the socket is getting closed? Is there a way to detect this in
code so it can be retried?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6ShL02Hhnfbc-uGTsMdKBNV8ij6kom7n9hJndwpRQGwg%40mail.gmail.com.


Re: Django date time picker

2023-05-29 Thread Larry Martell
On Mon, May 29, 2023 at 1:14 PM Thomas Mutavi  wrote:
>
> Hello, how  can i implement a form with several date fields which have date 
> and time picker in django?

You can use the jQuery UI datetimepicker.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY72xpH90NiaJMQCWeziz%3DqPZcnDPZewBVt3BHMSjVcowQ%40mail.gmail.com.


Re: Unable to write to database

2023-05-22 Thread Larry Martell
On Sun, May 21, 2023 at 10:54 AM William Nash (Bill)  wrote:
>
> I'm new to django and I'm trying to learn as I program a small website for my 
> scuba diving business.   I'm running into a error that when I try to add a 
> diver the database does not update.  When I goto 
> http://localhost:8000/add_diver/add_diver/  I'm able to add a diver.

This is confusing - you said you get an error when you try and add a
diver to the database but when you goto
http://localhost:8000/add_diver/add_diver/ it works. In the case where
you get an error, how are you adding it? Please post your code and
tell us what the error you get is.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7%3DcadzuWCt_7aRhmBYO2ZuAzPBbDjatLaCKVNM6xSS7g%40mail.gmail.com.


List validator

2023-02-27 Thread Larry Martell
I have this defined in my serializer:

case_status = serializers.ListField(
child=serializers.CharField(
allow_blank=True,
max_length=512,
allow_null=True,
required=False,
default="''",
),
source='casestatus',
required=False,
allow_empty=True,
)

When this data is received:

(Pdb) request.data


The casestatus field is not picked up:

(Pdb) serializer.validated_data
OrderedDict([('patientid', 0), ('pk', 0), ('patientname', "''"),
('dobstart', "''"), ('dobend', "''"), ('scanstart', "''"), ('scanend',
"''"), ('workitemstr', "''"), ('institutionid', 0), ('page_size', 10),
('sortByDateCreated', 'true')])

Can anyone see what I am doing wrong here?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6-wEO-vVDn_mhb8t0-w2C5vXyw-08EeuUeiAPmMK_oqw%40mail.gmail.com.


Re: Server Error 500 Nginx when DEBUG=False

2023-01-29 Thread Larry Martell
On Sun, Jan 29, 2023 at 9:14 AM ALBERT ASHABA AHEEBWA <
ashabaaheebwaalb...@gmail.com> wrote:

> So I was able to successfully host my first ever Django app on linode.
> After the excitement had won off, I started testing the routes, everything
> was running fine except for two routes.
>
> SERVER ERROR (500)
>
> These two views are sharing a template and I much doubt that is the cause.
> Since they are pointing to different routes.
>
> There's nothing in the /var/log/nginx/error.log file that is helpful.
>
> Everything is working as expected when DEBUG=True.
>
> Please help point me in the right direction.
>

Check the uwsgi and Django logs. Also you can try using runserver and
seeing if any errors are shown there. If that does not yield anything
useful, set a breakpoint and step through the code until you find where the
error is coming from.

>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6n_2CgcScNXtR8TwH_r8r2hMM6otQoVX8Or%2BkfsW617A%40mail.gmail.com.


filtering queryset in CreateAPIView view

2022-12-28 Thread Larry Martell
I have a CreateAPIView view with this code in the serializer:

class AssignWorkItemSerializer(serializers.Serializer, WorkitemSerializerMixin):
assigneeIds = serializers.ListSerializer(
child=serializers.PrimaryKeyRelatedField(

queryset=get_user_model().objects.filter(userrole__role__name='analyst')
),
source='assignees'
)

This is failing because that query returns multiple rows. I want to
filter that queryset at run time by something that is available to me
in the request. Is there a way to do that?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY46gZEjH9YNajSx%2B2uSSzozC7S_up9KY%3DB655p4zFL-Yg%40mail.gmail.com.


Re: getting unique id

2022-11-28 Thread Larry Martell
On Wed, Nov 23, 2022 at 3:11 PM Larry Martell  wrote:
>
> On Wed, Nov 23, 2022 at 3:01 PM Thomas Lockhart  
> wrote:
> >
> > Why not use the existing Django AutoField?
>
> Because I have multiple rows with the same batch_id, and also I would
> like the batch_ids to be sequential.
>
> The use case is a batch job dashboard. Users run jobs that spawn many
> sub jobs. The jobs all record their status in the JobStatus table. The
> batch dashboard shows all the sub jobs grouped under their parent job.
> The parent job creates a row with a new batch_id, and that is passed
> to the sub jobs. They all record their status using that same batch
> id, but each in its own row.
>
> > > On Nov 23, 2022, at 8:56 AM, Larry Martell  
> > > wrote:
> > >
> > > I have an app that needs to get a unique ID. Many threads run at the
> > > same time that need one. I would like the IDs to be sequential. When I
> > > need a unique ID I do this:
> > >
> > > with transaction.atomic():
> > >max_batch_id =
> > > JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
> > >json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
> > >status_row = JobStatus(**json_dict)
> > >status_row.save()
> > >
> > > But multiple jobs are getting the same ID. Why does the code not work
> > > as I expect? What is a better way to accomplish what I need?

I ended up using another table to get the batch_ids from. It works,
but I still wonder how to make it work without a second table.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY57mQ%2Bp19gPf21AuhwXi66yatSY10gdSWuGk9s5XZx-HQ%40mail.gmail.com.


Re: AttributeError: module 'django.db.models' has no attribute 'PointField'

2022-11-27 Thread Larry Martell
On Sun, Nov 27, 2022 at 2:40 PM Ilyas Modni  wrote:
>
> AttributeError: module 'django.db.models' has no attribute 'PointField'

Are you importing:

from django.contrib.gis.db import models

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6VyNv5RdQ5UbA2N2j9W2OKN0B0vg0gjS_kuphmAmd8xg%40mail.gmail.com.


Re: getting unique id

2022-11-23 Thread Larry Martell
On Wed, Nov 23, 2022 at 3:01 PM Thomas Lockhart  wrote:
>
> Why not use the existing Django AutoField?

Because I have multiple rows with the same batch_id, and also I would
like the batch_ids to be sequential.

The use case is a batch job dashboard. Users run jobs that spawn many
sub jobs. The jobs all record their status in the JobStatus table. The
batch dashboard shows all the sub jobs grouped under their parent job.
The parent job creates a row with a new batch_id, and that is passed
to the sub jobs. They all record their status using that same batch
id, but each in its own row.

> > On Nov 23, 2022, at 8:56 AM, Larry Martell  wrote:
> >
> > I have an app that needs to get a unique ID. Many threads run at the
> > same time that need one. I would like the IDs to be sequential. When I
> > need a unique ID I do this:
> >
> > with transaction.atomic():
> >max_batch_id =
> > JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
> >json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
> >status_row = JobStatus(**json_dict)
> >status_row.save()
> >
> > But multiple jobs are getting the same ID. Why does the code not work
> > as I expect? What is a better way to accomplish what I need?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY547umxs6E34c4sO7DqSLA1vuOf%2B7FsJDJOGVsR8SmZqw%40mail.gmail.com.


Re: getting unique id

2022-11-23 Thread Larry Martell
On Wed, Nov 23, 2022 at 1:43 PM Shaheed Haque  wrote:
>
> Are all the threads in the same Python process?

No

> Or the same machine?

No

> Do they have to persist across process (or machine) restarts?

Yes.

Playing around with using F() but still don't have it working as desired.

> On Wed, 23 Nov 2022, 16:57 Larry Martell,  wrote:
>>
>> I have an app that needs to get a unique ID. Many threads run at the
>> same time that need one. I would like the IDs to be sequential. When I
>> need a unique ID I do this:
>>
>> with transaction.atomic():
>> max_batch_id =
>> JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
>> json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
>> status_row = JobStatus(**json_dict)
>> status_row.save()
>>
>> But multiple jobs are getting the same ID. Why does the code not work
>> as I expect? What is a better way to accomplish what I need?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7A_zk%3DxJ3vg8csCSFPamkjtzm6fRGbzNjru1e2aJfa3A%40mail.gmail.com.


getting unique id

2022-11-23 Thread Larry Martell
I have an app that needs to get a unique ID. Many threads run at the
same time that need one. I would like the IDs to be sequential. When I
need a unique ID I do this:

with transaction.atomic():
max_batch_id =
JobStatus.objects.select_for_update(nowait=False).aggregate(Max('batch_id'))
json_dict['batch_id'] = max_batch_id['batch_id__max'] + 1
status_row = JobStatus(**json_dict)
status_row.save()

But multiple jobs are getting the same ID. Why does the code not work
as I expect? What is a better way to accomplish what I need?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY54vF6ZK7yy--15hy1u5vxJ%2Bq9Zp_ODGfAX973gPYpecw%40mail.gmail.com.


Lost connection to MySQL server during query

2022-06-17 Thread Larry Martell
I have a standalone python script (i.e. not part of a web app) that
makes use of the ORM. I call djago.setup(), make some queries, then
call a function that can take 8 hours or more to run. When the
function returns I want to make more queries, but they fail with 'Lost
connection to MySQL server during query'. My DB wait_timeout is set to
8 hours and if the function returns in less than 8 hours I don't get
the error, so I thought I understood what was going on.

But then I read about CONN_MAX_AGE which we do not set. If that is not
set it should default to 0, which should mean that it gets a new
connection for each request so we should not get the Lost connection
message. Does that not work when using djago.setup()?

Further reading I saw said to call close_old_connections() or
connection.close() before calling the long running function. What is
the difference between these 2 and is one a better practice than the
other?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4tBWRsLBW5URC%3DNcBgmuFhMaSxTO_y1rGf8HUD80B3Rw%40mail.gmail.com.


Re: variable inside a template

2022-06-16 Thread Larry Martell
On Thu, Jun 16, 2022 at 4:09 AM luca72.b...@gmail.com
 wrote:
>
> Hello i have a list like:
> mylist =  ['1,png','2.png',3.jpj']
> in the template i do as follow:
> {% for o in mylist %}
> 
> {% if "png" in o %}
> {{ o }}
> 
> {% else %}
> {{o}}
> 
> {% endif %}
> {% endfor %}
> in the template i see the file name but it never render, if i loock the 
> source code i see that in the   class="">
> So i never get the correct file name.
> How is the correct way to get the name of the variable o inside the img tag
> Thanks

mylist has 1,png not 1.png
   ^
Could that be the issue?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7j%2BRAqTN15MLtAch3f2JbC8-h_nL3o1rE0%2Br06THLm8Q%40mail.gmail.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 2:53 PM cseb...@gmail.com  wrote:
>
> The script should quietly exist without error.
>
> I actually have a longer script that is the real workhorse.
> I just made this tiny one to showcase the issue.
>
> I can past
>
> import datetime ; [datetime for e in [1, 2]]
>
> into a regular Python3 shell as well as the Django shell and all is fine.

$ python3
Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime ; [datetime for e in [1, 2]]
[,
]

It does not do anything.

>
> The problem I think has something to do with how I inject
> it into the Django shell via "< test".
>
> cs
> On Thursday, April 21, 2022 at 12:18:04 PM UTC-5 larry.mart...@gmail.com 
> wrote:
>>
>> On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>> >
>> > Why does this fail?...
>> >
>> > % echo "import datetime ; [datetime for e in [1, 2]]" > test
>> >
>> > % ./manage.py shell < test
>> >
>> > Traceback (most recent call last):
>> > File "./manage.py", line 8, in 
>> > django.core.management.execute_from_command_line(sys.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 381, in execute_from_command_line
>> > utility.execute()
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 375, in execute
>> > self.fetch_command(subcommand).run_from_argv(self.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 323, in run_from_argv
>> > self.execute(*args, **cmd_options)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 364, in execute
>> > output = self.handle(*args, **options)
>> > File 
>> > "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
>> > line 92, in handle
>> > exec(sys.stdin.read())
>> > File "", line 1, in 
>> > File "", line 1, in 
>> > NameError: name 'datetime' is not defined
>>
>> What do you expect to happen?
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/c4a36ffb-8c7a-477f-9d26-f6b898178d91n%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43-xRez5dXzhQ0RxU3BVp1Dx8YARKRr7V9f1hyJSHfuA%40mail.gmail.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>
> Why does this fail?...
>
> % echo "import datetime ; [datetime for e in [1, 2]]" > test
>
> % ./manage.py shell < test
>
> Traceback (most recent call last):
>   File "./manage.py", line 8, in 
> django.core.management.execute_from_command_line(sys.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 381, in execute_from_command_line
> utility.execute()
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 364, in execute
> output = self.handle(*args, **options)
>   File 
> "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
> line 92, in handle
> exec(sys.stdin.read())
>   File "", line 1, in 
>   File "", line 1, in 
> NameError: name 'datetime' is not defined

What do you expect to happen?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4%3D5kn5_ka%3DvDxXyt5P8cNWvEmHHg2%2BtWTUzNcRSWcHhg%40mail.gmail.com.


Re: How to protect Python Source Code

2021-02-25 Thread Larry Martell
On Thu, Feb 25, 2021 at 11:10 AM Kommula Kavitha
 wrote:
>
> Hi Team,
>
> We have application developed using Python. Want to know how to protect 
> source code?

There is pyinstaller (http://www.pyinstaller.org/). I tried to use it
4 or 5 years ago and it could not handle all the dependencies I had. I
have heard it's gotten better, but have not tried it since.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6CLirsB9hzZmOvMqb-o6pYbPNWhCUJuBnsd3hoB7nzCg%40mail.gmail.com.


Re: Django Microsoft Authentication Backend not succeeding on new deployments

2021-01-29 Thread Larry Martell
On Sat, Jan 23, 2021 at 7:41 PM Ryan Nowakowski  wrote:
>
> On Sat, Jan 23, 2021 at 11:05:14AM -0800, Larry Martell wrote:
> > On Sat, Jan 23, 2021 at 8:14 AM Ryan Nowakowski  wrote:
> > >
> > > A couple of places to look:
> > >
> > > 1. Different domains on the new boxes? You'll need to add the new 
> > > callback urls on the Microsoft side.
> > > 2. Different version of Python on the new boxes?
> >
> > Same domain name, same version of python and all python packages.
> > There are some minor revision differences in a bunch of OS level
> > packages. Could that be a factor?
> >
>
> Did you create your virtualenv with --system-site-packages?  If not then
> I don't think the OS packages will be a factor.

We finally found the issue - I said we had the same version of all the
python packages but we did not - the new system had 2.0.1 version of
pyjwt. When we downgraded to 1.7.1 it started working again. The
requirements file for Django Microsoft Authentication Backend have
pyjwt [required: Any]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4d_%3D3Q660gF%3DtrcAQmj7bkG%2BMnXaYf%3DgCt8WH0UnCkjg%40mail.gmail.com.


Re: Static Folder not loading

2021-01-28 Thread Larry Martell
On Thu, Jan 28, 2021 at 10:16 AM hari49pf  wrote:
>
> Hi,
>
> I am trying to load static file to my project its not loading,
> I have changed the path of static in settting.py still its not loading static 
> file.
> tryed to check the file is loading by using
> manage.py findstatic test.css
> PLZ help

Have you run collectstatic?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6m3eTzG_wBrTCUYXE2aYNEWzM6gt-R1Dj31XDtH8opKA%40mail.gmail.com.


Re: How can I use my Company SSO(Single sign On ) for login into my django application ??

2021-01-27 Thread Larry Martell
On Wed, Jan 27, 2021 at 6:02 AM Kumar Gaurav  wrote:
>
> Hii ,
>
> My users come to my django application after authenticated from company SSO.
> Now , I don't want to create my own authentication model. I just want to 
> login the users who come to my page from the requests storing the details.
>
> Anyone know how to implement this ?? I am stuck on it from last week .

What is your company's SSO? Azure? If so you could use
https://pypi.org/project/django-microsoft-auth/

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43u1r_L8yHLO17xQUgQBEpSzYpNoqUzPDHwg3VLOkB7A%40mail.gmail.com.


Re: Django Microsoft Authentication Backend not succeeding on new deployments

2021-01-23 Thread Larry Martell
On Sat, Jan 23, 2021 at 8:14 AM Ryan Nowakowski  wrote:
>
> A couple of places to look:
>
> 1. Different domains on the new boxes? You'll need to add the new callback 
> urls on the Microsoft side.
> 2. Different version of Python on the new boxes?

Same domain name, same version of python and all python packages.
There are some minor revision differences in a bunch of OS level
packages. Could that be a factor?

>
> On January 22, 2021 2:51:30 PM CST, Larry Martell  
> wrote:
>>
>> I have an app deployed in many places and it uses Django Microsoft 
>> Authentication Backend. Starting yesterday when we deploy the app the auth 
>> is now not working. We get back Failed to authenticate you for an unknown 
>> reason. Please try again later. We can see in the azure logs that the login 
>> was successful. We have the same version of Django Microsoft Authentication 
>> Backend installed, but for some reason on newly built boxes it is failing 
>> but older ones it is succeeding. What could be causing this? What can we 
>> check to track down what the issue may be?
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/963BCE7D-841C-4433-9081-55906AE11F31%40fattuba.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6A-tBxEVFWLp5TWju2BgZPtp_vh0bVKJ1aCtJENEOWiw%40mail.gmail.com.


Django Microsoft Authentication Backend not succeeding on new deployments

2021-01-22 Thread Larry Martell
I have an app deployed in many places and it uses Django Microsoft
Authentication Backend. Starting yesterday when we deploy the app the auth
is now not working. We get back Failed to authenticate you for an unknown
reason. Please try again later. We can see in the azure logs that the login
was successful. We have the same version of Django Microsoft Authentication
Backend installed, but for some reason on newly built boxes it is failing
but older ones it is succeeding. What could be causing this? What can we
check to track down what the issue may be?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7LB6ZUHfCDYRZJVHquFp1ZcMajUggCNWASLHLkwT2q_w%40mail.gmail.com.


Re: Admin help class CSS

2020-12-11 Thread Larry Martell
If you have a pure CSS question, this list can be very helpful:

https://www.css-discuss.org/mailman/listinfo/css-d/

On Fri, Dec 11, 2020 at 4:56 PM Mike Dewhirst  wrote:
>
> Joash
>
> By all means. If I wasn't entirely clear, I am using html inside model.field 
> help_text - which works nicely in the Admin for  and  and the 
> like.
>
> The mission is to design  CSS styling to reduce padding and remove cell 
> boundaries and adjust colours. I need to offer sophisticated styled "help" 
> for decision support for users.
>
> I can adjust normal help_text font styling in the Admin by inserting my own 
> css stylesheet which appears after all the Django stylesheets except 
> responsive.css.
>
> My real problem is CSS brainspace.
>
> Thanks for any ideas
>
> Cheers
>
> Mike
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Joash Monda 
> Date: 12/12/20 02:35 (GMT+10:00)
> To: django-users@googlegroups.com
> Subject: Re: Admin help class CSS
>
> Can we work together Sir.
>
> On Fri, Dec 11, 2020, 17:57 Joash Monda  wrote:
>>
>> Hello mike got your problem...
>>
>> On Fri, Dec 11, 2020, 05:35 Mike Dewhirst  wrote:
>>>
>>> I'm a CSS dunce so please point me in the right direction (docs or
>>> whatever) to figure out how to adjust table layout in Admin help_text.
>>>
>>> The table displays properly but is too greedy with screen real-estate. I
>>> want to reduce table padding and cell separation. I copied the following
>>> from the view source page and is what I want to tweak with CSS ...
>>>
>>> 
>>> Blah blah ... the following:
>>> 
>>> aluminiumbromine
>>> zirconium
>>> 
>>> 
>>>
>>> There are actually a few more rows between bromine and zirconium but I
>>> chopped them for brevity.
>>>
>>> Thanks
>>>
>>> Mike

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6Ro4yxE1R1HkY_Ym4Pro5OMY4RhCOdhQM_ftjCgu-d8A%40mail.gmail.com.


Re: forloop.counter

2020-10-15 Thread Larry Martell
On Thu, Oct 15, 2020 at 7:32 AM luca72.b...@gmail.com
 wrote:
>
> i have this :
>  {% if forloop.counter < {{ variable }} %}
> i have this error:
>
> Could not parse the remainder: '{{' from '{{'
>
> how i can solve it?

You don't need {{ }} inside of a {% %}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6NE7muV0oSnpUgAVA0sSfQnmp_i_cSb5DddwMGxbKe0Q%40mail.gmail.com.


Re: CSS problems

2020-09-16 Thread Larry Martell
On Wed, Sep 16, 2020 at 10:04 AM ‫אורי‬‎  wrote:‬
>
> Hi,
>
> My website, https://en.speedy.net/, the date of birth input is bordered red 
> with Firefox, and I can't find why the border is red? I checked and there is 
> nothing red in the CSS and it's not red with Chrome or Edge. Any idea why the 
> border is red and how do I cancel the red border?

Looks like that is because it's a required field:

https://www.google.com/search?client=firefox-b-1-d=firefox+datepciker+field+border+red

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5roKpz9zg-V56Rm9hAMnd4rf9-qp5qortDEB2JGB4BZw%40mail.gmail.com.


Re: Django dynamic time settings in DB

2020-07-26 Thread Larry Martell
On Sun, Jul 26, 2020 at 1:50 PM adiath...@gmail.com
 wrote:
>
> How can you continuously update your DB time field in django without post 
> request.

Use websockets and channels.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4jm_U-GCGPB%3D%3DE5-2EEff9Je_77%2BFCS%3DM-RahguQ0DhA%40mail.gmail.com.


Re: Invalid syntax on line 16 of manage.py

2020-07-20 Thread Larry Martell
On Mon, Jul 20, 2020 at 5:57 AM Douglas Ii  wrote:
>
> While following the tutorial for creating your first Django app, I run into a 
> problem when entering the command line "python manage.py runserver" into my 
> terminal. I am using a mac and I get the Error message:
>
>
> File "manage.py", line 16
>
> ) from exc
>
>  ^
>
> SyntaxError: invalid syntax
>
>
> What can I do to resolve this issue

What version of python do you have? What version of django? How did
you install django?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5SmqQB4dPgfCRHEtO_mRHzK-MoDnKy4Y1Xw9EYgxfZ-Q%40mail.gmail.com.


Re: how to fetch data into a template (table)

2020-06-22 Thread Larry Martell
On Sat, Jun 20, 2020 at 11:41 AM Faith Mwai  wrote:
>
> Am having a challenge of displaying data into my template table, the function 
> is;
>
> def customers(request):
> if request.method == 'POST':
> accountno = request.POST['accountno']
> id= request.POST['id']
> Mobilenumber = request.POST['Mobilenumber']
> cursor = con.cursor()
> querystring = ("Select Messages, amount, date from Accounts where 
> accountno = 'accountno' or Mobilenumber = 'Mobilenumber' ")
>
> cursor.execute(querystring)
>
> rows = cursor.fetchall()
> context = {'querystring': querystring}
> con.close()
> if cursor.rowcount == 0:
> return render(request,'kplcapp/customers.html', context)
> else:
> rows = cursor.fetchall()
> return render('kplcapp/customers.html', context)
> return render(request, 'kplcapp/customers.html', context)
>
> if 'print' in request.form:
> df = pd.DataFrame(result)
> df.to_excel(r"C:\Users\Public\Documents\data3.xlsx")
> else:
> return render(request, 'kplcapp/customers.html', context)

Why are you using raw SQL for such a simple query. In any case you
need to replace the strings with the variables.

 querystring = ("Select Messages, amount, date from Accounts where
accountno = '%s' or Mobilenumber = '%s' " % (accountno, Mobilenumber))

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY76PTax6MrD3zL99NJEB%3DSnnoP5izVJczQxFqBbKhbWaw%40mail.gmail.com.


Re: urgent

2020-06-19 Thread Larry Martell
On Fri, Jun 19, 2020 at 2:32 PM Awais Ahmad  wrote:
>
> i'm facing this problem and i can't fix it any body please help me or tell me 
> about this error

It should be static not staticfiles.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY41VTcOOjuMRwb0Jmg9jcnD6b6FefL98689CGubO6yuPw%40mail.gmail.com.


Re: Django IIS windows

2020-06-04 Thread Larry Martell
On Thu, Jun 4, 2020 at 10:05 PM Giovanni Silva  wrote:

> Hello.
>
> I need help to set up my Django Project in my IIS server.
>
> Does anyone has a tutorial or a link to help me to configure it?
>

I did this once and it was incredibly painful. If there is any way you can
deploy on Linux do so. It will improve your quality of life immeasurably.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5p7wFtmKZ%2BE4Tmmsf9bDdPh86QHFKQaEOLtG0yGt%3D-jA%40mail.gmail.com.


Re: Please help me out?

2020-05-31 Thread Larry Martell
On Sat, May 30, 2020 at 11:30 PM meera gangani  wrote:
>
>  I want to generate trello-board in my django application
> Can anyone tell me the How to do this?
> Trello-board is like( to-do and future enhancements and doing ) where there 
> are 3-4 columns

Take a look at https://github.com/riktar/jkanban

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4HUJmo4rEMMgRereAg9n6Dz75bsPLb3UFUuPAbsKj9CA%40mail.gmail.com.


Re: How to display pie chart using Django

2020-05-07 Thread Larry Martell
On Thu, May 7, 2020 at 6:39 AM ratnadeep ray  wrote:
>
> Hi all,
>
> I just started to work on Django and hence have limited knowledge about it.
>
> Now I need to design an app to display a pie chart based on some sample data. 
> Can anybody please help me to do so? Is there any sample app existing which 
> fulfills this requirement ?

You need to choose a charting package, such as google charts or
plotly, then in your python code get the data you want to chart and
pass it to your template and in the template write some javascript
code to render the chart. Googling django pie chart should give you
examples.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4kL4gb8feawyTQcpMskU3HbP7c%2B4%2BFdkoUCtk6bhMZXA%40mail.gmail.com.


Re: Watch "Ever Thought How This Games Like PUBG | CALL OF DUTY | Are developed" on YouTube

2020-05-02 Thread Larry Martell
On Sat, May 2, 2020 at 11:30 AM Kasper Laudrup  wrote:
>
> Hi Raj,
>
> On 02/05/2020 14.10, Anonymous Patel wrote:
> > https://youtu.be/kkNXbVFiqjc
> >
>
> How is this in any way related to Django?

This guy has spammed many many groups with this same posting.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6px5xpUb4E5bj0K53J%2BVM5JTV2dq9-APE%2BjAFgpCNiRg%40mail.gmail.com.


django_microsoft_auth

2020-04-20 Thread Larry Martell
Anyone here have any experience with django_microsoft_auth? I have
some issues and questions.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY57qAu_pwAayC3RPzXDWvp0Wto_TGnCS5VETaVmPAZA8g%40mail.gmail.com.


Azure AD SSO from django

2020-03-04 Thread Larry Martell
I would the users of my django app to be able to use SSO using their Azure
AD creds. To me SSO means if they have already logged in to something using
their ADA creds then when they go to my django app they get in
without having to enter any creds. I found a few packages that support
logging in with ADA creds, but the users still have to enter them. Are they
any full ADA SSO packages?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4uXQUUL%3D%3DMrFVQJO5QhjFcomJbnERzpFHth09QQvPCQw%40mail.gmail.com.


Re: Channels, daphne, and asgiref, oh my!

2020-02-24 Thread Larry Martell
When I was using uwsgi, here was my nginx file:

upstream django {

# server unix:/run/uwsgi/devAppReporting.sock;

}


server {

listen 8090;

server_name foo.bar.com;

charset utf-8;


location /static {

alias /var/dev-app-reporting/static;

}


location / {

   uwsgi_pass django;

   include /var/dev-app-reporting/uwsgi_params;

   uwsgi_read_timeout 3600;

   client_max_body_size 50m;

}

}


Now I changed it to this:


upstream django {

server unix:/run/daphne/devAppReporting.sock;

}


server {

listen 8090;

server_name foo.bar.com;

charset utf-8;


location /static {

alias /var/dev-app-reporting/static;

}


location / {

proxy_pass http://0.0.0.0:8090;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";


proxy_redirect off;

proxy_set_header   Host $host;

proxy_set_header   X-Real-IP $remote_addr;

proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header   X-Forwarded-Host $server_name;

}

}


Started daphne like this:


daphne -u /run/daphne/devAppReporting.sock app.dse.asgi:application


I get a 502 bad gateway error and this in the log:


2020/02/24 22:17:26 [alert] 29169#29169: 768 worker_connections are not
enough

2020/02/24 22:17:26 [error] 29169#29169: *131545 recv() failed (104:
Connection reset by peer) while reading response header from upstream,
client: 127.0.0.1, server:
dse-portfolio-dev-assessments.md.virtualclarity.com, request: "GET /
HTTP/1.1", upstream: "http://0.0.0.0:8090/;, host: "xx.xx.xx.xx"


Any ideas on what I should have in my config file for this to work?

On Mon, Feb 24, 2020 at 4:19 PM Larry Martell 
wrote:

> Thanks Andrew. Upgrading to py 3.7 did the trick. Now struggling to
> get daphne working with nginx and TLS. Can't seem to get a nginx
> config file that works for me.
>
> On Fri, Feb 21, 2020 at 10:50 PM Andrew Godwin 
> wrote:
> >
> > Hi Larry,
> >
> > Your problem is the Python version - 3.5 is somewhat old (but most
> importantly, was still a very rough release for asyncio) and isn't
> supported by any current release of asgiref/channels for that reason. If
> you are able to upgrade that, I very much recommend it.
> >
> > Andrew
> >
> > On Sat, Feb 22, 2020 at 2:52 AM Aldian Fazrihady 
> wrote:
> >>
> >> I have these working module combinations, but my Python is 3.6.9:
> >> asgiref==2.2.0
> >> channels==2.0.2
> >> channels_redis==2.3.0
> >> daphne==2.1.0
> >> Django==2.2.4
> >> django-redis==4.10.0
> >> redis==3.3.6
> >> Twisted[tls,http2]
> >> uwsgi==2.0.18
> >> websockets==6.0
> >>
> >> On Sat, Feb 22, 2020 at 3:25 AM Larry Martell 
> wrote:
> >>>
> >>> I am in a bit of version hell. Not fun on a Friday afternoon.
> >>>
> >>> Django 2.0.4, python 3.5.2
> >>>
> >>> Trying to get channels, websockets, daphne, and asgiref working.
> >>>
> >>> When I installed the latest channels it did not work with my version
> >>> of mysqlclient and some googling led me to install 2.0 of channels.
> >>> That worked fine with the dev server, and then I wanted to deploy my
> >>> app in prod. In prod we use nginx/uwsgi so I was going to replace
> >>> uwsgi with daphne. When I tried to run daphne I got:
> >>>
> >>> ImportError: No module named 'asgiref.compatibility'
> >>>
> >>> Googling that I was led to upgrade asgiref to the latest version.
> >>> After I did that I got:
> >>>
> >>> AttributeError: module 'asyncio.coroutines' has no attribute
> '_is_coroutine'
> >>>
> >>> Have not been able to get past this one.
> >>>
> >>> Anyone have any thoughts? Would upgrading django and python fix these
> >>> issues? I am planning on doing that soon, but I was not planning on
> >>> doing that now. Don't want to upgrade now and then find I still have
> >>> issues. Can I get all this to work with my current versions and
> >>> upgrade later?
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43bVM0QEbniN3nzdRppM0ABo%3DOWFS5O5v0XX0YUh5Wcg%40mail.gmail.com.


Re: Channels, daphne, and asgiref, oh my!

2020-02-24 Thread Larry Martell
Thanks Andrew. Upgrading to py 3.7 did the trick. Now struggling to
get daphne working with nginx and TLS. Can't seem to get a nginx
config file that works for me.

On Fri, Feb 21, 2020 at 10:50 PM Andrew Godwin  wrote:
>
> Hi Larry,
>
> Your problem is the Python version - 3.5 is somewhat old (but most 
> importantly, was still a very rough release for asyncio) and isn't supported 
> by any current release of asgiref/channels for that reason. If you are able 
> to upgrade that, I very much recommend it.
>
> Andrew
>
> On Sat, Feb 22, 2020 at 2:52 AM Aldian Fazrihady  wrote:
>>
>> I have these working module combinations, but my Python is 3.6.9:
>> asgiref==2.2.0
>> channels==2.0.2
>> channels_redis==2.3.0
>> daphne==2.1.0
>> Django==2.2.4
>> django-redis==4.10.0
>> redis==3.3.6
>> Twisted[tls,http2]
>> uwsgi==2.0.18
>> websockets==6.0
>>
>> On Sat, Feb 22, 2020 at 3:25 AM Larry Martell  
>> wrote:
>>>
>>> I am in a bit of version hell. Not fun on a Friday afternoon.
>>>
>>> Django 2.0.4, python 3.5.2
>>>
>>> Trying to get channels, websockets, daphne, and asgiref working.
>>>
>>> When I installed the latest channels it did not work with my version
>>> of mysqlclient and some googling led me to install 2.0 of channels.
>>> That worked fine with the dev server, and then I wanted to deploy my
>>> app in prod. In prod we use nginx/uwsgi so I was going to replace
>>> uwsgi with daphne. When I tried to run daphne I got:
>>>
>>> ImportError: No module named 'asgiref.compatibility'
>>>
>>> Googling that I was led to upgrade asgiref to the latest version.
>>> After I did that I got:
>>>
>>> AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'
>>>
>>> Have not been able to get past this one.
>>>
>>> Anyone have any thoughts? Would upgrading django and python fix these
>>> issues? I am planning on doing that soon, but I was not planning on
>>> doing that now. Don't want to upgrade now and then find I still have
>>> issues. Can I get all this to work with my current versions and
>>> upgrade later?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5bgRxVDaK7L6b8H7Mw6mt0qWCRAmSYH4L-G_9hxBR7bg%40mail.gmail.com.


Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Larry Martell
I am in a bit of version hell. Not fun on a Friday afternoon.

Django 2.0.4, python 3.5.2

Trying to get channels, websockets, daphne, and asgiref working.

When I installed the latest channels it did not work with my version
of mysqlclient and some googling led me to install 2.0 of channels.
That worked fine with the dev server, and then I wanted to deploy my
app in prod. In prod we use nginx/uwsgi so I was going to replace
uwsgi with daphne. When I tried to run daphne I got:

ImportError: No module named 'asgiref.compatibility'

Googling that I was led to upgrade asgiref to the latest version.
After I did that I got:

AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'

Have not been able to get past this one.

Anyone have any thoughts? Would upgrading django and python fix these
issues? I am planning on doing that soon, but I was not planning on
doing that now. Don't want to upgrade now and then find I still have
issues. Can I get all this to work with my current versions and
upgrade later?

TIA!
Larry

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5SQzRG-7EuEM8rZvOfQor5bBOjt%3DBV1Qsbn9%2BBhMx12g%40mail.gmail.com.


Re: Could not parse the remainder: '='dashboard'' from 'section='dashboard''

2019-11-22 Thread Larry Martell
==

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7OWN9erkXXkXiaOeSARkQgLY13CG%2BscCXEihDiTAGnFQ%40mail.gmail.com.


Re: convert python 3 to python2

2019-09-24 Thread Larry Martell
Ha! How about perl? ;-)

On Tue, Sep 24, 2019 at 8:33 AM Nick Sarbicki  wrote:
>
> I'm not convinced anyone could pay me enough to go back to Python 1...
>
>
> On Tue, Sep 24, 2019 at 1:32 PM Larry Martell  wrote:
>>
>> You can get anyone to do anything for enough money.
>>
>> On Tue, Sep 24, 2019 at 8:30 AM Deep Sukhwani  wrote:
>> >
>> > Thanks for the prompt reply. Did a quick cursory check with Anaconda, I 
>> > don't think Anaconda does it. In fact Anaconda has posted a few months ago 
>> > about Python 2's EOL (End of Life) - 
>> > https://www.anaconda.com/end-of-life-eol-for-python-2-7-is-coming-are-you-ready/
>> >
>> > Also, just did a quick look at their professional services, couldn't see 
>> > anything suggesting they will offer python 2 support beyond the python 2's 
>> > community itself.
>> >
>> > --
>> > Regards
>> > Deep L Sukhwani
>> >
>> >
>> > On Tue, 24 Sep 2019 at 17:53, Larry Martell  
>> > wrote:
>> >>
>> >> Anaconda, Enthought, ActiveState, Red Hat and maybe others as well.
>> >> Also large companies can do their own support.
>> >>
>> >> On Tue, Sep 24, 2019 at 8:11 AM Deep Sukhwani  
>> >> wrote:
>> >> >
>> >> > Wow, TIL there are companies selling support for Python 2? Never heard 
>> >> > of it. So basically we are saying these companies will maintain there 
>> >> > own version of Python programming language which will continue to be 
>> >> > maintained as long as they have paid users for Python 2? I seriously 
>> >> > doubt that. Or may be I am understanding it all wrong.
>> >> >
>> >> >
>> >> > --
>> >> > Regards
>> >> > Deep L Sukhwani
>> >> >
>> >> >
>> >> > On Tue, 24 Sep 2019 at 17:32, Larry Martell  
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Sep 24, 2019 at 4:15 AM Andréas Kühne
>> >> >>  wrote:
>> >> >> >
>> >> >> > Official access isn't denied - and python 2 will probably be 
>> >> >> > available. The problem is that you don't get any security fixes or 
>> >> >> > any updates at all. That in itself is a major problem. If someone is 
>> >> >> > saying that you need to use python 2, I would strongly recommend 
>> >> >> > them to not even think about it. All code that is written will be 
>> >> >> > useless in a couple of years time, and need to be updated or even 
>> >> >> > worse thrown away.
>> >> >>
>> >> >> This is totally untrue. Yes, all code should be converted to py3, but
>> >> >> that is simply not happing at many companies. They will continue to
>> >> >> use their py2 apps, and either support them internally or purchase py2
>> >> >> support from one of the many companies offering it. Is that a good
>> >> >> idea? No, but it's a reality.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4kf0r8Dyicw9_b1%2B5_SGRK4NM8%3D2JBTaCcVF2kxC5XeQ%40mail.gmail.com.


Re: convert python 3 to python2

2019-09-24 Thread Larry Martell
You can get anyone to do anything for enough money.

On Tue, Sep 24, 2019 at 8:30 AM Deep Sukhwani  wrote:
>
> Thanks for the prompt reply. Did a quick cursory check with Anaconda, I don't 
> think Anaconda does it. In fact Anaconda has posted a few months ago about 
> Python 2's EOL (End of Life) - 
> https://www.anaconda.com/end-of-life-eol-for-python-2-7-is-coming-are-you-ready/
>
> Also, just did a quick look at their professional services, couldn't see 
> anything suggesting they will offer python 2 support beyond the python 2's 
> community itself.
>
> --
> Regards
> Deep L Sukhwani
>
>
> On Tue, 24 Sep 2019 at 17:53, Larry Martell  wrote:
>>
>> Anaconda, Enthought, ActiveState, Red Hat and maybe others as well.
>> Also large companies can do their own support.
>>
>> On Tue, Sep 24, 2019 at 8:11 AM Deep Sukhwani  wrote:
>> >
>> > Wow, TIL there are companies selling support for Python 2? Never heard of 
>> > it. So basically we are saying these companies will maintain there own 
>> > version of Python programming language which will continue to be 
>> > maintained as long as they have paid users for Python 2? I seriously doubt 
>> > that. Or may be I am understanding it all wrong.
>> >
>> >
>> > --
>> > Regards
>> > Deep L Sukhwani
>> >
>> >
>> > On Tue, 24 Sep 2019 at 17:32, Larry Martell  
>> > wrote:
>> >>
>> >> On Tue, Sep 24, 2019 at 4:15 AM Andréas Kühne
>> >>  wrote:
>> >> >
>> >> > Official access isn't denied - and python 2 will probably be available. 
>> >> > The problem is that you don't get any security fixes or any updates at 
>> >> > all. That in itself is a major problem. If someone is saying that you 
>> >> > need to use python 2, I would strongly recommend them to not even think 
>> >> > about it. All code that is written will be useless in a couple of years 
>> >> > time, and need to be updated or even worse thrown away.
>> >>
>> >> This is totally untrue. Yes, all code should be converted to py3, but
>> >> that is simply not happing at many companies. They will continue to
>> >> use their py2 apps, and either support them internally or purchase py2
>> >> support from one of the many companies offering it. Is that a good
>> >> idea? No, but it's a reality.
>> >>
>> >> --
>> >> 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 view this discussion on the web visit 
>> >> https://groups.google.com/d/msgid/django-users/CACwCsY4asgYPCoXVabOi4NABck-NfAsjOOsZN_1-MVQ07HZe7Q%40mail.gmail.com.
>> >
>> > --
>> > 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 view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/django-users/CAEMqiPeL8KMsq9d7FhZGh%2B73dY7i3rhA7kxHKjpWnMA3K83S-w%40mail.gmail.com.
>>
>> --
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CACwCsY4Y%2BhYS_oLaUVC4pkRW-v_rrsjY38CwHR1Vv1%2Bt0gNZQA%40mail.gmail.com.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAEMqiPe-ZOJLbiXn2Qesk-dSC%2Bw8JYcAii81ecsL%2BpV%2B_7AFfA%40mail.gmail.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4gfoNpTBewvCo3-3z6J1WENrjkJkaxS7B160ot1cYXaQ%40mail.gmail.com.


Re: convert python 3 to python2

2019-09-24 Thread Larry Martell
Anaconda, Enthought, ActiveState, Red Hat and maybe others as well.
Also large companies can do their own support.

On Tue, Sep 24, 2019 at 8:11 AM Deep Sukhwani  wrote:
>
> Wow, TIL there are companies selling support for Python 2? Never heard of it. 
> So basically we are saying these companies will maintain there own version of 
> Python programming language which will continue to be maintained as long as 
> they have paid users for Python 2? I seriously doubt that. Or may be I am 
> understanding it all wrong.
>
>
> --
> Regards
> Deep L Sukhwani
>
>
> On Tue, 24 Sep 2019 at 17:32, Larry Martell  wrote:
>>
>> On Tue, Sep 24, 2019 at 4:15 AM Andréas Kühne
>>  wrote:
>> >
>> > Official access isn't denied - and python 2 will probably be available. 
>> > The problem is that you don't get any security fixes or any updates at 
>> > all. That in itself is a major problem. If someone is saying that you need 
>> > to use python 2, I would strongly recommend them to not even think about 
>> > it. All code that is written will be useless in a couple of years time, 
>> > and need to be updated or even worse thrown away.
>>
>> This is totally untrue. Yes, all code should be converted to py3, but
>> that is simply not happing at many companies. They will continue to
>> use their py2 apps, and either support them internally or purchase py2
>> support from one of the many companies offering it. Is that a good
>> idea? No, but it's a reality.
>>
>> --
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CACwCsY4asgYPCoXVabOi4NABck-NfAsjOOsZN_1-MVQ07HZe7Q%40mail.gmail.com.
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAEMqiPeL8KMsq9d7FhZGh%2B73dY7i3rhA7kxHKjpWnMA3K83S-w%40mail.gmail.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4Y%2BhYS_oLaUVC4pkRW-v_rrsjY38CwHR1Vv1%2Bt0gNZQA%40mail.gmail.com.


Re: convert python 3 to python2

2019-09-24 Thread Larry Martell
On Tue, Sep 24, 2019 at 4:15 AM Andréas Kühne
 wrote:
>
> Official access isn't denied - and python 2 will probably be available. The 
> problem is that you don't get any security fixes or any updates at all. That 
> in itself is a major problem. If someone is saying that you need to use 
> python 2, I would strongly recommend them to not even think about it. All 
> code that is written will be useless in a couple of years time, and need to 
> be updated or even worse thrown away.

This is totally untrue. Yes, all code should be converted to py3, but
that is simply not happing at many companies. They will continue to
use their py2 apps, and either support them internally or purchase py2
support from one of the many companies offering it. Is that a good
idea? No, but it's a reality.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4asgYPCoXVabOi4NABck-NfAsjOOsZN_1-MVQ07HZe7Q%40mail.gmail.com.


Re: Creating pdf in python

2019-06-27 Thread Larry Martell
On Thu, Jun 27, 2019 at 10:45 AM Django Dojo  wrote:
>
> Hello everyone,
>
> I have a pdf template and I need different Individuals(s) to fill out 
> different sections of the document on the web using online form(s). Is there 
> an Django package that will allow me to do this?
>
> Ex: end user will go to a web form and fill out information which will be 
> imported into the pdf document.

I have used this: https://wkhtmltopdf.org/

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


Re: How to ask questions on Django

2019-04-28 Thread Larry Martell
http://www.catb.org/~esr/faqs/smart-questions.html


On Sun, Apr 28, 2019 at 12:01 PM John Bagiliko <
john.bagil...@aims-senegal.org> wrote:

> Hi all,
>
> I am a passionate Python Developer. I love Django. I have seen most of the
> questions that are posed here and have tried to help. I usually fail to be
> able to help for insufficient information. I think questions asked on this
> group should have much information to help us know where one is coming
> from, where one wants to go and what problem is stopping one from going
> where he wants to go. More importantly, let's know your efforts and where
> you've already looked and didn't succeed so you don't get suggestions about
> what you've tried already and so on.
> I like Stack Overflow for their strict rules. Check how I asked a question
> on Stack Overflow and got answered in less than 30 minutes here
> .
> I also have this tutorial which I think can be a general solution to most
> of of the questions asked here about forms, queries, CRUD activities etc.
> See it here
> 
>
>
> Best,
> John
>
>
> --
> *Regards*
>
> *JOHN BAGILIKO*
> *MSc. Mathematical Sciences (Big Data and Computer Security)*
> *African Institute for Mathematical Sciences (AIMS) | AIMS Senegal*
>
>

-- 
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/CACwCsY7Ch%2Bo0r%2Bnkq_0i%3DkVrPFNS69-Teyb3to3tJ0NCf3hW2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Thanks for the replies!

On Mon, Apr 22, 2019 at 12:43 PM Nick Sarbicki
 wrote:
>
> The JavaScript I assume is just for frontend logic so hopefully isn't very 
> relevant - this will always need to be redone in the native language (unless 
> using something like react native).
>
> If it only renders HTML then there is a bit of work you need to do in 
> python/Django land.
>
> Think about what you want to show on your app and what data this will require 
> from your backend server, as well as any other way it may have to interact 
> with the server. Usually it will be standard CRUD operations. Write these 
> down.
>
> Then find a library that will allow you to transmit this data in a serialised 
> format like JSON, and run the relevant operations. Usually you'd look at 
> something like a REST API (Django rest framework) or websockets (channels), 
> whatever you feel most comfortable with.
>
> These generally work well with existing projects (django rest framework can 
> often be integrated with <100 LOC). Once you have that integrated there is 
> generally very little to think about for the backend, it's almost all about 
> getting the frontend to make the correct requests and deserialising the data. 
> Authentication often serves as a tripping point as well but there's n 
> solutions to the problem.
>
> On Mon, 22 Apr 2019, 17:28 Larry Martell,  wrote:
>>
>> Yes, it only renders HTML and also has a lot of javascript.
>>
>> On Mon, Apr 22, 2019 at 12:25 PM Nick Sarbicki
>>  wrote:
>> >
>> > That's the point, you don't. Assuming your backend has an effective way of 
>> > delivering data (e.g. a REST API).
>> >
>> > If your Django server currently only renders HTML templates then you may 
>> > want to consider adding an API on top of that. But the backend definitely 
>> > does not need to be rewritten, only slightly expanded upon (using python).
>> >
>> > Outside of that you only need to focus on the frontend, usually with swift.
>> >
>> > On Mon, 22 Apr 2019, 16:47 Larry Martell,  wrote:
>> >>
>> >> Googling I found where someone said you could leave the back end in
>> >> python and rewrite the front end in objective C or swift or rewrite
>> >> the entire app in objective C or swift. Why would you need to rewrite
>> >> the python back end that runs on the server?
>> >>
>> >> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
>> >>  wrote:
>> >> >
>> >> > Kind of...
>> >> >
>> >> > I've worked with several Django APIs that we use to back apps on 
>> >> > Android and iOS as well as web apps.
>> >> >
>> >> > I generally find that's the key, make sure you can pass all the data 
>> >> > along as an API and the rest is just understanding how to build a 
>> >> > frontend on the platform. Django doesn't really get in the way at all 
>> >> > at that point.
>> >> >
>> >> >
>> >> > On Mon, 22 Apr 2019, 14:19 Larry Martell,  
>> >> > wrote:
>> >> >>
>> >> >> Has anyone here every taken a django web app and converted it to an
>> >> >> iPhone app? If so, can you share your experiences here please?
>> >> >>
>> >> >> Thanks!

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


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Yes, it only renders HTML and also has a lot of javascript.

On Mon, Apr 22, 2019 at 12:25 PM Nick Sarbicki
 wrote:
>
> That's the point, you don't. Assuming your backend has an effective way of 
> delivering data (e.g. a REST API).
>
> If your Django server currently only renders HTML templates then you may want 
> to consider adding an API on top of that. But the backend definitely does not 
> need to be rewritten, only slightly expanded upon (using python).
>
> Outside of that you only need to focus on the frontend, usually with swift.
>
> On Mon, 22 Apr 2019, 16:47 Larry Martell,  wrote:
>>
>> Googling I found where someone said you could leave the back end in
>> python and rewrite the front end in objective C or swift or rewrite
>> the entire app in objective C or swift. Why would you need to rewrite
>> the python back end that runs on the server?
>>
>> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
>>  wrote:
>> >
>> > Kind of...
>> >
>> > I've worked with several Django APIs that we use to back apps on Android 
>> > and iOS as well as web apps.
>> >
>> > I generally find that's the key, make sure you can pass all the data along 
>> > as an API and the rest is just understanding how to build a frontend on 
>> > the platform. Django doesn't really get in the way at all at that point.
>> >
>> >
>> > On Mon, 22 Apr 2019, 14:19 Larry Martell,  wrote:
>> >>
>> >> Has anyone here every taken a django web app and converted it to an
>> >> iPhone app? If so, can you share your experiences here please?
>> >>
>> >> Thanks!

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


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Googling I found where someone said you could leave the back end in
python and rewrite the front end in objective C or swift or rewrite
the entire app in objective C or swift. Why would you need to rewrite
the python back end that runs on the server?

On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
 wrote:
>
> Kind of...
>
> I've worked with several Django APIs that we use to back apps on Android and 
> iOS as well as web apps.
>
> I generally find that's the key, make sure you can pass all the data along as 
> an API and the rest is just understanding how to build a frontend on the 
> platform. Django doesn't really get in the way at all at that point.
>
>
> On Mon, 22 Apr 2019, 14:19 Larry Martell,  wrote:
>>
>> Has anyone here every taken a django web app and converted it to an
>> iPhone app? If so, can you share your experiences here please?
>>
>> Thanks!

-- 
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/CACwCsY586vT-kcP%2B6zq%2BLj6Lb70%2B1%3DscxTA-2n3HdgNESz_GOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Has anyone here every taken a django web app and converted it to an
iPhone app? If so, can you share your experiences here please?

Thanks!

-- 
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/CACwCsY6R%2BLAw5BGYZtrC%2BTJ%2B13yApo7JH6xn-fVORiOP%2BoLU%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Showing old data

2019-04-02 Thread Larry Martell
On Mon, Apr 1, 2019 at 11:12 PM Swetank Subham Roy
 wrote:
>
> Hello folks,
> I have created a hosted a django web app on apache2 using mod_wsgi, the 
> content should automatically refresh everyday. But it is not getting 
> refreshed automatically. I need to manually restart or reload the apache in 
> order to make the changes reflect. I don't want to set cron to restart apache 
> every single day.
>
> Kindly help me out.

What do you have that would make the content automatically refresh
every day? When I need something like this I do this:


window.setTimeout(function () {
window.location.reload(1);
}, 6); // refresh after 60 seconds.


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


Re: IIS configuration for python Django project

2019-03-22 Thread Larry Martell
On Fri, Mar 22, 2019 at 8:28 AM patel hastik  wrote:
>
> Hello, everyone
>
> I created python Django web Application I want to configure with IIS on the 
> window OS. I try many things and research about this I found video and 
> document and I follow all the step mention in the document but I am getting 
> Error "internal server Error 500.00 unknown FastCGI Occurred"
>
> my Question is I have to make any change in python and Django code to 
> configure my python Django project with IIS?
>
> can anyone help me with is thanks in advanced

I have a django app that I was able to get running on IIS. It was a
huge pain, with many battles along the way. In my case the app had to
run on both Windows and Linux so I had to make some settings changes,
but no code changes. I would check the logs (IIS logs, django logs,
any logs your app may generate). Also I found that connecting to the
app locally (i.e. from a browser running on the same machine as IIS)
gave me more informative error messages then when I ran from a remote
client. You can also try running the django devel server and seeing if
you get more info from that. Good luck.

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


No module named context_processors

2019-01-02 Thread Larry Martell
I am having an odd interment problem. I have an app which is deployed
at 30 different sites. At one site only, and only intermittently, user
will get the error 'No module named context_processors'.

It may happen on a page that was previously accessed with no error and
upon refreshing the same page it will come up fine. It will not occur
for months, then happen a few times in one day.

The app is deployed with nginx and uwsgi.

Here is a typical traceback:

Internal Server Error: /
Traceback (most recent call last):
  File 
"/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py",
line 35, in inner
response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py",
line 158, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py",
line 156, in _get_response
response = response.render()
  File "/usr/local/lib/python3.5/dist-packages/django/template/response.py",
line 106, in render
self.content = self.rendered_content
  File "/usr/local/lib/python3.5/dist-packages/django/template/response.py",
line 83, in rendered_content
content = template.render(context, self._request)
  File 
"/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py",
line 61, in render
return self.template.render(context)
  File "/usr/local/lib/python3.5/dist-packages/django/template/base.py",
line 173, in render
with context.bind_template(self):
  File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
  File "/usr/local/lib/python3.5/dist-packages/django/template/context.py",
line 246, in bind_template
processors = (template.engine.template_context_processors +
  File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py",
line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.5/dist-packages/django/template/engine.py",
line 85, in template_context_processors
return tuple(import_string(path) for path in context_processors)
  File "/usr/local/lib/python3.5/dist-packages/django/template/engine.py",
line 85, in 
return tuple(import_string(path) for path in context_processors)
  File "/usr/local/lib/python3.5/dist-packages/django/utils/module_loading.py",
line 17, in import_string
module = import_module(module_path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load
  File "", line 956, in _find_and_load_unlocked
ImportError: No module named 'ui.context_processors'

That file does exist and is readable:

-rw-rw-r-- 1 ubuntu ubuntu 1059 May  2  2018 ui/context_processors.py

And here is my TEMPLATES setting:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'ui/templates'),
os.path.join(BASE_DIR, 'app/dse/templates'),
os.path.join(BASE_DIR, 'core/reports/templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'context_processors.config',
'ui.context_processors.navigation',
'core.appmngr.context_processor',
],
},
},
]

As I said it's intermittent. Anyone have any ideas on what it could be
and/or how to debug 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/CACwCsY6djuwtvwpq3d0entJWGWUyb3RU-gHM_eaQbwkbNxZSqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on IIS

2018-12-19 Thread Larry Martell
Thanks very much Roger. I ran your command (updated for my system),
and then it started working.

On Tue, Dec 18, 2018 at 4:31 PM Roger Gammans
 wrote:
>
> Larry,
>
>
> Hmm, you may have reached the end of how I can help, but two things come to 
> mind:-
>
> 1 It might be worth trying a reboot, to ensure IIS and dependent services are 
> all reloaded.
> 2 I'm not sure the icon was created; I think I had to manually add the 
> handler which created the icon. ( remember
> having to select the name dome a combo select box. at one point)
>
> My script goes straight on from the adding the features, to install python 
> and then create a fastcgi handler with
>
>
> New-WebHandler -Name "DjangoFastCGI" -Path "*" -Verb "GET,POST" -Modules 
> FastCgiModule `
>
>-ResourceType Unspecified -ScriptProcessor "$PYEXE|-m 
> wfastcgi"
>
>
> (I've manually wrapped the above and added a '`' as the line continuation 
> character ; and note the PYEXE variable
> which would have been set to "C:\python36\python.exe" in my case. )
>
> Which is the command line version of point 2 above.
>
> IIS also a has a tendency to read a web.config XML in the IIS site root; from 
> which I think a lot of this can be set from. You can certainly set 
> environment variable there (such as PYTHONPATH , or DJANGO_SETTINGS_MODULE ).
>
>
> HTH,
> --
> Roger
>
> On Tue, 2018-12-18 at 12:07 -0500, Larry Martell wrote:
>
> Thanks. I ran that command, and I checked the settings and CGi is
> installed and enabled. I have the CGI icon in the IIS config page, but
> I do not have the FAST-CGI which is what all the docs seem to refer
> to.
>
> On Tue, Dec 18, 2018 at 10:49 AM Roger Gammans
>  wrote:
>
>
> Larry,
>
>
> My script draws from the following urls all of which I found useful.
>
>  https://docs.microsoft.com/en-us/iis/configuration/system.webserver/fastcgi/
> http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
> http://mrtn.me/blog/2012/06/27/running-django-under-windows-with-iis-using-fcgi/
> https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
> https://docs.microsoft.com/en-us/azure/virtual-machines/windows/classic/python-django-web-app
>
>
> I think you might not have all the correct 'features' installed, specifically 
> you are probably missing CGI.
> The PS line to install that seems to be:-
>
> Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI
>
>
> Hope this helps a little.
>
>
> On Tue, 2018-12-18 at 10:40 -0500, Larry Martell wrote:
>
> I am following the instructions I found here:
>
> https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
>
> I am up to this point: 'Configuring IIS to run a FastCGI application'
> It says 'Click OK on the handler information dialog. IIS will then ask
> you to confirm the creation of a matching FastCGI application entry
> which you will need to confirm. This entry will be visible in the
> FastCGI Settings feature, accessible at the root screen of the IIS
> Management Console'
>
> But after I set up the Module Mapping and do the above there is no
> entry for the handler in the FastCGI Settings.
>
> Anyone know what I may be doing wrong or how to proceed?
>
>
> On Tue, Dec 18, 2018 at 4:35 AM Roger Gammans
>  wrote:
>
>
> Hi,
>
> I was looking at this back in November., although I'm not a Powershell or 
> Windows expert I start to put together a powershell script to automate the 
> setup, although there was a couple of lose ends.
>
> Most critically the order of handlers is import and you need to force the 
> static files handler to be primary for media and static directories as 
> whatever handler (by script uses fastcgi / wfastcgi.py)  use use to interface 
> with wsgi as primary at the root level. (Eg so media and static overrides the 
> root with their local config)
>
> Unfortunately I couldn't find anyway to control the handler ordering through 
> powershell, I'm waiting on a window colleague to fix it up, but it is no 
> longer a prioirty as the project as move away form windows hosting.
>
> If there is interest I'll see what I can do about getting the script public.
>
>
> --
>
> Roger Gammans 
> Gamma Science
>
> On Tue, 2018-12-18 at 11:22 +0200, Avraham Serour wrote:
>
> I feel your pain, once I had to deploy a django project on windows, after 
> trying many different options I installed cygwin and form there nginx+uwsgi 
> like any other normal person.
>
> Today microsoft have WSL, I think you may use that too, you can still use IIS 
> to route traffic and forward

Re: Django on IIS

2018-12-18 Thread Larry Martell
Get-WindowsFeature shows that web-cgi is installed but not iis-cgi.
Are these the same?

On Tue, Dec 18, 2018 at 12:07 PM Larry Martell  wrote:
>
> Thanks. I ran that command, and I checked the settings and CGi is
> installed and enabled. I have the CGI icon in the IIS config page, but
> I do not have the FAST-CGI which is what all the docs seem to refer
> to.
>
> On Tue, Dec 18, 2018 at 10:49 AM Roger Gammans
>  wrote:
> >
> > Larry,
> >
> >
> > My script draws from the following urls all of which I found useful.
> >
> >  
> > https://docs.microsoft.com/en-us/iis/configuration/system.webserver/fastcgi/
> > http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
> > http://mrtn.me/blog/2012/06/27/running-django-under-windows-with-iis-using-fcgi/
> > https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
> > https://docs.microsoft.com/en-us/azure/virtual-machines/windows/classic/python-django-web-app
> >
> >
> > I think you might not have all the correct 'features' installed, 
> > specifically you are probably missing CGI.
> > The PS line to install that seems to be:-
> >
> > Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI
> >
> >
> > Hope this helps a little.
> >
> >
> > On Tue, 2018-12-18 at 10:40 -0500, Larry Martell wrote:
> >
> > I am following the instructions I found here:
> >
> > https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
> >
> > I am up to this point: 'Configuring IIS to run a FastCGI application'
> > It says 'Click OK on the handler information dialog. IIS will then ask
> > you to confirm the creation of a matching FastCGI application entry
> > which you will need to confirm. This entry will be visible in the
> > FastCGI Settings feature, accessible at the root screen of the IIS
> > Management Console'
> >
> > But after I set up the Module Mapping and do the above there is no
> > entry for the handler in the FastCGI Settings.
> >
> > Anyone know what I may be doing wrong or how to proceed?
> >
> >
> > On Tue, Dec 18, 2018 at 4:35 AM Roger Gammans
> >  wrote:
> >
> >
> > Hi,
> >
> > I was looking at this back in November., although I'm not a Powershell or 
> > Windows expert I start to put together a powershell script to automate the 
> > setup, although there was a couple of lose ends.
> >
> > Most critically the order of handlers is import and you need to force the 
> > static files handler to be primary for media and static directories as 
> > whatever handler (by script uses fastcgi / wfastcgi.py)  use use to 
> > interface with wsgi as primary at the root level. (Eg so media and static 
> > overrides the root with their local config)
> >
> > Unfortunately I couldn't find anyway to control the handler ordering 
> > through powershell, I'm waiting on a window colleague to fix it up, but it 
> > is no longer a prioirty as the project as move away form windows hosting.
> >
> > If there is interest I'll see what I can do about getting the script public.
> >
> >
> > --
> >
> > Roger Gammans 
> > Gamma Science
> >
> > On Tue, 2018-12-18 at 11:22 +0200, Avraham Serour wrote:
> >
> > I feel your pain, once I had to deploy a django project on windows, after 
> > trying many different options I installed cygwin and form there nginx+uwsgi 
> > like any other normal person.
> >
> > Today microsoft have WSL, I think you may use that too, you can still use 
> > IIS to route traffic and forward the http connections. Maybe not as 
> > efficient as it could be but I think it will save you headaches.
> >
> > Good luck
> >
> > On Tue, Dec 18, 2018 at 6:10 AM Mike Dewhirst  wrote:
> >
> > On 18/12/2018 2:16 PM, Alex Heyden wrote:
> >
> > I have recently, and it was equal parts misery and pain. FastCGI via
> > wfastcgi, as outlined at
> > http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
> >
> > I also had to downgrade from Python 3.7 to Python 3.6
> >
> > I wouldn't really consider myself an expert on the subject. All I can
> > say is that it is possible.
> >
> >
> > I once had to implement a web service on a Windows server and eventually
> > installed Apache. That worked brilliantly although it wasn't a heavy
> > duty application. Django works well on Windows so Apache is a fallback
> > if IIS doesn't cut it for you.
> >
> >
> >
> > On Mon, De

Re: Django on IIS

2018-12-18 Thread Larry Martell
Thanks. I ran that command, and I checked the settings and CGi is
installed and enabled. I have the CGI icon in the IIS config page, but
I do not have the FAST-CGI which is what all the docs seem to refer
to.

On Tue, Dec 18, 2018 at 10:49 AM Roger Gammans
 wrote:
>
> Larry,
>
>
> My script draws from the following urls all of which I found useful.
>
>  https://docs.microsoft.com/en-us/iis/configuration/system.webserver/fastcgi/
> http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
> http://mrtn.me/blog/2012/06/27/running-django-under-windows-with-iis-using-fcgi/
> https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
> https://docs.microsoft.com/en-us/azure/virtual-machines/windows/classic/python-django-web-app
>
>
> I think you might not have all the correct 'features' installed, specifically 
> you are probably missing CGI.
> The PS line to install that seems to be:-
>
> Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI
>
>
> Hope this helps a little.
>
>
> On Tue, 2018-12-18 at 10:40 -0500, Larry Martell wrote:
>
> I am following the instructions I found here:
>
> https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
>
> I am up to this point: 'Configuring IIS to run a FastCGI application'
> It says 'Click OK on the handler information dialog. IIS will then ask
> you to confirm the creation of a matching FastCGI application entry
> which you will need to confirm. This entry will be visible in the
> FastCGI Settings feature, accessible at the root screen of the IIS
> Management Console'
>
> But after I set up the Module Mapping and do the above there is no
> entry for the handler in the FastCGI Settings.
>
> Anyone know what I may be doing wrong or how to proceed?
>
>
> On Tue, Dec 18, 2018 at 4:35 AM Roger Gammans
>  wrote:
>
>
> Hi,
>
> I was looking at this back in November., although I'm not a Powershell or 
> Windows expert I start to put together a powershell script to automate the 
> setup, although there was a couple of lose ends.
>
> Most critically the order of handlers is import and you need to force the 
> static files handler to be primary for media and static directories as 
> whatever handler (by script uses fastcgi / wfastcgi.py)  use use to interface 
> with wsgi as primary at the root level. (Eg so media and static overrides the 
> root with their local config)
>
> Unfortunately I couldn't find anyway to control the handler ordering through 
> powershell, I'm waiting on a window colleague to fix it up, but it is no 
> longer a prioirty as the project as move away form windows hosting.
>
> If there is interest I'll see what I can do about getting the script public.
>
>
> --
>
> Roger Gammans 
> Gamma Science
>
> On Tue, 2018-12-18 at 11:22 +0200, Avraham Serour wrote:
>
> I feel your pain, once I had to deploy a django project on windows, after 
> trying many different options I installed cygwin and form there nginx+uwsgi 
> like any other normal person.
>
> Today microsoft have WSL, I think you may use that too, you can still use IIS 
> to route traffic and forward the http connections. Maybe not as efficient as 
> it could be but I think it will save you headaches.
>
> Good luck
>
> On Tue, Dec 18, 2018 at 6:10 AM Mike Dewhirst  wrote:
>
> On 18/12/2018 2:16 PM, Alex Heyden wrote:
>
> I have recently, and it was equal parts misery and pain. FastCGI via
> wfastcgi, as outlined at
> http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
>
> I also had to downgrade from Python 3.7 to Python 3.6
>
> I wouldn't really consider myself an expert on the subject. All I can
> say is that it is possible.
>
>
> I once had to implement a web service on a Windows server and eventually
> installed Apache. That worked brilliantly although it wasn't a heavy
> duty application. Django works well on Windows so Apache is a fallback
> if IIS doesn't cut it for you.
>
>
>
> On Mon, Dec 17, 2018 at 5:19 PM Larry Martell  <mailto:larry.mart...@gmail.com>> wrote:
>
> Anyone have any experience setting up a Django app to work with IIS? I
> have inherited what I was told is a working system, but it's not
> working. Before I post details of my issues and questions I wanted to
> see if anyone here has successfully got a Django app to run with IIS.

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


Re: Django on IIS

2018-12-18 Thread Larry Martell
I am following the instructions I found here:

https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial

I am up to this point: 'Configuring IIS to run a FastCGI application'
It says 'Click OK on the handler information dialog. IIS will then ask
you to confirm the creation of a matching FastCGI application entry
which you will need to confirm. This entry will be visible in the
FastCGI Settings feature, accessible at the root screen of the IIS
Management Console'

But after I set up the Module Mapping and do the above there is no
entry for the handler in the FastCGI Settings.

Anyone know what I may be doing wrong or how to proceed?


On Tue, Dec 18, 2018 at 4:35 AM Roger Gammans
 wrote:
>
> Hi,
>
> I was looking at this back in November., although I'm not a Powershell or 
> Windows expert I start to put together a powershell script to automate the 
> setup, although there was a couple of lose ends.
>
> Most critically the order of handlers is import and you need to force the 
> static files handler to be primary for media and static directories as 
> whatever handler (by script uses fastcgi / wfastcgi.py)  use use to interface 
> with wsgi as primary at the root level. (Eg so media and static overrides the 
> root with their local config)
>
> Unfortunately I couldn't find anyway to control the handler ordering through 
> powershell, I'm waiting on a window colleague to fix it up, but it is no 
> longer a prioirty as the project as move away form windows hosting.
>
> If there is interest I'll see what I can do about getting the script public.
>
>
> --
>
> Roger Gammans 
> Gamma Science
>
> On Tue, 2018-12-18 at 11:22 +0200, Avraham Serour wrote:
>
> I feel your pain, once I had to deploy a django project on windows, after 
> trying many different options I installed cygwin and form there nginx+uwsgi 
> like any other normal person.
>
> Today microsoft have WSL, I think you may use that too, you can still use IIS 
> to route traffic and forward the http connections. Maybe not as efficient as 
> it could be but I think it will save you headaches.
>
> Good luck
>
> On Tue, Dec 18, 2018 at 6:10 AM Mike Dewhirst  wrote:
>
> On 18/12/2018 2:16 PM, Alex Heyden wrote:
> > I have recently, and it was equal parts misery and pain. FastCGI via
> > wfastcgi, as outlined at
> > http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
> >
> > I also had to downgrade from Python 3.7 to Python 3.6
> >
> > I wouldn't really consider myself an expert on the subject. All I can
> > say is that it is possible.
>
> I once had to implement a web service on a Windows server and eventually
> installed Apache. That worked brilliantly although it wasn't a heavy
> duty application. Django works well on Windows so Apache is a fallback
> if IIS doesn't cut it for you.
>
>
> >
> > On Mon, Dec 17, 2018 at 5:19 PM Larry Martell  > <mailto:larry.mart...@gmail.com>> wrote:
> >
> > Anyone have any experience setting up a Django app to work with IIS? I
> > have inherited what I was told is a working system, but it's not
> > working. Before I post details of my issues and questions I wanted to
> > see if anyone here has successfully got a Django app to run with IIS.

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


Django on IIS

2018-12-17 Thread Larry Martell
Anyone have any experience setting up a Django app to work with IIS? I
have inherited what I was told is a working system, but it's not
working. Before I post details of my issues and questions I wanted to
see if anyone here has successfully got a Django app to run with IIS.

-- 
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/CACwCsY7bk-c7Za-PGUbaEkftA8Xxqd%2BaCUPkaQryW-1kXX0_nQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Password reset from address

2018-12-17 Thread Larry Martell
Thanks for the reply, Andréas, but I just found this in the docs,
which I had missed before:

https://docs.djangoproject.com/en/2.1/ref/settings/#std:setting-DEFAULT_FROM_EMAIL

On Fri, Dec 14, 2018 at 3:51 PM Andréas Kühne
 wrote:
>
> Hi,
>
> Check the views for password reset in the django.contrib.auth package. You 
> can add the form_email by creating a class that inherits the 
> PasswordResetView and sets the from_email property on that view.
>
> Regards,
>
> Andréas
>
>
> Den fre 14 dec. 2018 kl 19:02 skrev Larry Martell :
>>
>> Is there a way to set the from address used in the password reset email?

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


Password reset from address

2018-12-14 Thread Larry Martell
Is there a way to set the from address used in the password reset email?

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


Re: How to update if user exist instead of create?

2018-09-18 Thread Larry Martell
On Tue, Sep 18, 2018 at 8:13 AM, Django Lover  wrote:
> How i can update model when Key exist else create a new one??
>
>
> My code is-
>
> **Form.py**
>
> class UserSettingForm(forms.ModelForm):
>  class Meta:
>model = StUserSetting
>fields = ( 'default_language', 'prim_currency', 'number_format',
> 'decimal_format',
> 'date_format', 'time_format', 'currency_format',
> 'currency_position', 'financial_year_start',
>  'week_start', 'estimate_default_tab', 'invoice_default_tab',)
>
> **View.py**
>
>
> class CreateUpadateUserSetting(LoginRequiredMixin, FormView):
>  template_name = 'settings/user_settings.html'
>  form_class = UserSettingForm
>  success_url = '/user/setting/preference/'

https://docs.djangoproject.com/en/2.1/ref/models/querysets/#update-or-create

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


Re: odd crash

2018-06-13 Thread Larry Martell
Update:

The django code clearly has a bug, and I fixed it on my system. That
allowed me to see the next higher up error, which was an error
importing one of my own context_processors. This is odd, as the file
and function are there, and are readable, and if they were not I would
always get this error, not just get it intermittently. I still think
there is another higher up error, and I tried to find it by setting a
breakpoint and running the devel server, but with that the error never
occurs.

On Fri, Jun 8, 2018 at 4:16 PM, Larry Martell  wrote:
> I have an app that uses 1.9. It will work fine for weeks and weeks,
> and then out of the blue a page that has just worked will crash with
> this:
>
> Request Method: GET
> Request URL:
>
> Django Version: 1.9
> Python Version: 2.7.5
> Installed Applications:
> ['django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'core.data',
> 'core.alerts',
> 'core.reports',
> 'app.cdsem',
> 'app.semvision',
> 'app.developer',
> 'dispatch',
> 'ui',
> 'configuration']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'middleware.LastSiteUrl']
>
> Traceback:
>
> File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>  174. response =
> self.process_exception_by_middleware(e, request)
> File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>  172. response = response.render()
> File "/usr/lib/python2.7/site-packages/django/template/response.py" in render
>  160. self.content = self.rendered_content
> File "/usr/lib/python2.7/site-packages/django/template/response.py" in
> rendered_content
>  137. content = template.render(context, self._request)
> File "/usr/lib/python2.7/site-packages/django/template/backends/django.py"
> in render
>  95. return self.template.render(context)
> File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
>  204. with context.bind_template(self):
> File "/usr/lib64/python2.7/contextlib.py" in __enter__
>  17. return self.gen.next()
>
> exceptions must be old-style classes or derived from BaseException, not str
>
> Request Method: GET
> Request URL:
> Django Version: 1.9
> Exception Type: TypeError
> Exception Value:
>
> exceptions must be old-style classes or derived from BaseException, not str
>
> Exception Location:
> /usr/lib/python2.7/site-packages/django/utils/module_loading.py in
> import_string, line 23
>
> If I go the exact same URL again it will work.
>
> Anyone have any idea what could be causing this or how I can debug it further?

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


odd crash

2018-06-08 Thread Larry Martell
I have an app that uses 1.9. It will work fine for weeks and weeks,
and then out of the blue a page that has just worked will crash with
this:

Request Method: GET
Request URL:

Django Version: 1.9
Python Version: 2.7.5
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core.data',
'core.alerts',
'core.reports',
'app.cdsem',
'app.semvision',
'app.developer',
'dispatch',
'ui',
'configuration']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'middleware.LastSiteUrl']

Traceback:

File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
 174. response =
self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
 172. response = response.render()
File "/usr/lib/python2.7/site-packages/django/template/response.py" in render
 160. self.content = self.rendered_content
File "/usr/lib/python2.7/site-packages/django/template/response.py" in
rendered_content
 137. content = template.render(context, self._request)
File "/usr/lib/python2.7/site-packages/django/template/backends/django.py"
in render
 95. return self.template.render(context)
File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
 204. with context.bind_template(self):
File "/usr/lib64/python2.7/contextlib.py" in __enter__
 17. return self.gen.next()

exceptions must be old-style classes or derived from BaseException, not str

Request Method: GET
Request URL:
Django Version: 1.9
Exception Type: TypeError
Exception Value:

exceptions must be old-style classes or derived from BaseException, not str

Exception Location:
/usr/lib/python2.7/site-packages/django/utils/module_loading.py in
import_string, line 23

If I go the exact same URL again it will work.

Anyone have any idea what could be causing this or how I can debug it further?

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


Re: Implementing a 'please wait' page

2018-06-01 Thread Larry Martell
On Thu, May 31, 2018 at 7:35 PM, Mohammed Noor  wrote:
> Hello Guys,
>
> I currently have a process running on my django application which takes about 
> 10-15 minutes to complete.
>
> Currently, the user clicks on a 'submit' button and this process starts. The 
> web page remains in a hung state for the complete time this process takes to 
> run and after say 10-15 mins another 'results' page is displayed.
>
>
> I want to be able to display a page saying 'please wait for  taken to complete process>'  after submit button is clicked. Can you please 
> give me any ideas on how to implement this.

The way I have dealt wth this is to define something in the template like this:

 ... loading images 
$('.loadMsg').show();

And then in window.onload function:

$('.loadMsg').hide();

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


Re: Python Sqlalchemy filter by date range

2018-04-24 Thread Larry Martell
I think you are looking for the range function

https://docs.djangoproject.com/en/dev/ref/models/querysets/#range


On Mon, Apr 23, 2018 at 11:54 PM sum abiut  wrote:

> I have two date picker fields that i want the users to select from date to
> end date. and i want to display data between the two dates that was
> selected. From example form date: 2/14/2018 to date:3/15/2018. when the
> function is called i want to extract and display data between this two
> dates.
>
> i just need some help with the query to accomplish that.
>
> I am using sqlalchemy to pull data from an mssql
>

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


Re: if statement for development/production mode in templates?

2018-04-23 Thread Larry Martell
Somewhere in the code is a place where data is passed to the template.
Did you write the app?

On Mon, Apr 23, 2018 at 9:55 AM, Alexander Joseph
 wrote:
> I dont know what that means
>
> On Monday, April 23, 2018 at 7:49:25 AM UTC-6, larry@gmail.com wrote:
>>
>> On Mon, Apr 23, 2018 at 9:34 AM, Alexander Joseph
>>  wrote:
>> > Hello, is there a way to make an if statement that is based on whether
>> > you
>> > are running in development mode or production mode? Or based on which
>> > settings file you are using?
>> >
>> > My app allows users to login with their office365 account instead of
>> > with
>> > django allauth and I'd like to only give them that option, however I do
>> > need
>> > to login with allauth while developing because the settings for logging
>> > in
>> > to Office365 dont work with a development server. So I'd like to display
>> > the
>> > allauth login form and allow the user to login if it is in development
>> > mode,
>> > otherwise I'd only like to display the Office365 login.
>>
>> Just pass in something in the context from the server to the template
>> and test that.
>
> --
> 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/5aae6def-df66-40a1-90cc-733b2afa22b1%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/CACwCsY4ykA0BHtP_PbfzQ%3DrsYYLHg3U_562C2Nn0qt%2B0U8DXhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: if statement for development/production mode in templates?

2018-04-23 Thread Larry Martell
On Mon, Apr 23, 2018 at 9:34 AM, Alexander Joseph
 wrote:
> Hello, is there a way to make an if statement that is based on whether you
> are running in development mode or production mode? Or based on which
> settings file you are using?
>
> My app allows users to login with their office365 account instead of with
> django allauth and I'd like to only give them that option, however I do need
> to login with allauth while developing because the settings for logging in
> to Office365 dont work with a development server. So I'd like to display the
> allauth login form and allow the user to login if it is in development mode,
> otherwise I'd only like to display the Office365 login.

Just pass in something in the context from the server to the template
and test that.

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


Re: Adding stored procedures

2018-04-19 Thread Larry Martell
There are django-mssql and django_pyodbc but I was never able to get
either of those to work for me. I ended up using odbc - I couldn't use
the ORM, but I still was able to connect to the MSSQL DB from my
django app using raw queries.

On Wed, Apr 18, 2018 at 8:55 AM, Matthew Pava  wrote:
> Hi Chris,
>
> SQL Server is not one of the databases that Django supports out of the box.
> There are third party packages available, though, but I haven’t tested any
> of them with recent versions.
>
> Saying that, you can create views in your database backend.  In your
> migrations file, use the RunSQL operation.
>
> https://docs.djangoproject.com/en/2.0/ref/migration-operations/#runsql
>
>
>
> In your models file, change the Meta option, managed, to False.
>
> https://docs.djangoproject.com/en/2.0/ref/models/options/#managed
>
>
>
> Good luck!
>
>
>
> As for stored procedures and functions, I haven’t worked enough with those
> mixed in with Django to give you much guidance except to do some more
> searching on the web.  And I would also advise against using them so that
> you can keep your code in your Django project.  I haven’t found a need for
> them myself while using Django.
>
>
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Chris Wedgwood
> Sent: Wednesday, April 18, 2018 1:50 AM
> To: django-users@googlegroups.com
> Subject: Adding stored procedures
>
>
>
> Hi All
>
>
>
> I am using SQL SERVER in my latest django project and I am going to be using
> some stored procedures.
>
>
>
> My question is about how to go about deploying stored procedure changes with
> django. I have looked through the migrations documentation which looks very
> specific to model changes.
>
>
>
> Has anyone had experience of having to create other things such a stored
> procedures/views/functions?
>
>
>
> thanks
>
> Chris
>
>
>
>
>
>
>
>
>
> --
> 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/CACQBJYU5CDhCrP7cNRpzp7fRDr1pyf48css-EaVW%3Drj65SmEsg%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/58f5f935832647b0afd58ac5105b45f0%40ISS1.ISS.LOCAL.
> 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/CACwCsY4OOb3HufKYQ8v2y5cUGgVWmhzBTMgO6hn%2BEO%3Dwi9swww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread Larry Martell
The same way you pass parameters to any view.

On Mon, Apr 16, 2018 at 8:50 PM, sum abiut <suab...@gmail.com> wrote:
> Thanks Larry,
> How to i pass my query parameter to the xlsxwriter.
>
> Cheers
>
>
>
> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com>
> wrote:
>>
>> I use xlsxwriter and I do it like this:
>>
>> output = io.BytesIO()
>> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
>> # write file
>> output.seek(0)
>> response = HttpResponse(output.read(),
>> content_type='application/ms-excel')
>> response['Content-Disposition'] = "attachment; filename=%s" %
>> xls_name
>> return response
>>
>> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut <suab...@gmail.com> wrote:
>> > my code actually worked. I thought it was going to save the excel file
>> > to
>> > 'C:\excel' folder so i was looking for the file in the folder but i
>> > couldn't
>> > find the excel file. The excel file was actually exported to my django
>> > project folder instead.
>> >
>> > How to i allow the end user to be able to download the file to their
>> > desktop
>> > instead of exporting it to the server itself
>> >
>> >
>> >
>> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote:
>> >>
>> >> I wrote a function to export sql query to an excel file, but some how
>> >> the
>> >> excel file wasn't created when the function was call. appreciate any
>> >> assistances
>> >>
>> >> here is my view.py
>> >>
>> >> def download_excel(request):
>> >> if "selectdate" in request.POST:
>> >> if "selectaccount" in request.POST:
>> >> selected_date = request.POST["selectdate"]
>> >> selected_acc = request.POST["selectaccount"]
>> >> if selected_date==selected_date:
>> >> if selected_acc==selected_acc:
>> >> convert=datetime.datetime.strptime(selected_date,
>> >> "%Y-%m-%d").toordinal()
>> >>
>> >> engine=create_engine('mssql+pymssql://username:password@servername
>> >> /db')
>> >> connection = engine.connect()
>> >> metadata=MetaData()
>> >>
>> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>> >>
>> >>
>> >> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> >>
>> >>
>> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>> >>
>> >> df = pd.read_sql(stmt,connection)
>> >>
>> >> writer = pd.ExcelWriter('C:\excel\export.xls')
>> >> df.to_excel(writer, sheet_name ='bar')
>> >> writer.save()

-- 
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/CACwCsY5CNHJ%2BM1AP__6g%2BqwXu1eGPmUZrcfnZJuq1xm%2BQikDtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread Larry Martell
I was just giving you an example of how I do it. You do not need to
use xlsxwriter - you can use anything you want to generate your xls
files. The key to allowing the user to download it is returning a
HttpResponse with content_type='application/ms-excel'

On Mon, Apr 16, 2018 at 6:26 PM, sum abiut <suab...@gmail.com> wrote:
> Thanks Larry,
> I haven't actually try xlsxwriter before so i find some difficulties
> understanding your code. Do you mind explaining the code, i will definitely
> have a read on the documentation.
>
> cheers
>
>
> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com>
> wrote:
>>
>> I use xlsxwriter and I do it like this:
>>
>> output = io.BytesIO()
>> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
>> # write file
>> output.seek(0)
>> response = HttpResponse(output.read(),
>> content_type='application/ms-excel')
>> response['Content-Disposition'] = "attachment; filename=%s" %
>> xls_name
>> return response
>>
>> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut <suab...@gmail.com> wrote:
>> > my code actually worked. I thought it was going to save the excel file
>> > to
>> > 'C:\excel' folder so i was looking for the file in the folder but i
>> > couldn't
>> > find the excel file. The excel file was actually exported to my django
>> > project folder instead.
>> >
>> > How to i allow the end user to be able to download the file to their
>> > desktop
>> > instead of exporting it to the server itself
>> >
>> >
>> >
>> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote:
>> >>
>> >> I wrote a function to export sql query to an excel file, but some how
>> >> the
>> >> excel file wasn't created when the function was call. appreciate any
>> >> assistances
>> >>
>> >> here is my view.py
>> >>
>> >> def download_excel(request):
>> >> if "selectdate" in request.POST:
>> >> if "selectaccount" in request.POST:
>> >> selected_date = request.POST["selectdate"]
>> >> selected_acc = request.POST["selectaccount"]
>> >> if selected_date==selected_date:
>> >> if selected_acc==selected_acc:
>> >> convert=datetime.datetime.strptime(selected_date,
>> >> "%Y-%m-%d").toordinal()
>> >>
>> >> engine=create_engine('mssql+pymssql://username:password@servername
>> >> /db')
>> >> connection = engine.connect()
>> >> metadata=MetaData()
>> >>
>> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>> >>
>> >>
>> >> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> >>
>> >>
>> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>> >>
>> >> df = pd.read_sql(stmt,connection)
>> >>
>> >> writer = pd.ExcelWriter('C:\excel\export.xls')
>> >> df.to_excel(writer, sheet_name ='bar')
>> >> writer.save()

-- 
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/CACwCsY61bx7_oFFq4%3D7ShNJc3G-Em21DDD_b%3DwdJOxeK9wa-yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need Help With integrating Python Scripts with Django Frame Work

2018-04-16 Thread Larry Martell
Use ajax, e.g.:
https://stackoverflow.com/questions/30456958/python-script-called-by-ajax-executed-by-django-server

On Mon, Apr 16, 2018 at 3:48 PM, Balu Nanduri  wrote:
> Hi,
>  I am working on a project where I have to communicate with Tableau
> server and generate pptx with the images downloaded. I have a working script
> to do this piece, currently the script generates pptx and stores it to my
> local filesystem.
>
> Now I would like to create a web page which would accept necessary input
> from users and should trigger the script which generates pptx and then
> downloads the files to the user's browser.
>
> I had set up DJANGO environment of the same but not getting how to call this
> script from the web page so, could anyone help me out with a overview on how
> can I call my working script on click of a button and download the files
> generated by the script.

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


Re: export sql query to excel

2018-04-16 Thread Larry Martell
I use xlsxwriter and I do it like this:

output = io.BytesIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True})
# write file
output.seek(0)
response = HttpResponse(output.read(),
content_type='application/ms-excel')
response['Content-Disposition'] = "attachment; filename=%s" % xls_name
return response

On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
> my code actually worked. I thought it was going to save the excel file to
> 'C:\excel' folder so i was looking for the file in the folder but i couldn't
> find the excel file. The excel file was actually exported to my django
> project folder instead.
>
> How to i allow the end user to be able to download the file to their desktop
> instead of exporting it to the server itself
>
>
>
> On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
>>
>> I wrote a function to export sql query to an excel file, but some how the
>> excel file wasn't created when the function was call. appreciate any
>> assistances
>>
>> here is my view.py
>>
>> def download_excel(request):
>> if "selectdate" in request.POST:
>> if "selectaccount" in request.POST:
>> selected_date = request.POST["selectdate"]
>> selected_acc = request.POST["selectaccount"]
>> if selected_date==selected_date:
>> if selected_acc==selected_acc:
>> convert=datetime.datetime.strptime(selected_date,
>> "%Y-%m-%d").toordinal()
>>
>> engine=create_engine('mssql+pymssql://username:password@servername /db')
>> connection = engine.connect()
>> metadata=MetaData()
>>
>> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>>
>> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>>
>> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>>
>> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>>
>> df = pd.read_sql(stmt,connection)
>>
>> writer = pd.ExcelWriter('C:\excel\export.xls')
>> df.to_excel(writer, sheet_name ='bar')
>> writer.save()
>>
>>
>
>
>
> --
>
> --
> 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-y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%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/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Prevent site from requiring new login

2018-04-03 Thread Larry Martell
I have a site that, once a user logs in I would like them to never get
logged out. I have set SESSION_COOKIE_AGE = sys.maxint but still,
after some amount of time (I don't know exactly how long, but it's
around 12 hours) the users get a login page. Is there a way to
accomplish this?

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


Re: Setting Django

2018-03-27 Thread Larry Martell
On Tue, Mar 27, 2018 at 9:37 PM, Benoit EVRARD  wrote:
> Hello, I'm new to this Django Framework. By the way, is it a Framework? I
> have no time to read all of the posts and tutos. Django seems to interpret
> python's coding am I right?

You have no time to read the tutorials, but we are supposed to find
time to help you?

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


Re: writing to my django website via a separate application

2018-03-26 Thread Larry Martell
On Mon, Mar 26, 2018 at 5:26 PM, Damon Branch  wrote:
> Hi,
> I'm developing a website which contains a database. I then need to be able
> to update that database from a separate python application like a desktop or
> mobile app.
> I am new to Django and fairly new to Python (few months).
> After reading the introductory materials I'm thinking the way to do this is:
>
> 1. Write the website application which can update database entries with a
> call like ' myModel.Create(info1='blah', info2='blah') '
> 2. Package this application/website into something like 'django-myWebsite'
> 3. In my other program/app import my package like 'from django-myWebsite
> import *'
> 4. Make calls to the website via my package like '
> myModel.Create(info1='blah', info2='blah') '
>
> Is this the right approach/will it work or is there a better way to do it?
> Also, are there any examples of accessing a django built website through
> another program?

A bit confused but your saying 'accessing a django built website'
through another program. Do you mean access the server? I do that, and
also access the database, all the time. I have stand alone python
scripts that access the server using python requests or instantiating
one of my server's objects the same way a request from the browser
would. And I have script that access the db, both using the ORM and
with embedded SQL.

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


Re: Syntax Error when trying to migrate to Postgresql

2018-02-14 Thread Larry Martell
On Wed, Feb 14, 2018 at 5:32 PM, Joe  wrote:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': ‘postgres’,
> 'USER': ‘postgres’,
> 'PASSWORD': ‘*’,
> 'HOST': ‘localhost’,
> 'PORT': ‘8000’,
> }
> }

Looks like the quotes around the values are some non ascii character.
On my screen I see this:

‘

Change it to ' or "

Did you copy/paste that from Word perhaps?

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


Re: Two command-line questions. How do I get a list of model names? How do I match a user-inputted string with a model name?

2018-01-18 Thread Larry Martell
import django.apps
django.apps.apps.get_models()

On Wed, Jan 17, 2018 at 8:31 PM, Tom Tanner
 wrote:
> I've got the following in `management/commands/my_command.py`:
>
> from django.core.management.base import BaseCommand, CommandError
> from django.conf import settings
>
> import os.path, csv
>
> from theme.models import *
>
> class Command(BaseCommand):
>   def handle(self, *args, **options):
>modelName= raw_input("Enter model name: ")
>print "you entered", modelName
>
>
> I want to show the user a list of all model names. I want to take the user's
> input and see if's an existing model. How do I do this?

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


reading binary from django.core.files.uploadedfile.TemporaryUploadedFile

2018-01-17 Thread Larry Martell
I have a django app that runs on both linux and windows. One request
that it processes contains PNG files encoded as an octet-stream on the
client. The server gets an object of type
django.core.files.uploadedfile.TemporaryUploadedFile and it does this
to save the files on disk:

with open(fn, 'wb') as fd:
fd.write(request.FILES[key].read())

When the server is running on linux this works perfectly - i.e. the
PNG files are saved to disk properly and can be opened and viewed. But
when the server is running in Windows the PNG files are corrupt when
saved. I don't really know why that is, but my WAG is that it's due to
the file being binary. I did try this but it still failed:

with open(request.FILES[key], 'rb') as fd:
data = fd.read()
with open(fn, 'wb') as fd:
   fd.write(data)

So perhaps that is not the issue.  Anyone have any idea on what could
be the issue and/or how I can debug this?

-- 
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/CACwCsY5NJYVFzk6ojf4zn%2Bi7%3Dqt-7%2BziLS4VoU-NxgGs5nhtuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Calculate Response Time

2017-12-22 Thread Larry Martell
I had a need for this as well, and here is what I did. I split each
request up into 4 parts: Query Time, Process Time, Render Time, and
Network Latency. On the server I have a class all my request handlers
subclass and inherit from. That class has a method for getting the
data from the db and a method for processing the data before sending
the response. The execution of those 2 are grossly timed like this:

start = time.time()
data = self.get_data()
self._query_time = time.time() - start

start = time.time()
processed_data = self.postprocess_data(data)
self._processing_time = time.time() - start

These values are written to the db, and the id of the row is sent in
the context as pull_id. (Also written to the table is the URL, the
user and the datetime.)

On the client side I use the PerformanceTiming module
(https://w3c.github.io/perf-timing-primer/). I have a base template
that all my templates extend from and that has this code:

var t = performance.timing;
var render_time = parseInt(t.loadEventEnd) - parseInt(t.responseEnd);
var network_latency = parseInt(t.responseEnd) - parseInt(t.fetchStart);
var pull_id = {{ pull_id }};
$.ajax({url: 'metrics/' + pull_id + '/' + render_time + '/' +
network_latency});

The metrics handler adds the render_time and network_latency to the
row that the server inserted.

And we have a URL that only admins can access that queries this
metrics table and we can see who ran what when and how long each took.

On Fri, Dec 22, 2017 at 2:08 AM, liewsw28  wrote:
> Hi,
>
> I wonder how to calculate a response time for an entire Django project from
> where the user input the search criteria until the information are loaded
> and displayed onto the page. Please advise.
>
> Thanks.
>
> --
> 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/2d6c71f1-ad71-42c9-8cda-5aef549bebd2%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/CACwCsY70AyYEhdaMaa1EwoU-W2uAx6YXDAmvEKikCR4TVwaDCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: print option with django application

2017-12-19 Thread Larry Martell
On Tue, Dec 19, 2017 at 1:50 AM, Ketul Suthar  wrote:
> I want to print data from database when user click on print button.
>
> how can I achieve it ?
>
> Is there any in-built module in djnago for printing data ?

You cannot force the user to print. What I do in these situations is
generate a pfd (with wkhtmltopdf) and then the user can print that.

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


Re: [OT] Is Trump planning to break the Internet?

2017-12-12 Thread Larry Martell
I did not read what I wrote on neither foxnews.com nor on telecoms.com
(the latter site I have never even heard of).

On Tue, Dec 12, 2017 at 8:14 AM, mccc  wrote:
> I agree with Matthew's sentiment;
>
> also, I'd like to point out that the words you (Larry) posted are not your
> own but are literally coming off of foxnews.com (found also on telecoms.com,
> by means of a "feature article" from a not-so-trustworthy consultancy
> group).
> I do agree that the topic and the approach to the issue are not adequate for
> the group, but your (Larry's) attempt to "gain the high ground" fell _very_
> short.
>
> All the best,
> Michele
>
> On Monday, December 11, 2017 at 3:52:51 PM UTC+1, larry@gmail.com wrote:
>>
>> On Mon, Dec 11, 2017 at 9:24 AM, Matthew Pava  wrote:
>> >>> Please keep your political rhetoric and irresponsible scaremongering
>> >>> off this list.
>> >
>> >>> All the net neutrality repeal will do is restore some of the
>> >>> permissionless innovation that allowed the internet to blossom in the 
>> >>> first
>> >>> place.
>> >
>> > Dear Larry,
>> > Please read what you just wrote.  On the one hand, you asked Etienne not
>> > to share political rhetoric, and then you called Etienne's act one of
>> > irresponsible scaremongering.  And then you had to have the last word in
>> > this discussion by sharing your own political rhetoric about the topic.
>> > That's not right, and I'm not going to sit by and let that happen.
>> >
>> > The better way to handle it would have been a personal message to
>> > Etienne asking that user not to post political rhetoric (in a nicer way 
>> > than
>> > you just did) and not make that message public.
>> >
>> > So here's an article about Net Neutrality:
>> > https://www.savetheinternet.com/net-neutrality-what-you-need-know-now
>>
>> That article is from freepress.net, a very far left, statist group,
>> that feels the government should regulate, control and tax every
>> aspect of your lives. We do not need more government regulation, we
>> need less. A free market is always better. Net Neutrality is
>> censorship, and it's crony capitalism.

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


Re: [OT] Is Trump planning to break the Internet?

2017-12-11 Thread Larry Martell
On Mon, Dec 11, 2017 at 9:24 AM, Matthew Pava  wrote:
>>> Please keep your political rhetoric and irresponsible scaremongering off 
>>> this list.
>
>>> All the net neutrality repeal will do is restore some of the permissionless 
>>> innovation that allowed the internet to blossom in the first place.
>
> Dear Larry,
> Please read what you just wrote.  On the one hand, you asked Etienne not to 
> share political rhetoric, and then you called Etienne's act one of 
> irresponsible scaremongering.  And then you had to have the last word in this 
> discussion by sharing your own political rhetoric about the topic.  That's 
> not right, and I'm not going to sit by and let that happen.
>
> The better way to handle it would have been a personal message to Etienne 
> asking that user not to post political rhetoric (in a nicer way than you just 
> did) and not make that message public.
>
> So here's an article about Net Neutrality:
> https://www.savetheinternet.com/net-neutrality-what-you-need-know-now

That article is from freepress.net, a very far left, statist group,
that feels the government should regulate, control and tax every
aspect of your lives. We do not need more government regulation, we
need less. A free market is always better. Net Neutrality is
censorship, and it's crony capitalism.

-- 
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/CACwCsY4ZgWEiKvdiAx%2B%2BCiVc6Wvj8%2BwX9-p-OpG9AxKqvq70TA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [OT] Is Trump planning to break the Internet?

2017-12-10 Thread Larry Martell
On Sun, Dec 10, 2017 at 5:24 PM, Etienne Robillard  wrote:
> Hey all,
>
> On December 14, the FCC will vote to repeal net neutrality and possibly rig
> the Internet. This means that major corporations could pay to have their
> content delivered faster while independent websites traffic would be
> throttled. I think this is a outrageous move and could seriously harm
> independent websites and communities from reaching their key audience. We
> must not let this happen!
>
> Please share the word with your peers. It is imperative that we must unite
> and act together to fight for our freedom of speech and prevent the Internet
> from becoming obsolete. The Internet is a brilliant technology allowing
> billions of people to share their knowledge independently. We must defend at
> all costs its very own foundations and protect it from censorship and
> tyranny!

Please keep your political rhetoric and irresponsible scaremongering
off this list.

All the net neutrality repeal will do is restore some of the
permissionless innovation that allowed the internet to blossom in the
first place.

-- 
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/CACwCsY6xLxfMMLA1te%2Bn0WD8AurqO-fQzp3j%2B-irasaT7EVY-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: is anybody in NYC?

2017-11-05 Thread Larry Martell
On Sun, Nov 5, 2017 at 5:01 PM, li qiongyao  wrote:
> is anybody in NYC?

No, everyone left.

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


Re: Big data

2017-09-29 Thread Larry Martell
I know it's not big by some standards, and we have done a lot of
tuning. Really more then speed issues, our larger issues are
administrative - we need 24x7 uptime and the tables are so large we
cannot do any alters as they take days to run. Similarly, a restore
can take a week. So we want to look at other dbs that could mitigate
those issues.

On Fri, Sep 29, 2017 at 5:25 AM, Avraham Serour <tovm...@gmail.com> wrote:
> That doesn't sound that big.
> Maybe you can tune mysql, but I have worked with postgres handling more than
> that, it works fine without tuning, I changed a couple of settings (like
> work_mem) and improved
>
> On Fri, Sep 29, 2017 at 4:48 AM, Larry Martell <larry.mart...@gmail.com>
> wrote:
>>
>> I am taking about using hbase as a db for Django. My use case is that a
>> have a Django app and the data in mysql has grown to the point where
>> performance has greatly suffered.
>>
>> We have around 2TB of data with some very wide tables with many millions
>> of rows. So I am beginning my research into how to improve performance.
>>
>> On Thu, Sep 28, 2017 at 9:41 PM Vivek Shrivastava
>> <vivshrivast...@gmail.com> wrote:
>>>
>>> Are you asking HBase as database for Django or accessing HBase from
>>> Django? The popular framework Hue http://gethue.com/ is based on Django
>>> only..
>>>
>>> On Thu, Sep 28, 2017 at 9:34 PM, Larry Martell <larry.mart...@gmail.com>
>>> wrote:
>>>>
>>>> Has anyone ever used any big data solutions, such as hbase, with django?

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


Re: Big data

2017-09-28 Thread Larry Martell
I am taking about using hbase as a db for Django. My use case is that a
have a Django app and the data in mysql has grown to the point where
performance has greatly suffered.

We have around 2TB of data with some very wide tables with many millions of
rows. So I am beginning my research into how to improve performance.

On Thu, Sep 28, 2017 at 9:41 PM Vivek Shrivastava <vivshrivast...@gmail.com>
wrote:

> Are you asking HBase as database for Django or accessing HBase from
> Django? The popular framework Hue http://gethue.com/ is based on Django
> only..
>
> On Thu, Sep 28, 2017 at 9:34 PM, Larry Martell <larry.mart...@gmail.com>
> wrote:
>
>> Has anyone ever used any big data solutions, such as hbase, with django?
>>
>

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


Big data

2017-09-28 Thread Larry Martell
Has anyone ever used any big data solutions, such as hbase, with django?

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


Re: best practices for location of start up code

2017-09-25 Thread Larry Martell
On Sat, Sep 23, 2017 at 6:21 PM, Antonis Christofides
<anto...@djangodeployment.com> wrote:
> Hello Larry,
>
> The Django development server runs in more than one thread, which is probably
> why your initialization code run twice.
>
> OTOH, it run only once on production probably because you have configured 
> uwsgi
> to run only one process (it's possible that this is the default on single-core
> machines). However, we usually want to run at least two processes.

I have 5 uwsgi processes - I was only seeing the init code run once
because I was just sending uwsgi a reload signal. If I killed it and
restarted it I was seeing the init code run 5 times.

> Running initialization code only once per wsgi server (re)start instead of 
> once
> per process start seems a bit strange. Why do you need this?

I had not been given all the requirements. Turns out what we need to
do should not be part of the server init, so we moved it somewhere
else.

> On 2017-09-23 21:50, Larry Martell wrote:
>> On Sat, Sep 23, 2017 at 2:39 PM, Larry Martell <larry.mart...@gmail.com> 
>> wrote:
>>> On Sat, Sep 23, 2017 at 1:34 PM, James Schneider
>>> <jrschneide...@gmail.com> wrote:
>>>>
>>>> On Sep 22, 2017 2:58 PM, "Larry Martell" <larry.mart...@gmail.com> wrote:
>>>>
>>>> We have some code we want to run 1 time when our django app is
>>>> started. What is the best place for this? I tried putting it in my
>>>> app's config function, but from there I get:
>>>>
>>>> *** AppRegistryNotReady: Apps aren't loaded yet.
>>>>
>>>>
>>>> Once as in only when the app is initially deployed, or once every time the
>>>> web server process is started?
>>>>
>>>> Note that if you place code to run every time the web process is started,
>>>> that it will run for every process, and most web servers spawn multiple
>>>> processes.
>>> I'm looking to run it once when the web server is started (not each
>>> time another process of the web server is started)
>> I am using nginx and uwsgi. I tried experimenting with Antonis
>> Christofides suggestion of using AppConfig.ready(). That seems to get
>> called just once when I start (or restart uwsgi). I tried many
>> connections to the server from different browsers and computers, but
>> still that was only called once. Is that something I can count on?
>>
>> Note, when running the devel django server it was called twice at
>> start up, but when the 'real' server it was only called once. Anyone
>> know why I got the 2 calls here?

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


Re: best practices for location of start up code

2017-09-23 Thread Larry Martell
On Sat, Sep 23, 2017 at 2:39 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> On Sat, Sep 23, 2017 at 1:34 PM, James Schneider
> <jrschneide...@gmail.com> wrote:
>>
>>
>> On Sep 22, 2017 2:58 PM, "Larry Martell" <larry.mart...@gmail.com> wrote:
>>
>> We have some code we want to run 1 time when our django app is
>> started. What is the best place for this? I tried putting it in my
>> app's config function, but from there I get:
>>
>> *** AppRegistryNotReady: Apps aren't loaded yet.
>>
>>
>> Once as in only when the app is initially deployed, or once every time the
>> web server process is started?
>>
>> Note that if you place code to run every time the web process is started,
>> that it will run for every process, and most web servers spawn multiple
>> processes.
>
> I'm looking to run it once when the web server is started (not each
> time another process of the web server is started)

I am using nginx and uwsgi. I tried experimenting with Antonis
Christofides suggestion of using AppConfig.ready(). That seems to get
called just once when I start (or restart uwsgi). I tried many
connections to the server from different browsers and computers, but
still that was only called once. Is that something I can count on?

Note, when running the devel django server it was called twice at
start up, but when the 'real' server it was only called once. Anyone
know why I got the 2 calls here?

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


  1   2   3   4   5   6   >