Django - always getting False in form.is_valid()

2019-04-19 Thread Sipum Mishra
Hi All,

I am always getting - form.is_valid returning False. kindly check where I 
am doing wrong.
please find below code. 


views.py
---
def home(request):

if request.method == 'POST':
form = ListForm(request.POST or None)
print(form.is_valid(), "-->",request.POST['Item'])
print(form.errors)
print(form)
if form.is_valid():
form.save()
all_items = List.objects.all
messages.success(request, ('Item has been Added to the List!'))
return render(request,'home.html', {'all_items' : all_items})
else:
print("deba-->",request.POST)
return HttpResponse("Form is invalid!")
else:
all_items = List.objects.all
return render(request,'home.html', {'all_items' : all_items})

-
form.py
-

class ListForm(forms.ModelForm):
class Meta:
model = List
fields = ["item", "completed"]



model.py
-

class List(models.Model):
item = models.CharField(max_length=200)
completed = models.BooleanField(default=False)


def __str__(self):
return self.item + '|' + str(self.completed)

-- 
You received this message because you are subscribed to the Google Groups 
"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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-20 Thread Sipum Mishra
Hi Vineeth,

please find below is the output ->



On Fri, 19 Apr 2019 at 19:04, vineeth sagar 
wrote:

> can you please post, request.POST output?
>
> On Fri, 19 Apr 2019, 16:34 Sipum Mishra,  wrote:
>
>> Hi All,
>>
>> I am always getting - form.is_valid returning False. kindly check where I
>> am doing wrong.
>> please find below code.
>>
>>
>> views.py
>> ---
>> def home(request):
>>
>> if request.method == 'POST':
>> form = ListForm(request.POST or None)
>> print(form.is_valid(), "-->",request.POST['Item'])
>> print(form.errors)
>> print(form)
>> if form.is_valid():
>> form.save()
>> all_items = List.objects.all
>> messages.success(request, ('Item has been Added to the List!'))
>> return render(request,'home.html', {'all_items' : all_items})
>> else:
>> print("deba-->",request.POST)
>> return HttpResponse("Form is invalid!")
>> else:
>> all_items = List.objects.all
>> return render(request,'home.html', {'all_items' : all_items})
>>
>> -
>> form.py
>> -
>>
>> class ListForm(forms.ModelForm):
>> class Meta:
>> model = List
>> fields = ["item", "completed"]
>>
>>
>> 
>> model.py
>> -
>>
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>>
>>
>> def __str__(self):
>> return self.item + '|' + str(self.completed)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%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/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.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/CAGHZBzxon22bfLUUud8tMFxyxQ36bJxZKu2yhvObPMFwbQmVpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-20 Thread Sipum Mishra
Hi Vineeth,

when I am trying to add 'add testing' through html form for todo list app
getting this above form.is_valid() always False.

On Sat, 20 Apr 2019 at 23:02, Sipum Mishra  wrote:

> Hi Vineeth,
>
> please find below is the output ->
>
>  ['8V0Or1mvx2gtOa5fuYsdmAJ1o7SpGOcbSYulW0WMACHbrBhn8tOI0SO1z65MzXGx'],
> 'Item': ['add tesing']}>
>
> On Fri, 19 Apr 2019 at 19:04, vineeth sagar 
> wrote:
>
>> can you please post, request.POST output?
>>
>> On Fri, 19 Apr 2019, 16:34 Sipum Mishra,  wrote:
>>
>>> Hi All,
>>>
>>> I am always getting - form.is_valid returning False. kindly check where
>>> I am doing wrong.
>>> please find below code.
>>>
>>>
>>> views.py
>>> ---
>>> def home(request):
>>>
>>> if request.method == 'POST':
>>> form = ListForm(request.POST or None)
>>> print(form.is_valid(), "-->",request.POST['Item'])
>>> print(form.errors)
>>> print(form)
>>> if form.is_valid():
>>> form.save()
>>> all_items = List.objects.all
>>> messages.success(request, ('Item has been Added to the List!'))
>>> return render(request,'home.html', {'all_items' : all_items})
>>> else:
>>> print("deba-->",request.POST)
>>> return HttpResponse("Form is invalid!")
>>> else:
>>> all_items = List.objects.all
>>> return render(request,'home.html', {'all_items' : all_items})
>>>
>>> -
>>> form.py
>>> -
>>>
>>> class ListForm(forms.ModelForm):
>>> class Meta:
>>> model = List
>>> fields = ["item", "completed"]
>>>
>>>
>>> 
>>> model.py
>>> -
>>>
>>> class List(models.Model):
>>> item = models.CharField(max_length=200)
>>> completed = models.BooleanField(default=False)
>>>
>>>
>>> def __str__(self):
>>> return self.item + '|' + str(self.completed)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%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/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.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/CAGHZBzwVAQOBoksQFVhUgBpC0bJyL4ZeahDHpKfxLpT6Z833TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Storing HTML in DB using DJANGO

2019-04-20 Thread Sipum Mishra
Hi friends,

I want to store a html in database using python and need to retrieve that 
html and convert that in to PDF.
can u plz suggest me how to store that HTML in DB ?

-- 
You received this message because you are subscribed to the Google Groups 
"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/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Sipum Mishra
Hi Jani,
form.errors gives error as -

itemThis field is
required.<
/li>

can u plz tell me where i did wrong?

On Sun, 21 Apr 2019 at 16:43, Jani Tiainen  wrote:

> completed is a required field and you're not passing any value with it. If
> you print form.errors you would should see that it complains about
> "completed" "this field is required"
>
> Note that providing default value in a model is not same as making field
> optional.
>
> On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra  wrote:
>
>> Hi All,
>>
>> I am always getting - form.is_valid returning False. kindly check where I
>> am doing wrong.
>> please find below code.
>>
>>
>> views.py
>> ---
>> def home(request):
>>
>> if request.method == 'POST':
>> form = ListForm(request.POST or None)
>> print(form.is_valid(), "-->",request.POST['Item'])
>> print(form.errors)
>> print(form)
>> if form.is_valid():
>> form.save()
>> all_items = List.objects.all
>> messages.success(request, ('Item has been Added to the List!'))
>> return render(request,'home.html', {'all_items' : all_items})
>> else:
>> print("deba-->",request.POST)
>> return HttpResponse("Form is invalid!")
>> else:
>> all_items = List.objects.all
>> return render(request,'home.html', {'all_items' : all_items})
>>
>> -
>> form.py
>> -
>>
>> class ListForm(forms.ModelForm):
>> class Meta:
>> model = List
>> fields = ["item", "completed"]
>>
>>
>> 
>> model.py
>> -
>>
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>>
>>
>> def __str__(self):
>> return self.item + '|' + str(self.completed)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Jani Tiainen
> Software wizard
>
> https://blog.jani.tiainen.cc/
>
> Always open for short term jobs or contracts to work with Django.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.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/CAGHZBzxTPyWzT_5GJ3zPsvHmWPHQOka5uM2-yHq9tM4g8urQZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Sipum Mishra
Jani, Do you mean I need to change completed field in model like as below ?

completed = models.BooleanField(default=False,required=False)

On Sun, 21 Apr 2019 at 17:23, Sipum Mishra  wrote:

> Hi Jani,
> form.errors gives error as -
>
> itemThis field is
> required.<
> /li>
>
> can u plz tell me where i did wrong?
>
> On Sun, 21 Apr 2019 at 16:43, Jani Tiainen  wrote:
>
>> completed is a required field and you're not passing any value with it.
>> If you print form.errors you would should see that it complains about
>> "completed" "this field is required"
>>
>> Note that providing default value in a model is not same as making field
>> optional.
>>
>> On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra  wrote:
>>
>>> Hi All,
>>>
>>> I am always getting - form.is_valid returning False. kindly check where
>>> I am doing wrong.
>>> please find below code.
>>>
>>>
>>> views.py
>>> ---
>>> def home(request):
>>>
>>> if request.method == 'POST':
>>> form = ListForm(request.POST or None)
>>> print(form.is_valid(), "-->",request.POST['Item'])
>>> print(form.errors)
>>> print(form)
>>> if form.is_valid():
>>> form.save()
>>> all_items = List.objects.all
>>> messages.success(request, ('Item has been Added to the List!'))
>>> return render(request,'home.html', {'all_items' : all_items})
>>> else:
>>> print("deba-->",request.POST)
>>> return HttpResponse("Form is invalid!")
>>> else:
>>> all_items = List.objects.all
>>> return render(request,'home.html', {'all_items' : all_items})
>>>
>>> -
>>> form.py
>>> -
>>>
>>> class ListForm(forms.ModelForm):
>>> class Meta:
>>> model = List
>>> fields = ["item", "completed"]
>>>
>>>
>>> 
>>> model.py
>>> -
>>>
>>> class List(models.Model):
>>> item = models.CharField(max_length=200)
>>> completed = models.BooleanField(default=False)
>>>
>>>
>>> def __str__(self):
>>> return self.item + '|' + str(self.completed)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Jani Tiainen
>> Software wizard
>>
>> https://blog.jani.tiainen.cc/
>>
>> Always open for short term jobs or contracts to work with Django.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.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/CAGHZBzyF%3D5mNty%2BKW4xmg_GvKO_RMQrDxp5O7Pkpg%2BnTZXLOXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Sipum Mishra
if i do changes as above in model then it throws error like -

 class List(models.Model):
  File "F:\django\to_do_list\todo\models.py", line 6, in List
completed = models.BooleanField(required=False)
TypeError: __init__() got an unexpected keyword argument 'required'


On Sun, 21 Apr 2019 at 17:27, Sipum Mishra  wrote:

> Jani, Do you mean I need to change completed field in model like as below ?
>
> completed = models.BooleanField(default=False,required=False)
>
> On Sun, 21 Apr 2019 at 17:23, Sipum Mishra  wrote:
>
>> Hi Jani,
>> form.errors gives error as -
>>
>> itemThis field is
>> required.<
>> /li>
>>
>> can u plz tell me where i did wrong?
>>
>> On Sun, 21 Apr 2019 at 16:43, Jani Tiainen  wrote:
>>
>>> completed is a required field and you're not passing any value with it.
>>> If you print form.errors you would should see that it complains about
>>> "completed" "this field is required"
>>>
>>> Note that providing default value in a model is not same as making field
>>> optional.
>>>
>>> On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra  wrote:
>>>
>>>> Hi All,
>>>>
>>>> I am always getting - form.is_valid returning False. kindly check where
>>>> I am doing wrong.
>>>> please find below code.
>>>>
>>>>
>>>> views.py
>>>> ---
>>>> def home(request):
>>>>
>>>> if request.method == 'POST':
>>>> form = ListForm(request.POST or None)
>>>> print(form.is_valid(), "-->",request.POST['Item'])
>>>> print(form.errors)
>>>> print(form)
>>>> if form.is_valid():
>>>> form.save()
>>>> all_items = List.objects.all
>>>> messages.success(request, ('Item has been Added to the List!'))
>>>> return render(request,'home.html', {'all_items' : all_items})
>>>> else:
>>>> print("deba-->",request.POST)
>>>> return HttpResponse("Form is invalid!")
>>>> else:
>>>> all_items = List.objects.all
>>>> return render(request,'home.html', {'all_items' : all_items})
>>>>
>>>> -
>>>> form.py
>>>> -
>>>>
>>>> class ListForm(forms.ModelForm):
>>>> class Meta:
>>>> model = List
>>>> fields = ["item", "completed"]
>>>>
>>>>
>>>> 
>>>> model.py
>>>> -
>>>>
>>>> class List(models.Model):
>>>> item = models.CharField(max_length=200)
>>>> completed = models.BooleanField(default=False)
>>>>
>>>>
>>>> def __str__(self):
>>>> return self.item + '|' + str(self.completed)
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>> --
>>> Jani Tiainen
>>> Software wizard
>>>
>>> https://blog.jani.tiainen.cc/
>>>
>>> Always open for short term jobs or contracts to work with Django.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To 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/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.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/CAGHZBzx5TL%2BNZ--kbY2XpypCdOf5YP0AikdrFDQQ-rgg1026ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Sipum Mishra
Hi Jani, the above solution is not working, still having the same problem.

