Re: Problems sending email with django

2022-06-09 Thread Roger Gammans
Hi

I've used mailjet in a Django app.

Both using the rest API with requests, ( for our transactional mails )and via 
authenticated SMTP for our error alerts.

I don't recall any specific challenges on the Django side , although setting up 
domain vaith was a bit more involved iirc.

Are you having a specific problem you can share?

Thanks

On 8 June 2022 10:23:47 BST, Israel Akinoso  wrote:
>Please is there anyone who has integrated mailjet into their django 
>project, I really need  guidance
>
>-- 
>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/75a6b1d9-a0da-489b-a8b4-785ddcd64f21n%40googlegroups.com.

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
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/F0BF5BE7-A982-488D-8097-31ADC113C2E1%40gammascience.co.uk.


Re: ComboBox

2022-06-01 Thread Roger Gammans
Hi
If any arbitrary text is allowable, then at the model level I'd just
use a CharField.  I wouldn't add a choices= argument to the
field  unless is the value is strictly constrained to those choice as
other test would then fail validation.
At the Form level, I'm not sure. I'd probably work just mirror what the
frontend needed.
Does that help ?
On Tue, 2022-05-31 at 09:52 -0700, Phil Parkin wrote:
> Hi all
> 
> I am converting a desktop application to Django web application. The
> desktop app uses comboboxes (editable dropdown/select). Is their any
> elegant way of applying the same functionality in Django? Stack
> Overflow etc. all seem to be about dropdown select lists only.
> 
> I can see ways of doing this with a Choicefield plus a separate
> Charfield, but is there a better way?
> 
> Thanks -Phil 
> 
> 
> 
> 
> -- 
> 
> 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/1b7836ae-e52e-4e35-aefc-739ce6f586d0n%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/dc6c158253e6f6bfd4e0f7b3d523817f7a46f150.camel%40gammascience.co.uk.


Re: HTTPS on development enviroment

2022-01-05 Thread Roger Gammans
On Wed, 2022-01-05 at 06:36 -0800, Gwanghyeon Gim wrote:
> Can this help? https://stackoverflow.com/a/28933593/1179076
> Some browsers might keep you from even entering due to strict
> security, so try different browers if that's the case i.e firefox.
> 
> On Saturday, 1 January 2022 at 09:12:10 UTC+9 nassibs...@gmail.com
> wrote:
> > I have started using Django and I wanted to integrate social
> > authentication with Google so i had to create self certificates
> > using django_extensions so i test the the authentication with https
> > but when i open localhost it keeps loading without showing the
> > results
> 
> 

