Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
I edited it as you suggested but it is giving another error like 'method'
object is not subscriptable

On Wed, Apr 3, 2019 at 10:24 PM Nikolay Smirnov 
wrote:

> Your request.POST does not contain "search1".
> Do so search1 = request.POST.get('search1')
>
> Example:
> def viewstr(request):
> views = create_store.objects.all()
> brn = Prod_Brand.objects.all()
> mi = ''
> if request.method == 'POST':
> search1 = request.POST.get('search1')
> if search1:
> mi =
> create_store.objects.filter(Q(select_brand__Brand__icontains=search1))
> if mi:
> return render(request,'viewstr.html',{'vi':mi,'brn':brn})
> search = request.POST.get('search')
> if search:
> mi = create_store.objects.filter(Q(id__icontains=search))
> if mi:
> return render(request,'viewstr.html',{'vi':mi,'brn':brn})
>
> return
> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})
>
>
>
>
>
> On Wednesday, 3 April 2019 13:33:20 UTC+2, Abhineet Baranwal wrote:
>>
>>
>> *this is my views file which creates an error like
>> django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone
>> tell me where i go wrong?*
>>
>> *def viewstr(request):*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *views = create_store.objects.all()brn =
>> Prod_Brand.objects.all()mi = ''if request.method == 'POST':
>> # mi = ''search1 = request.POST['search1']if search1 == ''
>> :passelse:mi =
>> create_store.objects.filter(Q(select_brand__Brand__icontains=search1))
>> if mi:return
>> render(request,'viewstr.html',{'vi':mi,'brn':brn})search =
>> request.POST['search']if search == '' :passelse
>> :mi =
>> create_store.objects.filter(Q(id__icontains=search))if
>> mi:return
>> render(request,'viewstr.html',{'vi':mi,'brn':brn})return
>> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})*
>>
> --
> You received this message because you are subscribed to the Google Groups
> "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/4a37bed9-2860-4a54-9ff4-f6f43efa12ce%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/CAFOSuXLiCVsQy4VhbyzJgtxy5LYKKVqdm%2BWPhPXmrs9j9OCVSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
Thanks..I'll search for that but i think its not related to the query, its
related to two search i have used in one post request

On Wed, Apr 3, 2019 at 5:57 PM Guru Murthy  wrote:

> Hi abhineet baranwal,
> You have to use q(id__in=search) instead q(id__icontains=search) ..search
> more about how to use in query in django and 1 thing you are not getting
> correct post value of searc1
>
> On Wed, 3 Apr, 2019, 5:31 PM Abhineet Baranwal, <
> suabhineetbaran...@gmail.com> wrote:
>
>> Thanks for your efforts, But i didn't get it can you please elaborate
>> your answer?
>>
>> On Wed, Apr 3, 2019 at 5:16 PM Guru Murthy 
>> wrote:
>>
>>> Hi Abhijeet baranwal,
>>>   I think you are adding contains is not correct query listing you have
>>> to use in query instead
>>>
>>>
>>> On Wed, 3 Apr, 2019, 5:02 PM Abhineet Baranwal, <
>>> suabhineetbaran...@gmail.com> wrote:
>>>

 *this is my views file which creates an error like
 django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone
 tell me where i go wrong?*

 *def viewstr(request):*





















 *views = create_store.objects.all()brn =
 Prod_Brand.objects.all()mi = ''if request.method == 'POST':
 # mi = ''search1 = request.POST['search1']if search1 == ''
 :passelse:mi =
 create_store.objects.filter(Q(select_brand__Brand__icontains=search1))
 if mi:return
 render(request,'viewstr.html',{'vi':mi,'brn':brn})search =
 request.POST['search']if search == '' :passelse
 :mi =
 create_store.objects.filter(Q(id__icontains=search))if
 mi:return
 render(request,'viewstr.html',{'vi':mi,'brn':brn})return
 render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})*

 --
 You received this message because you are subscribed to the Google
 Groups "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/cdafd13a-46b5-471d-a927-b3d5d8e58f5c%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/CAMgkGLV-OzbGCnJZv-MoQz5GvjgetOjjZ-TVV5KLNQMezZC13g%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAFOSuXL4i%3DqCWNWkRwm2MFfHgvD9jJueZd4uARFb6Rza%2BAy-JA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMgkGLWeRc8DRMQxmtJ5hsb%2BWEvs1%3DQtCv4dO5v7d5_RJOwUGg%40mail.gmail.com
