RE: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

2021-04-22 Thread Chaitanya Sakoji
Thanks Kasper for your reply.

-Original Message-
From: django-users@googlegroups.com  On Behalf 
Of Kasper Laudrup
Sent: 23 April 2021 01:17
To: django-users@googlegroups.com
Subject: [EXTERNAL]Re: #Beginnerlevel Form sending get instead of post request

On 22/04/2021 17.14, chaitanya sakoji wrote:
> Previously this code was sending post request. Suddenly after 
> restarting server, it started sending get.

I *think* I might understand what you mean.

The code you posted doesn't send anything. It handles POST request sent from 
your browser. If you load a page with your browser normally, it will send a GET 
request.

My guess is, that you've sent a POST request to the page (which works
fine) and then you load the same page in your browser sending a GET request.

Could that explain it.

Just to be clear. Your code will not start changing behavior without you doing 
anything (self modifying code is indeed a thing, but that's not relevant here 
at all).

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/x6_U7_hCeOY/unsubscribe.
To unsubscribe from this group and all its topics, 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/4c96bea3-db71-ca42-7158-9e1f3a9bc6ea%40stacktrace.dk.

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


Re: Using Python Libraries in Django

2021-04-22 Thread Gerardo Palazuelos Guerrero
Have a look at the following video. It might help with your first question.
https://youtu.be/04L0BbAcCpQ

Regards,

--
Gerardo Palazuelos Guerrero



On Thu, Apr 22, 2021 at 2:45 PM felipe herrera  wrote:

> Awesome! Thank you .
>
> Andrés
>
> El jue, 22 de abr. de 2021 a la(s) 14:52, Kasper Laudrup (
> laud...@stacktrace.dk) escribió:
>
>> On 22/04/2021 18.48, felipe herrera wrote:
>> > 1) Can we use any python libraries in Django ( such as PDFplumber,
>> > pandas, etc) ?
>>
>> Yes.
>>
>> Of course something like a Python library for rendering 3D graphics with
>> OpenGL wouldn't make much sense to use for a web framework, but you can
>> use any Python code with Django.
>>
>> > 2) Would I put my python script in views.py?  (Something like this)
>> >
>>
>> That would probably be just fine most of the time and in this case it
>> looks like the simplest thing to do.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/dd418eeb-2799-c8bd-8916-8a83754bfeb5%40stacktrace.dk
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHg1JKz_ex0LHN2uFMU9Wing46eyRBrEAcWHw4B5cOTaJZMNgA%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/CAJ8iCyM4i3PdCM2d22ou5Ue7roC5dktDDEPBgWtqk3mMwjr8Wg%40mail.gmail.com.


Re: Assistance with Django Booking app

2021-04-22 Thread David Nugent
On Wed, Apr 21, 2021 at 8:46 PM Eric 247ERICPOINTCOM 
wrote:

> Hi Ryan,
>
> Am trying to use booking on a marketing system that is developing for
> different kinds of businesses like property where someone would be able to
> book an appointment for a viewing or a service like a Mobile car wash where
> someone would be able to book a car washer for a specific time. But on the
> same system so it would be dynamic depending on the service someone would
> like to book for or a product someone would like to schedule to buy like
> shoes or anything.
>
> I followed the steps as indicated in the README file and installed
> Django-booking successfully, but there are a couple of errors I get with
> this app when I run the server with: python manage.py runserver.
>
> This is what I get.
>
> (envirn) C:\Users\Eric\Desktop\Shop>python manage.py runserver
>  ...
>   File
> "C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django_libs\models_mixins.py",
> line 5, in 
> from django.utils.encoding import python_2_unicode_compatible
> ImportError: cannot import name 'python_2_unicode_compatible' from
> 'django.utils.encoding'
> (C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\encodi
> ng.py)
>


This is a pretty classic error caused by a mismatch between Django version
and the app you are trying to run.

Check the docs to ensure you're running a supported version of Django - the
python_2_unicode_compatible decorator has not been around since Python 2
support was dropped.

If the app has no other python 2 dependencies you may be able to get away
with simply removing the decorator from models that use it (and the import
statement for it as well) as it is no longer necessary.

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAE5VhgWHAUqD%2B6Mke7%2B6wRTuHV6YvAFdAUw3QtynepAWaw5Ygw%40mail.gmail.com.


Re: Testing Django User Login Form

2021-04-22 Thread David Nugent
Try creating a request using RequestFactory and use that to input the
credentials. I don't think the way you are creating the form is valid.

rf = RequestFactory()
request = rf.post('/some_mock_url', dict(username='abc',
password='password'))
form = AuthenticationForm(request)

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAE5VhgWBM7dqPBzMc4P8eGCOuksM54kcnPnVA83ciE93C6bqWw%40mail.gmail.com.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-04-22 Thread David Nugent
On Mon, Apr 19, 2021 at 2:07 AM Avi Mehenwal  wrote:

> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and
> Django 3.2 and have exactly the same problems as mentioned above.
>
> path('', views.index, name='index'),
> AttributeError: module 'polls.views' has no attribute 'index'
>
> any help on how can I debug this? I am a django noob
>

We all started out that way.

>From the error message, assuming views it is defined as:

from . import views

or, maybe

from polls import views

it means that python cannot find the function index() in the views module.

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAE5VhgUckZZtR%2BVBmW6ungOQ8uBowyE%2BSLG%3DVg%3DuqZVZmw275w%40mail.gmail.com.


Re: Using Python Libraries in Django

2021-04-22 Thread felipe herrera
Awesome! Thank you .

Andrés

