Re: From and Template in Django

2020-02-25 Thread Naveen Arora
Hi ben,

You can use the same form any number of times passing it through views.

Also, you can create a form.html which you can include anywhere for HTML 
forms using include tag.

Cheers
Naveen Arora

On Wednesday, 26 February 2020 04:25:29 UTC+5:30, ben aziz zizah wrote:
>
> Is that possible to use the same form in more than one template 
>

-- 
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/57795aff-1e7e-4520-b8bf-906f1b7b1445%40googlegroups.com.


Re: Django Session KeyError

2020-02-25 Thread Naveen Arora
Hi, 

please post the output of debugging the above, print after and before in 
these views and also check is something else is working using 
request.session. 
@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')
print(dataset.to_json(orient='values'))
request.session['ts_dataset_copy'] = dataset.to_json(orient=
'values')
print(request.session['ts_dataset_copy'])
return HttpResponse(dataset.to_json(orient='values'))
Post output of this plus the below one
def cv_classification(request, kfolds, dissimilarity_func, windows_length=0,
 noisy_law="", mu=0,std=0):
noisy_law = noisy_law.lower()
print(request.session['ts_dataset_copy'])
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)

On Tuesday, 25 February 2020 03:47:25 UTC+5:30, Guy NANA wrote:
>
> 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/ee6dd1d1-9567-46ba-a699-500d1e950788%40googlegroups.com.


Re: allauth- signup redirect

2020-02-25 Thread Naveen Arora


Hi Tosin,


The simplest way would be to override the template account/signup.html with 
your own copy. If you examine that template you will see the following 
section:

{% if redirect_field_value %}{% endif %}

If you remove the if/endif part and change the value inside, the signup 
page will redirect to a specific page, even if you pass a next argument in 
the URL:




Cheers,
Naveen Arora

On Tuesday, 25 February 2020 23:58:02 UTC+5:30, Tosin Ayoola wrote:
>
> halo guy, i'm using allauth for my authentication, but i wan redirect the 
> signup user to a page where they get update their profile detail, how do i 
> override the default success_url after the user have successfully signup ,  
>
>
>
>
>
>

-- 
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/7e5a5842-1aef-4afe-9cd1-46e1e40534fb%40googlegroups.com.


Re: 'ssl_disabled' is an invalid keyword argument for connect()

2020-02-25 Thread Naveen Arora
Hi sir,

Kindly use this as below,

'OPTIONS': {
'ssl' : {
'ssl_disabled': True
}
}

Cheers,
Naveen Arora

On Wednesday, 26 February 2020 04:25:29 UTC+5:30, Stephen Loughin wrote:
>
> The django doc 
> s say I 
> can pass OPTIONS for the db connection here:
>
> DATABASES = {
>
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'OPTIONS': {
> 'ssl_disabled': 'True',
> },
> 'NAME': 'somedatabase',
> 'USER': 'someuser',
> 'PASSWORD': 'somepassword',
> 'HOST': '10.0.0.1',  
> 'PORT': '3306',
> }
>
> Yet when I try python manage.py runserver I get this:
>
> TypeError: 'ssl_disabled' is an invalid keyword argument for connect()
>
> I have also tried 'ssl_disabled': True,  # that is an actual boolean 
> rather than string...
> Same result.  Running django 3 and python 3.7.4 
>
> Thanks,
> -- Steve
> slou...@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/2dbfa0b2-6e91-4a21-89d6-f8adb5383ceb%40googlegroups.com.


Re: 'ssl_disabled' is an invalid keyword argument for connect()

2020-02-25 Thread Integr@te System
Hi Steve,

Plz review again to take a right parameter.
Welcome.


On Wed, Feb 26, 2020, 05:54 Stephen Loughin  wrote:

> The django doc
> s say I
> can pass OPTIONS for the db connection here:
>
> DATABASES = {
>
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'OPTIONS': {
> 'ssl_disabled': 'True',
> },
> 'NAME': 'somedatabase',
> 'USER': 'someuser',
> 'PASSWORD': 'somepassword',
> 'HOST': '10.0.0.1',
> 'PORT': '3306',
> }
>
> Yet when I try python manage.py runserver I get this:
>
> TypeError: 'ssl_disabled' is an invalid keyword argument for connect()
>
> I have also tried 'ssl_disabled': True,  # that is an actual boolean
> rather than string...
> Same result.  Running django 3 and python 3.7.4
>
> Thanks,
> -- Steve
> sloug...@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/CAHM1-MAfUCJtZG5%2B5bOMO_bzYr6E8J%2BO28YNxXPZD4MZNyj5eg%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/CAP5HUWqDbyHiQ170z147CmTsq3-1UTx2Z7hpLntui7BFV7MSuA%40mail.gmail.com.