> 

Download html file using python

2019-04-04 Thread Guru Murthy
Hi all,
 IAM having html content file similar to as follows:



educa




login



I have to download this html content file using python remember I have to
download the html file not to write the data  in another file name

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAMgkGLV9SubH7upVE%2BwEYgPEnkEpBhHbG9R58o3wC8nL5Xc8Lg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: google chrome extension

2019-04-04 Thread Abhineet Baranwal
Thanks for the good explanation

On Wed, Apr 3, 2019, 6:40 PM Alex Chiaranda  wrote:

> Greetings,
>
> for Chrome Extension, you must use Javascript, or Javascript + Native Code
> (compiling for the target platform, and distributing it with the
> extension). So the quick answer is "You shouldn't do it", but it might be
> possible. I don't think it would be approved thought, because you would
> have to distribute a python interpreter with you extension, the extension
> size would be huge.
>
>
> However, if your extension is meant to communicate with a server side
> application, this part can be whatever you want, providing a REST API for
> your extension.
>
> Hope it helps !
>
> Regards,
>
> Alex
>
>
> On Wednesday, April 3, 2019 at 8:33:20 AM UTC-3, Abhineet Baranwal wrote:
>>
>>
>> *Can i create a chrome extension in django or flask ? I have already
>> created an extension in javascript but i didn't know how to start creating
>> it in django . Can anyone tell me how to do it with some example?*
>>
> --
> You received this message because you are subscribed to the Google Groups
> "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/1fd13cb2-637e-48de-a8f2-a9018edd5b92%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/CAFOSuXLUWwRVnrJWrsV4WWuQy%3DoMgvcjtveJ87dK9XOYMwvnCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
Thanks for the help, this is showing only one value in dictionary at a time
. There is no fault here but i have a question can we run multiple search
query in same page with different id ? And it shows that error even now

On Wed, Apr 3, 2019 at 5:56 PM dvij parekh  wrote:

>
> seems like search1 key is containg multi value dictionary and you are
> checking it with == which is for single value
> after
> *search1 = request.POST['search1']  *
> put
> *print(* *search1*  *)*
> *return "hello"*
>
>  and comment code remaining below ,check terminal it will show you how
> many value you have in dictionary
>
>
> On Wed, Apr 3, 2019 at 5:03 PM Abhineet Baranwal <
> suabhineetbaran...@gmail.com> wrote:
>
>>
>> *this is my views file which creates an error like
>> django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone
>> tell me where i go wrong?*
>>
>> *def viewstr(request):*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *views = create_store.objects.all()brn =
>> Prod_Brand.objects.all()mi = ''if request.method == 'POST':
>> # mi = ''search1 = request.POST['search1']if search1 == ''
>> :passelse:mi =
>> create_store.objects.filter(Q(select_brand__Brand__icontains=search1))
>> if mi:return
>> render(request,'viewstr.html',{'vi':mi,'brn':brn})search =
>> request.POST['search']if search == '' :passelse
>> :mi =
>> create_store.objects.filter(Q(id__icontains=search))if
>> mi:return
>> render(request,'viewstr.html',{'vi':mi,'brn':brn})return
>> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})*
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/cdafd13a-46b5-471d-a927-b3d5d8e58f5c%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/CAF-XeXYVy%3DyvtRrm9pOyERySbbAaQ%2BwarU-56ySpCnNvk%2B1Mjw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Models

2019-04-04 Thread Mike Dewhirst

On 4/04/2019 5:52 pm, John Crosby wrote:

Hi all,

does any one have any good tips or resources to help me get my head around 
designing models?


Everyone would love to dive in and help but it is just a tad too soon. 
You need to follow the tutorial and marry the polls models with the way 
you perceive the polls app should work.


