Re: d

2020-02-24 Thread Motaz Hejaze
You want to make a file sharing website ??

On Mon, 24 Feb 2020, 1:22 pm Muhammad Abdullah Nabeel, <
muhammadabdullahnab...@gmail.com> wrote:

> I have made few games and data storing and searching softwares using
> tkinter turtle numpy pygame math random etc modules but I still can not
> made a system in which I can make another person give a file and the other
> person can install my software in  his computer. Can I do this using Django
> module or I need to do something else
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c20ab536-b3ad-48ce-b1a1-191ea18d37cf%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/CAHV4E-cQfP5CyUjhziJZ1uVbmt5TwsebF-rdpeR8i8p3LWBjWA%40mail.gmail.com.


Re: ANN: django-yamlconf v1.2.0 is available

2020-02-24 Thread Gabriel - Iulian Dumbrava
You are suggesting in the demos that the settings.py file should contain de 
development definition of variables and override them later on with loading 
the specific settings from yaml.

would contain the development oriented definitions, e.g., database 
> definitions for user and password for a development database. The settings 
> file would then end with a call the the load function. Additional 
> definitions could be defined after the load function to update 
> conditional definitions, e.g., if DEBUG is enabled.
>

This approach is not very security oriented because there is always the 
danger to forget to override a specific variable and hence make the app 
less secure. I would suggest to have the most secure, drastic values set by 
default in settings.py and then loosen them up in yaml files. But, it's 
only a suggestion.

Best regards,
Gabriel