and that completed field is used later for cross_off and uncross the item
in list.

On Sun, 21 Apr 2019 at 17:36, Jani Tiainen  wrote:

> Hi,
>
> required attribute works in forms, not in models. For models fields that
> are not required in forms you need to use blank=True.
>
> Though that's not the right solution.
>
> Why are you including "completed" field in a form (which you validate for
> user input) if you are not going to have such a input (checkbox) in a form?
>
>
> On Sun, Apr 21, 2019 at 3:02 PM Sipum Mishra  wrote:
>
>> if i do changes as above in model then it throws error like -
>>
>>  class List(models.Model):
>>   File "F:\django\to_do_list\todo\models.py", line 6, in List
>> completed = models.BooleanField(required=False)
>> TypeError: __init__() got an unexpected keyword argument 'required'
>>
>>
>> On Sun, 21 Apr 2019 at 17:27, Sipum Mishra  wrote:
>>
>>> Jani, Do you mean I need to change completed field in model like as
>>> below ?
>>>
>>> completed = models.BooleanField(default=False,required=False)
>>>
>>> On Sun, 21 Apr 2019 at 17:23, Sipum Mishra  wrote:
>>>
>>>> Hi Jani,
>>>> form.errors gives error as -
>>>>
>>>> itemThis field is
>>>> required.<
>>>> /li>
>>>>
>>>> can u plz tell me where i did wrong?
>>>>
>>>> On Sun, 21 Apr 2019 at 16:43, Jani Tiainen  wrote:
>>>>
>>>>> completed is a required field and you're not passing any value with
>>>>> it. If you print form.errors you would should see that it complains about
>>>>> "completed" "this field is required"
>>>>>
>>>>> Note that providing default value in a model is not same as making
>>>>> field optional.
>>>>>
>>>>> On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra 
>>>>> wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I am always getting - form.is_valid returning False. kindly check
>>>>>> where I am doing wrong.
>>>>>> please find below code.
>>>>>>
>>>>>>
>>>>>> views.py
>>>>>> ---
>>>>>> def home(request):
>>>>>>
>>>>>> if request.method == 'POST':
>>>>>> form = ListForm(request.POST or None)
>>>>>> print(form.is_valid(), "-->",request.POST['Item'])
>>>>>> print(form.errors)
>>>>>> print(form)
>>>>>> if form.is_valid():
>>>>>> form.save()
>>>>>> all_items = List.objects.all
>>>>>> messages.success(request, ('Item has been Added to the List!'))
>>>>>> return render(request,'home.html', {'all_items' : all_items})
>>>>>> else:
>>>>>> print("deba-->",request.POST)
>>>>>> return HttpResponse("Form is invalid!")
>>>>>> else:
>>>>>> all_items = List.objects.all
>>>>>> return render(request,'home.html', {'all_items' : all_items})
>>>>>>
>>>>>> -
>>>>>> form.py
>>>>>> -
>>>>>>
>>>>>> class ListForm(forms.ModelForm):
>>>>>> class Meta:
>>>>>> model = List
>>>>>> fields = ["item", "completed"]
>>>>>>
>>>>>>
>>>>>> 
>>>>>> model.py
>>>>>> -
>>>>>>
>>>>>> class List(models.Model):
>>>>>> item = models.CharField(max_length=200)
>>>>>> completed = models.BooleanField(default=False)
>>>>>>
>>>>>>
>>>>>> def __str__(self):
>>>>>> return self.item + '|' + str(self.completed)
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Django users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> sen

Re: Storing HTML in DB using DJANGO

2019-04-21 Thread Sipum Mishra
thank you all guys for suggesting.

can I plz get any tutorial for these so that I can learn that properly.

On Sun, 21 Apr 2019 at 21:34, Joel Mathew  wrote:

> I fail to see the purpose of that. Serialisation is sufficient. Big
> projects like wordpress store even big blog posts, which is html like this.
> Sincerely yours,
>
>  Joel G Mathew
>
>
>
> On Sun, 21 Apr 2019 at 20:20, Brian M  wrote:
>
>> What if you convert the html to an array of bytes before storing?
>>
>> Then you’d convert from bytes array back to string when you retrieve.
>> This way you’d store raw data.
>>
>>
>> On Apr 21, 2019, at 8:41 AM, Jani Tiainen  wrote:
>>
>> Well after all, HTML is just plain text... Though you probably want to
>> think to do some sanitization so you won't get nasty injections via html.
>>
>> On Sat, Apr 20, 2019 at 9:09 PM Sipum Mishra  wrote:
>>
>>> Hi friends,
>>>
>>> I want to store a html in database using python and need to retrieve
>>> that html and convert that in to PDF.
>>> can u plz suggest me how to store that HTML in DB ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Jani Tiainen
>> Software wizard
>>
>> https://blog.jani.tiainen.cc/
>>
>> Always open for short term jobs or contracts to work with Django.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/CAHn91oe6hUWZtEYCx%3D8uNe%3DFEphZ4C_VRPv74oK2E-x9gvJjGw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91oe6hUWZtEYCx%3D8uNe%3DFEphZ4C_VRPv74oK2E-x9gvJjGw%40mail.gmail.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/47B36FA2-099C-4AAB-B5DA-1D9662513398%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/47B36FA2-099C-4AAB-B5DA-1D9662513398%40gmail.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/CAA%3Diw_-pMCYKd4_7CHbcU7jz7YFZmNw3BXd6Grgwa99x6WGALg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA%3Diw_-pMCYKd4_7CHbcU7jz7YFZmNw3BXd6Grgwa99x6WGALg%40mail.gmail.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/CAGHZBzz-%3Dca7eKzn-WD%3DVwhYG9J-OgAMXsWUm3gO3H52-JWxkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Integrating Google calendar API in TODO list