You might find mkcert ( https://github.com/FiloSottile/mkcert ), and
easier and potentially safer way to create and managetemporary
developer certs. 
obDNA: Certainly better than all that tedious mucking around with
openssl.-- Roger Gammans 
Gamma Science (Reg Nr: 07356014)


-- 
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/e9c08a05ac6f58e87d44876d55d62ef6a63db6ba.camel%40gammascience.co.uk.


Re: Aide pour erreur

2021-06-10 Thread Roger Gammans
Hi
My french isn't great, and this list mostly uses English, so you'll
probably get a better response if you can post in English even if you
resort to google translate (like I have below )  but I think the intent
of your email was clear.
Your error was "view stocksystema.views.home didn't return an
HttpResponse object. It returned None instead." is pretty much to the
point views - need to return a Response object which contains as the
response HTML , or status etc. (ie. anything which goes to the browser)
you either returned 'None', or possible fell out of the bottom of the
function without a return value - which python interprets as None.
--- (en Francais via Google)
Mon français n'est pas génial, et cette liste utilise principalement
l'anglais, donc vous obtiendrez probablement une meilleure réponse si
vous pouvez poster en anglais même si vous recourez à google translate
(comme ci-dessous) mais je pense que l'intention de votre e-mail
C'était clair. 


Votre erreur était "view stocksystema.views.home n'a pas renvoyé
d'objet HttpResponse. Il a renvoyé None à la place." est à peu près au
point que les vues ont besoin de retourner un objet Response qui
contient comme réponse HTML , ou status etc. (c'est-à-dire tout ce qui
va au navigateur) vous avez soit retourné 'Aucun', soit peut-être tombé
du bas du fonction sans valeur de retour - que python interprète comme
None.
HTH, TTFN
On Thu, 2021-06-10 at 07:32 -0700, Dieu merci Dramani wrote:
> Bonjour tous !Je suis nouveau en django-python et j'apprends.
> voici le fichier contenant le sms d'erreur. 
> 
> 
> 
> -- 
> 
> 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/15b87f54-afa1-4f01-9e6e-a496fe0fa81fn%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/4f6a93fd9ea54cf89843df0af798ee8fbb8741da.camel%40gammascience.co.uk.


Re: Unique and null

2021-04-08 Thread Roger Gammans
On Thu, 2021-04-08 at 16:36 -0500, Ryan Nowakowski wrote:
> On Wed, Apr 07, 2021 at 03:25:53PM +0100, Roger Gammans wrote:
> > This is mostly (form the Django perspective) and issue with
> > CharFields,
> > because a CharField can store None or ''.  For values of ''
> > in  CharField, IIRC, django will convert them to null, with
> > null=True,
> > blank=True. But not with blank=True,null=False.See also : 
> > https://docs.djangoproject.com/en/3.1/ref/models/fields/#null
> 
> I read the documentation a bit differently.  My interpretation is
> that
> CharField(null=True) means that both ''(empty string) and None(null)
> are
> valid values.  But no implicit conversion from '' to None takes
> place.
> 
> CharField(null=False) means that None(null) isn't a valid value and
> that
> only ''(empty string) is permitted.

I understand that reading, and the simple answer is we are both right!

See:
https://github.com/django/django/blob/45a58c31e64dbfdecab1178b1d00a3803a90ea2d/django/db/models/fields/__init__.py#L1082

This shows the model field telling the any auto creating form field, 
say like in the admin model, which value to prefer 'empty' values. 

Since it's not the model field, so any python code which saves '' and
None, directed onto the model will still have those respected as '' and
NULL.

-- 
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/2d0608b7d8c120af35d98c194659de1f89fafd08.camel%40gammascience.co.uk.


Re: Unique and null

2021-04-07 Thread Roger Gammans
I should have said SQL specifies NULL compares Non-equal, the ORM
converts None's in python to NULL in SQL for you, as well as all the
other things it does
On Wed, 2021-04-07 at 15:25 +0100, Roger Gammans wrote:
> Hi All,
> Let shed some actually light on the whole problem, before people
> start piling in.
> This is mostly (form the Django perspective) and issue with
> CharFields, because a CharField can store None or ''.  For values of
> '' in  CharField, IIRC, django will convert them to null, with
> null=True, blank=True. But not with blank=True,null=False.See also : 
> https://docs.djangoproject.com/en/3.1/ref/models/fields/#null
> So if it stores '', (with null=False) then the uniqueness should work
> as expected. 
> It is should (rather than will), because Django relies on
> the  backend Database to enforce the constraints, so will depend on
> the level of conformance the Backend Db has.
> Now SQL Specifies that two variables (or a literal and a field) which
> are None will ALWAYS compare as non-equal, and this stackoverflow ( 
> https://stackoverflow.com/questions/767657/how-do-i-create-a-unique-constraint-that-also-allows-nulls/767702#767702
> ) states the same concept holds for uniqeness .
> SQLite, MySQL, Postgres all work, like this, but SQL Server
> apparently doesn't.
> There's quite a bit there; but I hope it helps and isn't too
> confusing.
> On Wed, 2021-04-07 at 06:05 -0700, Derek wrote:
> > Are you using MySQL?
> > https://stackoverflow.com/questions/371/does-mysql-ignore-null-values-on-unique-constraints
> > 
> > 
> > On Wednesday, 7 April 2021 at 08:07:35 UTC+2 Mike Dewhirst wrote:
> > > I have just made a CharField unique and Django detects duplicates
> > > nicely 
> > > 
> > > but seems to ignore multiple instances where the field value is
> > > null.
> > > 
> > > 
> > > 
> > >  arn = models.CharField(
> > > 
> > >  max_length=MEDIUM,
> > > 
> > >  unique=True,
> > > 
> > >  null=True,
> > > 
> > >  blank=True,
> > > 
> > >  )
> > > 
> > > 
> > > 
> > > Is this correct behaviour?
> > > 
> > > 
> > > 
> > > 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/2a82e569667b2d2052614e15ba1b3ae8592a5734.camel%40gammascience.co.uk.


Re: Unique and null

2021-04-07 Thread Roger Gammans
Hi All,
Let shed some actually light on the whole problem, before people start
piling in.
This is mostly (form the Django perspective) and issue with CharFields,
because a CharField can store None or ''.  For values of ''
in  CharField, IIRC, django will convert them to null, with null=True,
blank=True. But not with blank=True,null=False.See also : 
https://docs.djangoproject.com/en/3.1/ref/models/fields/#null
So if it stores '', (with null=False) then the uniqueness should work
as expected. 
It is should (rather than will), because Django relies on the  backend
Database to enforce the constraints, so will depend on the level of
conformance the Backend Db has.
Now SQL Specifies that two variables (or a literal and a field) which
are None will ALWAYS compare as non-equal, and this stackoverflow ( 
https://stackoverflow.com/questions/767657/how-do-i-create-a-unique-constraint-that-also-allows-nulls/767702#767702
) states the same concept holds for uniqeness .
SQLite, MySQL, Postgres all work, like this, but SQL Server apparently
doesn't.
There's quite a bit there; but I hope it helps and isn't too confusing.
On Wed, 2021-04-07 at 06:05 -0700, Derek wrote:
> Are you using MySQL?
> https://stackoverflow.com/questions/371/does-mysql-ignore-null-values-on-unique-constraints
> 
> 
> On Wednesday, 7 April 2021 at 08:07:35 UTC+2 Mike Dewhirst wrote:
> > I have just made a CharField unique and Django detects duplicates
> > nicely 
> > 
> > but seems to ignore multiple instances where the field value is
> > null.
> > 
> > 
> > 
> >  arn = models.CharField(
> > 
> >  max_length=MEDIUM,
> > 
> >  unique=True,
> > 
> >  null=True,
> > 
> >  blank=True,
> > 
> >  )
> > 
> > 
> > 
> > Is this correct behaviour?
> > 
> > 
> > 
> > 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/2b5b6c7e1fe015bb1e8c4f28ded77e70cd3ae988.camel%40gammascience.co.uk.


Re: Python libraries for visualisations

2021-03-15 Thread Roger Gammans

Plotly comes to mind. there are quite a few charting libraries in this
python/web space. Google is as always your friend.
But at the end of the day the best UX is always going to come from a
library with a significant JS component. If you don't want to worry to
much about JS plotly's py component will generate the JS/JSON
definitions of the graphs, which you can ship , alongside plotly's
js  to thee browser.
On Mon, 2021-03-15 at 12:38 +0530, GEETHANJALI S P wrote:
> Can't we use python libraries instead of chart.js ...is there any
> method ..? 
> 
> On Mon, 15 Mar, 2021, 10:26 AM Omkar Parab, 
> wrote:
> > You can integrate chart.js with Django for visualization.
> > Check out this video 
> > https://youtu.be/B4Vmm3yZPgc
> > 
> > 
> > On Mon, Mar 15, 2021, 10:19 AM GEETHANJALI S P <
> > geethanjalisp1...@gmail.com> wrote:
> > > Hi..How to build a dashboard using django and python libraries
> > > for creating visualisations?. Please let me know .Thanks in
> > > advance!
> > > 
> > > 
> > > 
> > > -- 
> > > 
> > > 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/CAMKAcO%2BJqqp0kYMbWaWqjqJDcmMT9xMndv%3DD%2BNHbtYBvqL9CQg%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/0f5b1639f95ff25d7176244a7fa6d377e0f49902.camel%40gammascience.co.uk.


Re: Having problem with a api data

2020-10-10 Thread Roger Gammans
This is really a JavaScript question not a Django one.

But since I can see the problem...  ,

The issue is 'dissmal-info' isn't a valid Js identifier, the browser is trying 
to subtract the nonexistent 'info' variable from the 'dismissal' value. You 
should be able to use ['dismissal-info'] instead of . dismissal-info.







On 10 October 2020 07:19:06 BST, surendra bhaskar 
 wrote:
>*I am able to get all data from api but  not able to get certainvalues
>which have - in between of 2 words*
>"dismissal": "catch",
>"SR": 120,
>"6s": 0,
>"4s": 2,
>"M": 0,
>"B": 10,
>"R": 12,
>"dismissal-info": "c Curran b Chawla", <== this type is not
>working
>"batsman": "RG Sharma (c)",
>"pid": "34102"
>
>
>* Trying this code to get data  *
> document.write(JSON.stringify(data.data.fielding[0].scores[0].SR)) <==
>working
> document.write(JSON.stringify(data.data.batting[0].scores[0].batsman))
><== working
>document.write(JSON.stringify(data.data.batting[0].scores[0].dismissal))
><== working
>
>document.write(JSON.stringify(data.data.batting[0].scores[0].dismissal-info))
><==showing  info is not defined
>*I am tried with a lot but finally failed to get this type of data so
>can
>you pls help me out *
>[image: image.png]
>*Thank You,*
>*Surendra Ediga*

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
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/FAD1747A-1EFB-4CFA-9F25-DFA7BB9EDA17%40gammascience.co.uk.


Re: Django key/value JSON widget

2020-08-19 Thread Roger Gammans
Hi
Thanks that looks useful.
On my rather long TODO list is to turn use this (
https://github.com/josdejong/jsoneditor) npm package to build a less
restrictive json widget...
On Mon, 2020-08-17 at 14:42 -0700, Federico Capoano wrote:
> Since I wasn't able to find a package which had this kind of widget,
> I scratched my own itch and published django-flat-json-widget.I hope
> it will be useful to others as well, I included a gif that shows the
> widget in action.
> Best regardsFederico CapoanoOn Wednesday, July 22, 2020 at 1:34:01 PM
> UTC-5 Federico Capoano wrote:
> > Hey everyone,
> > I'm looking for a key/value widget to edit a JSON flat object, like
> > this widget here: 
> > https://django-hstore.readthedocs.io/en/latest/#django-admin-widget
> >  (I made this one a while ago, but I'm not maintaining that project
> > anymore).
> > 
> > But I'm having no luck in finding it, there must already be some,
> > right?
> > 
> > Thanks in advance
> > Federico
> 
> 
> 
> -- 
> 
> 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/27e1347b-6a17-4892-8ca8-736bcc6c6c27n%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/7d793f9092350ba994ecc6be5bf03e073a75a134.camel%40gammascience.co.uk.


Re: Invalid SQL : - Re: Query Optimization (Huge Data in the Database)

2020-07-19 Thread Roger Gammans
Hi 
I do appreciate what I was asking about wasn't your problem, I was
looking at learning  for myself etc.
For those that are following this, it seems that Postgres (as does
MySQL) loosens the SQL requirements. In Postgres  ( 
https://www.postgresql.org/docs/11/sql-select.html#SQL-GROUPBY ) the
rule is:
When GROUP BY is present, or any aggregate functions are present, it is
not valid for the SELECT  list expressions to refer to ungrouped
columns except within aggregate  functions or when the ungrouped column
is functionally dependent on the  grouped columns, since there would
otherwise be more than one possible  value to return for an ungrouped
column. A functional dependency exists  if the grouped columns (or a
subset thereof) are the primary key of the  table containing the
ungrouped column.

Which is what we are seeing here. In django the postgres backend has a
feature set so that the django SQL compiler knows that postgres can
accepts simplified GROUP BY clauses. 
Actually I've simplified this a little as there are two seperate
bits  (  allows_group_by_pk, andself.allows_group_by_selected_pks)  for
different type of simplification, and a backend helper function.
Thank you for that fascinating excursion.
On Sun, 2020-07-19 at 07:48 -0700, karthik challa wrote:
> Hi Roger,
> 
> I have fetched this query from the Django Debug tool bar. I am using
> POSTGRES database and Django 2.2.3 version.
> 
> I am able to fetch the records which i require but the issue is with
> the performance the django query set or the query which i am making.
> 
> 
> Thanks & Regards,karthik
> 
> On Sunday, July 19, 2020 at 7:01:28 AM UTC-4, Roger Gammans wrote:
> > Hi 
> > 
> > Just a side issue I spotted here, but I'm probably missing
> > something, so I'm seeking to understand.
> > 
> > Is this the SQL the django query builder made? If so which database
> > backend and django version are you using?
> > 
> > On Sun, 2020-07-19 at 08:30 +0100, Damanjeet Singh wrote:
> > > 2>SQL Query 
> > > 
> > > SELECT "urls_subdomain"."id", "urls_subdomain"."created_at",
> > > "urls_subdomain"."name", COUNT("urls_url"."id") AS "numItems"
> > > FROM "urls_subdomain" LEFT OUTER JOIN "urls_url" ON
> > > ("urls_subdomain"."id" = "urls_url"."subdomain_id") GROUP BY
> > > "urls_subdomain"."id" ORDER BY "urls_subdomain"."name" ASC
> > 
> > I only ask because normally in SQL the rule  is "However, each
> > table or view column in any nonaggregate expression in the
> >   list must be included in the GROUP BY list" (quote from
> > MS TSQL docs which was just the first hit my google search found) .
> > And the name and create_at columns are missing in the GROUP BY
> > clause in the quoted SQL statement.
> > 
> > It seems unlikely that Django is generating invalid SQL as we would
> > have seen more issues (although the intent of the SQL expression
> > above is clear, and I have met engines which can execute it fine)
> > 
> > TTFN
> > -- 
> > Roger Gammans 
> > 
> > 
> 
> 
> 
> -- 
> 
> 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/8ab2bcac-7f72-45e4-82c2-10f9cad5d8e2o%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/036a70854c81a80d0a9e2599433538556ba39e2b.camel%40gammascience.co.uk.


Invalid SQL : - Re: Query Optimization (Huge Data in the Database)

2020-07-19 Thread Roger Gammans
Hi 

Just a side issue I spotted here, but I'm probably missing something,
so I'm seeking to understand.

Is this the SQL the django query builder made? If so which database
backend and django version are you using?

On Sun, 2020-07-19 at 08:30 +0100, Damanjeet Singh wrote:
> 2>SQL Query 
> 
> SELECT "urls_subdomain"."id", "urls_subdomain"."created_at",
> "urls_subdomain"."name", COUNT("urls_url"."id") AS "numItems" FROM
> "urls_subdomain" LEFT OUTER JOIN "urls_url" ON ("urls_subdomain"."id"
> = "urls_url"."subdomain_id") GROUP BY "urls_subdomain"."id" ORDER BY
> "urls_subdomain"."name" ASC

I only ask because normally in SQL the rule  is "However, each table or
view column in any nonaggregate expression in the
  list must be included in the GROUP BY list" (quote from MS
TSQL docs which was just the first hit my google search found) . And
the name and create_at columns are missing in the GROUP BY clause in
the quoted SQL statement.

It seems unlikely that Django is generating invalid SQL as we would
have seen more issues (although the intent of the SQL expression above
is clear, and I have met engines which can execute it fine)

TTFN
-- 
Roger Gammans 

-- 
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/58c1572c4c40a5fca010d2b3dd345bb1b65b79d0.camel%40gammascience.co.uk.


Re: DB Router default issue

2020-07-14 Thread Roger Gammans
In allow_migrate () where you have 'return False', I've ended up (in my
otherwise very similar router) with:
return db != 'mydb'
You certainly don't want return False as that will disable all
migrations outside of your app_label, you want to return True,only in
the cases when the db is not your one; so everything else flows
normally.  But globally returnning False disables the  migrations in
the normal case as you have found.
There are some awkward corner cases ; around mutli databases; some of
which are probably a bug - (for instance  - all migrations whether
relevant or not are recorded in both databases)  But I don't think
that's your problem here.