After that you should be able to ask specific questions about your own 
project and people can more easily jump in and help.


If you are across the polls app and looking for more depth than it 
offers, look online for 'relational database design' or 'third normal 
form' which is relational-speak for designing databases to match the 
real world. The best advice I can offer is to adopt 3rd normal form and 
don't compromise. A good book if a little deep for beginners is Domain 
Driven Design by Eric Evans.


Welcome and all the best :)

Mike






I'm currently going through the Django docs and tinkering.

Kind regards,
John Crosby



--
You received this message because you are subscribed to the Google Groups "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/eaf7be38-6f12-e274-4dcd-990724419101%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Migration auth.0011_update_proxy_permissions from Django 2.2 fails to apply

2019-04-04 Thread Julien Enselme
Hi,

I am trying to update my project to Django 2.2 (we are currently on 
2.0.13). When I launch `python manage.py migrate`, I get this error message 
when migration auth.0011_update_proxy_permissions is applying (full 
stacktrace is available here ):
django.db.utils.IntegrityError: duplicate key value violates unique 
constraint "idx_18141_auth_permission_content_type_id_01ab375a_uniq"
DETAIL:  Key (content_type_id, codename)=(12, add_agency) already exists.

It looks like the migration is trying to re-create already existing entries 
in the auth_permission table. At first I though it cloud because we 
recently renamed a model. But after digging and deleting the entries 
associated with the renamed model from our database in the auth_permission 
table, the problem still occurs with other proxy models.

I search for a ticket about this on the bug tracker but found nothing.

Can someone help me on this? I guess I can keep deleting problematic 
entries from our database one by one but it will take a long time and it 
doesn't look right.

Regards,
Julien Enselme

-- 
You received this message because you are subscribed to the Google Groups 
"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/03432e49-935f-4735-894b-2e150eac4899%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Edubancassurance: Proposed Evolution of Virtual Government for the Universe.

2019-04-04 Thread Hemant Shirbavikar
 

Name: Hemant Shirbavikrar S/o Sharadchandra Shirbavikar

DOB   : 08.10.1956 POB Nagpur

Permanent Address: Plot S-16, Sahasrabuddhe Layout, Bharatnagar, NagpurMS 
0712-2549936

Current Address: Flat 12, Krishan Residency, Paras Paradise Apartment, Rau, 
Indore MP 450 001 (M) 7389732800

Mail: heyman...@rediffmail.com 

 

Health: Sound as took Exit from SBI and was working as Free-Lance Education 
/ Finance / Ayurved / Internet Communication Gov.co.in

 

Graduated: B Com Nagpur University 1978

 

1.   Appointed with SBI 01.07.1980,

2.   Quality Circle Leader SBI,

3.   Ayurved Ratna (Prayag Vishwavidyalaya),Purchased Agricultural Land 
for PARAD PURIFICATION 1983

*4.   **Coaching for competitive examinations of Banks etc with YUVAM 
of Hon. Paras Saklecha of Ratlam.*

5.   Worked with SBI 27 Yrs inclusive of Front Line executive, 
Marketing, Cross Selling etc

*6.   *Sought VRS in July 2007 

*7.   **Free Lancing conducted Pre-Sanction  Recommendations, 
Sanctions, Post- disbursement visits etc and Cross Selling,*

*8.   **LIASONONG of Audit and Inspection, Lead generation and booking 
loans for SBI, BOI & Corporation Bank,*

*9.   **Worked for Govt sponsored schemes,*

*10.   **Aspired for Public Limited Company IN THE NAME OF Edubancassurance 
pl see profile at linkedin.com,*

11.   There from worked as Principal at MP Board and CISCE Board affiliated 
schools making them Finance & Board Affiliation.

12.   Worked especially for Continuous-Curriculum-Assessment, Management of 
Staff, Admissions, Marketing, Accounts, Audit

13.   Supervising Examination, Redressers, HRMSs, Board / Bank Inspections, 
Parents meeting, infusion of Team Spirit,

14.   Appointment of Staff, Compliance of Society Act, Up-gradation of 
School, Implementing Prudential Norms at every one.

