Re: how to initialize input form fields using URL parameters

2023-01-23 Thread Michael Maina
Hello,

You need to start from the urls.py file and define a path that looks close 
this   

your_path/ or your_path/

Then change your view to handle the new parameter

def form_view(request, variable_data):

Within your view you can now manipulate this parameter through a 
variable/function/class

Hope this is of help.

The backend is the easy part, front-end needs to be stitched right to 
generate pass variable data accurately with minimal user input for data 
sanity.



On Monday, January 23, 2023 at 4:08:43 AM UTC+3 stumblin...@gmail.com wrote:

> I am trying to pass initial values to my form set via URL Query
> ex) Localhost:8000?/First_name_id_0=Samuel
> [image: forms.py.png]
>
> I was told to use the initial parameter and not the instance in my view 
> first
>
> "An inline formset is related to one instance of the parent model. You 
> identify *which* instance the formset is related to by the “instance” 
> parameter. The “initial” parameter has a different usage, which is defined 
> in the docs."
>
> But I can't seem to find an examples in the docs
> [image: Views.py.png]
>
> How do I change my view so that that it initialize my form set with URL 
> Query?
>

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


how to initialize input form fields using URL parameters

2023-01-22 Thread Andrew Brown

I am trying to pass initial values to my form set via URL Query
ex) Localhost:8000?/First_name_id_0=Samuel
[image: forms.py.png]

I was told to use the initial parameter and not the instance in my view 
first

"An inline formset is related to one instance of the parent model. You 
identify *which* instance the formset is related to by the “instance” 
parameter. The “initial” parameter has a different usage, which is defined 
in the docs."

But I can't seem to find an examples in the docs
[image: Views.py.png]

How do I change my view so that that it initialize my form set with URL 
Query?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/34ccbb87-11dc-4097-84ac-95f229d9183an%40googlegroups.com.


Re: File Upload with additional Parameters

2020-10-11 Thread Dvs Khamele
Hi do you hire contract based python/django freelancer?
 We can help you in this and related tasks at fair prices. Reply or send
email to divy...@pythonmate.com
Best Regards,
Divyesh Khamele,
Pythonmate

On Fri, 9 Oct 2020, 11:20 pm Noel Simela,  wrote:

> Hi guys,
>
> Any suggestions on the best approach to achieve the below with Django's
> upload handlers. I was reviewing documentation at
> https://docs.djangoproject.com/en/3.1/topics/http/file-uploads/
>
> On upload I want to be able to read the contents of the document as per
> below.
>
> Read: –File Name, Author’s Name, Index , count  number pages in the
> document. And populate fields on django template automatically
>
> N.B I am not looking for code, just insight or point me in the right
> direction.
>
> Thank you kindly.
>
> --
> 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/CAGBhr7Zkukurzvb%3DZ3JmawO3-AZs%3DjtHjEMgWwtCNn0Ln1fEhQ%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/CAH9mneVGUXZXTm2uu%3Dx_dkErqLnZA-xhdXEERewPrjnmMyySEQ%40mail.gmail.com.


File Upload with additional Parameters

2020-10-09 Thread Noel Simela
Hi guys,

Any suggestions on the best approach to achieve the below with Django's
upload handlers. I was reviewing documentation at
https://docs.djangoproject.com/en/3.1/topics/http/file-uploads/

On upload I want to be able to read the contents of the document as per
below.

Read: –File Name, Author’s Name, Index , count  number pages in the
document. And populate fields on django template automatically

N.B I am not looking for code, just insight or point me in the right
direction.

Thank you kindly.

-- 
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/CAGBhr7Zkukurzvb%3DZ3JmawO3-AZs%3DjtHjEMgWwtCNn0Ln1fEhQ%40mail.gmail.com.


Re: TypeError: object() takes No Parameters

2020-09-17 Thread coolguy
The error lies in the following line

>>>  queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region')) 

Your class monthlyCostTable does not take any parameter while you are 
passing getMonthlyCost... you know better what your doing but this line is 
the root cause...
 