On Tue, 2020-07-14 at 09:35 -0700, JJ Zolper wrote:
> Has anyone experienced this same thing? Anyone have a lot of
> experience working with multiple databases using a router? It's just
> a little unclear how I'm supposed to better control it.
> 
> On Friday, July 10, 2020 at 12:03:46 PM UTC-4, JJ Zolper wrote:
> > Hello, I am trying to prevent models in my api app from migrating
> > into the default database but I'm confused about the router. It
> > seems every time I run migrate even with the router it continues to
> > migrate.
> > 
> > #apps.pyfrom django.apps import AppConfig
> > 
> > class ApiConfig(AppConfig):
> > name = 'api'
> > label = 'api'
> > 
> > 
> > #settings.pyDATABASE_ROUTERS =
> > ['myproject.dev_db_router.APIRouter',]
> > 
> > DATABASES = {
> > 'default': {
> > 'ENGINE': 'django.db.backends.sqlite3',
> > 'NAME': os.path.join(BASE_DIR, 'default.sqlite3'),
> > },
> > 'mydb': {
> > 'ENGINE': 'django.db.backends.sqlite3',
> > 'NAME': os.path.join(BASE_DIR, 'mydb.sqlite3'),
> > },
> > }
> > 
> > #dev_db_router.pyclass APIRouter:
> > """
> > A router to control all database operations on models in the
> > api application.
> > """
> > route_app_labels = {'api',}
> > 
> > def db_for_read(self, model, **hints):
> > """
> > Attempts to read api models go to mydb.
> > """
> > if model._meta.app_label in self.route_app_labels:
> > return 'mydb'
> > return False
> > 
> > def db_for_write(self, model, **hints):
> > """
> > Attempts to write api models goes to mydb.
> > """
> > if model._meta.app_label in self.route_app_labels:
> > return 'mydb'
> > return False
> > 
> > def allow_migrate(self, db, app_label, model_name=None,
> > **hints):
> > """
> > Make sure the api app only appears in the
> > 'mydb' database.
> > """
> > if app_label in self.route_app_labels:
> > return db == 'mydb'
> > return False
> > I've tried:
> > python manage.py migrate --database=default
> > 
> > python manage.py migrate
> > 
> > etc and every time it says:
> > 
> >   Applying api.0001_initial... OK
> > 
> > Even though I told it False if it does not meet the case of db ==
> > 'mydb'. I can specify 'mydb' and it says it works:
> > python manage.py migrate --database=mydb
> > but my concern is it always migrates into default even when I'm
> > trying to tell it not to. In the future there will be models I do
> > want to migrate into default, but not these in the api app. Based
> > on the documentation I'm doing everything correctly.
> > What am I not understanding?
> > Thank you.
> > Best,
> > JJ
> 
> 
> 
> -- 
> 
> 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/1c50646c-6fbe-4d47-84f1-1250e4c515a1o%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/5c1bce32a9b2fe32fbc4fb5cc5c25ab985fdf28e.camel%40gammascience.co.uk.


Re: Confused...Django vs Django CMS/Wagtail and value of 'CMS' vs plain Django framework?

2020-06-08 Thread Roger Gammans
Hi
Move Wagtail and and Django-CMS are applications you install in your
INSTALLED_APPS  setting  settings.py to add CMS functionality to  a
Django project, so you can use these applications as you only app
in  django projects, or alongside your own custom apps, or other
downloaded apps.
Django cms add some middlewares ( Eg, lines in the MIDDLEWARE setting)
as it needs to be able to inject the editting tools if you've got the
appropriate permissions. I'm not sure of the top of my head about
wagtail. But in principle you can either to any django project by
imported them and and making the relevant changes to settings.py
The use case for Django without a CMS, is exactly that, you don't need
CMS functionality.
On Sat, 2020-06-06 at 21:20 -0700, fire base wrote:
> I have been learning and building a Django framework website and it
> is going nicely. The site will be used internationally but largely is
> a series of specialized forms collecting and manipulating and
> outputting data to be searched - not presenting changing  'content'
> per se. 
> 
> I had seen references to Wagtail and now Django CMS is there any
> reason why I should switch to Django CMS vs just continue building in
> Django framework? 
> 
> If there are good reasons to refactor/switch, can I simply import
> models/views/urls/forms, or some such, into Django CMS or Wagtail?
> 
> Can I add middleware to turn Django into Django CMS?
> 
> What are the Use Cases for Django framework that put it over a 'CMS'?
> 
>  I have searched extensively but not found answers to these qs...
>  
> 
> Many 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e942381f-e48e-411a-8de4-633e524581cdo%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/1c12359ecfa4aff9ce6f8b99d510661d9bd357d2.camel%40gammascience.co.uk.


Re: Using external libraries for analytics

2020-04-13 Thread Roger Gammans
On Mon, 2020-04-13 at 13:59 -0700, 'MH' via Django users wrote:
> d to create some kind of dashboard for myself. So I googled some
> applications of django for analytical dashboards and they proposed
> things like highcharts. From what I read I got the impression that I
> would use external sources and as if I would transmit data to other
> sites (e.g. 
> https://www.highcharts.com/blog/tutorials/create-a-dashboard-using-highcharts-and-django/
> ). But perhaps I misunderstood that.
> 

Plotly is one good alternative. There however are many Python based
visualisation libraries tuned for use with Jupyter, it shouldn't be to
difficult to use them with django. Plotly can defiantly be used as a
all local library (but don't confuse it with dash ), although it does
or did have online alternates.

If you are conformable doing more at the frontend there are quite a few
js visualisation tools (often based on d3), restricting myself to just
the open source ones, I can find/know about  nvd3js, dygraphs,
chart.js, n3-charts, c3  and more.

There are many alternatives and it can definitely be done a) open
source, and b) without uploading the data to a third party.


-- 
Roger Gammans 

-- 
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/329b39f6dec92ee7dc155b9ea91e87c0179aaa7d.camel%40gammascience.co.uk.


Re: font awesome loading problem

2020-04-09 Thread Roger Gammans
Hi,
that looks like it's your s3 bucket setup. s3 is not supporting the
CORS (cross-origin -request-security) check requests the browser is
making.
I googled "s3 bucket cors" and found this which looks like in contains
the answers  you are looking for.
https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html

On Thu, 2020-04-09 at 11:56 +0530, Soumen Khatua wrote:
> Hi Folks,
> I'm using AWS S3 bucket for my django project,now I want to serve all
> the sattic files using this s3 bucket. So I copied all the all
> static file from CDN and websites to my S3 bucket.All are working
> fine for font-awesome I'm getting some error like:
> 
> Access to font at '
> https://xyz.s3.amazonaws.com/static/css/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0'
> from origin 'http://127.0.0.1:8000' has been blocked by CORS policy:
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource.  
> 
> I spent  almost 1day to solve this probem and still I don't now How
> to solve it??
> Please help me guys regarding this issue.
> 
> Thank you in advance
> 
> Regards,
> Soumen
> 
> Note: All error are here
> 
> Access to font at '
> https://xyz.s3.amazonaws.com/static/css/font-awesome/fonts/fontawesome-webfont.woff?v=4.7.0'
> from origin 'http://127.0.0.1:8000' has been blocked by CORS policy:
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource.
> 
> 
> GET 
> https://xyz.s3.amazonaws.com/static/css/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0
> net::ERR_FAILED
> ?m=conversations=sql:945 1
> 
> 
> GET 
> https://xyz.s3.amazonaws.com/static/css/font-awesome/fonts/fontawesome-webfont.woff?v=4.7.0
> net::ERR_FAILED
> 
> Access to font at '
> https://xyz.s3.amazonaws.com/static/css/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0'
> from origin 'http://127.0.0.1:8000' has been blocked by CORS policy:
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> 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/CAPUw6WaCrSjdH7%2B0Ng1Wh_s5%2BAxH-7ike1Y9ntcwzUfQYqoOGw%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/afe19e8fa540993d3af8458cfedd3f1a55c9228a.camel%40gammascience.co.uk.


Re: [django-channels] How to close websocket connection from server?