15.   Valid suggestions for maintenance of School Premises and allied 
instruments, Library Books,

16.   Conducting hygiene supervision,  Facilitating on line parent check 
while pupil in Transit and / or  attending studies / games,

17.   Arranging Annual Functions, Social-Up-liftmen-Working programme, 
Routine Medical Check-ups

18.   Being renowned Astrologer counselling any pupil/parent etc.

19.   Managing Web-Site of the school, studies and remedial studies from 
home.

20.   Interlinking of four pillar  of Democracy. 

 

Innovation:

 

1.   Schooling without School,

2.   Creation of 225 Lac jobs at National Level,

3.   Prudential Norms at all sectors of Economy,

4.   Re-Engineering Democracy For the In-Divi-Dual, From the 
In-Divi-Dual, To the In-Divi-Dual,

5.   Conservation of 25% Time and Energy of every Individual.

 

Languages:

 

 

Active at Linkedin.com with more than 2500 members in the profile name 
Edubancassurance, Face Book etc
Participating Gov.Co.In, various National Schemes through SIDBI platform, 
Amrita TBI, Villgro, recently with Agni

















-- 
You received this message because you are subscribed to the Google Groups 
"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/640542ac-5b84-49cb-8a86-48d4fe27bd37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Democracy.odp
Description: application/vnd.oasis.opendocument.presentation


I cannot import my model classes in order to add data to my database

2019-04-04 Thread Demayne Collins


below is the code. When I try t import the class Membership I get an error 
message saying "*ModuleNotFoundError: No module named 'membership'" *
* at the python IDLE. I need to create an object from the class by 
instantiating a variable.. It appears my object class is not being 
recognized. *

*What I am missing? Help needed*




from django.db import models

# Create your models here.

class Membership(models.Model):
id = models.AutoField(primary_key=True)
last_name = models.CharField(max_length=100)
first_name = models.CharField(max_length=100)
email = models.EmailField(max_length=200)
address = models.CharField(max_length=80)
phone_number = models.CharField(max_length=100)
city = models.CharField(max_length=50)
state = models.CharField(max_length=50)
zipcode = models.IntegerField()
control_number = models.IntegerField()

class Meta:
ordering = ["-last_name"]

def __str__(self):
return self.first_name 


class Payment(models.Model):
id = models.AutoField(primary_key=True)
financial_status = models.CharField(max_length=30)
IHQ_payment_date = models.CharField(max_length=40)
IHQ_fees = models.IntegerField()
district_payment_date = models.DateField()
district_fees = models.IntegerField()
chapter_payment_date = models.DateField()
chapter_fees = models.IntegerField()
payment_method = models.CharField(max_length=30)
late_fees = models.IntegerField()
reinstate_fee = models.IntegerField()
total = models.IntegerField()
balance_due = models.IntegerField()

membership = models.ForeignKey(Membership, on_delete=models.CASCADE)
last_name = models.CharField(max_length=100)


def __str__(self):
return 'A {} requires a {} for Payment'.format(self.membership, self
.last_name)

-- 
You received this message because you are subscribed to the Google Groups 
"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/0ac63d49-6671-4f27-853e-86bc99409e18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Hello,

Am 03.04.19 um 21:28 schrieb Mohammad Etemaddar:
> Set default value:
> year = forms.ChoiceField(required=False, choices=[(j, j) for j in range(2018, 
> 2021)], default=2019)

Thanks for your reply, but unfortunately, `default` is a keyword for model 
fields only, not for form fields:
TypeError: __init__() got an unexpected keyword argument 'default'

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/666f4ad3-cc32-ce9d-7a21-d860223ba2a9%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


How to render the result of Model's method after submitting to another model?

2019-04-04 Thread Олег Котов
Hello. 
I have a model which saves data from field forms on site to the PostgreSQL.

And another model which must take some data her table and handle it.
So how can i print result of my second model's method to another field form 
on site?

I think it's a stupid question, but i've read many tutorials and still 
don't know how can i do that.

Thank you.


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


Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
To elaborate on this further:

Searching the web for this yields numerous hits, e.g. 
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
 mentions some ways to address this, but I've not come across a fully 
satisfactory solution.

Another approach might be this:


params = {'year': '2019'} # default values
params.update(request.GET)
year_form = JahrAuswahl(params)

# Can now use year_form normally, as intended:

if not year_form.is_valid():
# Pass year_form to the view to re-render the form with errors.
return render(..., {'year_form': year_form})

# year_form is valid, now use the year_form.cleaned_data values.
# If (unrelated) request.POST data turns out to be invalid,
# we may re-render year_form in this code path as well.
# ...


Thoughts?

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/7cce7f43-e5e1-995a-a201-92905ba8f2bc%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
If you need a default year in your template context, put it there.

def get_context_data(self, request, *args, **kwargs):
context = super().get_context_data(request, *args, **kwargs)
context['default_year'] = 2019
return context

In your template, you could use this type of construct:
{{ year or default_year }}

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

To elaborate on this further:

Searching the web for this yields numerous hits, e.g. 
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
 mentions some ways to address this, but I've not come across a fully 
satisfactory solution.

Another approach might be this:


params = {'year': '2019'} # default values
params.update(request.GET)
year_form = JahrAuswahl(params)

# Can now use year_form normally, as intended:

if not year_form.is_valid():
# Pass year_form to the view to re-render the form with errors.
return render(..., {'year_form': year_form})

# year_form is valid, now use the year_form.cleaned_data values.
# If (unrelated) request.POST data turns out to be invalid,
# we may re-render year_form in this code path as well.
# ...


Thoughts?

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/7cce7f43-e5e1-995a-a201-92905ba8f2bc%40cafu.de.
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/15ab780e0c214868bde744af7b93452f%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
And, since you really don't want constants littering your code, you probably 
want something like this:
context['default_year'] = timezone.now().year

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

To elaborate on this further:

Searching the web for this yields numerous hits, e.g. 
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
 mentions some ways to address this, but I've not come across a fully 
satisfactory solution.

Another approach might be this:


params = {'year': '2019'} # default values
params.update(request.GET)
year_form = JahrAuswahl(params)

# Can now use year_form normally, as intended:

if not year_form.is_valid():
# Pass year_form to the view to re-render the form with errors.
return render(..., {'year_form': year_form})

# year_form is valid, now use the year_form.cleaned_data values.
# If (unrelated) request.POST data turns out to be invalid,
# we may re-render year_form in this code path as well.
# ...


Thoughts?

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/7cce7f43-e5e1-995a-a201-92905ba8f2bc%40cafu.de.
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/0bdfd5f6826342a4ae929ea3a73fbd77%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Am 04.04.19 um 16:24 schrieb Matthew Pava:
> And, since you really don't want constants littering your code, you probably 
> want something like this:
> context['default_year'] = timezone.now().year

Sure, thanks, but the year was only used to keep the example code minimal and 
the focus on how to handle a form that is based on request.GET data and has 
default values.   ;-)

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/2374ce25-0a1e-8637-2608-af33f54ca9a9%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: Using forms to handle request.GET data?

2019-04-04 Thread Carsten Fuchs
Am 04.04.19 um 16:23 schrieb Matthew Pava:
> If you need a default year in your template context, put it there.
> 
> def get_context_data(self, request, *args, **kwargs):
> context = super().get_context_data(request, *args, **kwargs)
> context['default_year'] = 2019
> return context
> 
> In your template, you could use this type of construct:
> {{ year or default_year }}
> 

No, the goal is to have a HTTP GET based form that the user can use to 
customize the view, and I'm looking for an elegant way to handle this with 
Django forms.

The key problem is that default values for form fields are not relevant when 
working with POST requests (where `initial` values are used in GET requests or 
request.POST data in POST request), but *are* relevant for HTTP GET 
(request.GET) based forms. As Django forms are tailored to work with `initial` 
and POST data, I've not yet found a really Django-elegant way to deal with this 
problem.

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/fe1a5f18-7319-7358-00b4-2670e8111b08%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: django Query filter