On Thursday, September 17, 2020 at 4:00:08 PM UTC-4 pcar...@gmail.com wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>> resultsList = []
>>> for each in qs:
>>> resultsList.append(each[key])
>>> return resultsList
>>>
>>>
>>> def getDistinct(key):
>>> return Circuitinfotable.objects.all().values(key).distinct()
>>>
>>>
>>> def convertCurrency(val):
>>> return Decimal(sub(r'[^\d.]', '', val))
>>>
>>>
>>> def getMonthlyCostQuery(year, field):
>>> circuits = Circuitinfotable.objects.all()
>>> field_list = getList(getDistinct(field), field)
>>>
>>> results_list = []
>>> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
>>> 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>>> 'Dec': 0,
>>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw&#x

Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
[Thu Sep 17 23:07:26.870983 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Internal Server Error: /functions/ClassMonthlyCost/
[Thu Sep 17 23:07:26.871052 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Traceback (most recent call last):
[Thu Sep 17 23:07:26.871057 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
[Thu Sep 17 23:07:26.871060 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = get_response(request)
[Thu Sep 17 23:07:26.871064 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 115, in _get_response
[Thu Sep 17 23:07:26.871067 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = self.process_exception_by_middleware(e, 
request)
[Thu Sep 17 23:07:26.871070 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 113, in _get_response
[Thu Sep 17 23:07:26.871073 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
[Thu Sep 17 23:07:26.871079 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] TypeError: object() takes no parameters


On Thursday, September 17, 2020 at 3:00:08 PM UTC-5 Patrick Carra wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>> resultsList = []
>>> for each in qs:
&g

Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
The actual trace coolguy is 

TypeError at /functions/ClassMonthlyCost/object() takes no 
parametersRequest 
Method: GETRequest 
URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
Version: 2.2.4Exception 
Type: TypeErrorException 
Value: object() takes no parametersException 
Location: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
 
in _get_response, line 113Python 
Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
Version:3.6.8
Python Path:
['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
'/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
Server time: Thu, 17 Sep 2020 18:29:52 +  

On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:

> is there any specific line number that message is pointing too. Can you 
> share the actual error message and its trace...
>
> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
> wrote:
>
>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>> django_tables2 using a custom function that queries my database and 
>> aggregates the data into a list of dictionaries.  I read to use the 
>> SingleTableMixin that all I needed was an iterable containing a data 
>> structure that has a key(a list of dicts) and then to instantiate a table 
>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>> this TypeError: Object() takes no parameters.  I have included a link to 
>> the django tables 2 doc and my code below:
>>
>> #views.py
>> from django_tables2.views import SingleTableMixin
>> from django_tables2.export.views import ExportMixin
>> from django_filters.views import FilterView
>> from django.views.generic.list import ListView
>> from django.shortcuts import render
>>
>> from finance.models import Circuitinfotable, Budget
>> from .forms import monthlyCostForm
>> from .tables import CircuitTable, monthlyCostTable
>> from .filters import CircuitinfotableFilter
>>
>> from datetime import datetime
>> from decimal import Decimal
>> from re import sub
>> import calendar
>>
>> #convert a distinct queryset into a singular list of values
>> def getList(qs, key):
>> resultsList = []
>> for each in qs:
>> resultsList.append(each[key])
>> return resultsList
>>
>>
>> def getDistinct(key):
>> return Circuitinfotable.objects.all().values(key).distinct()
>>
>>
>> def convertCurrency(val):
>> return Decimal(sub(r'[^\d.]', '', val))
>>
>>
>> def getMonthlyCostQuery(year, field):
>> circuits = Circuitinfotable.objects.all()
>> field_list = getList(getDistinct(field), field)
>>
>> results_list = []
>> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
>> 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>> 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
>> 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
>> 'Decbw': 0}
>> results_list.append(resultsDict)
>> for each in field_list:
>> if each!=None and each!='None':
>> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 
>> 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 
>> 'Nov': 0, 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Se

Re: TypeError: object() takes No Parameters

2020-09-17 Thread coolguy
is there any specific line number that message is pointing too. Can you 
share the actual error message and its trace...

On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com wrote:

> Hello everyone, I am trying to utilize the SIngleTableMixin of 
> django_tables2 using a custom function that queries my database and 
> aggregates the data into a list of dictionaries.  I read to use the 
> SingleTableMixin that all I needed was an iterable containing a data 
> structure that has a key(a list of dicts) and then to instantiate a table 
> in tables.py and pass to a my views Class.  I am getting an error when I do 
> this TypeError: Object() takes no parameters.  I have included a link to 
> the django tables 2 doc and my code below:
>
> #views.py
> from django_tables2.views import SingleTableMixin
> from django_tables2.export.views import ExportMixin
> from django_filters.views import FilterView
> from django.views.generic.list import ListView
> from django.shortcuts import render
>
> from finance.models import Circuitinfotable, Budget
> from .forms import monthlyCostForm
> from .tables import CircuitTable, monthlyCostTable
> from .filters import CircuitinfotableFilter
>
> from datetime import datetime
> from decimal import Decimal
> from re import sub
> import calendar
>
> #convert a distinct queryset into a singular list of values
> def getList(qs, key):
> resultsList = []
> for each in qs:
> resultsList.append(each[key])
> return resultsList
>
>
> def getDistinct(key):
> return Circuitinfotable.objects.all().values(key).distinct()
>
>
> def convertCurrency(val):
> return Decimal(sub(r'[^\d.]', '', val))
>
>
> def getMonthlyCostQuery(year, field):
> circuits = Circuitinfotable.objects.all()
> field_list = getList(getDistinct(field), field)
>
> results_list = []
> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
> 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
> 'Dec': 0,
>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
> 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
> 'Decbw': 0}
> results_list.append(resultsDict)
> for each in field_list:
> if each!=None and each!='None':
> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
> 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
> 'Dec': 0,
>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
> 'Novbw': 0, 'Decbw': 0}
> resultsDict['field'] = each
> results_list.append(resultsDict)
>
> for circuit in circuits:
> #If you add a field to forms.py to aggregate by then add here
> if field=='region':
> matchField = circuit.region
> elif field=='carrier':
> matchField = circuit.carrier
> elif field=='bandwidth':
> matchField = circuit.bandwidth
> elif field=='status':
> matchField = circuit.status
> #get the budget for each circuit
> for budgetItem in circuit.budget_set.filter(yearnum=year):
> #if an item is budgeted for given month
> if(budgetItem.actualmrc!=0):
> #Cycle through results_list to find the correct dictionary
> for each in results_list:
> if each['field']==matchField:
> #update budgetItem and bw
> if budgetItem != None:
> 
> each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
> if circuit.bw!= None:
> each[calendar.month_abbr[budgetItem.monthnum] 
> + 'bw']+=int(circuit.bw)
> elif matchField==None:
> if budgetItem != None:
> 
> results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurr

TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
Hello everyone, I am trying to utilize the SIngleTableMixin of 
django_tables2 using a custom function that queries my database and 
aggregates the data into a list of dictionaries.  I read to use the 
SingleTableMixin that all I needed was an iterable containing a data 
structure that has a key(a list of dicts) and then to instantiate a table 
in tables.py and pass to a my views Class.  I am getting an error when I do 
this TypeError: Object() takes no parameters.  I have included a link to 
the django tables 2 doc and my code below:

#views.py
from django_tables2.views import SingleTableMixin
from django_tables2.export.views import ExportMixin
from django_filters.views import FilterView
from django.views.generic.list import ListView
from django.shortcuts import render

from finance.models import Circuitinfotable, Budget
from .forms import monthlyCostForm
from .tables import CircuitTable, monthlyCostTable
from .filters import CircuitinfotableFilter

from datetime import datetime
from decimal import Decimal
from re import sub
import calendar

#convert a distinct queryset into a singular list of values
def getList(qs, key):
resultsList = []
for each in qs:
resultsList.append(each[key])
return resultsList


def getDistinct(key):
return Circuitinfotable.objects.all().values(key).distinct()


def convertCurrency(val):
return Decimal(sub(r'[^\d.]', '', val))


def getMonthlyCostQuery(year, field):
circuits = Circuitinfotable.objects.all()
field_list = getList(getDistinct(field), field)

results_list = []
resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
'Decbw': 0}
results_list.append(resultsDict)
for each in field_list:
if each!=None and each!='None':
resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
'Novbw': 0, 'Decbw': 0}
resultsDict['field'] = each
results_list.append(resultsDict)

for circuit in circuits:
#If you add a field to forms.py to aggregate by then add here
if field=='region':
matchField = circuit.region
elif field=='carrier':
matchField = circuit.carrier
elif field=='bandwidth':
matchField = circuit.bandwidth
elif field=='status':
matchField = circuit.status
#get the budget for each circuit
for budgetItem in circuit.budget_set.filter(yearnum=year):
#if an item is budgeted for given month
if(budgetItem.actualmrc!=0):
#Cycle through results_list to find the correct dictionary
for each in results_list:
if each['field']==matchField:
#update budgetItem and bw
if budgetItem != None:

each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:
each[calendar.month_abbr[budgetItem.monthnum] + 
'bw']+=int(circuit.bw)
elif matchField==None:
if budgetItem != None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]+'bw']+=int(circuit.bw)

results_list = sorted(results_list, key=lambda i:i['field'])
return results_list


class MonthlyCost(SingleTableMixin):
template_name = 'functions/ClassMonthlyCost.html'
context_object_name = 'qs'
queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region'))


#tables.py
import django_tables2 as tables
from django_tables2.utils import A
from .models import Circuitinfotable

class CircuitTable(tables.Table)

Path parameters and security scanners best practice

2020-06-15 Thread Dan Davis
I have an odd question.  When I have a path parameter that is validated to 
be alphanumeric, and a security scanner sends a non-alphanumeric value, 
Django properly validates and then returns 404.   However, this gives the 
security scanner the mistaken impression that there is some some sort of 
security problem (it isn't very smart).

Is there an option I can give to Django to say that if an URL pattern 
matches but the path parameter does not match, it should return a different 
sort of 400 error?

Thanks,

-Dan

-- 
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/133b7cb9-b5fc-4758-9a98-595d99cce9dfo%40googlegroups.com.


Re: Issue with passing parameters in urls

2020-04-01 Thread aniket kamthe
hey Antje,
Let me check and get back. I think I have got the problem, I will get back
if I have further issues.

On Wed, Apr 1, 2020 at 2:32 PM Antje Kazimiers  wrote:

> Hi Aniket,
>
> Your thread object in your template is actually a message since your
> passing messages to context in your view.
>
> but when you initialize messages you don't set a name attribute.
>
> So I would double check your Message model if it has a name attribute.
>
> btw your error message didn't display for me.
>
> Antje
> On 3/30/20 4:50 PM, aniket kamthe wrote:
>
> Hey All,
> I have been watching your youtube tutorials and have been stuck on an
> issue for a while now. Can you help me out pls -
>
> I am trying to pass a parameter via a button in an HTML file and using
> that in the next link to access a specific set of entries from the database
> -
>
> HTML File code -
>
> {% for thread in object %}
>  role="button">{{ thread.name }}  Something  {% endfor 
> %}
>
> URLs files code -
>
> path('message//', views.message, name='message'),
>
> Views files code
>
> def message(request, threadid):
>   if request.method == 'POST':
> print(request.POST.get('message'))
> m = messages(message=request.POST.get('message'), thread_id='00', 
> likes='00', Message_flags='00')
> m.save();
> if (request.method == 'POST') and ("like" in request.POST):
>   print("hi")
> data = messages.objects.all()
> context = {
>   'object': data
> }
> return render(request, 'mysite/message.html', context)
>   else:
> data = messages.objects.all()
> context = {
>   'object': data
> }
> return render(request, 'mysite/message.html', context)
>
> But I get this error, idk how to resolve this one -
>
> [image: image.png]
> Pls let me know If you are able to figure out the problem.
> --
> 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/deae3154-4d36-438a-9669-5698d319ed27%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/879b4154-a801-9080-96a3-0f28e5e38ac1%40gmail.com
> 
> .
>


-- 
Aniket Kamthe
Final year Student | Dual Degree
Department of Mechanical Engineering
Masters in Robotics
Indian Institute Of Technology Madras.
Contact : +91-9970320507
Mail id : aniketkamthe...@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/CAKFu1CFy9eZhm1oCk3YC8yof220t__J%2BtEx%2B9Yjnto%3Dk8hMOtQ%40mail.gmail.com.


Re: Issue with passing parameters in urls

2020-04-01 Thread Antje Kazimiers
Hi Aniket,

Your thread object in your template is actually a message since your
passing messages to context in your view.

but when you initialize messages you don't set a name attribute.

So I would double check your Message model if it has a name attribute.

btw your error message didn't display for me.

Antje

On 3/30/20 4:50 PM, aniket kamthe wrote:
> Hey All, 
> I have been watching your youtube tutorials and have been stuck on an
> issue for a while now. Can you help me out pls - 
>
> I am trying to pass a parameter via a button in an HTML file and using
> that in the next link to access a specific set of entries from the
> database - 
>
> HTML File code - 
>
> {% for thread in object %}
> role="button">{{ thread.name }} Something  {% endfor %}
> URLs files code - 
> path('message//', views.message, name='message'),
> Views files code 
> def message(request, threadid):
>   if request.method == 'POST':
> print(request.POST.get('message'))
> m = messages(message=request.POST.get('message'), thread_id='00', 
> likes='00', Message_flags='00')
> m.save();
> if (request.method == 'POST') and ("like" in request.POST):
>   print("hi")
> data = messages.objects.all()
> context = {
>   'object': data
> }
> return render(request, 'mysite/message.html', context)
>   else:
> data = messages.objects.all()
> context = {
>   'object': data
> }
> return render(request, 'mysite/message.html', context)
> But I get this error, idk how to resolve this one - 
>
> image.png
> Pls let me know If you are able to figure out the problem. 
> -- 
> 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/deae3154-4d36-438a-9669-5698d319ed27%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/879b4154-a801-9080-96a3-0f28e5e38ac1%40gmail.com.


Issue with passing parameters in urls

2020-03-30 Thread aniket kamthe
Hey All, 
I have been watching your youtube tutorials and have been stuck on an issue 
for a while now. Can you help me out pls - 

I am trying to pass a parameter via a button in an HTML file and using that 
in the next link to access a specific set of entries from the database - 

HTML File code - 

{% for thread in object %}
  
  {{ thread.name }}
  Something
  
{% endfor %}

URLs files code - 

path('message//', views.message, name='message'),

Views files code 

def message(request, threadid):
  if request.method == 'POST':
print(request.POST.get('message'))
m = messages(message=request.POST.get('message'), thread_id='00', 
likes='00', Message_flags='00')
m.save();
if (request.method == 'POST') and ("like" in request.POST):
  print("hi")
data = messages.objects.all()
context = {
  'object': data
}
return render(request, 'mysite/message.html', context)
  else:
data = messages.objects.all()
context = {
  'object': data
}
return render(request, 'mysite/message.html', context)

But I get this error, idk how to resolve this one - 

[image: image.png]
Pls let me know If you are able to figure out the problem. 

-- 
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/deae3154-4d36-438a-9669-5698d319ed27%40googlegroups.com.


Re: unable to read POST parameters sent by payment gateway

2020-03-13 Thread sercan t.
Don't send POST to http://127.0.0.1:8000/cashfreeresponse,
Check your views and urls.py or redirect mechanism. Try to send like this 
==> http://127.0.0.1:8000/cashfreeresponse/

I simulate on my machine this. I got error like you when send POST request 
without '/' at the end.


9 Mart 2020 Pazartesi 23:23:24 UTC+3 tarihinde Sreekanth yazdı:
>
> I am unable to read POST parameters sent by payment gateway after payment 
> was processed. Payment gateway redirects to returnUrl (I pass this to 
> payment gateway before payment was processed) with some parameters by POST 
> request.
>
> In url.py
>
> path('cashfreeresponse/',views.cashfree_response, name='cashfree_response'),
>
> in views.py
>
> @csrf_exempt@login_requireddef cashfree_response(request):
> print(request.method)
> if request.method == "POST":
> print('inside post method')
> print(request.POST.get('cf_subReferenceId'))
> if request.method == "GET":
> print('inside get method')
> print(request.GET.get('cf_subReferenceId'))
>
> print(request.method) is showing as GET but it was supposed be POST method 
> also print(request.GET.get('cf_subReferenceId')) and 
> print(request.POST.get('cf_subReferenceId')) are showing as None.
>
> But it looks like payment gateway sending parameters as POST method. When 
> I pass returnUrl as http://127.0.0.1:8000/cashfreeresponse instead of 
> http://127.0.0.1:8000/cashfreeresponse/ ('/' is missing in the first one) 
> then I am getting error as
>
> You called this URL via POST, but the URL doesn't end in a slash and you 
> have APPEND_SLASH set. Django can't redirect to the slash URL while 
> maintaining POST data. Change your form to point to 
> 127.0.0.1:8000/cashfreeresponse/ (note the trailing slash), or set 
> APPEND_SLASH=False in your Django settings.
>
> but I see in my google chrome page that payment gateway sending parameters 
> with POST request. Below image shows parameters sent by payment gateway by 
> POST request
>
> [image: enter image description here] 
> <https://i.stack.imgur.com/kmhg2.png>
>
> If I change urls.py to
>
> path('cashfreeresponse',views.cashfree_response, name='cashfree_response'),
>
> in settings.py to
>
> APPEND_SLASH = False
>
> and returnUrl to http://127.0.0.1:8000/cashfreeresponse then I am not 
> getting any error but still not receiving any parameters. How do I read 
> those parameters sent by payment gateway by POST request? Here 
> <https://docs.cashfree.com/docs/sbc/guide/#payment-response> is the 
> documentation for payment gateway.
>

-- 
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/05c3a1a5-306d-41d9-9f3e-c1c4a0bada59%40googlegroups.com.


Re: unable to read POST parameters sent by payment gateway

2020-03-11 Thread Naveen Arora
There is something wrong with URL, you are pushing, try using some other 
url, append slash, etc.
That may help you :)

Cheers

On Tuesday, 10 March 2020 01:53:24 UTC+5:30, Sreekanth wrote:
>
> I am unable to read POST parameters sent by payment gateway after payment 
> was processed. Payment gateway redirects to returnUrl (I pass this to 
> payment gateway before payment was processed) with some parameters by POST 
> request.
>
> In url.py
>
> path('cashfreeresponse/',views.cashfree_response, name='cashfree_response'),
>
> in views.py
>
> @csrf_exempt@login_requireddef cashfree_response(request):
> print(request.method)
> if request.method == "POST":
> print('inside post method')
> print(request.POST.get('cf_subReferenceId'))
> if request.method == "GET":
> print('inside get method')
> print(request.GET.get('cf_subReferenceId'))
>
> print(request.method) is showing as GET but it was supposed be POST method 
> also print(request.GET.get('cf_subReferenceId')) and 
> print(request.POST.get('cf_subReferenceId')) are showing as None.
>
> But it looks like payment gateway sending parameters as POST method. When 
> I pass returnUrl as http://127.0.0.1:8000/cashfreeresponse instead of 
> http://127.0.0.1:8000/cashfreeresponse/ ('/' is missing in the first one) 
> then I am getting error as
>
> You called this URL via POST, but the URL doesn't end in a slash and you 
> have APPEND_SLASH set. Django can't redirect to the slash URL while 
> maintaining POST data. Change your form to point to 
> 127.0.0.1:8000/cashfreeresponse/ (note the trailing slash), or set 
> APPEND_SLASH=False in your Django settings.
>
> but I see in my google chrome page that payment gateway sending parameters 
> with POST request. Below image shows parameters sent by payment gateway by 
> POST request
>
> [image: enter image description here] 
> <https://i.stack.imgur.com/kmhg2.png>
>
> If I change urls.py to
>
> path('cashfreeresponse',views.cashfree_response, name='cashfree_response'),
>
> in settings.py to
>
> APPEND_SLASH = False
>
> and returnUrl to http://127.0.0.1:8000/cashfreeresponse then I am not 
> getting any error but still not receiving any parameters. How do I read 
> those parameters sent by payment gateway by POST request? Here 
> <https://docs.cashfree.com/docs/sbc/guide/#payment-response> is the 
> documentation for payment gateway.
>

-- 
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/48da7caa-f76d-47d2-8283-67fe5a0fcbda%40googlegroups.com.


unable to read POST parameters sent by payment gateway

2020-03-09 Thread Sreekanth


I am unable to read POST parameters sent by payment gateway after payment 
was processed. Payment gateway redirects to returnUrl (I pass this to 
payment gateway before payment was processed) with some parameters by POST 
request.

In url.py

path('cashfreeresponse/',views.cashfree_response, name='cashfree_response'),

in views.py

@csrf_exempt@login_requireddef cashfree_response(request):
print(request.method)
if request.method == "POST":
print('inside post method')
print(request.POST.get('cf_subReferenceId'))
if request.method == "GET":
print('inside get method')
print(request.GET.get('cf_subReferenceId'))

print(request.method) is showing as GET but it was supposed be POST method 
also print(request.GET.get('cf_subReferenceId')) and 
print(request.POST.get('cf_subReferenceId')) are showing as None.

But it looks like payment gateway sending parameters as POST method. When I 
pass returnUrl as http://127.0.0.1:8000/cashfreeresponse instead of 
http://127.0.0.1:8000/cashfreeresponse/ ('/' is missing in the first one) 
then I am getting error as

You called this URL via POST, but the URL doesn't end in a slash and you 
have APPEND_SLASH set. Django can't redirect to the slash URL while 
maintaining POST data. Change your form to point to 
127.0.0.1:8000/cashfreeresponse/ (note the trailing slash), or set 
APPEND_SLASH=False in your Django settings.

but I see in my google chrome page that payment gateway sending parameters 
with POST request. Below image shows parameters sent by payment gateway by 
POST request

[image: enter image description here] <https://i.stack.imgur.com/kmhg2.png>

If I change urls.py to

path('cashfreeresponse',views.cashfree_response, name='cashfree_response'),

in settings.py to

APPEND_SLASH = False

and returnUrl to http://127.0.0.1:8000/cashfreeresponse then I am not 
getting any error but still not receiving any parameters. How do I read 
those parameters sent by payment gateway by POST request? Here 
<https://docs.cashfree.com/docs/sbc/guide/#payment-response> is the 
documentation for payment gateway.

-- 
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/bc93bd88-eecd-420e-ae86-6253676fdf12%40googlegroups.com.


Django translate_url not working with optional parameters

2019-09-26 Thread NKSM
I am using django 1.11.

My url is:
url(r'^apply(?:/(?P[\d-]+)/(?P[\w-]+))?.html$', applyview, name=
'applyview'),


Line to tranlate url:

translate_url('/nl/job/apply.html', "fr")


Django internal function:

def translate_url(url, lang_code):
"""
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated 
regex).
Return the original URL if no translated version is found.
"""
parsed = urlsplit(url)
try:
match = resolve(parsed.path)
except Resolver404:
pass
else:
to_be_reversed = "%s:%s" % (match.namespace, match.url_name) if 
match.namespace else match.url_name
with override(lang_code):
try:
url = reverse(to_be_reversed, args=match.args, kwargs=match.
kwargs)
except NoReverseMatch:
pass
else:
url = urlunsplit((parsed.scheme, parsed.netloc, url, parsed.
query, parsed.fragment))
return url


Django can not tranlate url  get an error NoReverseMatch because kwargs are 
None. ({'pk': None, 'slug': None}).
By my parameters are optional. 


*Does anyone have an idea, how can that be solved?*


-- 
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/b2b7fbd8-8ecb-42a3-8fa7-059c5572cbf1%40googlegroups.com.


Django translate_url not working with optional parameters

2019-09-26 Thread NKSM
I am using django 1.11.

My url is:
url(r'^apply(?:/(?P[\d-]+)/(?P[\w-]+))?.html$', applyview, name=
'applyview'),


Line to tranlate url:

translate_url('/nl/job/apply.html', "fr")


Django internal function:

def translate_url(url, lang_code):
"""
Given a URL (absolute or relative), try to get its translated version in
the `lang_code` language (either by i18n_patterns or by translated 
regex).
Return the original URL if no translated version is found.
"""
parsed = urlsplit(url)
try:
match = resolve(parsed.path)
except Resolver404:
pass
else:
to_be_reversed = "%s:%s" % (match.namespace, match.url_name) if 
match.namespace else match.url_name
with override(lang_code):
try:
url = reverse(to_be_reversed, args=match.args, kwargs=match.
kwargs)
except NoReverseMatch:
pass
else:
url = urlunsplit((parsed.scheme, parsed.netloc, url, parsed.
query, parsed.fragment))
return url


Django can not tranlate url  get an error NoReverseMatch because kwargs are 
None. ({'pk': None, 'slug': None}).
By my parameters are optional. 


*Does anyone have an idea, how can that be solved?*


-- 
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/92288a98-3083-4d3c-a52d-78aa90696557%40googlegroups.com.


Re: Django parameters

2019-08-13 Thread Derek
You're better off adopting an existing CMS built on top of Django, and 
checking how close its feature set matches your needs.  If there is a gap, 
then contact the developers to see how that gap could be closed. 

Some examples:.  https://www.django-cms.org/en/features/list/  or 
https://wagtail.io/features/ 

On Monday, 12 August 2019 13:13:55 UTC+2, tomas mracnik wrote:
>
> Hi, we are considering a new cms system in our company. Does Django allows 
> features like customize widget , emmbeding and single sign-on Active 
> directory or office 365 ? Thank you for your answers.
>

-- 
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/30aee349-f0f4-41f8-a6ab-c89aea81ec43%40googlegroups.com.


Re: Django parameters

2019-08-12 Thread Jani Tiainen
Hi.

Yes and no.

Django isn't cms but web application development library written in python.

So yes you can do all those things. How much work and effort it requires
depends on many factors.


ma 12. elok. 2019 klo 14.13 tomas mracnik 
kirjoitti:

> Hi, we are considering a new cms system in our company. Does Django allows
> features like customize widget , emmbeding and single sign-on Active
> directory or office 365 ? Thank you for your answers.
>
> --
> 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/e38b9731-bca7-4edb-ba80-3e4bf1d670dc%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/CAHn91oeupMefg7YHsg54PRGc04c3kTZZDCGdV7dg0XFrvKPkxw%40mail.gmail.com.


Django parameters

2019-08-12 Thread tomas mracnik
Hi, we are considering a new cms system in our company. Does Django allows 
features like customize widget , emmbeding and single sign-on Active 
directory or office 365 ? Thank you for your answers.

-- 
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/e38b9731-bca7-4edb-ba80-3e4bf1d670dc%40googlegroups.com.


django-storages parameters

2019-05-04 Thread Britto .
Hello All,

How could we find out what are the parameters are available for a variable
in django-storages?

For example AWS_S3_OBJECT_PARAMETERS what are the available parameters?
Where could we find it?

Cannot see it in django-storages documentation other than a sample.

AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}

So CacheControl is a parameter, what are other parameters available?

Regards
Britto

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


Re: Separating remote vs local settings.py parameters - - “EMAIL”?

2019-03-16 Thread Phillip Moracha
If you take a look at this gist provided by a Udemy instructor and at this
specific location
<https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
here he wisely recommends separating important local development
configuration parameters, such as SECRET _KEY. Of course everyone knows how
stupid and foolish it would be to share the SECRET_KEY publicly on GitHub
and then to use it in your production environment.

On Sat, Mar 16, 2019, 3:15 AM drone4four  wrote:

> If you take a look at this gist provided by a Udemy instructor and at
> this specific location
> <https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
> here he wisely recommends separating important local development
> configuration parameters, such as SECRET _KEY. Of course everyone knows how
> stupid and foolish it would be to share the SECRET_KEY publicly on GitHub
> and then to use it in your production environment.
>
>
> So here is the list of parameters to place in the separate remote
> settings.py as it appears in that gist linked to above:
>
>
>-
>
>SECRET_KEY
>-
>
>ALLOWED_HOSTS
>-
>
>DATABASES
>-
>
>DEBUG
>-
>
>EMAIL_*
>
>
> If you look at the last one, it says: “EMAIL_*”. What do you people think
> the “_*” suffix? Is this standard for settings.py configurations? Or would
> you people think this is just a glaring typo on the side of the instructor?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Separating remote vs local settings.py parameters - - “EMAIL”?

2019-03-16 Thread Ahmed Ishtiaque
If you don't need to send e-mail to your users then it's best not to 
specify any of the EMAIL_* settings. You can change the backend you use to 
send email with using EMAIL_BACKEND variable. This can be useful when 
you're tring to test your email format and such while developing your app. 
The django.core.mail.smtp.EmailBackend, as far as I remember, sends emails 
to your development server terminal so you can take a look at a text 
rendering of the email you're trying to test. If you want to hook up an 
external e-mail service for  your users in deployment, you can use email 
services like SendGrid, Mailchimp, etc. and these services use SMTP servers 
to send e-mails. Django lets you configure these as well. This tutorial 
helped me understand how sending e-mail to users in deployment 
works: 
https://simpleisbetterthancomplex.com/tutorial/2016/06/13/how-to-send-email.html
Since it makes use of an external mail service, you might find it helpful 
to understand the EMAIL_* variables.

But again, if you don't need to programmatically send e-mails to your 
users, don't bother specifying these settings. 

On Saturday, March 16, 2019 at 7:12:37 AM UTC-4, drone4four wrote:
>
> So the remote server production email contact information could be 
> different from the developer’s testcase email contact info?
>
> I’ve taken a closer look at the “email-backend” section of the Django docs 
> that you’ve linked to, Ahmed. I see Django supports email settings.  I 
> don’t really understand what these EMAIL parameters would be used for. For 
> example, EMAIL_BACKEND says:
>
> Default: 'django.core.mail.backends.smtp.EmailBackend 
>> <https://docs.djangoproject.com/en/2.1/topics/email/#django.core.mail.backends.smtp.EmailBackend>
>> '
>> The backend to use for sending emails. For the list of available backends 
>> see Sending email <https://docs.djangoproject.com/en/2.1/topics/email/>.
>
>
> I followed these two links and it is still not clear to me: Are these 
> email settings only used if I implement SMTP or other email services? 
>
> Would it be OK for me to just exclude altogether “EMAIL_*” until I reach a 
> point when there is a need for an SMTP server (which will probably be never 
> for the project I am working on)?
>
>
> On Friday, March 15, 2019 at 9:27:41 PM UTC-4, Ahmed Ishtiaque wrote:
>>
>> The character "*" represents "wildcard". Here is the real reason why the 
>> instructor puts it that way: 
>> https://docs.djangoproject.com/en/2.1/ref/settings/#email-backend
>>
>> There are a lot of variables that contain the 'EMAIL_' prefix, which is 
>> why the instructor wrote it that way.
>>
>> On Fri, Mar 15, 2019 at 8:16 PM drone4four  wrote:
>>
>>> If you take a look at this gist provided by a Udemy instructor and at 
>>> this specific location 
>>> <https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
>>>  
>>> here he wisely recommends separating important local development 
>>> configuration parameters, such as SECRET _KEY. Of course everyone knows how 
>>> stupid and foolish it would be to share the SECRET_KEY publicly on GitHub 
>>> and then to use it in your production environment. 
>>>
>>>
>>> So here is the list of parameters to place in the separate remote 
>>> settings.py as it appears in that gist linked to above:
>>>
>>>
>>>- 
>>>
>>>SECRET_KEY
>>>- 
>>>
>>>ALLOWED_HOSTS
>>>- 
>>>
>>>DATABASES
>>>- 
>>>
>>>DEBUG
>>>- 
>>>
>>>EMAIL_*
>>>
>>>
>>> If you look at the last one, it says: “EMAIL_*”. What do you people 
>>> think the “_*” suffix? Is this standard for settings.py configurations? Or 
>>> would you people think this is just a glaring typo on the side of the 
>>> instructor?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com
>>>  
>>> <https://groups.googl

Re: Separating remote vs local settings.py parameters - - “EMAIL”?

2019-03-16 Thread drone4four


So the remote server production email contact information could be 
different from the developer’s testcase email contact info?

I’ve taken a closer look at the “email-backend” section of the Django docs 
that you’ve linked to, Ahmed. I see Django supports email settings.  I 
don’t really understand what these EMAIL parameters would be used for. For 
example, EMAIL_BACKEND says:

Default: 'django.core.mail.backends.smtp.EmailBackend 
> <https://docs.djangoproject.com/en/2.1/topics/email/#django.core.mail.backends.smtp.EmailBackend>
> '
> The backend to use for sending emails. For the list of available backends 
> see Sending email <https://docs.djangoproject.com/en/2.1/topics/email/>.


I followed these two links and it is still not clear to me: Are these email 
settings only used if I implement SMTP or other email services? 

Would it be OK for me to just exclude altogether “EMAIL_*” until I reach a 
point when there is a need for an SMTP server (which will probably be never 
for the project I am working on)?


On Friday, March 15, 2019 at 9:27:41 PM UTC-4, Ahmed Ishtiaque wrote:
>
> The character "*" represents "wildcard". Here is the real reason why the 
> instructor puts it that way: 
> https://docs.djangoproject.com/en/2.1/ref/settings/#email-backend
>
> There are a lot of variables that contain the 'EMAIL_' prefix, which is 
> why the instructor wrote it that way.
>
> On Fri, Mar 15, 2019 at 8:16 PM drone4four  > wrote:
>
>> If you take a look at this gist provided by a Udemy instructor and at 
>> this specific location 
>> <https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
>>  
>> here he wisely recommends separating important local development 
>> configuration parameters, such as SECRET _KEY. Of course everyone knows how 
>> stupid and foolish it would be to share the SECRET_KEY publicly on GitHub 
>> and then to use it in your production environment. 
>>
>>
>> So here is the list of parameters to place in the separate remote 
>> settings.py as it appears in that gist linked to above:
>>
>>
>>- 
>>
>>SECRET_KEY
>>- 
>>
>>ALLOWED_HOSTS
>>- 
>>
>>DATABASES
>>- 
>>
>>DEBUG
>>- 
>>
>>EMAIL_*
>>
>>
>> If you look at the last one, it says: “EMAIL_*”. What do you people think 
>> the “_*” suffix? Is this standard for settings.py configurations? Or would 
>> you people think this is just a glaring typo on the side of the instructor?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d0fca8e-3750-4fd0-8b36-5383b29e3191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Separating remote vs local settings.py parameters - - “EMAIL”?

2019-03-15 Thread Ahmed Ishtiaque
The character "*" represents "wildcard". Here is the real reason why the
instructor puts it that way:
https://docs.djangoproject.com/en/2.1/ref/settings/#email-backend

There are a lot of variables that contain the 'EMAIL_' prefix, which is why
the instructor wrote it that way.

On Fri, Mar 15, 2019 at 8:16 PM drone4four  wrote:

> If you take a look at this gist provided by a Udemy instructor and at
> this specific location
> <https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
> here he wisely recommends separating important local development
> configuration parameters, such as SECRET _KEY. Of course everyone knows how
> stupid and foolish it would be to share the SECRET_KEY publicly on GitHub
> and then to use it in your production environment.
>
>
> So here is the list of parameters to place in the separate remote
> settings.py as it appears in that gist linked to above:
>
>
>-
>
>SECRET_KEY
>-
>
>ALLOWED_HOSTS
>-
>
>DATABASES
>-
>
>DEBUG
>-
>
>EMAIL_*
>
>
> If you look at the last one, it says: “EMAIL_*”. What do you people think
> the “_*” suffix? Is this standard for settings.py configurations? Or would
> you people think this is just a glaring typo on the side of the instructor?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKizqR7JGGJyD9c7AXG%3Dun%2BL7dNsknE2XF_xC2r%3D0x2%2BRmzueg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Separating remote vs local settings.py parameters - - “EMAIL”?

2019-03-15 Thread drone4four


If you take a look at this gist provided by a Udemy instructor and at this 
specific location 
<https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#local-settings-setup>,
 
here he wisely recommends separating important local development 
configuration parameters, such as SECRET _KEY. Of course everyone knows how 
stupid and foolish it would be to share the SECRET_KEY publicly on GitHub 
and then to use it in your production environment. 


So here is the list of parameters to place in the separate remote 
settings.py as it appears in that gist linked to above:


   - 
   
   SECRET_KEY
   - 
   
   ALLOWED_HOSTS
   - 
   
   DATABASES
   - 
   
   DEBUG
   - 
   
   EMAIL_*
   

If you look at the last one, it says: “EMAIL_*”. What do you people think 
the “_*” suffix? Is this standard for settings.py configurations? Or would 
you people think this is just a glaring typo on the side of the instructor?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa499e85-b7cd-43a1-b21a-e8d6c665e498%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to send parameters to templates and adjust the page url by path?

2018-12-13 Thread Saeed Pooladzadeh
Thank you Ira

در چهارشنبه 12 دسامبر 2018، ساعت 19:21:26 (UTC-8)، lingo...@gmail.com نوشته:
>
> Hello,
>
> How to send parameters to templates and adjust the page url by path?
>
> regards, 
>
> Saeed
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ccb8f35-324f-4bb1-8aa2-00878607768f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to send parameters to templates and adjust the page url by path?

2018-12-12 Thread Ira Abbott
hi,

This is not much to go on:  The 'parameters' are called 'context'

You can read: 
https://docs.djangoproject.com/en/2.1/ref/templates/api/

to learn about templates and context.  

adding context in a view is done by adding context to a view as follows:

def get_context_data(self, *args, **kwargs):
data = super().get_context_data(*args, **kwargs)
data['title'] = 'New User Signup'
data['login_url'] = '/accounts/login/'
return data

'adjust the page url path' could mean one of two things:
- access the url path in the view (self.request.path) and then adjust 
context accordingly would simply the path this way and adjust 'data'
- change the url to which a page responds or assign a new url to a view - 
this is done in urls.py via a regualr expression.

Please elaborate - you have to provide information to get it.

Regards,

Ira

On Wednesday, December 12, 2018 at 10:21:26 PM UTC-5, lingo...@gmail.com 
wrote:
>
> Hello,
>
> How to send parameters to templates and adjust the page url by path?
>
> regards, 
>
> Saeed
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e55a15f-6a1b-440b-9b46-64f566a5817f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to send parameters to templates and adjust the page url by path?

2018-12-12 Thread lingo . saeed
Hello,

How to send parameters to templates and adjust the page url by path?

regards, 

Saeed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22e0f9bb-c2b7-42de-a792-f2123a6bd03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Url parameters don't work

2018-04-30 Thread Саша Губський
Hi, have GET request :  
 https://mydomain/auth/complete/instagram/?code=mycode
And i want to get parameter 'code'

path('auth/complete/instagram/', views.instagram, name='auth')

def instagram(request):
code = request.GET.get('code')
if code:
return HttpResponse(code)
return HttpResponse(request.get_full_path())

#Always return /auth/complete/instagram/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/79d00d10-cac0-4825-81f6-18d01f482458%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters to SOAP Zeep client

2017-11-28 Thread giuseppe ricci
Thanks James for your precious suggestions. 
Unfortunatly Zeep haven't a support forum, so I tryed on the django-users 
group.
According your suggestions I try with:


var=({'utenteApplicativo': 'YZSMOPMO'}, {'carrelloDto':{'idCarrelloSorgente': 
'994'}, 'itemCarrelloDtoList':{'causale': 'prova', 'codiceEnte':
'CCIAA_MI', \
'importo':2, 'importoImposta':1, 'importoTotale':3, 'importoUnitario':2, 
'quantitaItem':1, 'tipoContabilizzazione':'TA'}})
print('variabile: ', var)
print(type(var))

call=client.service.creaCarrello(var)
in this manner I have a list variable: var. But I receive the error: 

Missing element utenteApplicativo (creaCarrello.GestioneCarrelliRequest)

It is not the correct manner.
Any help are welcome.
Thanks.

Il giorno martedì 28 novembre 2017 10:49:10 UTC+1, James Schneider ha 
scritto:
>
>
>
> On Nov 28, 2017 1:20 AM, "giuseppe ricci"  > wrote:
>
> I'm using Zeep library to query a SOAP webservice wrote in Java.
> My piece of the wsdl file is:
>
>
> This is the Django users mailing list, so we probably won't be of much 
> help. You should investigate the support forums for Zeep. 
>
> I piloted a small program using it a year or so ago, but I don't have much 
> experience with it as the project went south for other reasons. Neat 
> library to handle the awfulness that is SOAP.
>
>
> ValidationError at /soapclient/
> Missing element utenteApplicativo (creaCarrello.GestioneCarrelliRequest)
> The problem it seems the manner of passing the parameters. With this other 
> manner:
>
> call=client.service.creaCarrello(', {11223344, {'causale':'prova', 
> 'codiceEnte':'CCIAA_MI', \
> 'importo':2, 'importoImposta':1, 'importoTotale':3, 'importoUnitario':2, 
> 'quantitaItem':1, 'tipoContabilizzazione':'TA'}, },)
>
> I receive the error: unhashable type: 'dict'.
>
> Can you help me to understand what is the correct manner to pass these 
> parameters to the zeep client? There are a set of parameters inside another 
> set..Is it supported by zeep?
> Thanks.
>
> If memory serves, yes, you can nest parameters and values in a request, 
> pretty sure I've done it. However, your code is not using nested 
> dictionaries. It appears you are missing a dict key (and possibly a ' 
> unless that's from sanitizing the code). The way your code stands, the 
> second parameter is a Python set, and the second element of that set is a 
> dict, which can't be hashed. Hashing is required for sets, but not for 
> dicts. 
>
> Most likely you meant for the set to be a dict, but forgot to include the 
> keys. I think Zeep exclusively used dicts and lists in their method calls 
> to ease XML serialization, unless something has changed recently.
>
> But again, you'll find better help on the Zeep forums.
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5a212e2d-13cd-4df3-b72c-7a32bd7b9c31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters to SOAP Zeep client

2017-11-28 Thread James Schneider
On Nov 28, 2017 1:20 AM, "giuseppe ricci"  wrote:

I'm using Zeep library to query a SOAP webservice wrote in Java.
My piece of the wsdl file is:


This is the Django users mailing list, so we probably won't be of much
help. You should investigate the support forums for Zeep.

I piloted a small program using it a year or so ago, but I don't have much
experience with it as the project went south for other reasons. Neat
library to handle the awfulness that is SOAP.


ValidationError at /soapclient/
Missing element utenteApplicativo (creaCarrello.GestioneCarrelliRequest)
The problem it seems the manner of passing the parameters. With this other
manner:

call=client.service.creaCarrello(', {11223344, {'causale':'prova',
'codiceEnte':'CCIAA_MI', \
'importo':2, 'importoImposta':1, 'importoTotale':3, 'importoUnitario':2,
'quantitaItem':1, 'tipoContabilizzazione':'TA'}, },)