2020-04-06 Thread Roger Gammans
You don't have to send the messages all the way to the client
(browser), you can handle them directly in the consumer still on the
serverside.
As far as I know you'll have to keep track of metadata like all users
connections yourself, but you have the connect(), disconnect() method
pair to put your tracking code into.
On Mon, 2020-04-06 at 05:36 -0700, krnrrr wrote:
> thank you for the help.
> I need to try it out. i think it's more down the "tell-clients-to-
> tell-me-to-close" route which i wanted to escape.
> however, i still don't understand how i can get ALL connections of a
> user knowing only his token.
> 
> i mean, when i have an event in the system, i want to notify a user
> about - i KNOW which group I must send it to, so it's up to client to
> consume this message. I did all I should - sent it. And now it's like
> vice versa - I must learn which group to send message to, knowing
> only a recipient ID.
> 
> I imagined it as like in django admin view there could be a page at
> UserAdmin: "close all websockets for this user" - in such case we
> have a manage.py command, or any random view which knows nothing
> about clients-communicatiors. only about a user, whose connections
> must be closed.
> 
> maybe, you're right, and i'm thinking about it the wrong way
> 
> On Monday, 6 April 2020 15:28:44 UTC+4, Roger Gammans  wrote:
> > I think you are looking at it from the wrong direction.
> > Think about it in terms of consumers/connections, not in terms of
> > users,and in terms of send receiving events.
> > When in your consumers connect method, you subscribe
> > (eg  self.channel_layer.group_add() ) to add appropriate group to
> > send user global messages. One of those messages is close. Then you
> > just need to send the close message, and make sure you have code to
> > close the connection at each subscriber. The group doesn't matter
> > you had use any which doesn't conflict, you might even be able to
> > use one of your exisiting groups.  Although are they the Redis
> > names? I would avoid delving under the hood with channel_layers and
> > poking redis directly - unless your creating you own keys.
> 
> 
> 
> -- 
> 
> 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/cb1b8bbc-dc9c-4cdc-a45c-9c30ed871cd8%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/16b7c749df844d13fd186daf69d91276a0cc451b.camel%40gammascience.co.uk.


Re: [django-channels] How to close websocket connection from server?