El jue, 22 de abr. de 2021 a la(s) 14:52, Kasper Laudrup (
laud...@stacktrace.dk) escribió:

> On 22/04/2021 18.48, felipe herrera wrote:
> > 1) Can we use any python libraries in Django ( such as PDFplumber,
> > pandas, etc) ?
>
> Yes.
>
> Of course something like a Python library for rendering 3D graphics with
> OpenGL wouldn't make much sense to use for a web framework, but you can
> use any Python code with Django.
>
> > 2) Would I put my python script in views.py?  (Something like this)
> >
>
> That would probably be just fine most of the time and in this case it
> looks like the simplest thing to do.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dd418eeb-2799-c8bd-8916-8a83754bfeb5%40stacktrace.dk
> .
>

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


Re: Using Python Libraries in Django

2021-04-22 Thread Kasper Laudrup
On 22/04/2021 18.48, felipe herrera wrote:
> 1) Can we use any python libraries in Django ( such as PDFplumber,
> pandas, etc) ?

Yes.

Of course something like a Python library for rendering 3D graphics with
OpenGL wouldn't make much sense to use for a web framework, but you can
use any Python code with Django.

> 2) Would I put my python script in views.py?  (Something like this) 
> 

That would probably be just fine most of the time and in this case it
looks like the simplest thing to do.

Kind regards,

Kasper Laudrup

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


OpenPGP_signature
Description: OpenPGP digital signature


Re: #Beginnerlevel Form sending get instead of post request

2021-04-22 Thread Kasper Laudrup
On 22/04/2021 17.14, chaitanya sakoji wrote:
> Previously this code was sending post request. Suddenly after restarting
> server, it started sending get.

I *think* I might understand what you mean.

The code you posted doesn't send anything. It handles POST request sent
from your browser. If you load a page with your browser normally, it
will send a GET request.

My guess is, that you've sent a POST request to the page (which works
fine) and then you load the same page in your browser sending a GET request.

Could that explain it.

Just to be clear. Your code will not start changing behavior without you
doing anything (self modifying code is indeed a thing, but that's not
relevant here at all).

Kind regards,

Kasper Laudrup

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c96bea3-db71-ca42-7158-9e1f3a9bc6ea%40stacktrace.dk.


OpenPGP_signature
Description: OpenPGP digital signature


#Beginnerlevel Form sending get instead of post request

2021-04-22 Thread chaitanya sakoji


Previously this code was sending post request. Suddenly after restarting 
server, it started sending get. If I take some working post code for form 
from internet and then go on trying and erasing then my code starts sending 
post request. But again after some time when I put my original code, this 
will start sending get request instead of post request.
user_registration_form.html

{% csrf_token %}
{{ form }}



 forms.py
from django.forms import ModelForm
from django import forms
from .models import StudentData


class StudentRegister(ModelForm):

class Meta:
model = StudentData
fields = "__all__"
widgets = {'password': forms.PasswordInput(),
'rpassword': forms.PasswordInput()}

def clean(self):
cleaned_data = super().clean()
password, rpassword = cleaned_data.get('password'), 
cleaned_data.get('rpassword')
if password != rpassword:
error_msg = "Both passwords must match"
self.add_error('rpassword', error_msg)


views.py
from django.shortcuts import render
from .forms import StudentRegister
from django.contrib import messages


def login_register(request):
return render(request, 'users/login_register.html')


def guest_register(request):
return render(request, 'users/guest_register.html')


def student_data(request):
if request.method == 'POST':
print('post')
form = StudentRegister(request.POST)
if form.is_valid():
print('valid form')
form.save()
messages.success(request, f"You are registered successfully, 
{form.cleaned_data.get('name')}")
return render(request, "Registration done")
else:
print('get')
form = StudentRegister()
return render(request, 'users/user_registration_form.html', {'form': form})

model.py
from django.db import models
from django.core.validators import MaxLengthValidator


class StudentData(models.Model):
name = models.CharField(max_length=100)
room_no = models.CharField(max_length=4)
email = models.EmailField()
mobile = models.CharField(max_length=10)
password = models.CharField(max_length=20)
rpassword = models.CharField(max_length=20)

def __str__(self):
return f'{self.name} data'

Thanks,
Chaitanya

-- 
You received this message because you are subscribed to the Google Groups 
"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/88869687-aba7-48f3-99d1-08bfe5643821n%40googlegroups.com.


how to get only the 'title' attribute value from following data in django

2021-04-22 Thread Bhathiya Amarasinghe



This is the views.py I want to get 'title' attribute from the serialize data

views.py
class CalculatView(views.APIView):
query = CartProduct.objects.latest('id') 
 serializer = CartProductSerializer(query) 
 choose_product = serializer.data.get('product') 
 [sell_id] = choose_product 
 querye = Product.objects.filter(id = sell_id) 
 serializere = ProductSerializers(querye, many=True) 
 choosee = serializere.data 

  print(choosee)

Output : 

[OrderedDict([('id', 2), ('title', 'Frock'), ('date', '2021-04-22'), 
('image', '/media/products/kids2.jpg'), ('marcket_price', 1.2), 
('selling_price', 1.2), ('description', 'a'), 
('category', OrderedDict([('id', 2), ('title', 'Fashion'), ('date', 
'2021-04-22')])), ('seller', OrderedDict([('id', 2), ('seller_name', 'CIB - 
Piliyandala'), ('lat', 6.8018), ('lng', 79.9227), ('date', 
'2021-04-22')]))])]


-- 
You received this message because you are subscribed to the Google Groups 
"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/d1dba65a-6f05-4ea4-978a-900ddcc649d2n%40googlegroups.com.