Re: allauth- signup redirect

2020-02-25 Thread Vishnu Thuletiya
In setting.py you can write
LOGIN_REDIRECT_URL='your redirect path'

On Tue, 25 Feb 2020, 11:57 pm Tosin Ayoola,  wrote:

> halo guy, i'm using allauth for my authentication, but i wan redirect the
> signup user to a page where they get update their profile detail, how do i
> override the default success_url after the user have successfully signup ,
>
>
>
>
>
> --
> 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/CAHLKn72_%2BsS%2Bcmz_CATcWWA9DQ7T-7_c86HjSBMfYKW9%2BsWzcA%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/CACggCHsVnnbUTNnV9CBT7LmgcJsXGsTWOcYin%3DqscCjscrn7-Q%40mail.gmail.com.


Re: Django Session KeyError

2020-02-25 Thread Guy NANA
Hi!
Yes, it is.

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tsanalysisapp.apps.TsanalysisappConfig',

# Django Rest Framework - DRF
'rest_framework',
# Django Rest Pandas - DRP
'rest_pandas',

# CORS
'corsheaders',
]

MIDDLEWARE = [
# CORS
'corsheaders.middleware.CorsMiddleware',

'django.middleware.common.CommonMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]


Le mercredi 26 février 2020 02:23:59 UTC+1, juanblo a écrit :
>
> Hi, 
>
> In your Django application, session middleware is enabled ? [1]
>
> [1] https://docs.djangoproject.com/en/3.0/topics/http/sessions/
>
> On Tue, Feb 25, 2020 at 8:16 AM Guy NANA  > wrote:
>
>> I don't understand the first part of your answer : *Make sure your 
>>> line request.session['ts_dataset_copy'], print anything above it.*
>>
>>  For sending dataset file from angular app to django, I've used a post 
>> request.
>>
>> The matter is that when I send the second http crosss-origin from angular 
>> app to my django app the previously session's elements that I've stored 
>> doesn't exist anymore. (I checked the session keys in the 
>> upload_local_dataset and receive *In upload_local_dataset Session's keys 
>> : dict_keys(['ts_dataset', 'ts_dataset_copy'])* but in the second views 
>> I received an empty dict *In cv_classification Session's keys : 
>> dict_keys([])* so pandas' read_json throws an error *ValueError: Invalid 
>> file path or buffer object type: *
>> How can I save the state of session between two http cross-origin from 
>> angular app to django app ?
>>
>> Le mardi 25 février 2020 13:29:53 UTC+1, Pankaj Sharma a écrit :
>>
>>> Make sure your line request.session['ts_dataset_copy'], print anything 
>>> above it, also make sure you are using POST method in forms (method = 
>>> "post") 
>>>
>>> On Tuesday, February 25, 2020 at 3:47:25 AM UTC+5:30, Guy NANA wrote:

 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/c0d3a833-15f2-415f-b4e0-c05951f523f0%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Juan 
>

-- 
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/b82b18f4-79d3-4001-8f5f-7d68c063421c%40googlegroups.com.


Re: Django Session KeyError

2020-02-25 Thread Juan Pablo Romero Bernal
Hi,

In your Django application, session middleware is enabled ? [1]

[1] https://docs.djangoproject.com/en/3.0/topics/http/sessions/

On Tue, Feb 25, 2020 at 8:16 AM Guy NANA  wrote:

> I don't understand the first part of your answer : *Make sure your
>> line request.session['ts_dataset_copy'], print anything above it.*
>
>  For sending dataset file from angular app to django, I've used a post
> request.
>
> The matter is that when I send the second http crosss-origin from angular
> app to my django app the previously session's elements that I've stored
> doesn't exist anymore. (I checked the session keys in the
> upload_local_dataset and receive *In upload_local_dataset Session's keys
> : dict_keys(['ts_dataset', 'ts_dataset_copy'])* but in the second views I
> received an empty dict *In cv_classification Session's keys :
> dict_keys([])* so pandas' read_json throws an error *ValueError: Invalid
> file path or buffer object type: *
> How can I save the state of session between two http cross-origin from
> angular app to django app ?
>
> Le mardi 25 février 2020 13:29:53 UTC+1, Pankaj Sharma a écrit :
>
>> Make sure your line request.session['ts_dataset_copy'], print anything
>> above it, also make sure you are using POST method in forms (method =
>> "post")
>>
>> On Tuesday, February 25, 2020 at 3:47:25 AM UTC+5:30, Guy NANA wrote:
>>>
>>> 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/c0d3a833-15f2-415f-b4e0-c05951f523f0%40googlegroups.com
> 
> .
>


-- 
Juan

-- 
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/CAJK1Jg26mZp4wdq9tmiAmhUCRY4vZk5krLrBaP3hSwkBWh%3DDnA%40mail.gmail.com.


Re: From and Template in Django

2020-02-25 Thread Juan Pablo Romero Bernal
Hi,

Yes, you can use an instance of Form in more than one template:

See: https://docs.djangoproject.com/en/3.0/topics/forms/ for more details.


On Tue, Feb 25, 2020 at 4:54 PM ben aziz zizah 
wrote:

> Is that possible to use the same form in more than one template
>
> --
> 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/f9ac6f20-8d59-47be-b32f-27471b122c3b%40googlegroups.com
> 
> .
>


-- 
Juan

-- 
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/CAJK1Jg0nOcL5M-jPZ3B%3DT2jL3U1qd_JkVm%3D1BeUQEo_SJRzG1w%40mail.gmail.com.


Re: 'ssl_disabled' is an invalid keyword argument for connect()

2020-02-25 Thread Juan Pablo Romero Bernal
Hi Steve,

The supported option is ssl, see:

https://github.com/django/django/blob/stable/3.0.x/django/db/backends/mysql/client.py

I hope this helps,

On Tue, Feb 25, 2020 at 4:54 PM Stephen Loughin  wrote:

> The django doc
> s say I
> can pass OPTIONS for the db connection here:
>
> DATABASES = {
>
> 'default': {
> 'ENGINE': 'django.db.backends.mysql',
> 'OPTIONS': {
> 'ssl_disabled': 'True',
> },
> 'NAME': 'somedatabase',
> 'USER': 'someuser',
> 'PASSWORD': 'somepassword',
> 'HOST': '10.0.0.1',
> 'PORT': '3306',
> }
>
> Yet when I try python manage.py runserver I get this:
>
> TypeError: 'ssl_disabled' is an invalid keyword argument for connect()
>
> I have also tried 'ssl_disabled': True,  # that is an actual boolean
> rather than string...
> Same result.  Running django 3 and python 3.7.4
>
> Thanks,
> -- Steve
> sloug...@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/CAHM1-MAfUCJtZG5%2B5bOMO_bzYr6E8J%2BO28YNxXPZD4MZNyj5eg%40mail.gmail.com
> 
> .
>


-- 
Juan

-- 
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/CAJK1Jg2mEFCr-3NHg8CuAgKHOSyNVP-gg7gC8fa-yvTkiN%3DDYA%40mail.gmail.com.


Re: Get last instance object per each month and sum per month in Django

2020-02-25 Thread Simon Charette
If you don't want to operate on Activity instances annotations you can use 
the following queryset

Status.objects.annotate(
status_month=TruncMonth('status_date'),
).order_by(
'activity', 'status_month',
).values_list(
'activity', 'status_month',
).annotate(
progress_sum=Sum(actual_progress)
)

That will return an iterable of lists of the form [activity_id, 
status_month, progress_sum]

If you want to annotate your Activity instances you'll need to use window 
functions[0].

Simon

[0] 
https://docs.djangoproject.com/en/3.0/ref/models/expressions/#window-functions

Le mardi 25 février 2020 17:55:49 UTC-5, Agnese Camellini a écrit :
>
> You should search how to make a group by activity and a partition by month 
> then take each partition and sum the record up, i don't know how to do it 
> in Django orm but in sql is the most effective way to solve the issue and 
> it's a lot let expensive than taking all the activities and then search in 
> the status Table.
> my 2 cents
> Agnese
>
> On Tue, 25 Feb 2020 at 21:07, Mario Bisiani  > wrote:
>
>> I tryed to search for answer but nothing yet can help me.
>>
>> I have one class model Activity and a class model Status :
>>
>> class Status(models.Model):
>> activity = models.ForeignKey(Activity, on_delete=models.CASCADE, 
>> related_name="all_status")
>> status_date = models.DateField()
>> actual_progress = models.DecimalField(max_digits=3, decimal_places=2)
>>
>> I need to get last 'status_date' for each activity for each month and sum 
>> up its actual_progress.
>>
>> Can't find after many research a way out.
>>
>> *Update*
>>
>> I found a way to get latest status per activity helped here Django - get 
>> latest object in each relation 
>> 
>> :
>>
>> @classmethod
>> def get_latest_by_activity_ids(cls, activity_id):
>> found = []
>> for aid in Activity.objects.all():
>> 
>> found.append(cls.objects.filter(activity_id=aid).latest("status_date"))
>> return found 
>>
>> This gave me a list of dates. Now I'm blocked to sum them up per month.
>>
>>
>>
>> https://stackoverflow.com/questions/60366457/get-last-instance-object-per-each-month-and-sum-per-month-in-django
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/91d43812-6c7a-431d-9117-7a79519564fd%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/c2cbe3ac-9acd-44cd-a48b-24d74f75cb09%40googlegroups.com.


From and Template in Django

2020-02-25 Thread ben aziz zizah
Is that possible to use the same form in more than one template 

-- 
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/f9ac6f20-8d59-47be-b32f-27471b122c3b%40googlegroups.com.


Re: Get last instance object per each month and sum per month in Django

2020-02-25 Thread Agnese Camellini
You should search how to make a group by activity and a partition by month
then take each partition and sum the record up, i don't know how to do it
in Django orm but in sql is the most effective way to solve the issue and
it's a lot let expensive than taking all the activities and then search in
the status Table.
my 2 cents
Agnese

On Tue, 25 Feb 2020 at 21:07, Mario Bisiani  wrote:

> I tryed to search for answer but nothing yet can help me.
>
> I have one class model Activity and a class model Status :
>
> class Status(models.Model):
> activity = models.ForeignKey(Activity, on_delete=models.CASCADE, 
> related_name="all_status")
> status_date = models.DateField()
> actual_progress = models.DecimalField(max_digits=3, decimal_places=2)
>
> I need to get last 'status_date' for each activity for each month and sum
> up its actual_progress.
>
> Can't find after many research a way out.
>
> *Update*
>
> I found a way to get latest status per activity helped here Django - get
> latest object in each relation
> 
> :
>
> @classmethod
> def get_latest_by_activity_ids(cls, activity_id):
> found = []
> for aid in Activity.objects.all():
> 
> found.append(cls.objects.filter(activity_id=aid).latest("status_date"))
> return found
>
> This gave me a list of dates. Now I'm blocked to sum them up per month.
>
>
>
> https://stackoverflow.com/questions/60366457/get-last-instance-object-per-each-month-and-sum-per-month-in-django
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/91d43812-6c7a-431d-9117-7a79519564fd%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/CACXuh-Ryg0C6W%2Br7U%2BZqJywcmv9-o1MiwKCarm1dmT%3DK%2B5quHQ%40mail.gmail.com.


'ssl_disabled' is an invalid keyword argument for connect()

2020-02-25 Thread Stephen Loughin
The django doc
s say I
can pass OPTIONS for the db connection here:

DATABASES = {

'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'ssl_disabled': 'True',
},
'NAME': 'somedatabase',
'USER': 'someuser',
'PASSWORD': 'somepassword',
'HOST': '10.0.0.1',
'PORT': '3306',
}

Yet when I try python manage.py runserver I get this:

TypeError: 'ssl_disabled' is an invalid keyword argument for connect()

I have also tried 'ssl_disabled': True,  # that is an actual boolean rather
than string...
Same result.  Running django 3 and python 3.7.4

Thanks,
-- Steve
sloug...@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/CAHM1-MAfUCJtZG5%2B5bOMO_bzYr6E8J%2BO28YNxXPZD4MZNyj5eg%40mail.gmail.com.


Get last instance object per each month and sum per month in Django

2020-02-25 Thread Mario Bisiani


I tryed to search for answer but nothing yet can help me.

I have one class model Activity and a class model Status :

class Status(models.Model):
activity = models.ForeignKey(Activity, on_delete=models.CASCADE, 
related_name="all_status")
status_date = models.DateField()
actual_progress = models.DecimalField(max_digits=3, decimal_places=2)

I need to get last 'status_date' for each activity for each month and sum 
up its actual_progress.

Can't find after many research a way out.

*Update*

I found a way to get latest status per activity helped here Django - get 
latest object in each relation 

:

@classmethod
def get_latest_by_activity_ids(cls, activity_id):
found = []
for aid in Activity.objects.all():

found.append(cls.objects.filter(activity_id=aid).latest("status_date"))
return found 

This gave me a list of dates. Now I'm blocked to sum them up per month.


https://stackoverflow.com/questions/60366457/get-last-instance-object-per-each-month-and-sum-per-month-in-django


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


Django rest api connect with android mobile app

2020-02-25 Thread Zain Mehar
please anyone tell me how i connect my Django rest API with my Andriod 
mobile application please anyone tells? 

-- 
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/e942a95b-18bd-470d-9354-8682d5eb8ff5%40googlegroups.com.


allauth- signup redirect

2020-02-25 Thread Tosin Ayoola
halo guy, i'm using allauth for my authentication, but i wan redirect the
signup user to a page where they get update their profile detail, how do i
override the default success_url after the user have successfully signup ,

-- 
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/CAHLKn72_%2BsS%2Bcmz_CATcWWA9DQ7T-7_c86HjSBMfYKW9%2BsWzcA%40mail.gmail.com.


Re: django context data into javascript

2020-02-25 Thread 'Artem Vasin' via Django users
.js files, even if linked in Django templates are not processed by template 
engine. To output value from context to file, this file should be an output 
from template engine.

You have three ways to solve your problem:
Make your myjs.js file generated by template processor. It’s most difficult and 
worst way so I don’t really suggest it, but feel free to experiment. Think 
about a view, which outputs js file content instead of html and link to this 
view url from your page template
Move js assignment from myjs.js to your template (one in which you link 
myjs.js) wrap it in 

Re: django context data into javascript

2020-02-25 Thread Soumen Khatua
But I'm getting one error

On Tue 25 Feb, 2020, 5:59 PM Naveen Arora, 
wrote:

> Hi, this is simple just enclose {{name}} into " " as "{{name}}" for your
> part.
>
> Thanks
>
> On Tuesday, 25 February 2020 15:56:05 UTC+5:30, Soumen Khatua wrote:
>>
>> Hi Folks,
>>
>> I'm sending some context data into html like
>> name = 'soumen'
>> return render(request,'xyz.html', context = {'name':name})
>>
>> inside myjs.js(js script has been integrated to html):
>> ---
>> var my_name = {{name}};
>>
>> I'm getting an error::: Uncaught SyntaxError: Unexpected token '{'
>>
>> So,How I can render data into frontend??
>>
>> 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/b6c9cd98-b9bd-4178-919a-13d8156029a6%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/CAPUw6WatGXxg0G%3DxC%3DS8ddMFmMpQm-TeZ8B2zZxZi9AAFj8npA%40mail.gmail.com.


Re: Django Session KeyError

2020-02-25 Thread Guy NANA

>
> I don't understand the first part of your answer : *Make sure your 
> line request.session['ts_dataset_copy'], print anything above it.*

 For sending dataset file from angular app to django, I've used a post 
request.

The matter is that when I send the second http crosss-origin from angular 
app to my django app the previously session's elements that I've stored 
doesn't exist anymore. (I checked the session keys in the 
upload_local_dataset and receive *In upload_local_dataset Session's keys : 
dict_keys(['ts_dataset', 'ts_dataset_copy'])* but in the second views I 
received an empty dict *In cv_classification Session's keys : dict_keys([])* 
so pandas' read_json throws an error *ValueError: Invalid file path or 
buffer object type: *
How can I save the state of session between two http cross-origin from 
angular app to django app ?

Le mardi 25 février 2020 13:29:53 UTC+1, Pankaj Sharma a écrit :

> Make sure your line request.session['ts_dataset_copy'], print anything 
> above it, also make sure you are using POST method in forms (method = 
> "post") 
>
> On Tuesday, February 25, 2020 at 3:47:25 AM UTC+5:30, Guy NANA wrote:
>>
>> 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/c0d3a833-15f2-415f-b4e0-c05951f523f0%40googlegroups.com.


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

2020-02-25 Thread Ganesh Babu
Hi Team,
 I am getting an issue that issue i.e., ERROR: Command errored out with
exit status 1: python setup.py egg_info Check the logs for full command
output.

i am trying to install mysql using django template.   please help me.

On Mon, Feb 24, 2020 at 8:13 PM '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
> 
> .
>


-- 
Best Regards
Sri Ganesh Babu.S
Sr. Software Engineer,

*Doyen Solutions*

-- 
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/CAJZVxAsFka9OTMqOZ0GZ2rGb%2BfzEktsq4py__TCe0pu6DuPm3Q%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-25 Thread Naveen Arora
This can be resolved using max_length attribute. If it doesn't work try 
deleting the migration files and doing makemigrations and migrate again.

On Monday, 24 February 2020 20:14:25 UTC+5:30, Amitesh Sahay 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/277413b1-79a0-4e87-a181-f7dba4b23489%40googlegroups.com.


Re: Django Session KeyError

2020-02-25 Thread Pankaj Sharma
Make sure your line request.session['ts_dataset_copy'], print anything 
above it, also make sure you are using POST method in forms (method = 
"post") 

On Tuesday, February 25, 2020 at 3:47:25 AM UTC+5:30, Guy NANA wrote:
>
> 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/1822d7cf-442d-4f9d-83ea-9037e8a98408%40googlegroups.com.


Re: django context data into javascript

2020-02-25 Thread Naveen Arora
Hi, this is simple just enclose {{name}} into " " as "{{name}}" for your 
part.

Thanks

On Tuesday, 25 February 2020 15:56:05 UTC+5:30, Soumen Khatua wrote:
>
> Hi Folks,
>
> I'm sending some context data into html like 
> name = 'soumen'
> return render(request,'xyz.html', context = {'name':name})
>
> inside myjs.js(js script has been integrated to html):
> ---
> var my_name = {{name}};
>
> I'm getting an error::: Uncaught SyntaxError: Unexpected token '{'
>
> So,How I can render data into frontend??
>
> 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/b6c9cd98-b9bd-4178-919a-13d8156029a6%40googlegroups.com.


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

2020-02-25 Thread Pankaj Sharma
You haven't set max_len of TextField, use this - do it like this --  
Description = models.TextField(max_length=1000)

On Monday, February 24, 2020 at 8:14:25 PM UTC+5:30, Amitesh Sahay 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/7e96fa8d-a9d1-4dbf-bcbe-7596ed9d3975%40googlegroups.com.


Re: django context data into javascript

2020-02-25 Thread Gil Obradors
Hi!

The context is a dictionary mapping template variable names to Python
objects.
from https://docs.djangoproject.com/en/3.0/intro/tutorial03/

May be you need to test with a dict nor string directly.
I haven't test a direct variable.

Try not using JS, first resolve dict context in html , then JS.

Luck!

Missatge de Soumen Khatua  del dia dt., 25 de
febr. 2020 a les 11:25:

> Hi Folks,
>
> I'm sending some context data into html like
> name = 'soumen'
> return render(request,'xyz.html', context = {'name':name})
>
> inside myjs.js(js script has been integrated to html):
> ---
> var my_name = {{name}};
>
> I'm getting an error::: Uncaught SyntaxError: Unexpected token '{'
>
> So,How I can render data into frontend??
>
> 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/CAPUw6WYM%2BvkoRqOaUn0%2Bt0j9fBf%2BhUZ2myvfsfY4qoBmLAgTfw%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/CAK-JoTRqi_2rRoshwmr7G74%3DH6STp0LSL_4nKBsODpi4%2BwrrCw%40mail.gmail.com.


django context data into javascript

2020-02-25 Thread Soumen Khatua
Hi Folks,

I'm sending some context data into html like
name = 'soumen'
return render(request,'xyz.html', context = {'name':name})

inside myjs.js(js script has been integrated to html):
---
var my_name = {{name}};

I'm getting an error::: Uncaught SyntaxError: Unexpected token '{'

So,How I can render data into frontend??

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/CAPUw6WYM%2BvkoRqOaUn0%2Bt0j9fBf%2BhUZ2myvfsfY4qoBmLAgTfw%40mail.gmail.com.