I receive the error: unhashable type: 'dict'.

Can you help me to understand what is the correct manner to pass these
parameters to the zeep client? There are a set of parameters inside another
set..Is it supported by zeep?
Thanks.

If memory serves, yes, you can nest parameters and values in a request,
pretty sure I've done it. However, your code is not using nested
dictionaries. It appears you are missing a dict key (and possibly a '
unless that's from sanitizing the code). The way your code stands, the
second parameter is a Python set, and the second element of that set is a
dict, which can't be hashed. Hashing is required for sets, but not for
dicts.

Most likely you meant for the set to be a dict, but forgot to include the
keys. I think Zeep exclusively used dicts and lists in their method calls
to ease XML serialization, unless something has changed recently.

But again, you'll find better help on the Zeep forums.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXctJVR3PNBcForRs_vFJrsT2%2BnpVK8pYBYK5zSMZByfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Passing parameters to SOAP Zeep client

2017-11-28 Thread giuseppe ricci
I'm using Zeep library to query a SOAP webservice wrote in Java.
My piece of the wsdl file is:



  
 


   11223344
   
  prova
  CCIAA_MI
  2
  1
  3
  2
  1
  TA
   

 
  

and I create a SOAP client in this manner:

def soapclient(request):

 session = Session()
 session.auth = HTTPBasicAuth('user', 'password', 
transport=Transport(session=session))
 client = Client('my_url_of_wsdl_file.wsdl')

 utenteApplicativo='' 
 idCarrelloSorgente=11223344
 itemCarrelloDtoList=('prova', 'Datatest', 2, 1, 3, 2, 1, 'TA')
 carrelloDto=(idCarrelloSorgente, itemCarrelloDtoList)
 var=(utenteApplicativo, carrelloDto)
 call=client.service.creaCarrello(var)
 var=(utenteApplicativo, carrelloDto) 

 print('variabile del client: ', var)

 call1=client.service.creaCarrello(var)

 print(call1)
 
but I receive the error: 

ValidationError at /soapclient/
Missing element utenteApplicativo (creaCarrello.GestioneCarrelliRequest)
The problem it seems the manner of passing the parameters. With this other 
manner:

call=client.service.creaCarrello(', {11223344, {'causale':'prova', 
'codiceEnte':'CCIAA_MI', \
'importo':2, 'importoImposta':1, 'importoTotale':3, 'importoUnitario':2, 
'quantitaItem':1, 'tipoContabilizzazione':'TA'}, },)