2019-04-24 Thread Sipum Mishra
Joel, i know there is python code for yhat API but how to integrate it.. I
want to know that.. I tried to do but failed.

On Wed, 24 Apr, 2019, 6:55 PM Joel Mathew,  wrote:

> Just do it. The API has python sample code.
> Sincerely yours,
>
>  Joel G Mathew
>
>
>
> On Tue, 23 Apr 2019 at 09:58, Sipum  wrote:
>
>> Hello friends.
>>
>> I am going to integrate google calendar API in to my TODO List.
>> can anyone suggest how to integrate so that when I will add any event in
>> my TODO List app it will directly show in my google calendar.
>>
>> 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/ebbfbf68-4445-4146-9e49-c18041796343%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/CAA%3Diw_9UTM0izFDbwcGMDxGPZaUHSy9r9L90cEkYA0Vc0JDAmQ%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/CAGHZBzxv28c%3Db8MQEnXiGVY9pM6rj-u%3DwEr1VOVYMNYcZSbCVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django issue with NoModuleError

2019-05-13 Thread Sipum Mishra
Hi RLM,

Did you import samples in root urls.py
Like as below

>From samples import urls

Hope it will solve ur error.
Thanks.

On Mon, 13 May, 2019, 7:45 PM John Bagiliko, 
wrote:

> Try this in samples/urls.py
>
> from django.urls import path
> from . import views
>
> urlpatterns = [
>  path(''",views.index, name='index'),
> ]
>
> By the way, what is the error you are getting?
> On Mon, May 13, 2019, 7:14 AM RLM  wrote:
>
>> Hi Everyone.
>> I have been away from Django for the past 18 months and am refreshing to
>> use it for a complex samples storage project.
>>
>> Python 3.7, Django 2.2 the LTS fails with too many errors.
>>
>> Unfortunately I have had this particular error every time I try Django
>> over the past 18 months which is why I had to resort to HuGo for a
>> particular web site build.
>>
>> I feel there is something I have forgotten to do and will appreciate
>> help understanding why it occurs.
>>
>> I have researched but no advice helps.
>> I have seen pages on PYTHONPATH and the like but problem is not solved
>> and it seems to have been an issue for at least a year.
>>
>> The project is called Storage, it's app is called samples.
>>
>> The problem I have is the ModuleNotFoundError: No module named 'samples'.
>>
>> Where samples is the only app.
>>
>> INSTALLED_APPS = [
>>  'django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'samples',
>>
>> root urls/py is:
>> urlpatterns = [
>>  path('admin/', admin.site.urls),
>>  path('samples/', include('samples.urls')),
>> ]
>>
>> samples/urls.py is:
>> from django.urls import path
>> from . import views
>>
>> urlpatterns = [
>>  path('',views.index, name='index'),
>> ]
>>
>> There are no models.
>>
>> samples/views.py is:
>> from django.shortcuts import render
>> from django.http import HttpResponse
>>
>> def index(request):
>>  return HttpResponse("Hello from the RMH App")
>>
>> Thanks for any help
>> Cheers
>> Roger
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/dee6f7a2-23e9-eaa7-052e-fb714dd7f3b4%40gmail.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/CAC26BE02jK937V6XhQXv4MtEGyeo%2BV%2BWpDgB4S%3D%2BHWmv9RxFFA%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/CAGHZBzxdnEyosELPnY9wn%2BFQiUFpLwtMQFWybkRXVkm8fo94Qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting MultiValueDictKeyError

2019-05-16 Thread Sipum Mishra
Hi friends, still getting same error after using encrypt..

Bt if i am using request. POST. get('document') then error vanishes but
another error comes as job_title is an invalid keyword argument for this
function.

Kindly help on this issue. I m trying hard but unable to solve.

Thanks

On Thu, 16 May, 2019, 6:42 PM Test Bot,  wrote:

> Try putting encrypt="multipart/form-data" in your form tag
>
> On Thu, May 16, 2019, 6:05 PM Sipum  wrote:
>
>> Hi Friends,
>>
>> when retrieving file that is uploaded , I'm getting
>> multiValueDictKeyError.
>> Below are my codes. I have proided some codes where I m getting error.
>> could anyone help me here ?
>>
>> views.py
>> -
>>
>> def webform_submit(request):
>> if request.method =='POST':
>> name = request.POST['name']
>> email = request.POST['email']
>> phone = request.POST['phone']
>> job_title = request.POST['job_title']
>> resume = request.FILES['document']   -- getting
>> error here
>>
>> user_info = UserField(name = name, email = email, phone = phone,
>>   job_title = job_title, resume = resume)
>> user_info.save()
>> messages.success(request,"Congrats!! Form is successfully saved
>> in DB")
>> return render(request, 'html/form.html', {})
>>
>>
>> form.html
>> --
>>   
>> Job title
>> 
>>
>> 
>> Resume
>> > id="exampleFormControlFile1">
>>   
>> 
>> 
>>
>> 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/37a3ca49-6410-420f-a6a6-23bcf8e3f983%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/CAD%3DM5eQp8%3DBZVmDe7RFjdf0LOvoZcdGMqGgt0xSdEw_Nj%2BJaig%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/CAGHZBzyWYUF8JsBuAU3PeHp%2BnWGqadp%3DJz_vW7yHzYZUm-yXqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customising django user model

2019-05-20 Thread Sipum Mishra
Ok thanks for reply.

On Mon, 20 May, 2019, 5:36 PM Rafael E. Ferrero, 
wrote:

> Hello, you must to extend User model... search on google with this
> aproach!!
>
> Cheers!
>
> Rafael E. Ferrero
>
>
> El dom., 19 may. 2019 a las 14:13, Sipum () escribió:
>
>> Hello Friends,
>>
>> I want to customise django default user table and which should consist of
>> name,phone, email and gender.
>> And after that when every time a user logs in, he/she should able to log
>> in through an OTP to phone or email.
>>
>> can anyone guide me  What to do here.??
>>
>> Thanks.
>> Sipum
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/9b92fdc5-8f36-45e7-809e-b32d4ab41687%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/CAJJc_8XYD7zGAOmaezmS_sGoDr5R0gz1Y44y6ED-sn-dxzj02A%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/CAGHZBzyygP31OdejPiNn7V_KtYprD5kfswBeJMbD1y2zesmuOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customising django user model

2019-05-20 Thread Sipum Mishra
Thanks a lot.. @Joe @Mahes
It will help me a lot.

On Tue, 21 May, 2019, 8:14 AM mahesh boini, 
wrote:

> Extend AbstractUser class and give that name in settings file like
> AUTH_USER_MODEL=‘appname.modelname’
>
> On Tue, 21 May 2019 at 05:51, Joe Reitman  wrote:
>
>> You can customize the user table by extending AbstractUser and add the
>> fields you want to add (gender, phone)
>>
>> I have a custom user example adding age field:
>>
>> from django.db import models
>> from django.contrib.auth.models import AbstractUser
>>
>> class CustomUser(AbstractUser):
>>age = models.PositiveIntegerField(null=True, blank=True)
>>
>>
>> On Sunday, May 19, 2019 at 12:13:08 PM UTC-5, Sipum wrote:
>>>
>>> Hello Friends,
>>>
>>> I want to customise django default user table and which should consist
>>> of name,phone, email and gender.
>>> And after that when every time a user logs in, he/she should able to log
>>> in through an OTP to phone or email.
>>>
>>> can anyone guide me  What to do here.??
>>>
>>> Thanks.
>>> Sipum
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/24afe883-98b9-4bfc-a9fe-284c7a6cb771%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/CANR2ZjviAk_hCz%2BVum2kUa7vo6SJP8ZCuOsg0cH9uLncL_mDBQ%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/CAGHZBzzNHg4-Xkn5aGVRpttxBZooKy1DSS_SGNU5gbUdW7FCYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re:

2019-06-04 Thread Sipum Mishra
Hi Pradeep,

You are using a non nullable field image. And for that you have to provide
a default value. Without default value it is  unable find.


On Tue, 4 Jun, 2019, 9:12 PM Pradeep Singh,  wrote:

> why i am getting these error ..please help me to fix it
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANwgZcYJBTbKeAwOh4gqc4nYu_J8DT%3DjF5CYgLRA2vW8Nu_16Q%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/CAGHZBzyJzob25OHaL-fuGZ4U98QboUU7vX7jfKMfHKFS7PPqCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name error

2019-06-05 Thread Sipum Mishra
Plz show your code otherwise search your total error line in Google you can
find it.
Always try to paste error codes so that it will b easy to find out error.

Thanks.

On Wed, 5 Jun, 2019, 3:12 PM RAJA MISHRA, 
wrote:

> Name error : name 'django' is not defined in one of my app
> Plzz anyone explain how to fix this
>  also how to use django.setup()
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/4bbd7afe-ddd8-4c25-a620-7e6da5ddd5c5%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/CAGHZBzzo8Ks05zFq7eVHjGFQV1aF5E5D%2B7zMe1cH%3D2PAUwN6Vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django question.

2019-06-09 Thread Sipum Mishra
Hi Bhaskar,

You  can write your helper functions inside utils.py and can use it
wherever you want. And basically utils.py contains utility functions or
helper functions.

Thanks.

On Sun, 9 Jun, 2019, 2:29 AM Bhashkar Bisht, 
wrote:

> HI there is there any best way to create django helper class
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/e0df3308-455f-4f4b-8870-9e7da90677cc%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/CAGHZBzzQnUx5Ex1C9Ok2etOY1Sv5OT1K-PfdfWiPqeu%3Dfo0R9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django App - Database connection

2019-06-14 Thread Sipum Mishra
Hi sapna,

Check your settings.py file and search for DATABASE there you can get a
link which is commented. Copy n paste that url and that will take you to
documentation page where you can get what needs to be imported in DATABASE.

On Fri, 14 Jun, 2019, 4:45 PM Sapna Dhage,  wrote:

>
> Hello,
>
> I'm implementing Django application using PostgreSQL. However, I'm not
> able to configure database connection string.
>
> Any idea how do I configure database connection and where should I mention
> database connection string?
>
> Thank you,
> Sapna
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/35a7d002-cf8a-4924-8b8b-9df35419b1f2%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/CAGHZBzyK69aoq02n6dLvYpvJLc5aTxH_RZOOCma3kgqY-ZCLBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany no Model

2019-06-19 Thread Sipum Mishra
Ggt yano jika teme sulo faso tadan siku.
Lhggg

On Wed, 19 Jun, 2019, 5:55 PM Christian Oliveira, <
christianoliveir...@gmail.com> wrote:

> Bom dia, como posso fazer para acessar os dados de uma tabela derivada de
> um ManyToMany??
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/8ebadc27-79d9-46f8-89c0-19b9a875b9b5%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/CAGHZBzzf%2BSR%3DSdyBzhwOp2DfawUJNfmAMiyFETh2CwmwDLN%3Dxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wrong Redirect

2019-06-20 Thread Sipum Mishra
Hi Ramadhan,

Instead of rendering to any page please use HttpResponseRedirect('put home
page url where u want to redirect' ).

And also import django.http import HttpResponseRedirect

Do the above & let me know. I hope it will work.

On Thu, 20 Jun, 2019, 2:41 PM ramadhan ngallen,  wrote:

> Hello Team
> I created an app(called users) for user registration
> If user enter two mismatched password an app should redirect to the same
> page. otherwise it should redirect to the homepage
> Unfortunately when user enter two mismatched password it redirect to the
> wrong url http://127.0.0.1:8000/users/register/register
> and also if user enter matched password it also redirect to the wrong url
> http://127.0.0.1:8000/users/register/register
>
>  its view.py
> from django.shortcuts import render, redirect
> from django.contrib.auth.models import User, auth
>
>
> # Create your views here.
>
>
> def register(request):
>
> if request.method == 'POST':
> first_name = request.POST['first_name']
> first_name = first_name.title
> last_name = request.POST['last_name']
> last_name = last_name.title
> username = request.POST['username']
> password1 = request.POST['password1']
> password2 = request.POST['password2']
> email = request.POST['email']
> if password1 == password2:
> user = User.objects.create_user(
> username=username, first_name=first_name, last_name=last_name, email=email,
> password=password1)
>
> user.save()
> print('user created')
> return redirect('/travello/')
>
> else:
> return render(request, 'users/register.html')
>
> else:
> return render(request, 'users/register.html')
> I have also created its urls.py as follows
> from . import views
> from django.urls import path
>
>
> app_name = 'users'
>
> *urlpatterns = [*
> * path('register/', views.register, name='register'),*
> ]
>
> Settings.py
> INSTALLED_APPS = [
> * 'users.apps.UsersConfig',*
> 'travello.apps.TravelloConfig',
> 'calc.apps.CalcConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> user app directory
>
> [image: image.png]
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAAhXuBF07Q72_mi1AfPJ5LHHmaEdd5PhvQ79ToqSvpEt0gCivg%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/CAGHZBzx-XO4S58msQB%3DJmV9UAgDJmfk7dDOco2JZr4uXQer%3DYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: action in a form

2019-06-23 Thread Sipum Mishra
Hello,

In action use the url associated with that view then it will work for you.
If not then kindly tell what errors you are getting.

Thanks.

On Sun, 23 Jun, 2019, 10:17 PM Sebastian Jung, 
wrote:

> Hello,
>
> You must Put in Action not a Name from a function. You must Put a url dir
> example action="/newurl/"
>
> And in your url a Link from /newurl/ to the function
>
> Regards
>
> bengoshi  schrieb am So., 23. Juni 2019,
> 17:57:
>
>> Hi,
>> I tried to write a form:
>>
>> ###
>>
>> {% extends 'base.html' %}
>> {% block content %}
>> Test
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>> {% endblock %}
>> ###
>>
>> and it works. But if I replace it with
>>
>> >
>> "journal" is a view for shown the saved data which work, too. If I click to 
>> "Save" it change to "journal" but won't save the data anymoren.
>>
>> Could anybody explain me please this behavior?
>>
>> Thanks and Greetings
>>
>> bengoshi
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/e153dd08-3678-4620-8f1d-dae1fa1b978f%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/CAKGT9mxSq-ZKdQc_zUdHZmqZ5g%2Bfr8YVn0Upm%3DWru9SD6%3DwWkg%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/CAGHZBzxz9rVTpGVokwOYM_oirKKM3AbM7bEkebnVuRAqZNoEvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: action in a form

2019-06-23 Thread Sipum Mishra
Hi bengoshi,

If i m not wrong, your concern is when you add action ='journal' then data
are not saved.
Right?

Thanks.


On Mon, 24 Jun, 2019, 2:07 AM bengoshi,  wrote:

> Thanks for your responses. I didn't describe it well.. if I write
>
> 
> it calls the url journal and this is the my requested result. All fine.
> Without the attribute "action" the form save the input in the database - the 
> requested result, great.
> With "action" it doesn't. That is the point which I don't understand becauce 
> in my understanding
> action should not have any effect for saving data.
>
> Greetings
> bengoshi
>
>
> Am Sonntag, 23. Juni 2019 19:31:05 UTC+2 schrieb Sipum:
>>
>> Hello,
>>
>> In action use the url associated with that view then it will work for
>> you.
>> If not then kindly tell what errors you are getting.
>>
>> Thanks.
>>
>> On Sun, 23 Jun, 2019, 10:17 PM Sebastian Jung, 
>> wrote:
>>
>>> Hello,
>>>
>>> You must Put in Action not a Name from a function. You must Put a url
>>> dir example action="/newurl/"
>>>
>>> And in your url a Link from /newurl/ to the function
>>>
>>> Regards
>>>
>>> bengoshi  schrieb am So., 23. Juni 2019, 17:57:
>>>
 Hi,
 I tried to write a form:

 ###

 {% extends 'base.html' %}
 {% block content %}
 Test
 
 {% csrf_token %}
 {{ form.as_p }}
 
 
 {% endblock %}
 ###

 and it works. But if I replace it with

 >>>
 "journal" is a view for shown the saved data which work, too. If I click 
 to "Save" it change to "journal" but won't save the data anymoren.

 Could anybody explain me please this behavior?

 Thanks and Greetings

 bengoshi


 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django...@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/e153dd08-3678-4620-8f1d-dae1fa1b978f%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/CAKGT9mxSq-ZKdQc_zUdHZmqZ5g%2Bfr8YVn0Upm%3DWru9SD6%3DwWkg%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/3ffc7b93-4536-4c29-9998-1d4b10e380dc%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/CAGHZBzx6CbvXyqD3Z5HnEh3f3FYd5AmyEJDVNEunzyp4X3dfuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: invalid literal for int() with base 10: 'admin'

2019-06-25 Thread Sipum Mishra
Can u plz attach your urls.py as functions associated in views.py

Thanks.

On Mon, 24 Jun, 2019, 8:08 PM Harshit Agarwal, 
wrote:

>  Hi guys,
> I am currently working on a working on a project. Everything is working
> fine but i am not able to access my admin. How can i solve this?
> Here is my Stack Trace
> Traceback:
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\exception.py"
> in inner
>   34. response = get_response(request)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\base.py"
> in _get_response
>   126. response = self.process_exception_by_middleware(e,
> request)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\base.py"
> in _get_response
>   124. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\base.py"
> in view
>   68. return self.dispatch(request, *args, **kwargs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\base.py"
> in dispatch
>   88. return handler(request, *args, **kwargs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\detail.py"
> in get
>   106. self.object = self.get_object()
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\detail.py"
> in get_object
>   36. queryset = queryset.filter(pk=pk)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\query.py" in
> filter
>   844. return self._filter_or_exclude(False, *args, **kwargs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\query.py" in
> _filter_or_exclude
>   862. clone.query.add_q(Q(*args, **kwargs))
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
> in add_q
>   1263. clause, _ = self._add_q(q_object, self.used_aliases)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
> in _add_q
>   1287. split_subq=split_subq,
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
> in build_filter
>   1225. condition = self.build_lookup(lookups, col, value)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
> in build_lookup
>   1096. lookup = lookup_class(lhs, rhs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\lookups.py" in
> __init__
>   20. self.rhs = self.get_prep_lookup()
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\lookups.py" in
> get_prep_lookup
>   70. return self.lhs.output_field.get_prep_value(self.rhs)
>
> File
> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\fields\__init__.py"
> in get_prep_value
>   965. return int(value)
>
> Exception Type: ValueError at /admin/
> Exception Value: invalid literal for int() with base 10: 'admin'
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAE%2BC-X-o7sW8m2-DMx4R5CnGrYbYS%2B%2Bx_cYi-BL%3DHwK_b%2BdrHg%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/CAGHZBzy1X-KiMXtLPmQ3V5nC2HBLC%2BpD_Wd8vAjV3nAnGGsFAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: invalid literal for int() with base 10: 'admin'

2019-06-25 Thread Sipum Mishra
Plz share views.py as well.. I hvae mentioned two. Kindly share.

On Tue, 25 Jun, 2019, 8:47 PM Harshit,  wrote:

> Here is urls.py of my app
>
> from django.urls import path
> from . import views
> from django.conf import settings
> from django.conf.urls.static import static
>
> app_name="music"
>
> urlpatterns=[
> #/music/
> path('',views.IndexView.as_view(),name='index'),
>
> path('register/',views.UserFormView.as_view(),name='register'),
>
> path('/',views.DetailView.as_view(),name='detail'),
>
> path('album/add/',views.AlbumCreate.as_view(),name='album-add'),
> ]
> urlpatterns += static(settings.MEDIA_URL, document_root
> =settings.MEDIA_ROOT)
>
> Here is my main urls.py
> from django.contrib import admin
> from django.urls import path,include
> from . import settings
> from django.contrib.staticfiles.urls import static
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>
> urlpatterns = [
> path('',include('music.urls')),
> path('music/',include('music.urls')),
> path('admin/', admin.site.urls),
> ]
> urlpatterns += staticfiles_urlpatterns()
> urlpatterns += static(settings.MEDIA_URL, document_root
> =settings.MEDIA_ROOT)
>
> On Tuesday, June 25, 2019 at 4:14:05 PM UTC+5:30, Sipum wrote:
>>
>> Can u plz attach your urls.py as functions associated in views.py
>>
>> Thanks.
>>
>> On Mon, 24 Jun, 2019, 8:08 PM Harshit Agarwal, 
>> wrote:
>>
>>>  Hi guys,
>>> I am currently working on a working on a project. Everything is working
>>> fine but i am not able to access my admin. How can i solve this?
>>> Here is my Stack Trace
>>> Traceback:
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\exception.py"
>>> in inner
>>>   34. response = get_response(request)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\base.py"
>>> in _get_response
>>>   126. response =
>>> self.process_exception_by_middleware(e, request)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\core\handlers\base.py"
>>> in _get_response
>>>   124. response = wrapped_callback(request,
>>> *callback_args, **callback_kwargs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\base.py"
>>> in view
>>>   68. return self.dispatch(request, *args, **kwargs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\base.py"
>>> in dispatch
>>>   88. return handler(request, *args, **kwargs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\detail.py"
>>> in get
>>>   106. self.object = self.get_object()
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\views\generic\detail.py"
>>> in get_object
>>>   36. queryset = queryset.filter(pk=pk)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\query.py" in
>>> filter
>>>   844. return self._filter_or_exclude(False, *args, **kwargs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\query.py" in
>>> _filter_or_exclude
>>>   862. clone.query.add_q(Q(*args, **kwargs))
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
>>> in add_q
>>>   1263. clause, _ = self._add_q(q_object, self.used_aliases)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
>>> in _add_q
>>>   1287. split_subq=split_subq,
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
>>> in build_filter
>>>   1225. condition = self.build_lookup(lookups, col, value)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\sql\query.py"
>>> in build_lookup
>>>   1096. lookup = lookup_class(lhs, rhs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\lookups.py" in
>>> __init__
>>>   20. self.rhs = self.get_prep_lookup()
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\lookups.py" in
>>> get_prep_lookup
>>>   70. return self.lhs.output_field.get_prep_value(self.rhs)
>>>
>>> File
>>> "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\fields\__init__.py"
>>> in get_prep_value
>>>   965. return int(value)
>>>
>>> Exception Type: ValueError at /admin/
>>> Exception Value: invalid literal for int() with base 10: 'admin'
>>>
>>> --
>>> You received this message because you are 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/CAE%2BC-X-o7sW8m2-DMx4R5CnGrYbYS%2B%2Bx_cYi-BL

Re: invalid literal for int() with base 10: 'admin'

2019-06-26 Thread Sipum Mishra
Your problem is, in url you are passing id to detailview, but in views.py
you have done anything with that...

Check this again.

On Wed, 26 Jun, 2019, 4:01 AM onyilimba martins mclaren tochukwu, <
tochimcla...@gmail.com> wrote:

> I guess it's Django 2.2?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/bb10db99-0411-468b-aace-e40509c34b51%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/CAGHZBzzi7Lt9u299aGQOhd0e6rYsFeWyDgX%3DM1yB%2BpgWP_v_iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get Value of Drop Down

2019-06-26 Thread Sipum Mishra
Hello csn u plz share ur codes as well as errors.

On Thu, 27 Jun, 2019, 12:09 AM Aayush Bhattarai, <
bhattaraiaayus...@gmail.com> wrote:

> Hi,
> I have encountered a problem. How can I get the value of dropdown,
> Boolean Field and send it to the database. Note: I am not using forms.py
> files and using a function-based view. I have created own form in HTML.
> I am not able to match the value of database and value in html dropdown.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/dcde52cb-b6c6-4271-8d0a-8931fcbbf547%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/CAGHZBzzozhAP-_XUVOp9hW%3DSbTbgrtNR_mS-em0%3D96ksomQboQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: trying to use a variable inside a static content tag

2019-07-27 Thread Sipum Mishra
Hi Lyman,

PFB.

Configure the following setting in your setting.py

STATIC_ROOT = os.path.join(BASE_DIR,"static_files")
STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),)

load *staticfiles* tag to template

{% load staticfiles %}

and then use in *src* attribute of *img HTML tag as you did. *


On Sun, 28 Jul, 2019, 4:37 AM Sithembewena L. Dube, 
wrote:

> Interesting.
>
> Kind regards,
> Lloyd
>
>
> *Sent with Shift
> *
>
> On Sat, Jul 27, 2019 at 11:25 PM Lyman Hurd  wrote:
>
>> A helpful user in the Python #django slack channel showed me this answer:
>>
>>
>> https://stackoverflow.com/questions/16655851/django-1-5-how-to-use-variables-inside-static-tag
>>
>>
>> On Saturday, July 20, 2019 at 4:31:52 AM UTC-7, Lyman Hurd wrote:
>>>
>>> Greetings.  I am writing a card game and I can load an image when I give
>>> a fixed value such as:
>>>
>>> >> style="width:69px;height:106px;">
>>>
>>> but I would actually like part o fthis to be determined by a tag (there
>>> is a for loop setting values) but when I write:
>>>
>>> >> style="width:69px;height:106px;">
>>>
>>> however when this is rendered into HTML the tag {{ card }} ha sbeen
>>> URL-escaped:
>>>
>>> 
>>>
>>> How can I render a static image based on the contents of a tag?
>>>
>>>
>>> Cheers,
>>>
>>> Lyman Hurd
>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/6706118e-f64a-4c6d-8bc6-c558d48640f5%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/CAH-SnCCtH6%3DP6rzezAk1ErTaFnhYyVmBNj82wGN4osw%3DPeEdFA%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/CAGHZBzwSf04Cao6xzYumTZWOoDqqEUF7J4moHGHx3tkU0SQVSQ%40mail.gmail.com.


Re: dlango MultiValueDictKeyError

2019-08-05 Thread Sipum Mishra
Hey Ajit,

This error comes when You are trying to get username, passwords from the
form.
It is due to the below reason -

In Login,
You are using -> request.POST['username'] which will raise a KeyError
exception if 'username' is not in request.POST.

Instead use -> request.POST.get('username') which will return None if '
username' is not in request.POST.

Additionally, .get allows you to provide an additional parameter of a
default value which is returned if the key is not in the dictionary.

For example, request.POST.get('username', 'mydefaultvalue')

Hope this helps. If any concern then let us know.

On Mon, 5 Aug 2019 at 15:47, Ajeet Kumar Gupt 
wrote:

> Dear Team,
>
> I am developing custom registration and login page for end-user but
> getting the below error. Please find the views.py code also in the trail.
>
>
> *MultiValueDictKeyError at /login/*
>
> 'username'
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/login/
> Django Version: 2.2.3
> Exception Type: MultiValueDictKeyError
> Exception Value:
>
> 'username'
>
> Exception Location: 
> C:\Python\Python37\lib\site-packages\django\utils\datastructures.py
> in __getitem__, line 80
> Python Executable: C:\Python\Python37\python.exe
> Python Version: 3.7.3
>
> --
> *Views.py*
> **
>
> rom django.shortcuts import render
> from django.contrib.auth.models import User
> from django.http import HttpResponseRedirect
> from .forms import RegisterForm
> from django.conf import settings
> from django.shortcuts import redirect
> from django.contrib.auth.decorators import login_required
> from django.contrib import messages
> from django.contrib.auth import authenticate,login
> from django.contrib import auth
> from django.core.exceptions import ObjectDoesNotExist
>
>
> def user_register(request):
> # if this is a POST request we need to process the form data
> template = 'mymodule/register.html'
># template = 'index.html'
> if request.method == 'POST':
> # create a form instance and populate it with data from the request:
> form = RegisterForm(request.POST)
> # check whether it's valid:
> if form.is_valid():
> if 
> User.objects.filter(username=form.cleaned_data['username']).exists():
> return render(request, template, {
> 'form': form,
> 'error_message': 'Username already exists.'
> })
> elif 
> User.objects.filter(email=form.cleaned_data['email']).exists():
> return render(request, template, {
> 'form': form,
> 'error_message': 'Email already exists.'
> })
> elif form.cleaned_data['password'] != 
> form.cleaned_data['password_repeat']:
> return render(request, template, {
> 'form': form,
> 'error_message': 'Passwords do not match.'
> })
> else:
> # Create the user:
> user = User.objects.create_user(
> form.cleaned_data['username'],
> form.cleaned_data['email'],
> form.cleaned_data['password']
> )
> user.first_name = form.cleaned_data['first_name']
> user.last_name = form.cleaned_data['last_name']
> user.phone_number = form.cleaned_data['phone_number']
> user.save()
> return redirect('index.html')
> # Login the user
> #login(request, user)
> #def user_login(request):
> # redirect to accounts page:
> #return render(request, '/login.html')
># return HttpResponseRedirect(return, '/login.html')
># No post data availabe, let's just show the page.
> else:
> form = RegisterForm()
> return render(request, template, {'form': form})
>
>
>
>
>
> def login_view(request):
> username = request.POST['username']
> password = request.POST['pass']
> users = authenticate(request, username=username, password=password)
> if users is not None:
> login(request, users)
> return redirect('welcome.html')
> else:
> return redirect('index.html')
>
>
>
> def logout(request):
> auth.logout(request)
> return render(request, 'login.html')
>
>
>
>
> *Thanks & Regards*
> Ajeet Kumar Gupt
> +91-9311232332
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CA%2BTqRsvD7P8Mk4RCUUg-5%3DYTE7PjBnHyJA%3DVZowGgGoYQnyNKw%40mail.gmail.com
>