2019-04-04 Thread Nikolay Smirnov
The global POST variable allows you to access the data sent with the POST 
method by* input name*. See more info 
https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data
.

Your html:

  First name:
  
  
  Last name:
  
  
  
 




On Thursday, 4 April 2019 09:43:51 UTC+2, Abhineet Baranwal wrote:
>
> Thanks for the help, this is showing only one value in dictionary at a 
> time . There is no fault here but i have a question can we run multiple 
> search query in same page with different id ? And it shows that error even 
> now 
>
> On Wed, Apr 3, 2019 at 5:56 PM dvij parekh  > wrote:
>
>>
>> seems like search1 key is containg multi value dictionary and you are 
>> checking it with == which is for single value
>> after  
>> *search1 = request.POST['search1']  *
>> put  
>> *print(* *search1*  *)*
>> *return "hello"*
>>
>>  and comment code remaining below ,check terminal it will show you how 
>> many value you have in dictionary 
>>
>>
>> On Wed, Apr 3, 2019 at 5:03 PM Abhineet Baranwal > > wrote:
>>
>>>
>>> *this is my views file which creates an error like  
>>> django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone 
>>> tell me where i go wrong?*
>>>
>>> *def viewstr(request):*
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *views = create_store.objects.all()brn = 
>>> Prod_Brand.objects.all()mi = ''if request.method == 'POST':
>>> # mi = ''search1 = request.POST['search1']if search1 == '' 
>>> :passelse:mi = 
>>> create_store.objects.filter(Q(select_brand__Brand__icontains=search1))  
>>>   
>>> if mi:return 
>>> render(request,'viewstr.html',{'vi':mi,'brn':brn})search = 
>>> request.POST['search']if search == '' :passelse 
>>> :mi = 
>>> create_store.objects.filter(Q(id__icontains=search))if 
>>> mi:return 
>>> render(request,'viewstr.html',{'vi':mi,'brn':brn})return 
>>> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})*
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django...@googlegroups.com .
>>> To 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/cdafd13a-46b5-471d-a927-b3d5d8e58f5c%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...@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/CAF-XeXYVy%3DyvtRrm9pOyERySbbAaQ%2BwarU-56ySpCnNvk%2B1Mjw%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: django Query filter

2019-04-04 Thread Nikolay Smirnov
The global POST variable allows you to access the data sent with the POST 
method by* input name*. See more info 
https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data
.

Your html:

  First name:
  
  
  Last name:
  
  
  


On Wednesday, 3 April 2019 13:33:20 UTC+2, Abhineet Baranwal wrote:
>
>
> *this is my views file which creates an error like  
> django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone 
> tell me where i go wrong?*
>
> *def viewstr(request):*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *views = create_store.objects.all()brn = 
> Prod_Brand.objects.all()mi = ''if request.method == 'POST':
> # mi = ''search1 = request.POST['search1']if search1 == '' 
> :passelse:mi = 
> create_store.objects.filter(Q(select_brand__Brand__icontains=search1))
> 
> if mi:return 
> render(request,'viewstr.html',{'vi':mi,'brn':brn})search = 
> request.POST['search']if search == '' :passelse 
> :mi = 
> create_store.objects.filter(Q(id__icontains=search))if 
> mi:return 
> render(request,'viewstr.html',{'vi':mi,'brn':brn})return 
> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})*
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/b2404353-bcc7-47fc-92c3-23f6816c37d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
You could try something like this:
data = request.GET.copy()
data.setdefault('year', 2019)  # fill 'year' in data if it's not already set; 
returns 2019
year_form = JahrAuswahl(data)


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:51 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

Am 04.04.19 um 16:23 schrieb Matthew Pava:
> If you need a default year in your template context, put it there.
> 
> def get_context_data(self, request, *args, **kwargs):
> context = super().get_context_data(request, *args, **kwargs)
> context['default_year'] = 2019
> return context
> 
> In your template, you could use this type of construct:
> {{ year or default_year }}
> 

No, the goal is to have a HTTP GET based form that the user can use to 
customize the view, and I'm looking for an elegant way to handle this with 
Django forms.