I receive the error: unhashable type: 'dict'.

Can you help me to understand what is the correct manner to pass these 
parameters to the zeep client? There are a set of parameters inside another 
set..Is it supported by zeep?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28b2ad71-3253-442c-8a0e-d1693d117be9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: urls with https and s3:// as parameters

2017-01-19 Thread Vijay Khemlani
Shouldn't the paths be passed as GET or POST arguments instead of part
of the URL path? Why would you need the regex then?

On 1/19/17, Ramon Ramirez-Linan  wrote:
> Hi
>
> I am building a django app which urls take 2 parameters a source and
> destination.
> The source is either a url for a file http://something.com/file.jpg or an
> s3 arn s3://bucketname/key.jpg
>
> I am having difficulties creating a regex expression that matches that to
> route it to my view
>
> The first problem is from the fact that the source may contain '/' and '.'
>
> Any suggestion will be welcome
>
> Thanks
>
> Ramon
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/44c48066-2cd1-49a9-aa88-c9730c9a9d79%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei1rm%3DXG%2BGTgKoB%3D_q7_BQO2XGMAr2vQeUbAtGAPpc9mxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


urls with https and s3:// as parameters

2017-01-19 Thread Ramon Ramirez-Linan
Hi 

I am building a django app which urls take 2 parameters a source and 
destination.
The source is either a url for a file http://something.com/file.jpg or an 
s3 arn s3://bucketname/key.jpg

I am having difficulties creating a regex expression that matches that to 
route it to my view

The first problem is from the fact that the source may contain '/' and '.'

Any suggestion will be welcome

Thanks

Ramon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44c48066-2cd1-49a9-aa88-c9730c9a9d79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Password hashing parameters selection methodology description

2016-12-23 Thread Tim Graham
>From the "new stable branch" tasks [0]:

Increase the default PBKDF2 iterations in 
django.contrib.auth.hashers.PBKDF2PasswordHasher by about 20% (pick a round 
number). Run the tests, and update the 3 failing hasher tests with the new 
values. Make sure this gets noted in the release notes (see the 1.8 release 
notes for an example).

To see the discussion about the reasoning, I'd suggest to search the 
archives of the django-developers mailing list and/or the Django ticket 
tracker -- that's what I'd do to answer your question.

This is the last topic I remember about it:
https://groups.google.com/d/topic/django-developers/Qab-hRG-SKs/discussion

[0] 
https://docs.djangoproject.com/en/dev/internals/howto-release-django/#new-stable-branch-tasks

On Friday, December 23, 2016 at 12:40:43 PM UTC-5, Martin Koistinen wrote:
>
> Django has a very nice implementation for hashing passwords using PBKDF2 
> and a number of iterations to increase the work-load. Thanks!
>
> I know this is very customizable and I know how to do this. This post is 
> not about "how".
>
> What I would like to know is the methodology and "inputs" into deciding 
> the number of iterations. For a quick summary, these iterations change with 
> every recent iteration of Django as follows:
>
>- Django 1.10: uses 3 iterations
>- Django 1.9: 24000
>- Django 1.8: 2
>- Django 1.7: 15000
>- ...
>
> Clearly these are increased to offset increases in computational power of 
> the typical server, etc. But is there anything more methodical to this than 
> just "hey, let's add some iterations to the default password hasher" for 
> each release?
>
> Ideally, someone could make plain the methodology used, the 
> inputs/assumptions and the desired strength achieved (I.e., how many days 
> of brute-forcing does a hashed password withstand on some assumed set of 
> hardware). I suspect that the Django project is not inventing the 
> methodology but rather is using a reference to a study somewhere.
>
> Anyone have this handy somewhere?
>
> Many thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d77ec718-2f7e-4227-bd4b-0e5a380837d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Password hashing parameters selection methodology description

2016-12-23 Thread Martin Koistinen
Django has a very nice implementation for hashing passwords using PBKDF2 
and a number of iterations to increase the work-load. Thanks!

I know this is very customizable and I know how to do this. This post is 
not about "how".

What I would like to know is the methodology and "inputs" into deciding the 
number of iterations. For a quick summary, these iterations change with 
every recent iteration of Django as follows:

   - Django 1.10: uses 3 iterations
   - Django 1.9: 24000
   - Django 1.8: 2
   - Django 1.7: 15000
   - ...
   
Clearly these are increased to offset increases in computational power of 
the typical server, etc. But is there anything more methodical to this than 
just "hey, let's add some iterations to the default password hasher" for 
each release?