2020-04-06 Thread Roger Gammans
I think you are looking at it from the wrong direction.
Think about it in terms of consumers/connections, not in terms of
users,and in terms of send receiving events.
When in your consumers connect method, you subscribe
(eg  self.channel_layer.group_add() ) to add appropriate group to send
user global messages. One of those messages is close. Then you just
need to send the close message, and make sure you have code to close
the connection at each subscriber. The group doesn't matter you had use
any which doesn't conflict, you might even be able to use one of your
exisiting groups.  Although are they the Redis names? I would avoid
delving under the hood with channel_layers and poking redis directly -
unless your creating you own keys.
The channel dos say you should be able to get the users out of
self.scope, exactly where will depend on your auth middleware, but
probably self.scope['user']
self.channel_layer.group_send(group, {type: 'close'}) , almost does the
same as your loop to all the consumers in the group, but it might be
better to call your own sub method (if for no other reason than close()
doesn't normally take a event object as a argument)

On Mon, 2020-04-06 at 04:07 -0700, krnrrr wrote:
> well, how I see it:
> 
> - a user can subscribe to any amount of groups during the lifecycle
> of his JWT
> - how can I get a list these groups in the first place? so to be able
> to "send a message to an appropriate group"?
> 
> I thought there's a way to decode JWT, get user ID from it and then
> somehow:
> 
> channels = get_channel_layer():
> for ws in channels.get_connections_for_user(user_id):
> ws.close()
> 
> but i couldn't find a way
> On Monday, 6 April 2020 14:36:46 UTC+4, Roger Gammans  wrote:
> > Don't you just have to send a message to an appropriate group which
> > contains just that users/sessions connections/consumers and in the
> > message handler on the consumer call  'self.close()' and remove the
> > consumer from any subscriptions. 
> > If I understand the docs, in the disconnect method is still called
> > so can do it there, and should be anyway. (Although it doesn't hurt
> > to do it twice group_discard() is defined a s NOOP if the
> > consumer's unique channel  isn't in the group)
> > Or have I missed something,?
> 
> 
> 
> -- 
> 
> 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/5673c750-b428-4ffd-87c8-7de10f19ba6e%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/87e250928689bb9eefbc470af2446dfdee584597.camel%40gammascience.co.uk.


Re: [django-channels] How to close websocket connection from server?

2020-04-06 Thread Roger Gammans
Don't you just have to send a message to an appropriate group which
contains just that users/sessions connections/consumers and in the
message handler on the consumer call  'self.close()' and remove the
consumer from any subscriptions. 
If I understand the docs, in the disconnect method is still called so
can do it there, and should be anyway. (Although it doesn't hurt to do
it twice group_discard() is defined a s NOOP if the consumer's unique
channel  isn't in the group)
Or have I missed something,?
On Mon, 2020-04-06 at 03:08 -0700, krnrrr wrote:
> or maybe any example of "superuser with groups: he can list all
> connections and close them if he likes"-type of application. All i
> found was some types of chats, but none of them included some kind of
> "chat-admin" with management of the rooms and visitors
> 
> 
> 
> -- 
> 
> 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/ad5f38cd-0d4e-4187-a2c2-d092df869f8e%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/530606d8f5e1320eed464ffe94e968b66260b0f0.camel%40gammascience.co.uk.


Re: iterate through list

2020-02-14 Thread Roger Gammans
No problem,

It 's all explained here :
https://docs.djangoproject.com/en/3.0/ref/models/querysets/


On Fri, 2020-02-14 at 14:27 +0100, Kai Kobschätzki wrote:
> Hi Roger:
> 
> Thanks a lot! Such as easy :)
> 
> Greetings
> 
> bengoshi
> 
> 
> On 2/14/20 2:15 PM, Roger Gammans wrote:
> > Use:
> > 
> > for data in Journal.objects.all():
> > 
> > 
> > 
> > 
> > On Fri, 2020-02-14 at 14:13 +0100, Kai Kobschätzki wrote:
> > > Hi:
> > > 
> > > I want to do something with the content of a table. Problem is,
> > > that
> > > the
> > > IDs are not continuous. I tried:
> > > 
> > > import .models from Journal
> > > 
> > > last = Journal.obejects.last()
> > > last += 1
> > > for i in range(last):
> > >   try:
> > > data = Journal.objects.get(pk=i)
> > > doing something with this data
> > >   except:
> > > pass
> > > 
> > > This solution runs but it seems not smart...
> > > 
> > > I need the try because there a gaps in the table, so I have got
> > > e.g.
> > > element 1, element 3, element 8. If there is not an try/except
> > > the
> > > for
> > > will crash. And I need the last +=1 otherwise the last element
> > > won't
> > > be
> > > interpret.
> > > 
> > > Could anyone show me how I could improve it?
> > > 
> > > Thansk and Greetings
> > > 
> > > bengoshi
> > > 
> > > 
> > > 

-- 
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/b7e3c940adeca708834de2d51620eb5b363767ac.camel%40gammascience.co.uk.


Re: iterate through list

2020-02-14 Thread Roger Gammans
Use:

for data in Journal.objects.all():




On Fri, 2020-02-14 at 14:13 +0100, Kai Kobschätzki wrote:
> Hi:
> 
> I want to do something with the content of a table. Problem is, that
> the
> IDs are not continuous. I tried:
> 
> import .models from Journal
> 
> last = Journal.obejects.last()
> last += 1
> for i in range(last):
>   try:
> data = Journal.objects.get(pk=i)
> doing something with this data
>   except:
> pass
> 
> This solution runs but it seems not smart...
> 
> I need the try because there a gaps in the table, so I have got e.g.
> element 1, element 3, element 8. If there is not an try/except the
> for
> will crash. And I need the last +=1 otherwise the last element won't
> be
> interpret.
> 
> Could anyone show me how I could improve it?
> 
> Thansk and Greetings
> 
> bengoshi
> 
> 
> 

-- 
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/a1762f64afd90ca6ad1a28b6a10dc81af722c313.camel%40gammascience.co.uk.


Re: Tracking IP

2020-01-21 Thread Roger Gammans
Hi

The precise details of this depend on your hosting environment, but the
canonical method is request.get_host() ;   see 
https://docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpRequest.get_host

If your hosting environment is non-standard; you might need some custom
middleware to help, as per the discussion in the link documentation.

On Tue, 2020-01-21 at 17:38 +0530, Soumen Khatua wrote:
> I want to show the users/clients IP address
> 
> 
> 
> On Tue, Jan 21, 2020 at 5:29 PM bharat pamnani <
> bharatpamnan...@gmail.com> wrote:
> > hostname -I will give you the ip of user.
> > On Tue, Jan 21, 2020 at 5:27 PM Soumen Khatua <
> > soumenkhatua...@gmail.com> wrote:
> > > Hi Folks,
> > > In my Django application I want to show IP address of users, Just
> > > like others financial websites. How I can do that using Django(of
> > > course it's should be free cost).
> > > 
> > > Thank You in advance
> > > 
> > > Regards,
> > > Soumen
> > > 
> > > 
> > > 
> > > -- 
> > > 
> > > 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/CAPUw6WZX_VEzB3jCR4DvOTUE08JXifr9todeHHUP29MumgrM2w%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/404609067d9c78d3e427cbb08cd109b63b7e8d0c.camel%40gammascience.co.uk.


Re: Django issues on upgradation

2019-10-27 Thread Roger Gammans
Hi ,
Looking at the second problem only (
https://stackoverflow.com/questions/58568561/nonetype-object-has-no-attribute-render-context
 ) I can't see any thing obviously wrong with  the call  you show.
 django.template.backends.Template.render() ; which you can see called
in your backtrace on SO, should call make_context (imported from
django.template.context) which should return a context instance (or
raise an TypeError). This isn't happening for you. Git seems to suggest
code in these area has been pretty stable over the period you are
referring to.
Given  you have at least one other odd error, I wonder if you've
damaged you django installation, or python environment insome way.
On possibility is if you've opened django/template/context.py in your
text editor and managed to scrambled the indentation, eg; if the
last  line of make_context() got promoted into the preceding else
clause it would have the effect you are seeing.
You best bet ,if you are still stick, is probably to create a clean
virtual env and try to generate a minimal example of what doesn't work,
Perhaps by starting with a fail  an deleting code, until you get to the
smallest possible example. 100 lines is the usual target. You will find
the exercise is really useful often reveals the problem to you when you
do it yourself.
HTH,


On Sun, 2019-10-27 at 12:52 +0530, Abhay Pan wrote:
> Hi there, 
> Can anyone assist with this? I'm really stuck hard here. It would
> really be great to learn from such a wonderful django community that
> we have here. 
> 
> Best Regards,
> Abhaypanhere
> 
> On Sun, 27 Oct, 2019, 1:15 AM Abhay Pan, 
> wrote:
> > Hi All,
> > 
> > I have raised an issue. Can any of you provide some insight on
> > this? 
> > 
> > That would be really helpful for me. 
> > 
> > https://stackoverflow.com/questions/58570933/decorator-got-an-unexpected-keyword-argument-trim-url-limit
> >  
> > https://stackoverflow.com/questions/58568561/nonetype-object-has-no-attribute-render-context
> >  
> > 
> > Regards,
> > Abhaypanhere 
> 
> 
> 
> 
> 
> 
> 
> django-users+unsubscr...@googlegroups.com
> 
> 
> 
> https://groups.google.com/d/msgid/django-users/CABhBUA88nmyzegZejAyOO-99Bq_rjPBzcqLF9zArwD4L6xRMAQ%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/824a7c67a7b68e85ccca8854c04b2f2b8c6c3585.camel%40gammascience.co.uk.


Re: django+rasperrypi_sensor

2019-10-15 Thread Roger Gammans
Can you define what you mean by real-time?
There are many way to achieve this depending on your other needs, for
instance if you need the server (the raspberrypi) to push the data,
it's suddenly not really a beginners task as you have to think about
whether to use websockets , or long polling. (or other complex
strategies which haven't immediately come to mind)
If however you are happy with the client to drive the update rate; by
say,  refreshing the page every few seconds (or perhaps longer) then
you can get away with a pretty simple django app with a single view
(your webpage with the sensor data) and have that webpage auto redirect
to itself at your refresh period.
In the latter case follow the tutorial to learn the basics, then write
an app with a single template which looks good, and you can use your
view function to fetch your sensor data and insert it into the template
context. If that isn't clear, hopefully the tutorial will help .
On Tue, 2019-10-15 at 09:43 -0700, 佟博 wrote:
> I need to build a website with django and pass the sensor data on
> rasperrypi to the webpage in real time. What should I do?
> I am a django beginner。
> 
> 
> 
> -- 
> 
> 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/60392967-fe9b-4733-a0e6-420e07f4dfc6%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/f533ec42b78a9933df6c819e636d63b0817eb3eb.camel%40gammascience.co.uk.


Re: Mocking models or at least creating Fakes.

2019-07-24 Thread Roger Gammans
> class TestThing(TestCase):def test_x():fake =
> FakeThingy()out = m.Foo( thing = fake )
> 
> All the error come from the last line when I try to construct a Foo.
> Without FakeThinky deriving from Thingy I get a error that fake is
> not of the correct class,
> and it is (as shown above) I get the following traceback.
> 
>File "tests.py"
> out = m.Foo( thing = fake )  File ".../lib/python3.7/site-
> packages/django/db/models/base.py", line 483, in
> __init___setattr(self, field.name, rel_obj)  File
> ".../lib/python3.7/site-
> packages/django/db/models/fields/related_descriptors.py", line 216,
> in __set__instance._state.db =
> router.db_for_write(instance.__class__, instance=value)  File
> ".../lib/python3.7/site-packages/django/db/utils.py", line 261, in
> _route_dbif instance is not None and
> instance._state.db:AttributeError: 'FakeBackend' object has no
> attribute '_state'
> 
> I'm sure someone here must have had to write unit test which deal
> with foreign jets before what approach did you end up taking?

I've done some more research and found at least the origins of the
problem is that the ORM persists Foriegn objects (since 1.8). ( Which
I'm sure sure removes a whole pile of nasty corner cases form the ORM).

Anyway for me the following is an alternative pattern which works;
requiring only changes to the TestCase; ( because the FK is a property
you 
have to patch the class otherwise setattr is called with the Fake, the
same is in the original code).


class TestThing(TestCase):
def test_x():
fake = FakeThingy()
def getter(om):
return fake

thingy_getter = property(getter)
out = m.Foo( title ="")
with
unittest.mock.patch.object(out.__class__,'thing',thingy_getter):
    self.assertEqual(out.title,"")





I'm still interested in other possible solutions out there .

-- 
Roger Gammans 
Gamma Science
On Wed, 2019-07-24 at 12:05 +0100, Roger Gammans wrote:

-- 
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/b95f0c032f5c68355a7ce9fb22cf7ab52d27db18.camel%40gammascience.co.uk.


Mocking models or at least creating Fakes.

2019-07-24 Thread Roger Gammans
Hi,
The django ORM is being far to helpful for me in this case; I need to
find some method of bypasssing it; for my unittests.
I've got system which look something like:-
## In models.pyclass Thingy(models.Model):friendly_name =
models.CharField(max_length =200)title =
models.CharField(max_length =200)other_name =
models.CharField(max_length =200)
def get_client(self,):return None
# In tests.py with appropriate imports.X = object()
class FakeThingy(Thingy):class Meta:proxy = True
def __init__(self,):self.fake_proxy  =
unittest.mock.sentinel
def get_client(self):global xreturn X
class Foo(models.Model):title = models.CharField(max_length = 200,
)thing = models.ForeignKey(Thingy, on_delete=
models.PROTECT)def __str__(self,):return self.title

class TestThing(TestCase):def test_x():fake =
FakeThingy()out = m.Foo( thing = fake )

All the error come from the last line when I try to construct a Foo.
Without FakeThinky deriving from Thingy I get a error that fake is not
of the correct class,and it is (as shown above) I get the following
traceback.
   File "tests.py"out = m.Foo( thing = fake )  File
".../lib/python3.7/site-packages/django/db/models/base.py", line 483,
in __init___setattr(self, field.name, rel_obj)  File
".../lib/python3.7/site-
packages/django/db/models/fields/related_descriptors.py", line 216, in
__set__instance._state.db = router.db_for_write(instance.__class__,
instance=value)  File ".../lib/python3.7/site-
packages/django/db/utils.py", line 261, in _route_dbif instance is
not None and instance._state.db:AttributeError: 'FakeBackend' object
has no attribute '_state'

I'm sure someone here must have had to write unit test which deal with
foreign jets before what approach did you end up taking?

-- 
Roger Gammans 
Gamma Science

-- 
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/42fe9272db3c0ed50bdeb9a3f8625f576c8a21d0.camel%40gammascience.co.uk.


Re: Django to exe ... windows executable

2019-07-03 Thread Roger Gammans
On Wed, 2019-07-03 at 19:42 +1000, Mike Dewhirst wrote:
>  web.
> >  which is the best option.
> 
> Either py2exe or pyoxidizer
> 
> I have used py2exe successfully some years ago but not pyoxidizer. It
> is 
> new so the developer supporty will probably be quite good.

There is also briefcase:
https://beeware.org/project/projects/tools/briefcase/

I've not used it ; so this isn't a recommendation; just a head up that
it exists; but does it seems to have explicit django support, if that's
important

-- 
Roger Gammans 
Gamma Science Ltd. (GB Nr. 07356014 )

-- 
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/56b99c6c22d18c86db375d93c8a514f65ac2561f.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Django channels on IIS

2019-05-24 Thread Roger Gammans
On Thu, 2019-05-23 at 22:17 -0700, Daniel Butler wrote:
> It looks like I found my key I had to install the application module
> CGI then use this library to get everything to work! 
> https://pypi.org/project/wfastcgi/

Does that support websockets? 

IIS itself seems to ( https://docs.microsoft.com/en-us/iis/get-started/
whats-new-in-iis-8/iis-80-websocket-protocol-support ) , but I don't
the factcgi ->wsgi adaptor does.

I've used it for non-channels projects, but didn't think it would
support websockets; and channels - for a start it's WSGI not ASGI.

Or have I missed something. 

-- 
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/1558686736.16116.3.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Server Error (500)

2019-04-08 Thread Roger Gammans
Did you run 'python manage.py migrate' ?

Did it come back with any errors? 

I ask because specifying  price field for values up to 10^9998 strikes
me as extreme an likely to causes problems; perhaps you meant
max_digits=7 not 1 .


On Mon, 2019-04-08 at 04:26 -0700, fazal rehman wrote:
> Hello,I am a beginner in django.I am getting Server error(500)
> whenever I am trying to open the server have made some objects, I can
> see them but when i am trying to open it I get error 500. I have one
> DEBUG=false.I have attached models.py and settings.py.
> 
> 
> 
> -- 
> 
> 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/922704da-519c-4503-8753-
> a631949ba9a7%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/1554727878.3451.6.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError unsupported operand type(s) for *: 'NoneType' and 'int'

2019-04-07 Thread Roger Gammans
Omar,

When posting question to the list  it's good practice to  practice tell
us a little bit about what your trying to do, and how what
actions cause the error to occur.

In this case though you only have a (single line in CalcPoints) which
uses the '*' operator.

On Sat, 2019-04-06 at 10:35 -0700, omar ahmed wrote:
> models.py
> def CalcPoints(self):
> return self.won*3 + self.draw


The python documentation has this to say about the '*' operator
(from: 
https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
)

The * (multiplication) operator yields the product of its
arguments.  The
arguments must either both be numbers, or one argument must be an
integer and
the other must be a sequence. In the former case, the numbers are
converted to a
common type and then multiplied together.  In the latter case, sequence
repetition is performed; a negative repetition factor yields an empty
sequence.

Since you've provided a literal integer ( the '3') as one of your
arguments, we can deduce the None value
is in self.won. Since you have 'declared' self.won as an
IntegerField;  we can see that as in the
normal case we should satisfy the first clause of the reference,
"arguments must either both be numbers"
however so some reason self.won is None in your case.

Without seeing the rest of your code it's impossible to guess
accurately but my instinct is your haven't
initialised your instance from the database (or set a won value when
creating the object).

If you expected to have a default value you need to set one where you
set up self.won see 
:  https://docs.djangoproject.com/en/2.2/ref/models/fields/#default

HTH,


-- 
Roger Gammans 

-- 
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/ea23ce16123320b41ad5f468ebb742f1bcb25b37.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Re: Composite Primary / Foreign Key support

2019-02-18 Thread Roger Gammans
Lance,

I can't speak for the core team, only inform you based on what I've
seen here and in other projects.

I suspect if there was a significant need across a number of users,
then enough work could be done by those that needed it and as long as
it was 
1) fully functional, 
2) had clean good code 
3) the people who wrote where going to stay within the
community to support it 

Then there is a chance a set of code written might get merged, I don't
however thing there is sufficient interest from the core team for them
to do the work themselves.

Those requirements are quite a high bar, I started on some code to do
this, for a project a few years ago and got a limited set of composite
key functionality working in my own tree, which was just about enough
for the project I was working on. So I do have some understanding of
what is needed, and how intrusive and can get.

My code was fine for reading and writing, but you couldn't use
ForeignKey Fields to traverse composite key relationships. Which has a
surprising number of corner cases. This was for Django 1.8 and isn't
compatible with later versions (unfortunately). On the other hand some
of the code changes in the ORM point at a better approach, than we
took.

So it possible, but someone will need to invest some time into it.


The only immediately helpfuly ideas I have are;
As your requirement is read-only if the data is static you could to create a 
second database, with all the PK of the legacy database, and
then as single Pk field to that table, and access everything through a view of 
a join the two tables. 

Of course if another app is adding rows then you are a bit stuck, but if you 
absolutely can't add a autonumber field to use as a fake PK, then there is not 
a lot you can do. I've started adding single PK autonumber fields to legacy 
databases now when I get this issue, and
making the old PK into a unique index. So far that has working and hasn't 
broken my legacy apps.

If those are no good, either you can't use django or you going to need to 
invest in understanding the ORMs internals.

HTH,

-- 
Roger Gammans 
Gamma Science


On Mon, 2019-02-18 at 08:26 +, 'Ellinghaus, Lance J' via Django
users wrote:
> 
> ONCONFIDENTIAL // EXTERNAL
> So, basically, Django will not be supporting Composite Primary Keys
> in the future?
> 
> Lance
> 
> -Original Message-
> From: django-users@googlegroups.com 
> On Behalf Of Michal Petrucha
> Sent: Monday, February 11, 2019 8:34 AM
> To: Django users 
> Subject: [External] Re: Composite Primary / Foreign Key support
> 
> NONCONFIDENTIAL // EXTERNAL
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA512
> 
> On Mon, Feb 11, 2019 at 01:08:41AM -0800, 'Lance Ellinghaus' via
> Django users wrote:
> > I have seen references to people adding the support of composite 
> > primary keys to Django for years, but it does not look like it has
> been added.
> >
> > I have a number of legacy databases that I cannot add fields to
> but 
> > need to be able to be queried through Django. They are read-only
> tables.
> > A number of the tables are also related through Composite Foreign
> Keys 
> > and I have seen some addons but not sure what is fully supported.
> >
> > I am trying to use Django 2.1.5.
> >
> > Any help or ideas would be appreciated, and saying  "Add a field
> to 
> > your tables" is not an option.
> >
> > Thank you.
> 
> Hi Lance,
> 
> I haven't been on top of this in recent years, but let me try.
> 
> When it comes to just composite primary keys, as long as you only
> need read access, you might be able to get away with marking an
> arbitrary field as the primary key. Using a non-unique field as the
> primary key would make any writes to the database dangerous, but
> that's not your case here. However, you also lose the invariant that
> filtering on the “pk” field alias will match at most one row, which
> means the admin would probably be off the table, too – since that
> assumes the “pk” is, in fact, unique, and the same holds for any
> other package that makes use of “pk”. You should still be okay in
> your own code, though.
> 
> For composite foreign keys, there is nowadays a private, undocumented
> API, ForeignObject, which is what ForeignKey builds on. The general
> ForeignObject lets you specify multiple fields that make up the
> relation, you should be able to find some examples in the test suite
> (there is a foreign_object package in there). Keep in mind that this
> is an internal API, so it might change without warning.
> 
> Good luck,
> 
> Michal
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1
> 
> iQIcBAEBCgAGBQJcYXniAAoJEHA7T/IPM/kl8EAP/Rzaxqe0bDO6vkxb4/Mmmj5S
> 62t6Cfm3VqqK

Re: channnels -- communication with redis

2019-01-15 Thread Roger Gammans
Hi Yuval 

Are you using docker machine ? If so  the redis server is on the docker
machine's IP not on the localhost so you would need to update the
docker host in the CHANNEL_LAYERS portion of settings.py.

You show a unix-like shell like for controlling docker; but the connect
failed error looks very windowssy; so I'm not sure that the docker
engine (daemon) and the python is running on the TCP stack (or
kernel/VM) which you would need for the local host connection to work.
Also it might be sensible to ensure the connection is being block by a
local firewall if you have one.

It looks  network/local environment related rather than something
redis/docker specific. The error show the TCP connection (which you can
test with telnet if you have it install) not be made between python and
the redis deamon the most likely reason for that is a local firewall or
a more complex environment.

-- 
Roger Gammans 
Gamma Science



On Tue, 2019-01-15 at 18:49 +0200, Yuval Bachrach wrote:
> I did not configure anything, which is probably the problem..I am
> following the tutorial. I just did what the tutorial instructed to
> do: So I have installed docker as instructed but haven't configured
> anything. The tutorial calls installing docker and does not state any
> action to take after installing) 
> as I am not familiar with docker, could not tell if there is a need
> to configure anything to make django channels work.  I still need to
> do whatever is required to make the tutorial work.Do I need to learn
> basics of docker first, or are there some simple things I can do to
> enable the environment and keep going with the channels tutorial? 
> 
> On Tue, Jan 15, 2019 at 6:38 PM PASCUAL Eric 
> wrote:
> > 
> > 
> > 
> > 
> > 
> > Hi,
> > 
> > 
> > 
> > How is configured your Docker stack exactly ? You should have
> > several containers in it, at least one for the Redis server,
> > another one for the Django app.
> > 
> > 
> > 
> > Do you use docker-compose to run the stack ? If yes, could you
> > provide the YAML descriptor of the stack ?
> > 
> > 
> > 
> > Best
> > 
> > 
> > 
> > Eric
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > From: django-users@googlegroups.com 
> > on behalf of Yuval Bachrach 
> > 
> > Sent: Tuesday, January 15, 2019 5:31:18 PM
> > 
> > To: django-users@googlegroups.com
> > 
> > Subject: channnels -- communication with redis
> >  
> > 
> > 
> > 
> > 
> > I fail to have django channels communication with redis running at
> > docker container: I am running the channels tutorial and I get an
> > error when just following the tutorial instructions.
> > 
> > 
> > 
> > 
> > 
> > I am quite new with Django (designed a simple site) and have no
> > knowledge on redis nor docker
> > 
> > 
> > 
> > 
> > 
> > I am trying to lean channels using the tutorial: 
> > https://channels.readthedocs.io/en/latest/tutorial/
> > 
> > It uses redis over docker
> > 
> >  
> > 
> > At tutorial part 2 there is a test for “channel layer can
> > communicate with Redis”.
> > 
> > 
> > I fails this test. I was looking over the web for solving this
> > communication problem with no luck.
> > 
> > As I am not familiar with redis nor docker, I have hard time
> > analyzing the reasons for the communication problems. I can see
> > that redis is running inside a docker container.
> > 
> > 
> >  
> > 
> > $ docker ps
> > 
> > CONTAINER IDIMAGE   COMMAND 
> > CREATED STATUS  PORTS
> > 
> >  NAMES
> > 
> > 2bdabc272ec3redis   "docker-entrypoint.s…"  
> > About an hour ago   Up About an hour0.0.0.0:6379->6379/tcp
> > 
> >  quizzical_panini
> > 
> > $ docker inspect quizzical_panini > redisimage.log
> > 
> >   (YB: will paste the logfile at the end of this  message)
> > 
> > 
> >  
> > 
> > 
> >  
> > 
> > python manage.py shell
> > 
> > import channels.layers
> > 
> > channel_layer = channels.layers.get_channel_layer()
> > 
> > from asgiref.sync import async_to_sync
> > 
> > async_to_sync(channel_layer.send)('test_channel', {'type':
> > 'hello'})
> > 
> > Error begins with:
> > 
> > In [4]: async_to_sync(channel_layer.send)('test_cha

Re: Django on IIS

2018-12-18 Thread Roger Gammans
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.webserve
> > r/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-ii
> > s-using-fcgi/
> > https://www.toptal.com/django/installing-django-on-iis-a-step-by-st
> > ep-tutorial
> > https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cla
> > ssic/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-st
> > ep-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 cyg

Re: Django on IIS

2018-12-18 Thread Roger Gammans
On 18 December 2018 17:28:41 GMT, Larry Martell  wrote:
>Get-WindowsFeature shows that web-cgi is installed but not iis-cgi.
>Are these the same?
>
Maybe. I think they Microsoft renamed on to the other. My script was for the 
most recent iteration of windows server.


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
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/9E5B7EE1-4E12-45A7-9E96-9CA79604882A%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Django on IIS

2018-12-18 Thread Roger Gammans
Larry,


My script draws from the following urls all of which I found useful.

 https://docs.microsoft.com/en-us/iis/configuration/system.webserver/fa
stcgi/
 http://blog.mattwoodward.com/2016/07/running-django-application-on-win
dows.html
 http://mrtn.me/blog/2012/06/27/running-django-under-windows-with-iis-u
sing-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/classi
c/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  > u> 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-o
> > > n-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
> > eventuallyinstalled Apache. That worked brilliantly although it
> > wasn't a heavyduty application. Django works well on Windows so
> > Apache is a fallbackif IIS doesn't cut it for you.
> > 
> > > On Mon, Dec 17, 2018 at 5:19 PM Larry Martell  > > l.com
> > > <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/1545148053.14784.36.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Django on IIS

2018-12-18 Thread Roger Gammans

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-o
> > n-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  > l.com 
> > 
> > > <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
> > 
> > > <mailto:django-users%2bunsubscr...@googlegroups.com>.
> > 
> > > To post to this group, send email to django-users@googlegroup
> > s.com
> > 
> > > <mailto:django-users@googlegroups.com>.
> > 
> > > Visit this group at https://groups.google.com/group/django-us
> > ers.
> > 
> > > To view this discussion on the web visit
> > 
> > > https://groups.google.com/d/msgid/django-users/CACwCsY7bk-c7Z
> > a-PGUbaEkftA8Xxqd%2BaCUPkaQryW-1kXX0_nQ%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 
> > 
> > > <mailto:django-users+unsubscr...@googlegroups.com>.
> > 
> > > To post to this group, send email to django-us...@googlegroups.co
> > m 
> > 
> > > <mailto:django-users@googlegroups.com>.
> > 
> > > Visit this group at https://groups.google.com/group/django-users.
> > 
> > > To view this discussion on the web visit 
> > 
> > > https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVWO5bFTx%
> > 3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com 
> > 
> > > <https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVWO5bFTx
> > %3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com?utm_mediu
> > m=email_source=footer>.
> > 
> > > For more options, visit https://groups.google.com/d/optout.
> > 
> > 
> > 


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 nee

Re: Help

2018-07-08 Thread Roger Gammans
Umar,
IIRC - (and it's been a while since I used windows) - Windows maintains
a global flag for internet connectivity. 
Unfortunately if windows  decides it's not connected , bad many apps
such as Internet Explorer, Edge etc, refuse to attempt to make any TCP
connections even if they are to localhost (127.0.0.1). A quick google
suggests that your AV or firewall could also cause this.
I hope this gives you a few places to look.
On Sun, 2018-07-08 at 09:57 -0700, Umar Kambala wrote:
> Am being using de django server which is 127.0.0.1 and never had any
> problem till today. 
> 
> Thanks
> 
> On Jul 8, 2018 4:51 PM, "Jason"  wrote:
> the error states the issue: your computer is not connected to the
> internet.
> https://docs.djangoproject.com/en/2.0/intro/tutorial01/#the-developme
> nt-server
> 
> 
> 
> 
> 
> 
> 

-- 
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/153107.25821.9.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Django channels with python background tasks

2018-05-27 Thread Roger Gammans
Jaiswal,
Either my solution 1 or 2 will solve your problem, or rewriting your
scripts as management commands (which is probably the easiest route).
If you want to keep them separate :-
For solution 1; I would look at using the requests library (see https:/
/pypi.org/project/requests/ ) in your backend scripts and adding
django-rest-framework to your django project ( http://www.django-rest-f
ramework.org  ) to handle to API views. 
For solution 2:  it is more roll your own; but googling 'zmq' and
'redis'  would be a start to get you thinking about how these things
can hang together. This is probably the most advanced solution though.
I'm sorry this is not a lot more help, it is all up to understanding
what your comfortable with *exactly*  what you want to achieve from
here.

On Sun, 2018-05-27 at 02:22 -0700, Sourabh Jaiswal wrote:
> Hi Roger,
> Thanks for your reply.
> 
> Yes you are correct. There are actually 2 modules of this project:-
> 1. Django front end which is totally isolated in itself if I talk
> about it with back-end reference. And currently it has no mechanism
> whatsoever to communicate with back-end.
> 2. python based back-end scripts. which itself is a program. It can
> be started with some management IPs of Network elements and that
> program will keep getting the data from those NE synchronously.
>     This back-end can not communicate with any external program yet.
> And uses a global variable file for starting the threads.
> 
> Now to link these 2 modules I understand I need to to introduce APIs
> in module 2. and call those APIs from django.
> Which is exactly what you are suggesting in your suggestion 1.
> Correct me if I am wrong.
> 
> Just a little bit more help. Can you please guide me to some tutorial
> to get this thing started.
> 
> Thanks in advance.
> 
> Regards,
> Jaiswal
> 
> On Sunday, May 27, 2018 at 2:34:05 PM UTC+5:30, Roger Gammans wrote:
> > I think there is a little bit of confusion in this thread,a s we
> > keep talk about django and the deamon process and ignoring the
> > frontend.
> > So to clarify; there we are talking about a system with at least 3
> > execution environments:
> > 1 The Browser2 Django backend processes3 The backend daemon/cli
> > -process.
> > django-channel provides a mechanism which (amongst other uses) can
> > get near-realtime updates from a django environment to the web
> > browser, but if you don't need this you can just store all your
> > status data in the data base . Then when the browser fetches a
> > views it will have the most recent data in the database.
> > You still however need to communicate between the backend process
> > and the rest of the django environment, the simplest way as Ryan
> > suggesting is tobring this inside the django environment by
> > implementing it as a management command, from there you have access
> > to the python end of the channels api to send messages to the
> > browsers, or the model objects to save to the database. Management
> > commands can be arbitrarily complex, so that not a problem in
> > itself.
> > I have a similar system in development and there we do run the
> > backend daemon outside of the dajngo environment, but that makes
> > database access hard as you need a separate copy of the database
> > models, or to use raw SQL. In our system we still have a django
> > management command though which has the responsibility of
> > pumping/handling messages from the deamon to the intended
> > destination.
> > If you want to keep your backend separate l I can see two
> > reasonable paths:   1. Use a custom set of django views to
> > provide a API your backend connects to over localhost/http to send
> > the it message updates. 2. A django management command as a
> > API interface message handler, which connects to the backend over
> > one of many message channels out there. (ie. zmq, redis, unix-
> > sockets, etc)
> > Hope this helps a little bit.
> > On Sun, 2018-05-27 at 01:01 -0700, Sourabh Jaiswal wrote:
> > > HI Ryan,
> > > The back-end script in this case is not only doing telnet. Its
> > > getting data from multiple network elements using telnet and
> > > multi-threading. There are multiple threads started when I start
> > > the backend script which takes monitoring data from diff-diff
> > > network elements at the same time. The communication between the
> > > threads is happening using a python Sockets. A TCP server is
> > > responsible to pass the messages between threads. So I have to
> > > have this background program run to collect data.
> > > 
> > > The control from django I want is, to b

Re: Django channels with python background tasks

2018-05-27 Thread Roger Gammans
I think there is a little bit of confusion in this thread,a s we keep
talk about django and the deamon process and ignoring the frontend.
So to clarify; there we are talking about a system with at least 3
execution environments:
1 The Browser2 Django backend processes3 The backend daemon/cli
-process.
django-channel provides a mechanism which (amongst other uses) can get
near-realtime updates from a django environment to the web browser, but
if you don't need this you can just store all your status data in the
data base . Then when the browser fetches a views it will have the most
recent data in the database.
You still however need to communicate between the backend process and
the rest of the django environment, the simplest way as Ryan suggesting
is tobring this inside the django environment by implementing it as a
management command, from there you have access to the python end of the
channels api to send messages to the browsers, or the model objects to
save to the database. Management commands can be arbitrarily complex,
so that not a problem in itself.
I have a similar system in development and there we do run the backend
daemon outside of the dajngo environment, but that makes database
access hard as you need a separate copy of the database models, or to
use raw SQL. In our system we still have a django management command
though which has the responsibility of pumping/handling messages from
the deamon to the intended destination.
If you want to keep your backend separate l I can see two reasonable
paths:  1. Use a custom set of django views to provide a API your
backend connects to over localhost/http to send the it message updates. 
2. A django management command as a API interface message handler,
which connects to the backend over one of many message channels out
there. (ie. zmq, redis, unix-sockets, etc)
Hope this helps a little bit.
On Sun, 2018-05-27 at 01:01 -0700, Sourabh Jaiswal wrote:
> HI Ryan,
> The back-end script in this case is not only doing telnet. Its
> getting data from multiple network elements using telnet and multi-
> threading. There are multiple threads started when I start the
> backend script which takes monitoring data from diff-diff network
> elements at the same time. The communication between the threads is
> happening using a python Sockets. A TCP server is responsible to pass
> the messages between threads. So I have to have this background
> program run to collect data.
> 
> The control from django I want is, to be able to start multiple
> instance of this whole back-end package when user clicks on such
> cluster in django front end. Passing management IP and other relevant
> information from django DB. and after starting particular instance
> django should be able to control it.
> 
> What I found out from recent googling and stuff is. I need to write
> some APIs in back-end program and as Andrew suggested it needs to be
> written in such a way that it can be polled via django.
> So where to start in this regard? can you please guide me for that.
> 
> Thanks in advance!
> 
> Regards,
> Jaiswal.
> 
> On Saturday, May 26, 2018 at 8:15:28 PM UTC+5:30, Ryan Nowakowski
> wrote:
> > Another idea: create a Django management command that does the
> > telnet stuff and just run that periodically via Cron. You can
> > always move to channels or celery later.
> > 
> > On May 26, 2018 9:33:16 AM CDT, Ryan Nowakowski  > > wrote:
> > > In addition to websockets, channels can be used to run background
> > > tasks that could take a long time for example a telnet
> > > connection. You can Google Django channels background tasks.
> > > 
> > > 
> > > 
> > > An alternative to channels for background tasks is celery. 
> > > 
> > > On May 26, 2018 5:03:51 AM CDT, Andrew Godwin  > > g> wrote:
> > > > Hi Jaiswal,
> > > > I'm afraid that I can't give detailed help about what your best
> > > > options are or walk you through how to do it - that's something
> > > > you'll have to research and decide on yourself. Channels allows
> > > > you to do low-latency communictation between Django back-ends
> > > > and JavaScript, but anything you can do with it can also be
> > > > done slower using a polling API connection.
> > > > 
> > > > My recommendation would be to start simple - doing it using an
> > > > API that you poll every few seconds - and then once you have
> > > > that figured out, look at how you could improve it using
> > > > WebSockets and channels.
> > > > 
> > > > Andrew
> > > > On Sat, May 26, 2018 at 8:38 AM Sourabh Jaiswal  > > > ail.com> wrote:
> > > > > Hi,
> > > > > 
> > > > > I am writing a python based application(CLI Back End) which
> > > > > does telnet to some network components and gets some data. It
> > > > > saves the data in sqlite db.
> > > > > 
> > > > > For this application I am writing Django based frond end.
> > > > > Which will start the CLI app and monitor it. For
> > > > > communication between the CLI 

Re: Django and Angular2/4 example project

2017-10-16 Thread Roger Gammans
Hi,

I'd certainly be interested in helping with such a project; as I
current have two angular.io/Django projects here.

We've been concentrated more on the such thinks and enhance runserve;
to also spawn 'ng build' in another process so the developer experience
was smooth.

ng.io components for django contrib.auth functions do look like another
sensible feature. 

The other value I see in that project is to provide pointer on best
practice way of structuring such development. I think it doesn't exists
because enough people haven't come together to do it.


On Sun, 2017-10-15 at 08:59 -0700, MartinF11 wrote:
> Hello,
> is there any example project or scaffolding tool for creating some
> sample project including frontend/backend?
> 
> I am wondering why such project does not exist or maybe I just cannot
> find it. There was django-angular but it is for AngularJS1 which so
> obsolete todays. 
> 
> I need such very basic things that one have to solve very frequently:
> 
> - login/logout
> - social auth
> - registration
> - forgotten password
> 
> We have to solve this in every project which involves user
> interaction within web. To implement all this is like re-inventing a
> wheel.
> 
> Are you aware of such project that could serve which I could further
> extend to my needs? Thank 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/fb36d032-2450-414e-9d26-
> 7379f069301d%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/1508147971.19873.7.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: Django Websockets / Several Users on the Website

2017-10-13 Thread Roger Gammans
One architecture you could consider, is to put all the sensor values into
redis or similar. Have a worker to out the values into redis from the
automation source.

Then use each websocket recieve event to add the reply channel to the group
which gets the appropriate sensor value.

You will probably need a second worker to forward redis messages to the
appropriate group.

But you can end up with the the values going down a couple of channels, and
each user doesn't need a separate worker.

Personally I'd do as much of be the filtering on the client side as
possible, if there is no security concern with publishing the values to a
user send the values to them. The client side code can ignore it if
necessary.



On 13 Oct 2017 07:14, "'matrix1900' via Django users" <
django-users@googlegroups.com> wrote:

Hi Andrew,

thanks for the answer.
Are there some Examples available for using Background Worker and
receive/send websockets in there ?

I am not sure, if it is the better way to use celery or should I use the
background worker?
My Project:
I should develop a maintain website for a automation control.  Each user
can view different sensor values (Described on several websites) from the
automation control.

IDEA: Each user have his own background worker which request the sensor
values from the automation control and send the information to the user. The
sensor values are updated upon change. (Providing Live DATA)


Am Donnerstag, 12. Oktober 2017 20:05:42 UTC+2 schrieb Andrew Godwin:

>
>
> On Wed, Oct 11, 2017 at 3:02 AM, 'matrix1900' via Django users <
> django...@googlegroups.com> wrote:
>
>> Hi together,
>>
>> I try to get started with Django Channels.  I have actually two questions:
>>
>> 1. I use web sockets with channels. I want to have for each frontend user
>> which opens the website his own websocket channel without groups. I am not
>> sure how does it works when several Users opens the website ? Has each
>> frontend user his own consumer thread which handles the web socket messages
>> ? How are the concept here?
>>
>
> The server holds on to all the websockets in one big async thread, then
> calls your Django code synchronously whenever an event happens on the
> socket.
>
>
>>
>> 2. How can I receive websocket messages in a separate task. I found in
>> the FAQ on the Channels Site the hint to use *receive_many()* but I'm
>> not sure how to use it exactly.
>>
>
> You shouldn't do this, use the normal worker pattern, there's lot more
> than just receive_many to do
>
>
>>
>> 3. How can I start a separate task  in the consumer.py after receive a
>> message ('websocket.receive')
>> ( for example: In Consumer I get a message via websocket from the
>> frontend user, according to the message I start a process with some
>> arguments, after execute the process,  I get the results back and send it
>> to the individual  websocket channel client)
>>
>
>
> You have to send it to a custom channel with the reply_channel of the
> socket, have a worker listen on that channel, and when it is done send
> information back to the reply_channel.
>
> Andrew
>
>
-- 
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/7ebb5b85-064b-421f-a906-a638ba97bb10%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/CA%2B_0JkLtGUd49FNoAt6jBZeNp7%2Bj7PPOh2UF%3DogOAWBxg_CjwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Forward messages from a third party async source.

2017-09-04 Thread Roger Gammans
Andrew,

Thanks for that.

Is there is anything I should avoid in my design and worker process to
ensure it would be compatible with what goes in later versions of
channels?


On Fri, 2017-09-01 at 12:38 -0700, Andrew Godwin wrote:
> Hey,
> You can send onto Channels from anywhere, event loop or no, but if
> you want a background process that monitors an external source and
> forwards events from it you will need to write that yourself (I
> usually suggest management commands for this purpose).
> 
> I'm working on hopefully making it easier to write worker processes
> like this, but that's not something that's ready in the short term.
> 
> Andrew
> On Fri, Sep 1, 2017 at 3:56 AM, Roger Gammans <rgammans@gammascience.
> co.uk> wrote:
> > Hi all,
> > 
> > 
> > 
> > I'm trying to build a system with a Django frontend which displays
> > live
> > 
> > information from other services on the backend (eg, the one running
> > 
> > python - not the browser) host.
> > 
> > 
> > 
> > To keep my dependencies as light as possibly I'm trying to avoid
> > import
> > 
> > the settings file for django and channel into the backend services.
> > And
> > 
> > run those a much lighter an simple process which concentrate on
> > their
> > 
> > tasks.
> > 
> > 
> > 
> > I can easily create an async event in the backend processes; but to
> > 
> > get the channels layer to respond to it; It seems that I need to
> > create
> > 
> > my own thread with it own tight loop doing something like:-
> > 
> > 
> > 
> >         def forward_sensor_to_web(sensor_gen,dj_channel):
> > 
> >                 for sensor_data in sensor_gen():
> > 
> >                        
> > Channel(dj_channel).send(sensor_data.as_json())
> > 
> > 
> > 
> > 
> > 
> > Obviously this needs to be kept running and restarted if the
> > 
> > loop/thread raises an exception etc.
> > 
> > 
> > 
> > Is there any extant best practice for how to set this sort of
> > 
> > architecture up using channels? Can I integrate the into the
> > channels
> > 
> > main Aio loop?  Or is channels to the best way to go?
> > 
> > 
> > 
> > I'm seeking to make sure I'm not missing anything; before thing
> > start
> > 
> > to get hard to change.
> > 
> > 
> > 
> > Anybody got any thoughts?
> > 
> > 
> > 
> > --
> > 
> > Roger Gammans <rgamm...@gammascience.co.uk>
> > 
> > 
> > 
> > --
> > 
> > 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/1504263403.30060.7.camel%40gammascience.co.uk.
> > 
> > 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/CAFwN1upd8HhPu2hznKrHsNV_-
> M5pvAOCJrDKhumEcBpYP_Zncw%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/1504514960.18439.3.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.


Channels - Forward messages from a third party async source.

2017-09-01 Thread Roger Gammans
Hi all,

I'm trying to build a system with a Django frontend which displays live
information from other services on the backend (eg, the one running
python - not the browser) host.

To keep my dependencies as light as possibly I'm trying to avoid import
the settings file for django and channel into the backend services. And
run those a much lighter an simple process which concentrate on their
tasks.

I can easily create an async event in the backend processes; but to 
get the channels layer to respond to it; It seems that I need to create
my own thread with it own tight loop doing something like:-

def forward_sensor_to_web(sensor_gen,dj_channel):
for sensor_data in sensor_gen():
Channel(dj_channel).send(sensor_data.as_json())


Obviously this needs to be kept running and restarted if the
loop/thread raises an exception etc.

Is there any extant best practice for how to set this sort of
architecture up using channels? Can I integrate the into the channels
main Aio loop?  Or is channels to the best way to go?

I'm seeking to make sure I'm not missing anything; before thing start
to get hard to change.

Anybody got any thoughts?

-- 
Roger Gammans <rgamm...@gammascience.co.uk>

-- 
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/1504263403.30060.7.camel%40gammascience.co.uk.
For more options, visit https://groups.google.com/d/optout.