The key problem is that default values for form fields are not relevant when 
working with POST requests (where `initial` values are used in GET requests or 
request.POST data in POST request), but *are* relevant for HTTP GET 
(request.GET) based forms. As Django forms are tailored to work with `initial` 
and POST data, I've not yet found a really Django-elegant way to deal with this 
problem.

Best regards,
Carsten

-- 
You received this message because you are subscribed to the Google Groups 
"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/fe1a5f18-7319-7358-00b4-2670e8111b08%40cafu.de.
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/d181d870d6a345fd8cf9b96a5fea607e%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


How is the best way to separate costumers on my django site?

2019-04-04 Thread Fellipe Henrique
Hello,

I need to separate my django website, for different costumers...

Which is the best option:

1) One database and separate each costumer as a django user
2) different database, one for each costumer?

There's no need the costumer has "users"...


Any tips or ideas?

Regards,
T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAF1jwZGRNzWNRFEsi4tjgOU1aft%2BpK16FB8_%2Bra2U1TpRrQHqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How is the best way to separate costumers on my django site?

2019-04-04 Thread Sithembewena L. Dube
Hi

https://www.codementor.io/pauloscardine/15-minute-guide-to-secure-saas-multitenancy-with-django-and-let-s-encrypt-ijtlarca8

https://blog.usejournal.com/building-a-saas-application-with-django-web-framework-part-1-2-the-principe-2f0730a6693f

Kind regards,
Sithembewena


*Sent with Shift
*

On Fri, Apr 5, 2019 at 3:13 AM Fellipe Henrique  wrote:

> Hello,
>
> I need to separate my django website, for different costumers...
>
> Which is the best option:
>
> 1) One database and separate each costumer as a django user
> 2) different database, one for each costumer?
>
> There's no need the costumer has "users"...
>
>
> Any tips or ideas?
>
> Regards,
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAF1jwZGRNzWNRFEsi4tjgOU1aft%2BpK16FB8_%2Bra2U1TpRrQHqQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django validation

2019-04-04 Thread veera nagaraja sankar Inti
Hi All,

I working on Django validation,

i have done some practice,

I observed somethig plase let know if any misunderstadings,

1) When every datatype in models  have default validators or worked, it is 
worked on the form contains *is_valid()* or else  ?..

2)we can add the custom validations using *validators=[nameofthevalidation 
function] which *is only inadditionto the existing validators means 
validate defaultvalidators first and then next custom validations, If we 
use *required=true * use in remove only custom validation only ?..

3) i need to mute all default validation and add only my custom validation 
---Explain in datail  plesase


Thank you all

-- 
You received this message because you are subscribed to the Google Groups 
"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/3e2e519b-4d0f-429c-9ed1-ffe0b7de9055%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django validation

2019-04-04 Thread אורי
I think the default validators are relevant to the type of field you
define. If you define a general field which is not required and without
max_length, I assume there will not be any default validators. You can then
define your own validators, either in the model or in the relevant forms
and views. In the forms I think you can also add your own validators before
the default validators, if you want to keep the default validators but show
your own error messages instead of the error messages of the default
validators.
אורי
u...@speedy.net


On Fri, Apr 5, 2019 at 8:10 AM veera nagaraja sankar Inti <
intisank...@gmail.com> wrote:

> Hi All,
>
> I working on Django validation,
>
> i have done some practice,
>
> I observed somethig plase let know if any misunderstadings,
>
> 1) When every datatype in models  have default validators or worked, it is
> worked on the form contains *is_valid()* or else  ?..
>
> 2)we can add the custom validations using *validators=[nameofthevalidation
> function] which *is only inadditionto the existing validators means
> validate defaultvalidators first and then next custom validations, If we
> use *required=true * use in remove only custom validation only ?..
>
> 3) i need to mute all default validation and add only my custom validation
> ---Explain in datail  plesase
>
>
> Thank you all
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/3e2e519b-4d0f-429c-9ed1-ffe0b7de9055%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/CABD5YeFK0fkVQQ_GSe4-Wjhp%3De0hBR-HOyPd%3DPEtgnAVL%2B9ESQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.