luni, 24 februarie 2020, 03:57:55 UTC+2, Michael Rohan a scris:
>
> Hi Folks,
>
> Have release v1.2.0 for django-yamlconf, a module supporting Django 
> settings via YAML files (searching up the directory hierarchy, e.g., in a 
> K8s environment, adding a "final" set of settings via "/APPLICATION.yaml", 
> see the documentation a https://django-yamlconf.readthedocs.io/en/latest/ 
> for more detailed info.
>
> The updates for the this release are:
>
> - Tagged with ``v1.2.0``.
> - Updates to support Django 3.0: Simply use "`six`" instead of the
>   support "`django.utils.six`" package and use "`render`" instead of
>   "`render_to_response`".
> - `ycsysfiles` should generate executable files if the source template
>   file is executable.
> - Ensure the absolute path is used when searching for YAML control
>   files.  This issue is seen when running Django apps under uWSGI
>   control.
> - Added the built-in attribute ``CPU_COUNT`` (primarily for use in uWSGI
>   ini files) giving the number of available CPUs.
>
> Take care,
> Michael.
>
> -- 
> Michael Rohan
> mro...@acm.org 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd1c2605-f99e-48de-b091-e9d4ce562f29%40googlegroups.com.


New to Django, need help using my intermediate table to show the m2m relationship in my templates.

2020-02-24 Thread Silas Nicholls
Hello

Sorry I am very new to Django and have come across quite the stumbling 
block. The details to the issue are in this Stack Overflow post I made a 
while ago with no answers:

https://stackoverflow.com/questions/60223686/how-do-i-use-my-intermediate-table-to-show-the-m2m-relationship-in-my-templates

Thank you 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/609a095c-6a5a-4ccf-9a02-5ff517871a99%40googlegroups.com.


New to Django need help with m2m database with intermediate table.

2020-02-24 Thread Silas Nicholls

Hello,

Sorry for my amateur question. 

I've been stuck on this issue for a while and I can't work out if there is 
way I can use my current models to work in this way.

Here is a link to my issue:

https://stackoverflow.com/questions/60223686/how-do-i-use-my-intermediate-table-to-show-the-m2m-relationship-in-my-templates

Thank you 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/1b173ea5-fbfc-429f-9b50-505e914f2766%40googlegroups.com.


Django models and multiprocessing: "no results to fetch"

2020-02-24 Thread Rainer Hihn
Hi all,

in my project, I'm traversing through a huge directory with millions of files, 
parse them and write the results into a Postgres database.
Unfortunately, I'm facing erros when I'm using multiprocessing.Pool with more 
than one processes.

This is how I'm inserting new values into the database:

obj, created = MyModel.objects.get_or_create(foo=foo, defaults={'foo': foo,}) # 
foo is unique


And this is the error message I'm getting: 


[ERROR] no results to fetch
Traceback (most recent call last):
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
psycopg2.ProgrammingError: no results to fetch

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/develop/myApp/web/service/ais.py", line 94, in save
db_foo = utils.create_foo(obj.get("foo"), obj.get("source"))
  File "~/develop/myApp/web/utils.py", line 85, in create_foo
obj = MyModel.objects.get(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 411, in get
num = len(clone)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 258, in __len__
self._fetch_all()
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 1261, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 57, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1177, in execute_sql
return list(result)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1576, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/sql/compiler.py",
 line 1576, in 
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File "~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/utils.py", 
line 97, in inner
return func(*args, **kwargs)
django.db.utils.ProgrammingError: no results to fetch
[ERROR] error with status PGRES_TUPLES_OK and no message from the libpq
Traceback (most recent call last):
  File "~/develop/myApp/web/utils.py", line 85, in create_foo
obj = MyModel.objects.get(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 415, in get
raise self.model.DoesNotExist(
web.models.MyModel.DoesNotExist: MyModel matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/backends/utils.py", 
line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.DatabaseError: error with status PGRES_TUPLES_OK and no message from 
the libpq

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/develop/myApp/web/service/ais.py", line 94, in save
db_foo = utils.create_foo(obj.get("foo"), obj.get("source"))
  File "~/develop/myApp/web/utils.py", line 89, in create_foo
obj = MyModel.objects.create(foo=foo)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/manager.py", 
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/query.py", 
line 433, in create
obj.save(force_insert=True, using=self.db)
  File "~/develop/myApp/web/models.py", line 34, in save
return super().save(*args, **kwargs)
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 745, in save
self.save_base(using=using, force_insert=force_insert,
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 782, in save_base
updated = self._save_table(
  File 
"~/.virtualenvs/myApp/lib/python3.8/site-packages/django/db/models/base.py", 
line 887, in _save_table
results = self._do_insert(cls._base_manager

Re: d

2020-02-24 Thread Muhammad Abdullah Nabeel
I want to share file as a software that can be installed. not necessarily
it should be a website . like it can be given to another person in a USB
Drive and other person opens a file that shows "install it" and clicking on
that button the other computer gets installed that software and the other
computer has not downloaded  Django or python from the internet

On Mon, Feb 24, 2020 at 4:28 PM Motaz Hejaze  wrote:

> You want to make a file sharing website ??
>
> On Mon, 24 Feb 2020, 1:22 pm Muhammad Abdullah Nabeel, <
> muhammadabdullahnab...@gmail.com> wrote:
>
>> I have made few games and data storing and searching softwares using
>> tkinter turtle numpy pygame math random etc modules but I still can not
>> made a system in which I can make another person give a file and the other
>> person can install my software in  his computer. Can I do this using Django
>> module or I need to do something else
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/c20ab536-b3ad-48ce-b1a1-191ea18d37cf%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/CAHV4E-cQfP5CyUjhziJZ1uVbmt5TwsebF-rdpeR8i8p3LWBjWA%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/CAA-Why3TC3awsYTV420qYGm_gY29Z0%2BMx4VVPLFpNKERJmmKFg%40mail.gmail.com.


Re: d

2020-02-24 Thread Kasper Laudrup

Hi Muhammed,

On 24/02/2020 13.22, Muhammad Abdullah Nabeel wrote:
I want to share file as a software that can be installed. not 
necessarily it should be a website . like it can be given to another 
person in a USB Drive and other person opens a file that shows "install 
it" and clicking on that button the other computer gets installed that 
software and the other computer has not downloaded  Django or python 
from the internet




You are most likely looking for something like pyinstaller:

https://www.pyinstaller.org/

This is not related to Django at all.

Kind regards,

Kasper Laudrup

--
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/8ca448d9-186a-fec7-c621-040e5faaa29a%40stacktrace.dk.


Re: d

2020-02-24 Thread Motaz Hejaze
Ok i got it Mohammed ,

Kindly checkout PyInstaller 

Django is a web framework used to create websites and web services


On Mon, Feb 24, 2020 at 3:56 PM Kasper Laudrup 
wrote:

> Hi Muhammed,
>
> On 24/02/2020 13.22, Muhammad Abdullah Nabeel wrote:
> > I want to share file as a software that can be installed. not
> > necessarily it should be a website . like it can be given to another
> > person in a USB Drive and other person opens a file that shows "install
> > it" and clicking on that button the other computer gets installed that
> > software and the other computer has not downloaded  Django or python
> > from the internet
> >
>
> You are most likely looking for something like pyinstaller:
>
> https://www.pyinstaller.org/
>
> This is not related to Django at all.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/8ca448d9-186a-fec7-c621-040e5faaa29a%40stacktrace.dk
> .
>

-- 
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/CAHV4E-c9g_J7dFofsa6W7kTKCA7KT49-wCRPqpRPbB_1woxzxw%40mail.gmail.com.


reg: Error:-django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used in key specification without a key length")

2020-02-24 Thread 'Amitesh Sahay' via Django users
Hi, 
I am creating a model, which is taking a description as text field. when I 
migrate I see the below error:
django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used 
in key specification without a key length")

ON further research I came to know that its some limitation with MySQL. I am 
using MYSQL for my dev. Below is the link that describes the issue.
MySQL error: key specification without a key length

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
MySQL error: key specification without a key length

I have a table with a primary key that is a varchar(255). Some cases have 
arisen where 255 characters isn't enou...
 |

 |

 |


So what am I suppose to use if not TextField? I have tried CharField, that 
doesn't work either. Below is the model details:
class OnlineShop(models.Model):
Product_name = models.CharField(max_length=100, unique=True)
Price = models.IntegerField()
Slug = models.SlugField(max_length=250, unique=True)
Description = models.TextField()
Curr_Time = models.DateTimeField(auto_now_add=True)

def __str__(self):
return '{}'.format(self.Product_name)



Regards,
Amitesh Sahay91-750 797 8619

-- 
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/1073924601.858407.1582555396348%40mail.yahoo.com.


Re: Django i18n_patterns default language

2020-02-24 Thread Aldian Fazrihady
You can add a middleware to ignore the header:

class IgnoreLanguageHeaderLocaleMiddleware(LocaleMiddleware):

LANGUAGE_HEADER = 'HTTP_ACCEPT_LANGUAGE'

def process_request(self, request):
if self.LANGUAGE_HEADER in request.META:
del request.META[self.LANGUAGE_HEADER]

super(IgnoreLanguageHeaderLocaleMiddleware,
self).process_request(request)


On Mon, Feb 24, 2020 at 1:44 PM Szocs Arnold 
wrote:

> Is there any solution to add language prefix to the URL from the
> settings.LANGUAGE_CODE which is my preferred language. Instead from
>  "Accept-Language" header. I do not want to use the browser language.
>
> On Fri, Feb 21, 2020 at 4:14 PM Aldian Fazrihady 
> wrote:
>
>> A web browser has language preference setting. When a request made to
>> your Django server,  your browser reads its language preferences and it put
>> it in the request "Accept-Language" header.
>> Django will check if the request URL has language prefix in it. If it
>> doesn't it will add language prefix to the same URL and make web browser to
>> redirect to that new URL.
>>
>> You can see the flow using web browser developer tool.
>>
>> On Fri, Feb 21, 2020 at 8:43 PM Szocs Arnold 
>> wrote:
>>
>>> I am using i18n_patterns to change the language prefix in url. It s
>>> working fine ones the language cookie is set. The problem is that it's
>>> adding /en/ when I trying to access a page without the language code in
>>> private window, even though my preferred language is not en (the default
>>> one set in settings.LANGUAGE_CODE). The Django documentation says that how
>>> django discovers language prefference:
>>>
>>> Django documentation says it will use the following to choose the
>>> language:
>>>
>>> First, it looks for the language prefix in the requested URL.Failing
 that, it looks for the LANGUAGE_SESSION_KEY key in the current user’s
 session.Failing that, it looks for a cookie. The name of the cookie used is
 set by the LANGUAGE_COOKIE_NAME setting. (The default name is
 django_language.) Failing that, it looks at the Accept-Language HTTP
 header. This header is sent by your browser and tells the server which
 language(s) you prefer, in order by priority. Django tries each language in
 the header until it finds one with available translations. Failing that, it
 uses the global LANGUAGE_CODE setting.

>>>
>>> So the reason why I get /en/ prefix in my url, when there is no any
>>> cookie set is because of the Accept-Language HTTP header. How can i solve
>>> that if somebody visits my site for the first time when there is no cookie,
>>> the i18n to go to the final step to get the language from the global
>>> LANGUAGE_CODE?
>>>
>>>
>>> --
>>> 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/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.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/CAN7EoAbU5kUTc0UrX0etqp_s8bC4zK0L-wHpYNuoUB585DM7Og%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/CABRfZM%2BbayBueLk68gC8NiQhrkisG8G%2B_OktDdOr9uR%3DW2yk_w%40mail.gmail.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAak5nkd9mMVGRbUXzZc5g2A885cwKfQZoPf4QTXTdxzVA%40mail.gmail.com.


Re: reg: Error:-django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description' used in key specification without a key length")

2020-02-24 Thread Integr@te System
Hi Freind,

For simplify and minimize your dev time, review first in your err, code
base.
Thank your sharing and dont forget zen.


On Mon, Feb 24, 2020, 21:43 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> Hi,
>
> I am creating a model, which is taking a description as text field. when I
> migrate I see the below error:
>
> django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'Description'
> used in key specification without a key length")
>
> ON further research I came to know that its some limitation with MySQL. I
> am using MYSQL for my dev. Below is the link that describes the issue.
>
> MySQL error: key specification without a key length
> 
>
> MySQL error: key specification without a key length
>
> I have a table with a primary key that is a varchar(255). Some cases have
> arisen where 255 characters isn't enou...
>
> 
>
> *So what am I suppose to use if not TextField? I have tried CharField,
> that doesn't work either. Below is the model details:*
>
>
>
>
>
>
>
>
>
> *class OnlineShop(models.Model): Product_name =
> models.CharField(max_length=100, unique=True) Price = models.IntegerField()
> Slug = models.SlugField(max_length=250, unique=True) Description =
> models.TextField() Curr_Time = models.DateTimeField(auto_now_add=True) def
> __str__(self): return '{}'.format(self.Product_name)*
>
>
> Regards,
> Amitesh Sahay
> *91-750 797 8619*
>
> --
> 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/1073924601.858407.1582555396348%40mail.yahoo.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/CAP5HUWpJ2DTZUpacOdoisnT3_uSPebQ5D03H9i%2BN-PtehATrTg%40mail.gmail.com.


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

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

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5bgRxVDaK7L6b8H7Mw6mt0qWCRAmSYH4L-G_9hxBR7bg%40mail.gmail.com.


Django Session KeyError

2020-02-24 Thread Guy NANA
I have an angular frontend app which send file to django backend which data 
is setting in django session. After I send a httprequest to django backend 
to make ML tratements on that data and get the results. But I've a 500 
sever error: keyerror 'ts_dataset_copy': KeyError: 'ts_dataset_copy'
[24/Feb/2020 18:43:46] "GET /cv_classification/5/FOTS/283/None/0/0 
HTTP/1.1" 500 78264. Here are my django code:

Firstly I upload timeseries dataset file from angular frontend (All thing 
is ok)
@csrf_exempt
def upload_local_dataset(request):
if request.method == 'POST':
dataset = pd.read_csv(request.FILES.get('datasetfilepath'), 
header=None, index_col=None)
request.session['ts_datset'] = dataset.to_json(orient='values')
request.session['ts_dataset_copy'] = dataset.to_json(orient=
'values')

return HttpResponse(dataset.to_json(orient='values'))



# second httrequest that throws a server internal error

def cv_classification(request, kfolds, dissimilarity_func, 
windows_length=0, noisy_law="", mu=0, 

std=0):
noisy_law = noisy_law.lower()
df = pd.read_json(request.session['ts_dataset_copy'], orient=
'values')
predictions = cv_classify(df, kfolds, dissimilarity_func, 
windows_length, noisy_law, mu, std)
return JsonResponse(predictions, safe=False)



Thanks for your help!

-- 
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/0636beca-4da4-4af2-9025-c6638e752722%40googlegroups.com.


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

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

upstream django {

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

}


server {

listen 8090;

server_name foo.bar.com;

charset utf-8;


location /static {

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

}


location / {

   uwsgi_pass django;

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

   uwsgi_read_timeout 3600;

   client_max_body_size 50m;

}

}


Now I changed it to this:


upstream django {

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

}


server {

listen 8090;

server_name foo.bar.com;

charset utf-8;


location /static {

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

}


location / {

proxy_pass http://0.0.0.0:8090;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";


proxy_redirect off;

proxy_set_header   Host $host;

proxy_set_header   X-Real-IP $remote_addr;

proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header   X-Forwarded-Host $server_name;

}

}


Started daphne like this:


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


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


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

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


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

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

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY43bVM0QEbniN3nzdRppM0ABo%3DOWFS5O5v0XX0YUh5Wcg%40mail.gmail.com.


ANN: django-yamlconf v1.2.1 is available

2020-02-24 Thread Michael Rohan
 Hi Folks,

Have release v1.2.1 for django-yamlconf, a module supporting Django
settings via YAML files (searching up the directory hierarchy, e.g., in a
K8s environment, adding a "final" set of settings via "/APPLICATION.yaml",
see the documentation a https://django-yamlconf.readthedocs.io/en/latest/
for more detailed info.

The updates for the this release are:

- Tagged with ``v1.2.1``.
- Fixed the long description which caused failures for "pip install" of
v1.2.0.

Take care,
Michael.


-- 
Michael Rohan
mro...@acm.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOCsNFjR4kVsisswSPkOUWD6zVjfK%3DBZQJ9yQ5R7tp9mpPEyGg%40mail.gmail.com.


Re: Selecting all and posting

2020-02-24 Thread Integr@te System
Hi Isaac,

Plz review and attempt sth like this sample:

as we have with any type of fields you like for user input :

sth.html


 Click On 


const checkbox = document.querySelector('input[type=checkbox]');
const button = document.querySelector('button');
checkbox.onchange = () => {
if (checkbox.checked) {
button.onclick = () => {  alert('Alert sth of user input. ');
};
}
};


If you asign any id of each input tag or type, you can map to db, that base
on your declare and define.



On Mon, Feb 24, 2020, 10:31 maninder singh Kumar 
wrote:

> There is a doubt about the model
>
>
> [image: --]
>
> Maninder Kumar
> [image: http://]about.me/maninder.s.kumar
> 
>
>
>
>
> On Mon, Feb 24, 2020 at 4:37 AM Rishabh Gupta 
> wrote:
>
>> I can help give me checkout . You need to use of javascript .You can
>> take id from input field and place in value
>>
>> On Sun, Feb 23, 2020 at 9:12 PM Isaac Ndutumo 
>> wrote:
>> >
>> > Am working on a hospital system where the billing model requires users
>> to select varies items from the bill list and post them by creating a
>> receipt or an invoice. Am new in JavaScript programming combined with
>> Django.
>> >
>> > Any help on below tasks will be highly appreciated
>> >
>> > Select all or few and post either as a receipt or invoice.
>> > Show total of selected items dynamically
>> >
>> >
>> >   Find attached capture for bill view.
>> >
>> > --
>> > 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/1b59fa26-910c-4fb6-81c4-a7b38291abf7%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/CACpDem3efVDbusZHhJGWvLh_F1epgK4nEO2hNxe5%2BdnO5ObJDw%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/CABOHK3R71Jjz6TyB566ExsuA7bNk0FBEcYLf0vMoFuNV8TZwag%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/CAP5HUWp7Vjt2mfAwWg%3DGMNMvUcPb_KtVtYaeOCcKrYwfapsgQA%40mail.gmail.com.


Basic Django Website Hangs on Apache 2.4.41 due to Pandas 1.0.1

2020-02-24 Thread Siddharth Agarwal
Hello Everyone,

I have build a basic Website using Python 3.7 + Django 3.0.0 + MySQL 8.0.18 
+ Pandas 1.0.1. This site works very well using py manage.py runserver on 
my local environment.

However, as soon as I deploy it on Apache 2.4.41 configured on Windows 10 
Server. The site starts giving 408 error. 

On further debugging I have observed that imports from pandas are the root 
cause of the issue. Please code from model.py for your reference - 

from django.db import models, connection

*# from pandas import DataFrame*
*# from pandas import concat, to_datetime, to_numeric*
*# Un-commenting above two lines cause the issue*

# Create your models here.
class ISMADates(models.Manager):
def date_list(self):
with connection.cursor() as cursor:
cursor.execute("select date_id, date from master_date order by 
date_id desc LIMIT 10;")
result_list = cursor.fetchall()
# print(result_list)
return result_list

However as per my understanding pandas should work seamlessly with Django. 
And this combination is quite widely used.

Please let me know how to proceed further.

Thanks and Regards,
Siddharth Agarwal

-- 
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/bbeba4dc-d364-4e6b-a2fc-421afb4d942f%40googlegroups.com.


Django Redis error

2020-02-24 Thread Charles
Hi i have encountered an error after installing django 3.0 and i after i 
reverted it back to my old version it doesn't run here is the traceback 
error 

Loading .env environment variables…
Loading .env environment variables…
Traceback (most recent call last):
  File "manage.py", line 19, in 
execute_from_command_line(sys.argv)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/core/management/__init__.py",
 
line 381, in execute_from_command_line
utility.execute()
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/core/management/__init__.py",
 
line 357, in execute
django.setup()
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/__init__.py",
 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/apps/registry.py",
 
line 91, in populate
app_config = AppConfig.create(entry)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/apps/config.py",
 
line 116, in create
mod = import_module(mod_path)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/importlib/__init__.py",
 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 985, in _gcd_import
  File "", line 968, in _find_and_load
  File "", line 957, in _find_and_load_unlocked
  File "", line 673, in _load_unlocked
  File "", line 697, in exec_module
  File "", line 222, in 
_call_with_frames_removed
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django_q/apps.py",
 
line 3, in 
from django_q.conf import Conf
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django_q/conf.py",
 
line 153
Q_STAT = f"django_q:{PREFIX}:cluster"
^
SyntaxError: invalid syntax
Traceback (most recent call last):
  File "manage.py", line 19, in 
execute_from_command_line(sys.argv)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/core/management/__init__.py",
 
line 381, in execute_from_command_line
utility.execute()
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/core/management/__init__.py",
 
line 357, in execute
django.setup()
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/__init__.py",
 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/apps/registry.py",
 
line 91, in populate
app_config = AppConfig.create(entry)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django/apps/config.py",
 
line 116, in create
mod = import_module(mod_path)
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/importlib/__init__.py",
 
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 985, in _gcd_import
  File "", line 968, in _find_and_load
  File "", line 957, in _find_and_load_unlocked
  File "", line 673, in _load_unlocked
  File "", line 697, in exec_module
  File "", line 222, in 
_call_with_frames_removed
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django_q/apps.py",
 
line 3, in 
from django_q.conf import Conf
  File 
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django_q/conf.py",
 
line 153
Q_STAT = f"django_q:{PREFIX}:cluster"

-- 
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/fec9d8ef-f7ff-4ed8-9b2e-b1681765426b%40googlegroups.com.


Learning Django

2020-02-24 Thread DamnGeniuses' Squad
I'm learning Django from django documentation tutorial
But when i want to clone a template from link that was in web , the repo is 
empty
Can i get another template or link to clone ? Thankyouu

Getting a copy of Django’s development version¶ 


The first step to contributing to Django is to get a copy of the source 
code. First, fork Django on GitHub . 
Then, from the command line, use the cd command to navigate to the 
directory where you’ll want your local copy of Django to live.

Download the Django source code repository using the following command:
/ 

$ git clone https://github.com/YourGitHubName/django.git

Low bandwidth connection?

You can add the --depth 1 argument to git clone to skip downloading all of 
Django’s commit history, which reduces data transfer from ~250 MB to ~70 MB.

Now that you have a local copy of Django, you can install it just like you 
would install any package using pip. The most convenient way to do so is by 
using a *virtual environment*, which is a feature built into Python that 
allows you to keep a separate directory of installed packages for each of 
your projects so that they don’t interfere with each other.

It’s a good idea to keep all your virtual environments in one place, for 
example in .virtualenvs/ in your home directory.

Create a new virtual environment by running:

-- 
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/4df0014a-607b-4bb0-9b0c-14ea6e9a1954%40googlegroups.com.


Issue with Fixutre loading with multiple test cases on Postgres - duplicate key value violates unique constraint

2020-02-24 Thread Lokesh


class Test1(TestCase):
fixtures = ['fixture.json']

@classmethod
def tearDownClass(cls):
super(TestCase, cls).tearDownClass()

def test_demo(self):
u = User.objects.get(username='testuser1')
#some testing - removed actual tests as we can replicate the issue with 
even this code

class Test2(TestCase):
fixtures = ['fixture.json']

def test_demo2(self):
u = User.objects.get(username='testuser1')
#Some testing


I have these two test cases and my fixture has 2 rows in total, one for the 
User table with pk=1, and the other for profile table (one-to-one relation 
with User table)

If I run the test cases independently, both of the work perfect;y. But if I 
run them both at the same time, I get this error

Could not load app1.Profile(pk=1): duplicate key value violates unique 
> constraint "app1_profile_user_id_key"


>From my understanding of the documentation, Django will rollback all 
fixtures after the TestCase is done so that the DB is back to the point 
where only migrations are done and no fixture data is present.  

 Few StackOverflow answers suggested that we need to make an explicit call 
to teardown after the test case is done. So I added this code

@classmethod
def tearDownClass(cls):
super(TestCase, cls).tearDownClass()

This helps in running both the test cases together. But this leads to a new 
issue of DB not being flushed between test cases. Filed a bug report in 
detail on Bug tracker . 


Is there something I'm missing here? Any help would be greatly appreciated.

-- 
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/10245efe-9789-4ff9-9eda-a3f4bbc343df%40googlegroups.com.


Re: Django Redis error

2020-02-24 Thread Kasper Laudrup

Hi Charles,

On 24/02/2020 06.20, Charles wrote:
"/home/panda/.local/share/virtualenvs/loans-engine-backend-iaqdRd9l/lib/python3.5/site-packages/django_q/conf.py", 
line 153

     Q_STAT = f"django_q:{PREFIX}:cluster"
                                         ^


Python f-strings has only been introduced in Python 3.6:

https://realpython.com/python-f-strings/

You seem to be using python 3.5.

Kind regards,

Kasper Laudrup

--
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/1644cc57-d517-da86-e05f-588e7b82e022%40stacktrace.dk.


d

2020-02-24 Thread Muhammad Abdullah Nabeel
I have made few games and data storing and searching softwares using 
tkinter turtle numpy pygame math random etc modules but I still can not 
made a system in which I can make another person give a file and the other 
person can install my software in  his computer. Can I do this using Django 
module or I need to do something else

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c20ab536-b3ad-48ce-b1a1-191ea18d37cf%40googlegroups.com.