Ideally, someone could make plain the methodology used, the 
inputs/assumptions and the desired strength achieved (I.e., how many days 
of brute-forcing does a hashed password withstand on some assumed set of 
hardware). I suspect that the Django project is not inventing the 
methodology but rather is using a reference to a study somewhere.

Anyone have this handy somewhere?

Many thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6442d30d-5b00-43ec-8cdd-0376f170a8b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to add additional parameters to the queryset in forms.py

2016-11-12 Thread ludovic coues
You already have a parameter named year so you should use self.year =
year instead of self.year = kwargs.pop('year'). Same for month and
day.

2016-11-12 22:39 GMT+01:00 احسان خراسانی :
> HI
> i want to add additional parameters to the queryset in forms
>
> class Reserve(forms.ModelForm):
>
> food_name = forms.ModelChoiceField(queryset=Food.objects.all())
>
> def __init__(self, year=None, month=None, day=None, *args, **kwargs):
> super(Reserve, self).__init__(*args, **kwargs)
>
> self.year = kwargs.pop('year')
> self.month = kwargs.pop('month')
> self.day = kwargs.pop('day')
> self.fields['food_name'].queryset = Food.objects.filter(
> serve_date__year = year, serve_date__month = month,
> serve_date__day = day)
>
>
> class Meta:
> model = Reservation
> fields = ('food_count', 'food_name')
>
> but its return KeyError:
> 'year'
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/faf6ce5c-ec82-4451-90cd-413864167d1d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

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


how to add additional parameters to the queryset in forms.py

2016-11-12 Thread احسان خراسانی
HI
i want to add additional parameters to the queryset in forms

class Reserve(forms.ModelForm):

food_name = forms.ModelChoiceField(queryset=Food.objects.all())

def __init__(self, year=None, month=None, day=None, *args, **kwargs):
super(Reserve, self).__init__(*args, **kwargs)

self.year = kwargs.pop('year')
self.month = kwargs.pop('month')
self.day = kwargs.pop('day')
self.fields['food_name'].queryset = Food.objects.filter(
serve_date__year = year, serve_date__month = month, 
serve_date__day = day)


class Meta:
model = Reservation
fields = ('food_count', 'food_name')

but its return KeyError: 
'year'


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/faf6ce5c-ec82-4451-90cd-413864167d1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to send parameters in url tag?

2016-09-20 Thread Ares Ou
Hi, 

You have to use a form of keyword arguments to provide parameters in {% url 
%} tag.

For example,

{% url post_view post_id=post_id %}

the former post_id is the argument name in your view function, the latter 
post_id is the variable name in your template context.

If you have more than one parameters, just append them to the list, 
separated by a space:

{% url post_view post_id=post_id tag='post tag' %}

On Tuesday, September 20, 2016 at 3:51:56 AM UTC-7, Za Ars wrote:
>
> Hou to send parameters in url as string?
>
> {%url url_name url_params%}
>
> where url_params as 'pk=object.id' or 'page=page.number'
>
>
> Please, help me, if you can
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d151994f-fd84-4137-a2d7-163839c264cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to send parameters in url tag?

2016-09-20 Thread Alessandro Madruga Correia
>
> {%url url_name url_params%}
>
> where url_params as 'pk=object.id' or 'page=page.number'
>

Here have an example
https://docs.djangoproject.com/en/1.10/topics/http/urls/#reverse-resolution-of-urls


-- 
  ,= ,-_-. =.   [] Alessandro Madruga Correia
 ((_/)o o(\_))  [http://counter.li.org]   Debian User# 342751
   `-'(. .)`-'"O fanatismo é a única forma de força de vontade
   \_/acessível aos fracos." (Friedrich Nietzsche)

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


How to send parameters in url tag?

2016-09-20 Thread Za Ars
Hou to send parameters in url as string?

{%url url_name url_params%}

where url_params as 'pk=object.id' or 'page=page.number'


Please, help me, if you can

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61b01206-c63f-4134-891f-aa36c2427f06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread James Schneider
On Fri, Feb 26, 2016 at 2:49 AM, Remco Gerlich  wrote:

> Hi James,
>
> I agree with the general dirtyness of PHP and I have used Django
> exclusively for years.
>
>
Ah, the way you posed the question I took you to be a recent convert. Sorry
about that. ;-)


The type of parameter I mean is where, say a list of two elements [1,2] is
> sent as
>
> http://example.com/?list[0]=1&list[1]=2
>
> So instead of two parameters with the same name, this has two parameters
> with different names ("list[0]" and "list[1]"). PHP automatically
> recognizes such parameters and turns them into an list under the name
> "list", I seem to recall vaguely. The same works for dictionaries and for
> nested lists and dictionaries. I don't think Django does this and I don't
> see anything about it in the docs you linked to.
>
> I can use [request.GET.get("list[0]"), request.GET.get("list[1]")] etc but
> the structure can get quite involved ("columns[2][search][regex]") and so I
> was wondering if someone had written something like that already.
>
>
I vaguely recall this being PHP-specific back in my Drupal days, and
thought it was a terrible idea then, so you may be right. Looks like this
SO may cover it though:
http://stackoverflow.com/questions/5170087/reading-multidimensional-arrays-from-a-post-request-in-django

That SO links to this thing: https://github.com/bernii/querystring-parser

Looks like it might be what you're looking for.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWTBH3EJUaQyn3%2B%2BA4QxT788pROnFkpdCMgXaCzkMQYiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread Remco Gerlich
Hi James,

I agree with the general dirtyness of PHP and I have used Django
exclusively for years.

The type of parameter I mean is where, say a list of two elements [1,2] is
sent as

http://example.com/?list[0]=1&list[1]=2

So instead of two parameters with the same name, this has two parameters
with different names ("list[0]" and "list[1]"). PHP automatically
recognizes such parameters and turns them into an list under the name
"list", I seem to recall vaguely. The same works for dictionaries and for
nested lists and dictionaries. I don't think Django does this and I don't
see anything about it in the docs you linked to.

I can use [request.GET.get("list[0]"), request.GET.get("list[1]")] etc but
the structure can get quite involved ("columns[2][search][regex]") and so I
was wondering if someone had written something like that already.

Greetings,
Remco


On Fri, Feb 26, 2016 at 11:24 AM, James Schneider 
wrote:

>
> On Feb 26, 2016 1:21 AM, "Remco Gerlich"  wrote:
> >
> > I need to work with DataTables, a jQuery-plugin for sortable HTML tables.
> >
> > It sends Ajax GET requests with parameters like the following (but
> urlencoded, of course):
> >
> > columns[0][data]=0
> > columns[0][name]=
> > columns[0][searchable]=true
> > columns[0][orderable]=true
> > columns[0][search][value]=
> > columns[0][search][regex]=false
> > columns[1][data]=1
> > columns[1][name]=
> > columns[1][searchable]=true
> > columns[1][orderable]=true
> > columns[1][search][value]=
> > columns[1][search][regex]=false
> > columns[2][data]=2
> > columns[2][name]=
> > columns[2][searchable]=true
> > columns[2][orderable]=true
> > columns[2][search][value]=
> > columns[2][search][regex]=false
> >
> > I think this plugin was written with PHP in mind, and that PHP can
> automatically convert that into a list of dicts that would in Python look
> something like
>
> PHP is a dirty word in this forum. :-P
>
> >
> > columns = [
> > {"data": 0, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > {"data": 1, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > {"data": 2, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > ]
> >
> > Does anybody know of any Python or Django app / library that does this?
>
> Easy. It's called Django. :-D
>
> The HttpRequest object is automatically populated with both GET and POST
> values when Django parses the request from the browser, and handles
> multiple values for the same key just fine.
>
>
> https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.GET
>
> Usually this object is made available as a variable called request in a
> function-based view, or is available via self.request in a class-based view.
>
> To get multiple values for the same key, simply access that key multiple
> times (see the QueryDict link in the section I linked above), usually as
> part of a loop. The QueryDict (request.GET) acts like a Python generator.
>
> Usually you access the keys using .get() calls so that a missing or empty
> key return None instead of raising an exception:
>
> fn = self.request.GET.get('first_name')
>
> This part of the tutorial has example usage:
> https://docs.djangoproject.com/en/1.9/intro/tutorial04/#write-a-simple-form
>
> It uses request.POST, but it works exactly the same way.
>
> On a side note, nothing you've mentioned is specific to PHP, rather it is
> all part of the HTTP protocol. The languages/frameworks just have different
> methods of accessing the same information. A form generated by a PHP
> process can submit to a Django view with no issue, and vice versa.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2Bci

Re: Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread James Schneider
On Feb 26, 2016 1:21 AM, "Remco Gerlich"  wrote:
>
> I need to work with DataTables, a jQuery-plugin for sortable HTML tables.
>
> It sends Ajax GET requests with parameters like the following (but
urlencoded, of course):
>
> columns[0][data]=0
> columns[0][name]=
> columns[0][searchable]=true
> columns[0][orderable]=true
> columns[0][search][value]=
> columns[0][search][regex]=false
> columns[1][data]=1
> columns[1][name]=
> columns[1][searchable]=true
> columns[1][orderable]=true
> columns[1][search][value]=
> columns[1][search][regex]=false
> columns[2][data]=2
> columns[2][name]=
> columns[2][searchable]=true
> columns[2][orderable]=true
> columns[2][search][value]=
> columns[2][search][regex]=false
>
> I think this plugin was written with PHP in mind, and that PHP can
automatically convert that into a list of dicts that would in Python look
something like

PHP is a dirty word in this forum. :-P

>
> columns = [
> {"data": 0, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
> {"data": 1, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
> {"data": 2, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
> ]
>
> Does anybody know of any Python or Django app / library that does this?

Easy. It's called Django. :-D

The HttpRequest object is automatically populated with both GET and POST
values when Django parses the request from the browser, and handles
multiple values for the same key just fine.

https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.GET

Usually this object is made available as a variable called request in a
function-based view, or is available via self.request in a class-based view.

To get multiple values for the same key, simply access that key multiple
times (see the QueryDict link in the section I linked above), usually as
part of a loop. The QueryDict (request.GET) acts like a Python generator.

Usually you access the keys using .get() calls so that a missing or empty
key return None instead of raising an exception:

fn = self.request.GET.get('first_name')

This part of the tutorial has example usage:
https://docs.djangoproject.com/en/1.9/intro/tutorial04/#write-a-simple-form

It uses request.POST, but it works exactly the same way.

On a side note, nothing you've mentioned is specific to PHP, rather it is
all part of the HTTP protocol. The languages/frameworks just have different
methods of accessing the same information. A form generated by a PHP
process can submit to a Django view with no issue, and vice versa.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVN%3DBNzapoBtv9kEO2c-e85S759WmYWR_YVaeXid8B9bQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread Remco Gerlich
I need to work with DataTables, a jQuery-plugin for sortable HTML tables.

It sends Ajax GET requests with parameters like the following (but
urlencoded, of course):

columns[0][data]=0
columns[0][name]=
columns[0][searchable]=true
columns[0][orderable]=true
columns[0][search][value]=
columns[0][search][regex]=false
columns[1][data]=1
columns[1][name]=
columns[1][searchable]=true
columns[1][orderable]=true
columns[1][search][value]=
columns[1][search][regex]=false
columns[2][data]=2
columns[2][name]=
columns[2][searchable]=true
columns[2][orderable]=true
columns[2][search][value]=
columns[2][search][regex]=false

I think this plugin was written with PHP in mind, and that PHP can
automatically convert that into a list of dicts that would in Python look
something like

columns = [
{"data": 0, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
{"data": 1, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
{"data": 2, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
]

Does anybody know of any Python or Django app / library that does this?

Would it be possible to do this in a FormField? (convert many GET
parameters into one field)

Does anybody know what this technique is called? My Google-fu is failing,
and if I'm going write a field for this I need to name it.

Thanks,
Remco Gerlich

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


Re: are parameters compulsary in an url pattern?

2015-10-07 Thread Tim Graham
If you can accomplish what you need without passing parameters, there is 
certainly no requirement to do so.

Have you read: https://docs.djangoproject.com/en/stable/topics/http/urls/ ?

On Wednesday, October 7, 2015 at 12:10:54 AM UTC-4, krmane wrote:
>
> Dear all, 
> I just wish to know if I must have all the parameters from my form as a 
> part of the url pattern? 
> I need to use only the request so was wondering if that is the case? 
> I have seen tutorials and all of them come with url parameters 
> I don't need a url like /articles/2013/03 etc. 
> I am writing a accounting/ inventory system and don't need a blogging 
> kind of application or a news room kind of stuff which Django is mostly 
> known for. 
> My forms will contain all the data and I can access all that in a view 
> through the request object I guess? 
> so a pattern like r(^setaccount'), views/account/setaccount must work. 
> is this correct or do I always need to pass parameters? 
> Which is the best time to use parameters apart from the request object? 
> Happy hacking. 
> Krishnakant. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db5d6795-bcbf-4f9e-97c2-b49a3efe2952%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


are parameters compulsary in an url pattern?

2015-10-06 Thread kk

Dear all,
I just wish to know if I must have all the parameters from my form as a 
part of the url pattern?

I need to use only the request so was wondering if that is the case?
I have seen tutorials and all of them come with url parameters
I don't need a url like /articles/2013/03 etc.
I am writing a accounting/ inventory system and don't need a blogging 
kind of application or a news room kind of stuff which Django is mostly 
known for.
My forms will contain all the data and I can access all that in a view 
through the request object I guess?

so a pattern like r(^setaccount'), views/account/setaccount must work.
is this correct or do I always need to pass parameters?
Which is the best time to use parameters apart from the request object?
Happy hacking.
Krishnakant.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56147E6A.3080105%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-05 Thread Déborah Leder
Thank you for your answers, everyone.
Alex, indeed I didn't know about the forloop last trick. It worked like a 
charm !
And Daniel, for some reasons I prefer not to mess with the views for now, 
but when if I need to clean up my code, I keep your answer in mind.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d2259957-cb0d-4876-bda2-71599c0a854a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Daniel Roseman
On Tuesday, 4 August 2015 17:32:11 UTC+1, Alex Heyden wrote:
>
> I don't quite follow what you're doing with set_first_call_true and 
> set_first_call_false. Are you using that to control the for loop behavior?
>
> If you are, take a look at 
> https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for. 
> Django's template language has that built in.
>
> If you're pushing to an array like in your initial example, you don't need 
> to handle commas at all. Here's an example out of Chrome's dev tools:
>
> > var a = []
> > a.push('foo')
> > a.push('bar')
> > a
> < ["foo", "bar"]
>
> If you want to define it in one go, try something more like:
>
> 
> my_markers = [
> {% for current_addr in mymodel.addresses.all %}
> {
> lat: {{ current_addr.lat }},
> lon: {{ current_addr.lon }},
> description: {{ current_addr.description | safe }}
> }{% if not forloop.last %}, {% endif %}
> {% endfor %}
> ];
> 
>
>
An even better solution is to keep this logic where it belongs, in the 
view, and use the accepted format for interchange of data with Javascript, 
which is JSON.

my_markers = [{'lat': addr.lat, 'lon': addr.lon, 'description': 
addr.description} for addr in mymodel.addresses.all]
return render(request, 'template.html', {'my_markers': 
json.dumps(my_markers)})

and refer to it directly in the template:


 my_markers = {{ my_markers|safe }}


-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c82b618-008e-450f-9f64-5267ec795795%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Alex Heyden
I don't quite follow what you're doing with set_first_call_true and
set_first_call_false. Are you using that to control the for loop behavior?

If you are, take a look at
https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for. Django's
template language has that built in.

If you're pushing to an array like in your initial example, you don't need
to handle commas at all. Here's an example out of Chrome's dev tools:

> var a = []
> a.push('foo')
> a.push('bar')
> a
< ["foo", "bar"]

If you want to define it in one go, try something more like:


my_markers = [
{% for current_addr in mymodel.addresses.all %}
{
lat: {{ current_addr.lat }},
lon: {{ current_addr.lon }},
description: {{ current_addr.description | safe }}
}{% if not forloop.last %}, {% endif %}
{% endfor %}
];


On Tue, Aug 4, 2015 at 10:53 AM, Déborah Leder  wrote:

> After some more tests, I have managed to understand where my problem is
> (but I don't know how to resolve it).
> Here is my final piece of code :
>  >
>
> 
> my_markers = [
> {{ mymodel.set_first_call_true }}
> {% for current_addr in mymodel.addresses.all %}
> {% if not mymodel.first_call %},{% endif %}
> {
> lat: {{ current_addr.lat }},
> lon: {{ current_addr.lon }},
> description: {{ current_addr.description | safe }}
> }
> {{ mymodel.set_first_call_false }}
> {% endfor %}
> ];
> 
>
>  >
>
>
> I had to add an attribute "first_call" to mymodel, so that my javascript
> declaration was correct (in an array, we should always write the comma
> between 2 elements, but not after each element or before each element).
> The only problem is that every time I call mymodel.set_first_call_true or
> mymodel.set_first_call_false, it inserts a "none" inside my javascript
> code.
> Is it possible to "delete" the "non" statement ?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/232757e4-0a4b-450f-808d-764453783dea%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVp8Z1S7qXq%3DjELWpWQKd4-KjTw5DX2ZDdTedxKtuja5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Déborah Leder
After some more tests, I have managed to understand where my problem is 
(but I don't know how to resolve it).
Here is my final piece of code :



my_markers = [
{{ mymodel.set_first_call_true }}
{% for current_addr in mymodel.addresses.all %}
{% if not mymodel.first_call %},{% endif %}
{
lat: {{ current_addr.lat }},
lon: {{ current_addr.lon }},
description: {{ current_addr.description | safe }}
}
{{ mymodel.set_first_call_false }}
{% endfor %}
];





I had to add an attribute "first_call" to mymodel, so that my javascript 
declaration was correct (in an array, we should always write the comma 
between 2 elements, but not after each element or before each element).
The only problem is that every time I call mymodel.set_first_call_true or 
mymodel.set_first_call_false, it inserts a "none" inside my javascript code.
Is it possible to "delete" the "non" statement ?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/232757e4-0a4b-450f-808d-764453783dea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Vijay Khemlani
Have you checked the HTML that is actually rendered by the Django template?

On Tue, Aug 4, 2015 at 10:39 AM, Déborah Leder  wrote:

> Hello Larry, thank you for your response.
>
> I didn't run the debugger, but i know that my values are correctly passed
> in the template (when it it outside of the script tags), because at the end
> of my template, I have also written the code :
> 
> {% for current_addr in mymodel.addresses.all %}
> {{ current_addr.description | safe}}
> Latitude : {{ current_addr.lat }},
> 
> Longitude : {{ current_addr.lon }},
> 
> {% endfor %}
> 
>
>
> And all the values are correctly displayed.
>
> If you think that I can check something else with the debbuger, I don't
> know what you mean so it would help me if you were more precise
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/23f8bdd5-86b6-40d3-9cb6-964a8d808a6c%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei0mBfoz92AAj4ZjTJ9beySyysO4pRcy-xT1UDU%2BtGqQ-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Déborah Leder
Hello Larry, thank you for your response.

I didn't run the debugger, but i know that my values are correctly passed 
in the template (when it it outside of the script tags), because at the end 
of my template, I have also written the code :

{% for current_addr in mymodel.addresses.all %}
{{ current_addr.description | safe}}
Latitude : {{ current_addr.lat }},

Longitude : {{ current_addr.lon }},

{% endfor %}



And all the values are correctly displayed.

If you think that I can check something else with the debbuger, I don't 
know what you mean so it would help me if you were more precise

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23f8bdd5-86b6-40d3-9cb6-964a8d808a6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Larry Martell
On Tue, Aug 4, 2015 at 9:14 AM, Déborah Leder  wrote:
> Hello
>
> I am currently developping a django geolocalisation application. Therefore,
> I need both python and javascript.
> I would like to give some parameters to a script in a template, that is to
> say, in my template, I want to use the script tag to define/modify some
> javascript variables.
> Here is my code (that doesn't work) :
>  %}">
> {% for current_addr in mymodel.addresses.all %}
> 
> my_markers.push(
> {
> lat: {{current_addr.lat}},
> lon: {{current_addr.lon}},
> description: {{current_addr.description | safe }}
> }
> );
> 
> {% endfor %}
>  %}">
>
>
> When I define the array of objects my_markers in my script by giving only
> "hard-coded" numbers and strings, it works fine, so I guess that the problem
> is to recognize and evaluate the lat, lon, and description attributes of my
> address class.
>
> And I also don't know how to display the value of a javascript array in a
> template, so it makes it quite hard for debugging.
>
> If it helps, mymodel is a model that has a field : addresses =
> ManyToManyField(address)

I do things like that all the time, so you must have some other issue.
I'd run the python script in the debugger and verify that values are
indeed getting passed in your context.

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


Passing parameters / attributes to javascript in a template

2015-08-04 Thread Déborah Leder
Hello

I am currently developping a django geolocalisation application. Therefore, 
I need both python and javascript.
I would like to give some parameters to a script in a template, that is to 
say, in my template, I want to use the script tag to define/modify some 
javascript variables.
Here is my code (that doesn't work) :

{% for current_addr in mymodel.addresses.all %}

my_markers.push(
{
lat: {{current_addr.lat}},
lon: {{current_addr.lon}},
description: {{current_addr.description | safe }}
}
);

{% endfor %}



When I define the array of objects my_markers in my script by giving only 
"hard-coded" numbers and strings, it works fine, so I guess that the 
problem is to recognize and evaluate the lat, lon, and description 
attributes of my address class.

And I also don't know how to display the value of a javascript array in a 
template, so it makes it quite hard for debugging.

If it helps, mymodel is a model that has a field : addresses = 
ManyToManyField(address)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3b565774-f4d5-4791-b83f-51df7da9ed83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Choices as a callable.. but no parameters?

2015-04-20 Thread Stephen J. Butler
On Mon, Apr 20, 2015 at 9:45 PM, Vijay Khemlani  wrote:
> Overwrite the constructor of the form (__init__), pass the user or whatever
> parameters you may need and overwrite the choices of the field in the body
> of the method.

This is the same strategy I've used to filter ForeignKey fields on the
current user. If you're using class based views you should override
get_form_kwargs() to add the user parameter to the form's __init__().

It's a little trickier if you want to make this work in a ModelAdmin
subclass though. I don't see a similar method to override. What I've
done is to override ModelAdmin.get_form() like this:

def get_form(self, request, obj=None, **kwargs):
form_class = super(MyModelAdmin, self).get_form(request, obj, **kwargs)
class _Form(form_class):
def __init__(form_self, *args, **kwargs):
super(_Form, form_self).__init__(user=request.user, *args, **kwargs)
return _Form

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWy%2Bs351iJcZHxqJgDQScMHa%3DNvbc5uqUqCTXmz6QEawA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Choices as a callable.. but no parameters?

2015-04-20 Thread Vijay Khemlani
Overwrite the constructor of the form (__init__), pass the user or whatever
parameters you may need and overwrite the choices of the field in the body
of the method.

On Mon, Apr 20, 2015 at 10:56 PM, Steve Hiemstra 
wrote:

> I am trying to build a form with dynamic choices. e.g., the choices should
> depend on the user.
>
> https://docs.djangoproject.com/en/1.8/ref/forms/fields/#choicefield
>
> Says choices may now be a callable, and sure enough it is called in `
> django/forms/fields.py(818)` – but without any parameters.
>
> How can I get access to the current user, view, or any bit of context.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4a74be7f-e3cc-4e72-9a15-6a1ca43c9677%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4a74be7f-e3cc-4e72-9a15-6a1ca43c9677%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei1O%3DXvKT7G%3DkwW4TjZvLpT5iw%2BmdBkwux%2B5bGZkidxfiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Choices as a callable.. but no parameters?

2015-04-20 Thread Steve Hiemstra
I am trying to build a form with dynamic choices. e.g., the choices should 
depend on the user.

https://docs.djangoproject.com/en/1.8/ref/forms/fields/#choicefield

Says choices may now be a callable, and sure enough it is called in `
django/forms/fields.py(818)` – but without any parameters.

How can I get access to the current user, view, or any bit of context.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a74be7f-e3cc-4e72-9a15-6a1ca43c9677%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing request parameters in Django (“+” behaves differently)

2015-04-20 Thread Eneko Illarramendi
Thank you Tom.

Somehow it seemed strange to test this view using client.get('/page/', {
'filter': 'one and two'})
but I get why it is like this.

Cheers,
Eneko


On Monday, April 20, 2015 at 3:30:55 PM UTC+2, Tom Evans wrote:
>
> On Sat, Apr 18, 2015 at 12:13 PM, Eneko Illarramendi 
> > wrote: 
> > Previously posted in SO: 
> > 
> http://stackoverflow.com/questions/29703930/testing-request-parameters-in-django-behaves-differently
>  
> > --- 
> > 
> > I have a Django View that uses a query parameter to so some content 
> > filtering. Something like this: 
> > 
> > /page/?filter=one+and+two 
> > /page/?filter=one,or,two 
> > 
> > I have noticed that Django converts the + to a space 
> > (request.GET.get('filter') returns one and two), and I´m OK with that. I 
> > just need to adjust the split() function I use in the View accordingly. 
>
> The arguments in a query string are urlencoded. Spaces are urlencoded 
> as '+'. Django's request.GET is a dict like object with the query 
> string arguments decoded. 
>
> > 
> > But... 
> > 
> > When I try to test this View, and I call: 
> > 
> > from django.test import Client 
> > client = Client() 
> > client.get('/page/', {'filter': 'one+and+two'}) 
>
> The test client takes a dictionary of raw strings, not urlencoded 
> strings. If you like, you are telling it to test the URL 
> '/page/?filter=one%2Band%2Btwo', as '+' is urlencoded as '%2B'. 
>
> Django is consistent, the test client takes raw un-encoded strings, 
> and request.GET delivers raw un-encoded strings. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/274a6eb9-dfa5-42ba-aff9-d564fad4e0c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing request parameters in Django (“+” behaves differently)

2015-04-20 Thread Tom Evans
On Sat, Apr 18, 2015 at 12:13 PM, Eneko Illarramendi
 wrote:
> Previously posted in SO:
> http://stackoverflow.com/questions/29703930/testing-request-parameters-in-django-behaves-differently
> ---
>
> I have a Django View that uses a query parameter to so some content
> filtering. Something like this:
>
> /page/?filter=one+and+two
> /page/?filter=one,or,two
>
> I have noticed that Django converts the + to a space
> (request.GET.get('filter') returns one and two), and I´m OK with that. I
> just need to adjust the split() function I use in the View accordingly.

The arguments in a query string are urlencoded. Spaces are urlencoded
as '+'. Django's request.GET is a dict like object with the query
string arguments decoded.

>
> But...
>
> When I try to test this View, and I call:
>
> from django.test import Client
> client = Client()
> client.get('/page/', {'filter': 'one+and+two'})

The test client takes a dictionary of raw strings, not urlencoded
strings. If you like, you are telling it to test the URL
'/page/?filter=one%2Band%2Btwo', as '+' is urlencoded as '%2B'.

Django is consistent, the test client takes raw un-encoded strings,
and request.GET delivers raw un-encoded strings.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1Lt7hvVA3mzR%2BZ4-srnr3pAvuwSDWRfxe_uV%2B%3D5Zoohig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Testing request parameters in Django (“+” behaves differently)

2015-04-18 Thread Eneko Illarramendi
*Previously posted in 
SO: 
http://stackoverflow.com/questions/29703930/testing-request-parameters-in-django-behaves-differently*
---

I have a Django View that uses a query parameter to so some content 
filtering. Something like this:

/page/?filter=one+and+two/page/?filter=one,or,two

I have noticed that Django converts the + to a space (
request.GET.get('filter') returns one and two), and I´m OK with that. I 
just need to adjust the split() function I use in the View accordingly.

*But...*

When I try to test this View, and I call:

from django.test import Client
client = Client()
client.get('/page/', {'filter': 'one+and+two'})

request.GET.get('filter') returns one+and+two: with plus signs and no 
spaces. Why is this?

I would like to think that Client().get() mimics the browser behaviour, so 
what I would like to understand is why calling client.get('/page/', 
{'filter': 'one+two+three'}) is not like browsing to 
/page/?filter=one+and+two. For testing purposes it should be the same in my 
opinion, and in both cases the view should receive a consistent value for 
filter: be it with + or with spaces. What I don´t get is why there are two 
different behaviours.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ae167e22-3cb6-4201-a301-204a02a3de2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: multiple parameters search

2015-03-23 Thread Vijay Khemlani
from django.db.models import Q

User.object.get(Q(username=myusername) | Q(email=myEmail))

On Mon, Mar 23, 2015 at 9:30 PM, nobody  wrote:

> Hi,
>
> How can I search the database using multiple parameters similar like
> "where username ="myUserName" or email = "MyEmail"?
>
> I tried to run User.object.get(username = myusername or email = myEmail),
> but that caused syntax error.
>
> Thank you.
>
> Kind regards,
>
>  - -j
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8e59ae31-579c-45d2-8490-6c64988c064a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8e59ae31-579c-45d2-8490-6c64988c064a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei3vVX4cEQ-evP9BhrGT99Fqoqu%2BvEB4hSyBHYWPbL-aQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


multiple parameters search

2015-03-23 Thread nobody
Hi,

How can I search the database using multiple parameters similar like "where 
username ="myUserName" or email = "MyEmail"? 

I tried to run User.object.get(username = myusername or email = myEmail), 
but that caused syntax error.

Thank you.

Kind regards,

 - -j

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8e59ae31-579c-45d2-8490-6c64988c064a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to supply parameters to "python manage.py syncdb" from a script?

2015-03-23 Thread Dan Dong
Thanks Russell, that's clear now.

Cheers,
Dan


在 2015年3月20日星期五 UTC-5下午6:27:12,Russell Keith-Magee写道:
>
>
> On Sat, Mar 21, 2015 at 5:25 AM, Dan Dong 
> > wrote:
>
>> Hi,
>>   Does anybody know how to supply the input parameters to "python 
>> manage.py syncdb" from a script? E.g, to set the the followings parameters:
>>
>> Would you like to create one now? (yes/no): yes
>> Username (leave blank to use 'root'): 
>> Email address: x
>> Password: xx
>> Password (again): xx
>>
>> You don't - and that's by design.
>
> If you're putting a password into a script, then that script is in plain 
> text, and so is your password - so you've just lost your security.
>
> So - you don't pass input parameters to the script. You run the script 
> with the --noinput flag, which will prevent the script from prompting for 
> user input.
>
> If you want to have an initial user in your database after syncdb, put 
> that user's data in a fixture, and load the fixture as part of the script. 
> The fixture will contain the password in a hashed format, so the password 
> will be protected.
>
> Yours,
> Russ Magee %-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e12b2f3a-05c5-4c33-bcfd-5c6a8c6c9d1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to supply parameters to "python manage.py syncdb" from a script?

2015-03-20 Thread Russell Keith-Magee
On Sat, Mar 21, 2015 at 5:25 AM, Dan Dong  wrote:

> Hi,
>   Does anybody know how to supply the input parameters to "python
> manage.py syncdb" from a script? E.g, to set the the followings parameters:
>
> Would you like to create one now? (yes/no): yes
> Username (leave blank to use 'root'):
> Email address: x
> Password: xx
> Password (again): xx
>
> You don't - and that's by design.

If you're putting a password into a script, then that script is in plain
text, and so is your password - so you've just lost your security.

So - you don't pass input parameters to the script. You run the script with
the --noinput flag, which will prevent the script from prompting for user
input.

If you want to have an initial user in your database after syncdb, put that
user's data in a fixture, and load the fixture as part of the script. The
fixture will contain the password in a hashed format, so the password will
be protected.

Yours,
Russ Magee %-)

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


Supply parameters to "manage.py syncdb" from a script?

2015-03-20 Thread Dan Dong
Hi, All,
  Does anybody know how to supply input parameters to "python manage.py 
syncdb" from a script? E.g. in a bash/python script, to set the following 
parameters:

Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'): 
Email address: x...@xxx.xxx
Password: x
Password (again): x


Cheers,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92eba9eb-1494-4b14-bbb5-482f002e5748%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to supply parameters to "python manage.py syncdb" from a script?

2015-03-20 Thread Dan Dong
Hi,
  Does anybody know how to supply the input parameters to "python manage.py 
syncdb" from a script? E.g, to set the the followings parameters:

Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'): 
Email address: x
Password: xx
Password (again): xx


Cheers,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f07775c-341f-40af-b25d-6364dfaaf966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect to external url with parameters in django

2015-01-26 Thread Stephen J. Butler
Use django.utils urlencode.

return HttpResponseRedirect(base_url + '?' + urlencode(params))

Note that a redirect is always turned into a GET request, never a
POST. If you really need POST you'll have to construct a page with the
proper form elements, and then either have the user submit it (no-js)
or post it using JavaScript yourself.

On Tue, Jan 27, 2015 at 1:30 AM, Hossein Rashnoo  wrote:
> I want when a user do something in my view then i redirect him to another
> website with some parameters as POST method Like when you submit a form.
> I think its may be something like this:
>
> return HttpResponseRedirect("url","parameters")
>
> How can i do that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6650db6b-1bd9-4f70-bbee-ed6bca3b95c2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxUvrRAF02F848RZkcg7n%2B9HsbHc0AkrFZNS0%3DBtMaFpDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Redirect to external url with parameters in django

2015-01-26 Thread Hossein Rashnoo
I want when a user do something in my view then i redirect him to another 
website with some parameters as POST method Like when you submit a form.
I think its may be something like this:

return HttpResponseRedirect("url","parameters")

How can i do that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6650db6b-1bd9-4f70-bbee-ed6bca3b95c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-25 Thread Azam Alias
Hi Collin,

I apologise for the late update. Didnt get any notifications from your 
reply.

I have solved this issue as per your suggestion. Pasting the solution for 
others' reference. 

Thanks !

from django.test import TestCase
from django.contrib.admin.sites import AdminSite
from batch_apps.models import App
from batch_apps.admin import AppAdmin


class MockRequest(object):
pass

request = MockRequest()


class AppAdminTest(TestCase):

def setUp(self):
self.app_admin = AppAdmin(App, AdminSite())

def test_activate_apps_should_activate_inactive_app(self):
app1 = App.objects.create(name='Inactive App 001', is_active=False)
queryset = App.objects.filter(pk=1)
self.app_admin.activate_apps(request, queryset)
self.assertTrue(App.objects.get(pk=1).is_active)

def test_deactivate_apps_should_deactivate_active_app(self):
app1 = App.objects.create(name='Active App 001', is_active=True)
queryset = App.objects.filter(pk=1)
self.app_admin.deactivate_apps(request, queryset)
self.assertFalse(App.objects.get(pk=1).is_active)



On Thursday, 6 November 2014 01:05:13 UTC+8, Collin Anderson wrote:
>
> Hello,
>
> Would it work to import AppAdmin, instantiate it, and then call the 
> methods in a unit test?
>
> Collin
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f79f583-99a9-4d1c-b384-9733bbf98ec0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-05 Thread Collin Anderson
Hello,

Would it work to import AppAdmin, instantiate it, and then call the methods 
in a unit test?

Collin
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9338e316-a58c-4ec1-a67a-47c52ffba1bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-02 Thread Azam Alias
Hi, 

I would like to unit-test the activate_apps( ) and deactivate_apps( ) 
functions below, as low-level as possible.

How could I do this without going through Selenium (FT) route?

In my admin.py:

from django.contrib import admin
from my_app_listing.models import App

class AppAdmin(admin.ModelAdmin):
actions = ['activate_apps', 'deactivate_apps']
list_display = ('name', 'is_active', 'frequency')
fieldsets = [
(None, {'fields': ['name']}),
(None, {'fields': ['is_active']}),
(None, {'fields': ['frequency']}),
('Description', {'fields': ['description'], 'classes': ['collapse'
]}),
]

def activate_apps(self, request, queryset):
queryset.update(is_active=True)
activate_apps.short_description = "Activate selected Apps"

def deactivate_apps(self, request, queryset):
queryset.update(is_active=False)
deactivate_apps.short_description = "Deactivate selected Apps"

admin.site.register(App, AppAdmin)

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bea4fcab-8d7c-4613-9454-f5a70181ce5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Correctly passing parameters to raw query

2014-09-24 Thread James Brewer
Also, it is worth mentioning that the RawQuerySet object looks to have been
refactored in the latest development release. I have not verified this
issue on the development branch.

On Wed, Sep 24, 2014 at 3:53 PM, James Brewer  wrote:

> This is going to depend on the version of Django you're using. Accord to
> the docs for 1.7[1], this should work fine.
>
> After playing around in the shell for a bit, I found I was getting an
> error complaining about arguments not being converted during string
> formatting. It seems the problem occurs when a `RawQuerySet` object is
> stringified. This line[2] converts the the params into a tuple if the
> `params` object is not a dictionary. For some reason, when this tuple is
> used in string formatting, everything breaks.
>
> I haven't been able to figure out a solution and, frankly, I don't even
> know if this is the error you're getting. We really do need more solution.
>
> If anyone else can shed some light on the issue I've raised, that would be
> fantastic. If not, I will submit a bug report.
>
> [1]:
> https://docs.djangoproject.com/en/dev/topics/db/sql/#passing-parameters-into-raw
> [2]:
> https://github.com/django/django/blob/stable/1.7.x/django/db/models/query.py#L1594
>
> On Wed, Sep 24, 2014 at 2:37 PM, Collin Anderson 
> wrote:
>
>> Interesting. I don't use raw queries, but I wonder if Django doesn't
>> support lists as parameters to raw()
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a117b2f7-2ff4-4fe9-8c56-9d5e137acd58%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/a117b2f7-2ff4-4fe9-8c56-9d5e137acd58%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> James Brewer
> jamesbrewer.io
>



-- 
James Brewer
jamesbrewer.io

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKj8pVpc54vR6yBeYkcUre4JrNtT%3DMON5mdhk7nvEfud9%3D7-iA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Correctly passing parameters to raw query

2014-09-24 Thread James Brewer
This is going to depend on the version of Django you're using. Accord to
the docs for 1.7[1], this should work fine.

After playing around in the shell for a bit, I found I was getting an error
complaining about arguments not being converted during string formatting.
It seems the problem occurs when a `RawQuerySet` object is stringified.
This line[2] converts the the params into a tuple if the `params` object is
not a dictionary. For some reason, when this tuple is used in string
formatting, everything breaks.

I haven't been able to figure out a solution and, frankly, I don't even
know if this is the error you're getting. We really do need more solution.

If anyone else can shed some light on the issue I've raised, that would be
fantastic. If not, I will submit a bug report.

[1]:
https://docs.djangoproject.com/en/dev/topics/db/sql/#passing-parameters-into-raw
[2]:
https://github.com/django/django/blob/stable/1.7.x/django/db/models/query.py#L1594

On Wed, Sep 24, 2014 at 2:37 PM, Collin Anderson 
wrote:

> Interesting. I don't use raw queries, but I wonder if Django doesn't
> support lists as parameters to raw()
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a117b2f7-2ff4-4fe9-8c56-9d5e137acd58%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a117b2f7-2ff4-4fe9-8c56-9d5e137acd58%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
James Brewer
jamesbrewer.io

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


Re: Correctly passing parameters to raw query

2014-09-24 Thread Collin Anderson
Interesting. I don't use raw queries, but I wonder if Django doesn't 
support lists as parameters to raw()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a117b2f7-2ff4-4fe9-8c56-9d5e137acd58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Correctly passing parameters to raw query

2014-09-24 Thread termopro
Hello,

I am constructing raw query which looks like the following:
"SELECT * FROM some_table  WHERE id IN (1,3,5);"

So inside my view i write:
entities = Entity.objects.raw("""
SELECT * FROM some_table  WHERE id IN (%s);
""", [ids_list])

How should i correctly pass the argument ? Because i keep getting errors no 
matter how i try.


p.s. - In reality my query is much more complex, i have simplified it just 
to explain the question

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/40d474d3-5582-448e-9727-4f5f457c1767%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-nose: How to provide nose parameters from the command line?

2014-09-10 Thread Andres Riancho
List,

I've been using django-nose for a long time but now I'm trying to 
specify command line parameters for "python manage.py test" that should be 
passed to "nose" and can't find out how.

So, the question is: How do you pass nose parameters from the command 
line? In an early blog post from the original django-nose author I found a 
mention to --, which still seems to do something:

$ python manage.py test -- -A smoke .
nosetests --verbosity 1 . -A smoke --with-yanc --with-id -s -v -- -A
...smoke tests are run... 

But afterwards:

80 Failure: OSError (No such file /home/pablo/pch/octopus/-A) ...

Also asked here [0]

[0] https://github.com/django-nose/django-nose/issues/168

-- 
Andrés Riancho
Project Leader at w3af - http://w3af.org/
Web Application Attack and Audit Framework
Twitter: @w3af
GPG: 0x93C344F3

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c52148bc-95a2-4e67-8ec3-5550d35a0dc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query parameters in the URL, with REST Framework

2014-09-09 Thread Elio Gerson Clímaco Herrera
Yes, Carlos

I, have read documentation, but this don't show how put parameters in 
router.register like this.
router.register(r'author/(?P\d+)/books', BooksList, base_name = 
'Books')

please, any 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d1d56fa4-6fda-47f8-894c-34283504250d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query parameters in the URL, with REST Framework

2014-09-09 Thread carlos
Hi, maybe you need read documentation about filtering
http://www.django-rest-framework.org/api-guide/filtering


Cheers

On Mon, Sep 8, 2014 at 1:41 PM, Elio Gerson Clímaco Herrera <
elioclim...@gmail.com> wrote:

> Hi, everybody.
>
> I, stared using *REST Framework* 
> few days ago, but I, can't find how create a customized url with parameter,
> in Django this kind of url is written like this.
>
> url(r'^author/(?P\d+)/books/$', BooksList.as_view(), name =
> 'books'),
>
> for this
>
> *http://mysite/author/1/books *
>
> I, try with:
> router.register(r'author/(?P\d+)/books', BooksList, base_name =
> 'Books')
> but this don't work.
>
> *Here is my code.*
>
> # models.py
> class Author(models.Model):
> Name = models.CharField(max_length = 50)
>
> class Book(models.Model):
> Book = models.ForeignKey(Author)
> Title = models.CharField(max_length = 200)
>
> def __unicode__(self):
> return self.Title
>
>
> # views.py
> class BooksList(viewsets.ModelViewSet):
> model = Book
> serializer_class = BookSerializer
> def get_queryset(self):
> author = self.kwargs['author']
> queryset = Book.objects.filter(Author = author)
> return queryset
>
> # urls.py
> router = routers.DefaultRouter()
> router.register(r'books', BooksList, base_name = 'Books')
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
> url(r'^api/', include('rest_framework.urls', namespace =
> 'rest_framework')),
> )
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f2eb0566-b38c-44f4-8814-f93710d03cec%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO1RgbX194Z%3DqTz4egSV3bJCwAReh3SA2FZKWuV6dgx-zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Query parameters in the URL, with REST Framework

2014-09-08 Thread Elio Gerson Clímaco Herrera
Hi, everybody.

I, stared using *REST Framework*  
few days ago, but I, can't find how create a customized url with parameter, 
in Django this kind of url is written like this.

url(r'^author/(?P\d+)/books/$', BooksList.as_view(), name = 
'books'),

for this 

*http://mysite/author/1/books*

I, try with:
router.register(r'author/(?P\d+)/books', BooksList, base_name = 
'Books')
but this don't work.

*Here is my code.*

# models.py
class Author(models.Model):
Name = models.CharField(max_length = 50)

class Book(models.Model):
Book = models.ForeignKey(Author)
Title = models.CharField(max_length = 200)

def __unicode__(self):
return self.Title


# views.py
class BooksList(viewsets.ModelViewSet):
model = Book
serializer_class = BookSerializer
def get_queryset(self):
author = self.kwargs['author']
queryset = Book.objects.filter(Author = author)
return queryset

# urls.py
router = routers.DefaultRouter()
router.register(r'books', BooksList, base_name = 'Books')

admin.autodiscover()

urlpatterns = patterns('',
url(r'^api/', include('rest_framework.urls', namespace = 'rest_framework')),
)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f2eb0566-b38c-44f4-8814-f93710d03cec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to decompose URL into model and parameters

2014-08-14 Thread 9devmail
Yes, I figured it out. Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/352776cd-f859-47c9-91c5-0b93f7620404%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to decompose URL into model and parameters

2014-08-14 Thread Collin Anderson
It raises an Http404 if it doesn't exist. Is that what's going on?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFO84S5gKoWikH9t-kF%2BYJ1Nwf%3Dw--5OfzvyYc61apgkfcDh1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to decompose URL into model and parameters

2014-08-14 Thread 9devmail
Line

match = urlresolvers.resolve(urlsplit(url).path)

stops executing the script and redirects me to given URL.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/606cc513-9e65-4740-96f7-7aa3dbb664ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to decompose URL into model and parameters

2014-08-14 Thread Collin Anderson
from django.core import urlresolvers

match = urlresolvers.resolve(urlsplit(url).path)
view = match.func
params = math.args

https://docs.djangoproject.com/en/dev/ref/urlresolvers/#resolve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ed76caad-2507-4c93-b115-0f63e5a9949d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to decompose URL into model and parameters

2014-08-14 Thread 9devmail
I want to parse an application URL just like Django does.

url = 'http://www.example.com/path/to/myview/123'
view, params = decompose(url)
# now view="MyView", params=('123',)

How can it be done?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08a4ed71-ec57-4d30-9223-ba6dbb7c2542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GET parameters in admin "add" model page

2014-05-12 Thread Russell Keith-Magee
Hi,

On Sun, May 11, 2014 at 11:42 PM, ?manu*  wrote:

> I noticed that django admin "add" page reads GET parameters and uses them
> as initial values in the form. However I was not able to pass DateTime
> values in this way. In particular if I try to pass a DateTime value I get a
> "server error".
>
> See
> http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parametersfor
>  more details.
>
> 1. is it possible to pass DateTime values this way?
>

Yes, but not "out of the box". I've responded on the SO thread; but the
short answer is that you need to override get_changeform_initial_data() in
your ModelAdmin class.

2. isn't it a bug if a user is able to generate a server error by messing
> with GET parameters?
>
>
Not necessarily. It's only a bug if, when *using the APIs as documented*, a
user is able to generate a server error by providing faulty GET arguments.
Taking the extreme case of the argument - if you write a view that
knowingly does divide by zero, it's not a bug in Django that the user is
able to generate a 500 by visiting that view. In your case, the argument is
much more subtle, but you still have code that is "wrong", and as a result,
it's raising a 500.

Yours,
Russ Magee %-)

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


GET parameters in admin "add" model page

2014-05-11 Thread ?manu*
I noticed that django admin "add" page reads GET parameters and uses them 
as initial values in the form. However I was not able to pass DateTime 
values in this way. In particular if I try to pass a DateTime value I get a 
"server error". 

See 
http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parameters
 
for more details. 

1. is it possible to pass DateTime values this way?

2. isn't it a bug if a user is able to generate a server error by messing 
with GET parameters?

thanks
E.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4021a36d-81d2-41ff-a160-f04fe0fc8513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nested includes and captured parameters

2013-10-09 Thread Jason Mayfield
Nevermind.  Discovered typo in a URLconf regex that was causing the problem.

On Wednesday, October 9, 2013 2:41:45 PM UTC-4, Jason Mayfield wrote:
>
> The docs state that "An included URLconf receives any captured parameters 
> from parent URLconfs".  And that does work as expected, when the child 
> URLconf makes immediate use of the parameter -- that is, the child URLconf 
> is a terminal node and doesn't include any further child URLconfs.
>
> In my particular use-case, I find myself needing to use two levels of 
> URLconf includes, and when I do this, the captured parameter seems to get 
> lost along the way.
>
> Examples:
>
> a)  In this scenario, "my_view" gets app1_pk passed in kwargs (expected 
> behavior).
>
> root urls.py:
> …
> url(r'^app1/(?P\d+)/app2/', include('app2.urls')),
> …
>
> app2.urls.py:
> …
> url(r'^my_view/$', 'app2.views.my_view'),
> …
>
> b)  In this scenario (my use-case), "my_view" does not get app1_pk passed 
> in kwargs (but I do not expect this to be the correct behavior).
>
> root urls.py:
> …
> url(r'^app1/', include('app1.urls')),
> …
>
> app1.urls.py:
> …
> url(r'^(?P\d+)/app2/', include('app2.urls')),
> …
>
> app2.urls.py:
> …
> url(r'^my_view/$', 'app2.views.my_view'),
> …
>
> Is this expected behavior?  Any thoughts?
>
> Thanks in advance,
> Jason
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97f5aed4-bf7b-462f-9e15-642c2786b596%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Nested includes and captured parameters

2013-10-09 Thread Jason Mayfield
The docs state that "An included URLconf receives any captured parameters 
from parent URLconfs".  And that does work as expected, when the child 
URLconf makes immediate use of the parameter -- that is, the child URLconf 
is a terminal node and doesn't include any further child URLconfs.

In my particular use-case, I find myself needing to use two levels of 
URLconf includes, and when I do this, the captured parameter seems to get 
lost along the way.

Examples:

a)  In this scenario, "my_view" gets app1_pk passed in kwargs (expected 
behavior).

root urls.py:
…
url(r'^app1/(?P\d+)/app2/', include('app2.urls')),
…

app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…

b)  In this scenario (my use-case), "my_view" does not get app1_pk passed 
in kwargs (but I do not expect this to be the correct behavior).

root urls.py:
…
url(r'^app1/', include('app1.urls')),
…

app1.urls.py:
…
url(r'^(?P\d+)/app2/', include('app2.urls')),
…

app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…

Is this expected behavior?  Any thoughts?

Thanks in advance,
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ebe111a9-b0f5-4a7b-9687-dc95ba1b016a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Your right... I can't testing now.


2013/10/9 Hélio Miranda 

> gives error:
> 'BaseList' object has no attribute 'values'
>
> The query has to be the same as I stated it works:
> *
> Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
> *
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7a4cf4fe-0c5a-40ff-92fc-60c51164239f%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOWHTn7xc%3DY11b8%2BU5sTP%3DCu03AhSvGM5F3R66wxO8AWUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
gives error:
'BaseList' object has no attribute 'values'

The query has to be the same as I stated it works:
*
Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a4cf4fe-0c5a-40ff-92fc-60c51164239f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
try this solution
http://plnkr.co/edit/cyM6AmZcyFVUU6soFKhB


2013/10/9 Denis Chernoshchekov 

> ok, i understand, i minute.
>
>
> 2013/10/9 Denis Chernoshchekov 
>
>> *fld_name = 'nationality_in' *must be with double '_'* **fld_name =
>> 'nationality__in'*
>>
>>
>> 2013/10/9 Denis Chernoshchekov 
>>
>>> Sorry, i don't understand you... You can control all your values for all
>>> fields, you can generate dict which you like.
>>>
>>>
>>> 2013/10/9 Hélio Miranda 
>>>
 I put that work, I wanted to know was how to put in the code, because
 you can not do the same to position

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To post to this group, send email to django-users@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
 .

 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>
>

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


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
ok, i understand, i minute.


2013/10/9 Denis Chernoshchekov 

> *fld_name = 'nationality_in' *must be with double '_'* **fld_name =
> 'nationality__in'*
>
>
> 2013/10/9 Denis Chernoshchekov 
>
>> Sorry, i don't understand you... You can control all your values for all
>> fields, you can generate dict which you like.
>>
>>
>> 2013/10/9 Hélio Miranda 
>>
>>> I put that work, I wanted to know was how to put in the code, because
>>> you can not do the same to position
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOUf7Ck0Y9ptjn_FaJLEaPzPdmas01CRPW_QPNVg39%2BD8A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
*fld_name = 'nationality_in' *must be with double '_'* **fld_name =
'nationality__in'*


2013/10/9 Denis Chernoshchekov 

> Sorry, i don't understand you... You can control all your values for all
> fields, you can generate dict which you like.
>
>
> 2013/10/9 Hélio Miranda 
>
>> I put that work, I wanted to know was how to put in the code, because you
>> can not do the same to position
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOW%3D_kZw7BWo6TWL3fzk92U89i7rqkw8yZ3jg-mxRuwKsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Sorry, i don't understand you... You can control all your values for all
fields, you can generate dict which you like.


2013/10/9 Hélio Miranda 

> I put that work, I wanted to know was how to put in the code, because you
> can not do the same to position
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOVmFDZ5kexgJgiec9GeLazOcA7fgAVdp-Ybv%3DfUmgchig%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
was trying something like this:
*if fld_name == 'nationality':*
*fld_name = 'nationality_in'*
*value = 
Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name=value)))
*

But it does not work

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/360f22d0-de14-4ec8-b9d4-3c4079f6ee39%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
I put that work, I wanted to know was how to put in the code, because you 
can not do the same to position

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Try this - *Player.objects.filter(country__in=**
Nationality.objects.filter(name='Espanhola').distinct('country').values('country'))
*


2013/10/9 Hélio Miranda 

> yes, that was it ...
> Just one more thing, if I would like to create the nationality of the
> player, so that the filter is:
> *
> Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
> *
> *
> *
> where only the step nationality, as I do, not only gives an if?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c8a6-6f7f-4603-9834-c94e426208e0%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOVx4ad26UpgA6YEPvQy%3DjNiNfQADgaAPW%2B%2BBNe4xBtexQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


  1   2   3   4   5   >