Rest Franework

2019-08-21 Thread Soumen Khatua
Hi Folks,
I want to implemnet something like if user type any query parameter then
matched string should come first then if the typed words contains in
between records then short length of string should come second and so on,as
an example:


*http://127.0.0.1:8000/get/search/?word=the
*

*the--- first record*
*they-- second **record*
*their--- third **record*
*theirs-- fourth **record*
**


Plase tell me how I can solve this probelm.

Thank you


Regards,
Soumen

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


Retrieving data from multiple tables

2019-08-21 Thread Suraj Thapa FC
This is my model

class courses(models.Model):
cid = models.UUIDField(default=uuid.uuid4, editable=True, primary_key=True)
course_title = models.CharField(max_length=255, default="")


class course_rating(models.Model):
cr_id = models.BigAutoField(primary_key=True)
cid = models.ForeignKey(courses,on_delete=models.CASCADE)
userid =
models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
rating =
models.IntegerField(validators[MaxValueValidator(5),MinValueValidator(1)],default=1)




I want to fetch the course_title and cid from courses tables and want to
perform the average rating of courses
Can someone write the query set for the same

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAPjsHcHXqr8%2Bnr91tA2Og%3DKpjeVGp8%2BFP%2BmsX9dbzuZxA5CHww%40mail.gmail.com.


Problem with SQLite and migrations

2019-08-21 Thread Jaemin Noh
Hello.

My application is currently in a development state, so it's using SQLite as 
a database backend at the moment.

Due to the bad design decisions, my application has a migration with raw 
CREATE VIEW statements and unmanaged models. These VIEWs refer other tables 
with JOIN clauses.
The problem is, when a column is being added to or removed from a table 
with a migration, Django remakes table(
https://github.com/django/django/blob/1e429df748867097451bf0b45d1080ae6828d921/django/db/backends/sqlite3/schema.py#L320-L346),
 
and VIEW throws a 'no such table' error when joined table is being deleted.

Maybe this is SQLite's problem since table is being deleted inside a 
transaction and this should not cause any problem in theory. Maybe it can 
be fixed in Django to use ALTER TABLE statement.
Ultimately, I can just get away with this problem if I switch to MySQL or 
PostgreSQL.

So, what should I do? Where should I report this 'bug' or 'problem'? 
SQLite? Django?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21c59661-bdba-43f6-9551-de1a6bf278de%40googlegroups.com.


Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread Ahmed Shahwan
Hi,

I have a very strange problem that I don't know why it happens.
I'm creating a REST API service that wraps another REST API payment 
service, let's call the other services XPAY. It has various payment options 
(Card, eWallet, Kiosk, and Cash). The steps required to use the services 
(to make a transaction)

1. authentication 2. order registration 3. payment key 4. prepare frontend 
based on payment type 5. Callback URL 6. Redirect URL

and each step depends on its predecessor. The first 4 steps are performed 
through HTTP Requests that I issue from my service. I store some of the 
information I receive in those steps in a Model called Transaction. 5th and 
6th steps are Callback endpoints that I create to receive further 
information about the status of the transaction that I started in the first 
4 steps.

My endpoints design is:

myservice/payment/card
myservice/payment/wallet
myservice/payment/kiosk
myservice/payment/cash

myservice/payment/callback-url
myservice/payment/redirect-url

These endpoints are wrappers for the payment methods available in XPAY's 
service that my frontend apps will use to provide those payment options for 
users.

I implemented the first 3 endpoints with no problem. inside those 
endpoints, I create a transaction object with a unique id and then update 
it from inside the *callback-url endpoint* after I receive the information 
from XPAY's service. Note that it takes some time between creating the 
Transaction object and saving it into the database from inside my endpoint, 
and updating it from inside the callback url endpoint.

The weird thing happens in the 4th endpoint `cash` endpoint. XPAY's service 
responds very quickly on my *callback-url endpoint* and when it gets to the 
updating step, I get *Transaction.DoesNotExist *Exception while getting the 
transaction object using Transaction.objects.get(id=id).

After some debugging time using ipdb I found that the instance has already 
been saved to the database! and I can retrieve it with its id. but when I 
let it run ordinarily the saving operation doesn't finish until that time 
(I got to know that using some print() statements), which is very strange, 
it's impossible that my laptop is that slow! 

Solutions I tried:
1. atomic transaction
2. time.sleep some time after making the request and saving the transaction 
object to the db
3. time.sleep in the callback-url before getting the transaction from DB

I checked any possible logic error related to it and there's nothing 
illogical.

the issue is related to Postgres and how it operates, and also with 
Django's ORM. I don't know.

Main technologies I use:
Django 2.2
Postgres Docker container
DRF

I hope someone gives me an insight into why this is happening and how to 
work around it.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e43be322-bab9-4162-9fbc-05c6c9b95c94%40googlegroups.com.


Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread mohammed habib
Are you sure the callback request passes the right parameters ?

Could you share some of your views code from the 6 steps, and your Transaction 
model ?

Sent from my iPhone

> On 21 Aug 2019, at 14:46, Ahmed Shahwan  wrote:
> 
> Hi,
> 
> I have a very strange problem that I don't know why it happens.
> I'm creating a REST API service that wraps another REST API payment service, 
> let's call the other services XPAY. It has various payment options (Card, 
> eWallet, Kiosk, and Cash). The steps required to use the services (to make a 
> transaction)
> 
> 1. authentication 2. order registration 3. payment key 4. prepare frontend 
> based on payment type 5. Callback URL 6. Redirect URL
> 
> and each step depends on its predecessor. The first 4 steps are performed 
> through HTTP Requests that I issue from my service. I store some of the 
> information I receive in those steps in a Model called Transaction. 5th and 
> 6th steps are Callback endpoints that I create to receive further information 
> about the status of the transaction that I started in the first 4 steps.
> 
> My endpoints design is:
> 
> myservice/payment/card
> myservice/payment/wallet
> myservice/payment/kiosk
> myservice/payment/cash
> 
> myservice/payment/callback-url
> myservice/payment/redirect-url
> 
> These endpoints are wrappers for the payment methods available in XPAY's 
> service that my frontend apps will use to provide those payment options for 
> users.
> 
> I implemented the first 3 endpoints with no problem. inside those endpoints, 
> I create a transaction object with a unique id and then update it from inside 
> the callback-url endpoint after I receive the information from XPAY's 
> service. Note that it takes some time between creating the Transaction object 
> and saving it into the database from inside my endpoint, and updating it from 
> inside the callback url endpoint.
> 
> The weird thing happens in the 4th endpoint `cash` endpoint. XPAY's service 
> responds very quickly on my callback-url endpoint and when it gets to the 
> updating step, I get Transaction.DoesNotExist Exception while getting the 
> transaction object using Transaction.objects.get(id=id).
> 
> After some debugging time using ipdb I found that the instance has already 
> been saved to the database! and I can retrieve it with its id. but when I let 
> it run ordinarily the saving operation doesn't finish until that time (I got 
> to know that using some print() statements), which is very strange, it's 
> impossible that my laptop is that slow! 
> 
> Solutions I tried:
> 1. atomic transaction
> 2. time.sleep some time after making the request and saving the transaction 
> object to the db
> 3. time.sleep in the callback-url before getting the transaction from DB
> 
> I checked any possible logic error related to it and there's nothing 
> illogical.
> 
> the issue is related to Postgres and how it operates, and also with Django's 
> ORM. I don't know.
> 
> Main technologies I use:
> Django 2.2
> Postgres Docker container
> DRF
> 
> I hope someone gives me an insight into why this is happening and how to work 
> around it.
> 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/e43be322-bab9-4162-9fbc-05c6c9b95c94%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/FADE1777-D4D8-442F-8FB4-2FDF265C2F14%40gmail.com.


Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread Ahmed Shahwan
Transaction model:


class WeacceptTransaction(Transaction):
   """Weaccept's Transaction model"""

# before frontend interaction
   auth_token = models.TextField()  # got from step 1
   order_id = models.IntegerField(verbose_name="Accept's Order ID")  # id 
from step 2
   order_url = models.CharField(max_length=255, null=True)  # order_url 
from step 2
   billing_data = JSONField()  # provided in request for paymet key, step 3
   payment_key = models.TextField()  # payment_token from step 3
   hmac = models.TextField(null=True)
   # after (from callback)
   success_status = models.BooleanField(default=False)
   is_refunded = models.BooleanField(default=False)
   reference_number = models.IntegerField(null=True)
   processed_clbk_json = JSONField(null=True)


The cash_payment View:

class CashPayment(APIView):
   """Cash Payment endpoint"""

serializer_class = serializers.CardPaymentSerializer
   required_fields = ["amount_cents", "billing_data"]

def post(self, request):
   # Validate required fields
   utils.validate(self.required_fields, request)
   payment = utils.CashPayment(**request.data)
   payment.prepare()
   payment.pay_request()
   # create a new transaction
   models.WeacceptTransaction.objects.create(
   merchant_order_id=payment.merchant_order_id,
   amount=payment.amount_cents,
   auth_token=payment.auth_res.get("token"),
   order_id=payment.order_reg_res.get("id"),
   order_url=payment.order_reg_res.get("order_url"),
   billing_data=payment.billing_data,
   payment_key=payment.payment_key_res.get("token"),
   hmac=payment.pay_req_res.get("hmac"),
   )

return Response(
   {
   "message": "Our representative will go to the address you 
provided "
   "to collect the cash from you",
   **payment.pay_req_res,
   }
   )


Please note: the first 3 steps are wrapped into the method `prepare()`
the 4th step is `pay_request()`


the callback-url endpoint (where the 5th step happens) 

class TransactionProcessedCallback(APIView):
   """Processed callback that will recieve "TRANSACTION", "TOKEN", "ORDER",
  "DELIVERY_STATUS" objects"""

def post(self, request):
   # XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
   t_obj = request.data.get("obj")  # transaction object
   incoming_hmac = request.query_params.get("hmac")
   calculated_hmac = utils.calculate_hmac_transaction(t_obj)

# if not equal hmac, not coming from Accept!
   if incoming_hmac != calculated_hmac:
   return Response(
   {"message": "invalid data"}, status=status.
HTTP_400_BAD_REQUEST
   )

import ipdb

ipdb.set_trace()
# XXX: The error happens here
transaction = models.WeacceptTransaction.objects.get(
   merchant_order_id=t_obj.get("order").get("merchant_order_id")
   )
   transaction.success_status = bool(t_obj.get("success"))
   transaction.is_refunded = bool(t_obj.get("is_refunded"))
   transaction.reference_number = int(t_obj.get("data").get(
"transaction_no") or 1)
   transaction.processed_clbk_json = t_obj
   transaction.save(
   update_fields=[
   "success_status",
   "is_refunded",
   "reference_number",
   "processed_clbk_json",
   ]
   )

email = t_obj.get("order").get("shipping_data").get("email")
   # TODO: send mail based upon success status
   try:
   send_mail(
   "Transaction Processed",
   "Your transaction is processed",
   "SERNDER MAIL",
   [email],
   fail_silently=False,
   )
   except Exception as ex:
   print(">>FAILED TO SEND MAIL")
   print(ex)

return Response({"message": "Transaction Updated!"}, status=status.
HTTP_200_OK)


The 6th step (redirect-url) is irrelevant here, and not included in the 
XPAY's service for this payment option.


On Wednesday, August 21, 2019 at 2:03:20 PM UTC+2, mohammed habib wrote:
>
> Are you sure the callback request passes the right parameters ?
>
> Could you share some of your views code from the 6 steps, and your 
> Transaction model ?
>
> Sent from my iPhone
>
> On 21 Aug 2019, at 14:46, Ahmed Shahwan > 
> wrote:
>
> Hi,
>
> I have a very strange problem that I don't know why it happens.
> I'm creating a REST API service that wraps another REST API payment 
> service, let's call the other services XPAY. It has various payment options 
> (Card, eWallet, Kiosk, and Cash). The steps required to use the services 
> (to make a transaction)
>
> 1. authentication 2. order registration 3. payment key 4. prepare frontend 
> based on payment type 5. Callback URL 6. Redirect URL
>
> and each step depends on its predecessor. The first 4 steps are performed 
> through HTTP Requests that

Re: Retrieving data from multiple tables

2019-08-21 Thread Sundararajan Seshadri
What you need to appreciate is that the foreign key field gives you the 
full record (corresponding to the foreign key).

So, if you fetch all records as course_rating.objects.all() then c.cid will 
also be an object giving you the corresponding foreign key record. So, you 
can access c.cid.cid and c.cid.course_title.(where c is one instance / 
record of the query set)

Some points:
(a) you are not following the convention. Not a crime. But if you follow 
the convention, it will prove convenient. For example. Courses will be the 
class name. (Table name can be anything)
(b) You named the foreign-key in the second table as cid, It is, again, not 
an issue but if you followed the convention, you could have called it as 
course so that field names could have been c.course.cid and 
c.course.course_title, probably more meaningful.

Again, convention is for convenience. 

Cheers.

On Wednesday, August 21, 2019 at 2:46:12 PM UTC+5:30, Suraj Thapa FC wrote:
>
> This is my model
>
> class courses(models.Model):
> cid = models.UUIDField(default=uuid.uuid4, editable=True, primary_key=True)
> course_title = models.CharField(max_length=255, default="")
>
>
> class course_rating(models.Model):
> cr_id = models.BigAutoField(primary_key=True)
> cid = models.ForeignKey(courses,on_delete=models.CASCADE)
> userid = 
> models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
> rating = 
> models.IntegerField(validators[MaxValueValidator(5),MinValueValidator(1)],default=1)
>
>
>
>
> I want to fetch the course_title and cid from courses tables and want to 
> perform the average rating of courses 
> Can someone write the query set for the same
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/f49660db-c157-43df-8563-3e9c2369a8dd%40googlegroups.com.


Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread mohamed habib
Wild guess in the dark here, as I am unfamiliar with this API. you are
doing:

 `payment.pay_request()`

before creating the WeacceptTransaction object.

Maybe this line needs to move below:
`models.WeAcceptTransaction.objects.create(...)` ?

At what point is the callback request triggered ?

On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:

> Transaction model:
>
>
> class WeacceptTransaction(Transaction):
>"""Weaccept's Transaction model"""
>
> # before frontend interaction
>auth_token = models.TextField()  # got from step 1
>order_id = models.IntegerField(verbose_name="Accept's Order ID")  # id
> from step 2
>order_url = models.CharField(max_length=255, null=True)  # order_url
> from step 2
>billing_data = JSONField()  # provided in request for paymet key, step
> 3
>payment_key = models.TextField()  # payment_token from step 3
>hmac = models.TextField(null=True)
># after (from callback)
>success_status = models.BooleanField(default=False)
>is_refunded = models.BooleanField(default=False)
>reference_number = models.IntegerField(null=True)
>processed_clbk_json = JSONField(null=True)
>
>
> The cash_payment View:
>
> class CashPayment(APIView):
>"""Cash Payment endpoint"""
>
> serializer_class = serializers.CardPaymentSerializer
>required_fields = ["amount_cents", "billing_data"]
>
> def post(self, request):
># Validate required fields
>utils.validate(self.required_fields, request)
>payment = utils.CashPayment(**request.data)
>payment.prepare()
>payment.pay_request()
># create a new transaction
>models.WeacceptTransaction.objects.create(
>merchant_order_id=payment.merchant_order_id,
>amount=payment.amount_cents,
>auth_token=payment.auth_res.get("token"),
>order_id=payment.order_reg_res.get("id"),
>order_url=payment.order_reg_res.get("order_url"),
>billing_data=payment.billing_data,
>payment_key=payment.payment_key_res.get("token"),
>hmac=payment.pay_req_res.get("hmac"),
>)
>
> return Response(
>{
>"message": "Our representative will go to the address you
> provided "
>"to collect the cash from you",
>**payment.pay_req_res,
>}
>)
>
>
> Please note: the first 3 steps are wrapped into the method `prepare()`
> the 4th step is `pay_request()`
>
>
> the callback-url endpoint (where the 5th step happens)
>
> class TransactionProcessedCallback(APIView):
>"""Processed callback that will recieve "TRANSACTION", "TOKEN", "ORDER
> ",
>   "DELIVERY_STATUS" objects"""
>
> def post(self, request):
># XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
>t_obj = request.data.get("obj")  # transaction object
>incoming_hmac = request.query_params.get("hmac")
>calculated_hmac = utils.calculate_hmac_transaction(t_obj)
>
> # if not equal hmac, not coming from Accept!
>if incoming_hmac != calculated_hmac:
>return Response(
>{"message": "invalid data"}, status=status.
> HTTP_400_BAD_REQUEST
>)
>
> import ipdb
>
> ipdb.set_trace()
> # XXX: The error happens here
> transaction = models.WeacceptTransaction.objects.get(
>merchant_order_id=t_obj.get("order").get("merchant_order_id")
>)
>transaction.success_status = bool(t_obj.get("success"))
>transaction.is_refunded = bool(t_obj.get("is_refunded"))
>transaction.reference_number = int(t_obj.get("data").get(
> "transaction_no") or 1)
>transaction.processed_clbk_json = t_obj
>transaction.save(
>update_fields=[
>"success_status",
>"is_refunded",
>"reference_number",
>"processed_clbk_json",
>]
>)
>
> email = t_obj.get("order").get("shipping_data").get("email")
># TODO: send mail based upon success status
>try:
>send_mail(
>"Transaction Processed",
>"Your transaction is processed",
>"SERNDER MAIL",
>[email],
>fail_silently=False,
>)
>except Exception as ex:
>print(">>FAILED TO SEND MAIL")
>print(ex)
>
> return Response({"message": "Transaction Updated!"}, status=status
> .HTTP_200_OK)
>
>
> The 6th step (redirect-url) is irrelevant here, and not included in the
> XPAY's service for this payment option.
>
>
> On Wednesday, August 21, 2019 at 2:03:20 PM UTC+2, mohammed habib wrote:
>>
>> Are you sure the callback request passes the right parameters ?
>>
>> Could you share some of your views code from the 6 steps, and your
>> Transaction model ?
>>
>> Sent from my iPhone
>>
>> On 21 Aug 2019, at 14:46, Ahmed Shahwan 

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread Ahmed Shahwan
I tried, same happened. it's related to how Postgres works internally with 
the Django-ORM.

On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:
>
> Wild guess in the dark here, as I am unfamiliar with this API. you are 
> doing:
>
>  `payment.pay_request()` 
>
> before creating the WeacceptTransaction object. 
>
> Maybe this line needs to move below: 
> `models.WeAcceptTransaction.objects.create(...)` ? 
>
> At what point is the callback request triggered ?
>
> On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  > wrote:
>
>> Transaction model:
>>
>>
>> class WeacceptTransaction(Transaction):
>>"""Weaccept's Transaction model"""
>>
>> # before frontend interaction
>>auth_token = models.TextField()  # got from step 1
>>order_id = models.IntegerField(verbose_name="Accept's Order ID")  # 
>> id from step 2
>>order_url = models.CharField(max_length=255, null=True)  # order_url 
>> from step 2
>>billing_data = JSONField()  # provided in request for paymet key, 
>> step 3
>>payment_key = models.TextField()  # payment_token from step 3
>>hmac = models.TextField(null=True)
>># after (from callback)
>>success_status = models.BooleanField(default=False)
>>is_refunded = models.BooleanField(default=False)
>>reference_number = models.IntegerField(null=True)
>>processed_clbk_json = JSONField(null=True)
>>
>>
>> The cash_payment View:
>>
>> class CashPayment(APIView):
>>"""Cash Payment endpoint"""
>>
>> serializer_class = serializers.CardPaymentSerializer
>>required_fields = ["amount_cents", "billing_data"]
>>
>> def post(self, request):
>># Validate required fields
>>utils.validate(self.required_fields, request)
>>payment = utils.CashPayment(**request.data)
>>payment.prepare()
>>payment.pay_request()
>># create a new transaction
>>models.WeacceptTransaction.objects.create(
>>merchant_order_id=payment.merchant_order_id,
>>amount=payment.amount_cents,
>>auth_token=payment.auth_res.get("token"),
>>order_id=payment.order_reg_res.get("id"),
>>order_url=payment.order_reg_res.get("order_url"),
>>billing_data=payment.billing_data,
>>payment_key=payment.payment_key_res.get("token"),
>>hmac=payment.pay_req_res.get("hmac"),
>>)
>>
>> return Response(
>>{
>>"message": "Our representative will go to the address you 
>> provided "
>>"to collect the cash from you",
>>**payment.pay_req_res,
>>}
>>)
>>
>>
>> Please note: the first 3 steps are wrapped into the method `prepare()`
>> the 4th step is `pay_request()`
>>
>>
>> the callback-url endpoint (where the 5th step happens) 
>>
>> class TransactionProcessedCallback(APIView):
>>"""Processed callback that will recieve "TRANSACTION", "TOKEN", "ORDER
>> ",
>>   "DELIVERY_STATUS" objects"""
>>
>> def post(self, request):
>># XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
>>t_obj = request.data.get("obj")  # transaction object
>>incoming_hmac = request.query_params.get("hmac")
>>calculated_hmac = utils.calculate_hmac_transaction(t_obj)
>>
>> # if not equal hmac, not coming from Accept!
>>if incoming_hmac != calculated_hmac:
>>return Response(
>>{"message": "invalid data"}, status=status.
>> HTTP_400_BAD_REQUEST
>>)
>>
>> import ipdb
>>
>> ipdb.set_trace()
>> # XXX: The error happens here
>> transaction = models.WeacceptTransaction.objects.get(
>>merchant_order_id=t_obj.get("order").get("merchant_order_id")
>>)
>>transaction.success_status = bool(t_obj.get("success"))
>>transaction.is_refunded = bool(t_obj.get("is_refunded"))
>>transaction.reference_number = int(t_obj.get("data").get(
>> "transaction_no") or 1)
>>transaction.processed_clbk_json = t_obj
>>transaction.save(
>>update_fields=[
>>"success_status",
>>"is_refunded",
>>"reference_number",
>>"processed_clbk_json",
>>]
>>)
>>
>> email = t_obj.get("order").get("shipping_data").get("email")
>># TODO: send mail based upon success status
>>try:
>>send_mail(
>>"Transaction Processed",
>>"Your transaction is processed",
>>"SERNDER MAIL",
>>[email],
>>fail_silently=False,
>>)
>>except Exception as ex:
>>print(">>FAILED TO SEND MAIL")
>>print(ex)
>>
>> return Response({"message": "Transaction Updated!"}, status=
>> status.HTTP_200_OK)
>>
>>
>> The 6th step (redirect-url) is irrelevant here, and not included in the 
>> XPAY's service for this payment

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread mohamed habib
I highly doubt its related to ORM or postgres, the creation of the record
is synchronous so you can be sure that the record exists after the create()
call.

Since you are sure that you are fetching the data properly we can rule out
this possibility

Its probably a race condition of the callback arriving too soon *before*
you hit the create() call. So do you know at what point your payment
gateway will make the callback request and what would trigger it? Make sure
you are

On Wed, Aug 21, 2019 at 4:19 PM Ahmed Shahwan  wrote:

> I tried, same happened. it's related to how Postgres works internally with
> the Django-ORM.
>
> On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:
>>
>> Wild guess in the dark here, as I am unfamiliar with this API. you are
>> doing:
>>
>>  `payment.pay_request()`
>>
>> before creating the WeacceptTransaction object.
>>
>> Maybe this line needs to move below:
>> `models.WeAcceptTransaction.objects.create(...)` ?
>>
>> At what point is the callback request triggered ?
>>
>> On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:
>>
>>> Transaction model:
>>>
>>>
>>> class WeacceptTransaction(Transaction):
>>>"""Weaccept's Transaction model"""
>>>
>>> # before frontend interaction
>>>auth_token = models.TextField()  # got from step 1
>>>order_id = models.IntegerField(verbose_name="Accept's Order ID")  #
>>> id from step 2
>>>order_url = models.CharField(max_length=255, null=True)  # order_url
>>> from step 2
>>>billing_data = JSONField()  # provided in request for paymet key,
>>> step 3
>>>payment_key = models.TextField()  # payment_token from step 3
>>>hmac = models.TextField(null=True)
>>># after (from callback)
>>>success_status = models.BooleanField(default=False)
>>>is_refunded = models.BooleanField(default=False)
>>>reference_number = models.IntegerField(null=True)
>>>processed_clbk_json = JSONField(null=True)
>>>
>>>
>>> The cash_payment View:
>>>
>>> class CashPayment(APIView):
>>>"""Cash Payment endpoint"""
>>>
>>> serializer_class = serializers.CardPaymentSerializer
>>>required_fields = ["amount_cents", "billing_data"]
>>>
>>> def post(self, request):
>>># Validate required fields
>>>utils.validate(self.required_fields, request)
>>>payment = utils.CashPayment(**request.data)
>>>payment.prepare()
>>>payment.pay_request()
>>># create a new transaction
>>>models.WeacceptTransaction.objects.create(
>>>merchant_order_id=payment.merchant_order_id,
>>>amount=payment.amount_cents,
>>>auth_token=payment.auth_res.get("token"),
>>>order_id=payment.order_reg_res.get("id"),
>>>order_url=payment.order_reg_res.get("order_url"),
>>>billing_data=payment.billing_data,
>>>payment_key=payment.payment_key_res.get("token"),
>>>hmac=payment.pay_req_res.get("hmac"),
>>>)
>>>
>>> return Response(
>>>{
>>>"message": "Our representative will go to the address
>>> you provided "
>>>"to collect the cash from you",
>>>**payment.pay_req_res,
>>>}
>>>)
>>>
>>>
>>> Please note: the first 3 steps are wrapped into the method `prepare()`
>>> the 4th step is `pay_request()`
>>>
>>>
>>> the callback-url endpoint (where the 5th step happens)
>>>
>>> class TransactionProcessedCallback(APIView):
>>>"""Processed callback that will recieve "TRANSACTION", "TOKEN", "
>>> ORDER",
>>>   "DELIVERY_STATUS" objects"""
>>>
>>> def post(self, request):
>>># XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
>>>t_obj = request.data.get("obj")  # transaction object
>>>incoming_hmac = request.query_params.get("hmac")
>>>calculated_hmac = utils.calculate_hmac_transaction(t_obj)
>>>
>>> # if not equal hmac, not coming from Accept!
>>>if incoming_hmac != calculated_hmac:
>>>return Response(
>>>{"message": "invalid data"}, status=status.
>>> HTTP_400_BAD_REQUEST
>>>)
>>>
>>> import ipdb
>>>
>>> ipdb.set_trace()
>>> # XXX: The error happens here
>>> transaction = models.WeacceptTransaction.objects.get(
>>>merchant_order_id=t_obj.get("order").get("merchant_order_id")
>>>)
>>>transaction.success_status = bool(t_obj.get("success"))
>>>transaction.is_refunded = bool(t_obj.get("is_refunded"))
>>>transaction.reference_number = int(t_obj.get("data").get(
>>> "transaction_no") or 1)
>>>transaction.processed_clbk_json = t_obj
>>>transaction.save(
>>>update_fields=[
>>>"success_status",
>>>"is_refunded",
>>>"reference_number",
>>>"processed_clbk_json",
>>>]
>>>)
>>>
>>> email = t_obj.get("order").get("shipping_dat

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread mohamed habib
if you are able to share more code from the `utils.CashPayment` call that
may help us

On Wed, Aug 21, 2019 at 4:37 PM mohamed habib  wrote:

> I highly doubt its related to ORM or postgres, the creation of the record
> is synchronous so you can be sure that the record exists after the create()
> call.
>
> Since you are sure that you are fetching the data properly we can rule out
> this possibility
>
> Its probably a race condition of the callback arriving too soon *before*
> you hit the create() call. So do you know at what point your payment
> gateway will make the callback request and what would trigger it? Make sure
> you are
>
> On Wed, Aug 21, 2019 at 4:19 PM Ahmed Shahwan  wrote:
>
>> I tried, same happened. it's related to how Postgres works internally
>> with the Django-ORM.
>>
>> On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:
>>>
>>> Wild guess in the dark here, as I am unfamiliar with this API. you are
>>> doing:
>>>
>>>  `payment.pay_request()`
>>>
>>> before creating the WeacceptTransaction object.
>>>
>>> Maybe this line needs to move below:
>>> `models.WeAcceptTransaction.objects.create(...)` ?
>>>
>>> At what point is the callback request triggered ?
>>>
>>> On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:
>>>
 Transaction model:


 class WeacceptTransaction(Transaction):
"""Weaccept's Transaction model"""

 # before frontend interaction
auth_token = models.TextField()  # got from step 1
order_id = models.IntegerField(verbose_name="Accept's Order ID")  #
 id from step 2
order_url = models.CharField(max_length=255, null=True)  #
 order_url from step 2
billing_data = JSONField()  # provided in request for paymet key,
 step 3
payment_key = models.TextField()  # payment_token from step 3
hmac = models.TextField(null=True)
# after (from callback)
success_status = models.BooleanField(default=False)
is_refunded = models.BooleanField(default=False)
reference_number = models.IntegerField(null=True)
processed_clbk_json = JSONField(null=True)


 The cash_payment View:

 class CashPayment(APIView):
"""Cash Payment endpoint"""

 serializer_class = serializers.CardPaymentSerializer
required_fields = ["amount_cents", "billing_data"]

 def post(self, request):
# Validate required fields
utils.validate(self.required_fields, request)
payment = utils.CashPayment(**request.data)
payment.prepare()
payment.pay_request()
# create a new transaction
models.WeacceptTransaction.objects.create(
merchant_order_id=payment.merchant_order_id,
amount=payment.amount_cents,
auth_token=payment.auth_res.get("token"),
order_id=payment.order_reg_res.get("id"),
order_url=payment.order_reg_res.get("order_url"),
billing_data=payment.billing_data,
payment_key=payment.payment_key_res.get("token"),
hmac=payment.pay_req_res.get("hmac"),
)

 return Response(
{
"message": "Our representative will go to the address
 you provided "
"to collect the cash from you",
**payment.pay_req_res,
}
)


 Please note: the first 3 steps are wrapped into the method `prepare()`
 the 4th step is `pay_request()`


 the callback-url endpoint (where the 5th step happens)

 class TransactionProcessedCallback(APIView):
"""Processed callback that will recieve "TRANSACTION", "TOKEN", "
 ORDER",
   "DELIVERY_STATUS" objects"""

 def post(self, request):
# XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
t_obj = request.data.get("obj")  # transaction object
incoming_hmac = request.query_params.get("hmac")
calculated_hmac = utils.calculate_hmac_transaction(t_obj)

 # if not equal hmac, not coming from Accept!
if incoming_hmac != calculated_hmac:
return Response(
{"message": "invalid data"}, status=status.
 HTTP_400_BAD_REQUEST
)

 import ipdb

 ipdb.set_trace()
 # XXX: The error happens here
 transaction = models.WeacceptTransaction.objects.get(
merchant_order_id=t_obj.get("order").get("merchant_order_id"
 )
)
transaction.success_status = bool(t_obj.get("success"))
transaction.is_refunded = bool(t_obj.get("is_refunded"))
transaction.reference_number = int(t_obj.get("data").get(
 "transaction_no") or 1)
transaction.processed_clbk_json = t_obj
tran

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread Ahmed Shahwan
the response to my callback quicker than saving the object?! it's highly 
unlikely! there's something else I don't understand. The step that 
`pay_request()` is the last before getting the response from XPAY's server. 
I tried to put it after saving the transaction object. same error occurred!

I also tried to put the transaction save operation inside the `with 
transaction.atomic()` statement, but same error.


also, I tried refresh_from_db() method on the transaction after saving it, 
and saving it again! and using some print statements

The weird thing is I get the transaction object printed before and after 
XPAY's server hitting my callback-url (with the same error)

using the ipdb and fetching the object from DB I get the same error, after 
trying the same statement for 2 or 3 times, it works!


On Wednesday, August 21, 2019 at 3:38:33 PM UTC+2, mohamed habib wrote:
>
> I highly doubt its related to ORM or postgres, the creation of the record 
> is synchronous so you can be sure that the record exists after the create() 
> call.
>
> Since you are sure that you are fetching the data properly we can rule out 
> this possibility
>
> Its probably a race condition of the callback arriving too soon *before* 
> you hit the create() call. So do you know at what point your payment 
> gateway will make the callback request and what would trigger it? Make sure 
> you are 
>
> On Wed, Aug 21, 2019 at 4:19 PM Ahmed Shahwan  > wrote:
>
>> I tried, same happened. it's related to how Postgres works internally 
>> with the Django-ORM.
>>
>> On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:
>>>
>>> Wild guess in the dark here, as I am unfamiliar with this API. you are 
>>> doing:
>>>
>>>  `payment.pay_request()` 
>>>
>>> before creating the WeacceptTransaction object. 
>>>
>>> Maybe this line needs to move below: 
>>> `models.WeAcceptTransaction.objects.create(...)` ? 
>>>
>>> At what point is the callback request triggered ?
>>>
>>> On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:
>>>
 Transaction model:


 class WeacceptTransaction(Transaction):
"""Weaccept's Transaction model"""

 # before frontend interaction
auth_token = models.TextField()  # got from step 1
order_id = models.IntegerField(verbose_name="Accept's Order ID")  # 
 id from step 2
order_url = models.CharField(max_length=255, null=True)  # 
 order_url from step 2
billing_data = JSONField()  # provided in request for paymet key, 
 step 3
payment_key = models.TextField()  # payment_token from step 3
hmac = models.TextField(null=True)
# after (from callback)
success_status = models.BooleanField(default=False)
is_refunded = models.BooleanField(default=False)
reference_number = models.IntegerField(null=True)
processed_clbk_json = JSONField(null=True)


 The cash_payment View:

 class CashPayment(APIView):
"""Cash Payment endpoint"""

 serializer_class = serializers.CardPaymentSerializer
required_fields = ["amount_cents", "billing_data"]

 def post(self, request):
# Validate required fields
utils.validate(self.required_fields, request)
payment = utils.CashPayment(**request.data)
payment.prepare()
payment.pay_request()
# create a new transaction
models.WeacceptTransaction.objects.create(
merchant_order_id=payment.merchant_order_id,
amount=payment.amount_cents,
auth_token=payment.auth_res.get("token"),
order_id=payment.order_reg_res.get("id"),
order_url=payment.order_reg_res.get("order_url"),
billing_data=payment.billing_data,
payment_key=payment.payment_key_res.get("token"),
hmac=payment.pay_req_res.get("hmac"),
)

 return Response(
{
"message": "Our representative will go to the address 
 you provided "
"to collect the cash from you",
**payment.pay_req_res,
}
)


 Please note: the first 3 steps are wrapped into the method `prepare()`
 the 4th step is `pay_request()`


 the callback-url endpoint (where the 5th step happens) 

 class TransactionProcessedCallback(APIView):
"""Processed callback that will recieve "TRANSACTION", "TOKEN", "
 ORDER",
   "DELIVERY_STATUS" objects"""

 def post(self, request):
# XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
t_obj = request.data.get("obj")  # transaction object
incoming_hmac = request.query_params.get("hmac")
calculated_hmac = utils.calculate_hmac_transaction(t_obj)

 # if not equal hmac, not coming from Accept!
>>

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread Ahmed Shahwan
That's the class, nothing different other than HTTP requests

class CashPayment(BasePayment):
"""Cash Payment Wrapper Class"""

integration_id = CASH_INTEGRATION_ID

def __init__(self, amount_cents: int, billing_data: dict):
super().__init__(amount_cents, billing_data)

def pay_request(self):
"""Step 4. issue Pay request"""
payload = {
"source": {"identifier": "cash", "subtype": "CASH"},
"payment_token": self.payment_key_res.get("token"),
}
self.pay_req_res = self.hit_accept(
self._api_url + "acceptance/payments/pay", payload=payload
)


On Wednesday, August 21, 2019 at 3:39:13 PM UTC+2, mohamed habib wrote:
>
> if you are able to share more code from the `utils.CashPayment` call that 
> may help us
>
> On Wed, Aug 21, 2019 at 4:37 PM mohamed habib  > wrote:
>
>> I highly doubt its related to ORM or postgres, the creation of the record 
>> is synchronous so you can be sure that the record exists after the create() 
>> call.
>>
>> Since you are sure that you are fetching the data properly we can rule 
>> out this possibility
>>
>> Its probably a race condition of the callback arriving too soon *before* 
>> you hit the create() call. So do you know at what point your payment 
>> gateway will make the callback request and what would trigger it? Make sure 
>> you are 
>>
>> On Wed, Aug 21, 2019 at 4:19 PM Ahmed Shahwan > > wrote:
>>
>>> I tried, same happened. it's related to how Postgres works internally 
>>> with the Django-ORM.
>>>
>>> On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:

 Wild guess in the dark here, as I am unfamiliar with this API. you are 
 doing:

  `payment.pay_request()` 

 before creating the WeacceptTransaction object. 

 Maybe this line needs to move below: 
 `models.WeAcceptTransaction.objects.create(...)` ? 

 At what point is the callback request triggered ?

 On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:

> Transaction model:
>
>
> class WeacceptTransaction(Transaction):
>"""Weaccept's Transaction model"""
>
> # before frontend interaction
>auth_token = models.TextField()  # got from step 1
>order_id = models.IntegerField(verbose_name="Accept's Order ID")  # 
> id from step 2
>order_url = models.CharField(max_length=255, null=True)  # 
> order_url from step 2
>billing_data = JSONField()  # provided in request for paymet key, 
> step 3
>payment_key = models.TextField()  # payment_token from step 3
>hmac = models.TextField(null=True)
># after (from callback)
>success_status = models.BooleanField(default=False)
>is_refunded = models.BooleanField(default=False)
>reference_number = models.IntegerField(null=True)
>processed_clbk_json = JSONField(null=True)
>
>
> The cash_payment View:
>
> class CashPayment(APIView):
>"""Cash Payment endpoint"""
>
> serializer_class = serializers.CardPaymentSerializer
>required_fields = ["amount_cents", "billing_data"]
>
> def post(self, request):
># Validate required fields
>utils.validate(self.required_fields, request)
>payment = utils.CashPayment(**request.data)
>payment.prepare()
>payment.pay_request()
># create a new transaction
>models.WeacceptTransaction.objects.create(
>merchant_order_id=payment.merchant_order_id,
>amount=payment.amount_cents,
>auth_token=payment.auth_res.get("token"),
>order_id=payment.order_reg_res.get("id"),
>order_url=payment.order_reg_res.get("order_url"),
>billing_data=payment.billing_data,
>payment_key=payment.payment_key_res.get("token"),
>hmac=payment.pay_req_res.get("hmac"),
>)
>
> return Response(
>{
>"message": "Our representative will go to the address 
> you provided "
>"to collect the cash from you",
>**payment.pay_req_res,
>}
>)
>
>
> Please note: the first 3 steps are wrapped into the method `prepare()`
> the 4th step is `pay_request()`
>
>
> the callback-url endpoint (where the 5th step happens) 
>
> class TransactionProcessedCallback(APIView):
>"""Processed callback that will recieve "TRANSACTION", "TOKEN", "
> ORDER",
>   "DELIVERY_STATUS" objects"""
>
> def post(self, request):
># XXX extend to handle TOKEN, DELIVERY_STATUS objects... later
>t_obj = request.data.get("obj")  # transaction object
>incoming_hmac = request.query_params.get("hmac")
>calculated_hmac = utils.calculate_hmac_transaction(t_obj)
>
> # if not equal hmac, not coming from Accept!
>  

Re: Weird Database behavior (Can't access object from a view after directly saving it from inside another view)

2019-08-21 Thread mohammed habib
What is the Transaction class which your model inherits from ? Is it just a 
base model ?

Let’s do an experiment 

Print(“object created”) right after the create() method

Print(“callback requested”) on top of your callback method

Which one do you see first ? 

Sent from my iPhone

> On 21 Aug 2019, at 16:56, Ahmed Shahwan  wrote:
> 
> That's the class, nothing different other than HTTP requests
> 
> class CashPayment(BasePayment):
> """Cash Payment Wrapper Class"""
> 
> integration_id = CASH_INTEGRATION_ID
> 
> def __init__(self, amount_cents: int, billing_data: dict):
> super().__init__(amount_cents, billing_data)
> 
> def pay_request(self):
> """Step 4. issue Pay request"""
> payload = {
> "source": {"identifier": "cash", "subtype": "CASH"},
> "payment_token": self.payment_key_res.get("token"),
> }
> self.pay_req_res = self.hit_accept(
> self._api_url + "acceptance/payments/pay", payload=payload
> )
> 
> 
>> On Wednesday, August 21, 2019 at 3:39:13 PM UTC+2, mohamed habib wrote:
>> if you are able to share more code from the `utils.CashPayment` call that 
>> may help us
>> 
>>> On Wed, Aug 21, 2019 at 4:37 PM mohamed habib  wrote:
>>> I highly doubt its related to ORM or postgres, the creation of the record 
>>> is synchronous so you can be sure that the record exists after the create() 
>>> call.
>>> 
>>> Since you are sure that you are fetching the data properly we can rule out 
>>> this possibility
>>> 
>>> Its probably a race condition of the callback arriving too soon *before* 
>>> you hit the create() call. So do you know at what point your payment 
>>> gateway will make the callback request and what would trigger it? Make sure 
>>> you are 
>>> 
 On Wed, Aug 21, 2019 at 4:19 PM Ahmed Shahwan  wrote:
 I tried, same happened. it's related to how Postgres works internally with 
 the Django-ORM.
 
> On Wednesday, August 21, 2019 at 3:07:47 PM UTC+2, mohamed habib wrote:
> Wild guess in the dark here, as I am unfamiliar with this API. you are 
> doing:
> 
>  `payment.pay_request()` 
> 
> before creating the WeacceptTransaction object. 
> 
> Maybe this line needs to move below: 
> `models.WeAcceptTransaction.objects.create(...)` ? 
> 
> At what point is the callback request triggered ?
> 
>> On Wed, Aug 21, 2019 at 3:36 PM Ahmed Shahwan  wrote:
>> Transaction model:
>> 
>> 
>> class WeacceptTransaction(Transaction):
>> """Weaccept's Transaction model"""
>> 
>> # before frontend interaction
>> auth_token = models.TextField()  # got from step 1
>> order_id = models.IntegerField(verbose_name="Accept's Order ID")  # 
>> id from step 2
>> order_url = models.CharField(max_length=255, null=True)  # order_url 
>> from step 2
>> billing_data = JSONField()  # provided in request for paymet key, 
>> step 3
>> payment_key = models.TextField()  # payment_token from step 3
>> hmac = models.TextField(null=True)
>> # after (from callback)
>> success_status = models.BooleanField(default=False)
>> is_refunded = models.BooleanField(default=False)
>> reference_number = models.IntegerField(null=True)
>> processed_clbk_json = JSONField(null=True)
>> 
>> 
>> The cash_payment View:
>> 
>> class CashPayment(APIView):
>> """Cash Payment endpoint"""
>> 
>> serializer_class = serializers.CardPaymentSerializer
>> required_fields = ["amount_cents", "billing_data"]
>> 
>> def post(self, request):
>> # Validate required fields
>> utils.validate(self.required_fields, request)
>> payment = utils.CashPayment(**request.data)
>> payment.prepare()
>> payment.pay_request()
>> # create a new transaction
>> models.WeacceptTransaction.objects.create(
>> merchant_order_id=payment.merchant_order_id,
>> amount=payment.amount_cents,
>> auth_token=payment.auth_res.get("token"),
>> order_id=payment.order_reg_res.get("id"),
>> order_url=payment.order_reg_res.get("order_url"),
>> billing_data=payment.billing_data,
>> payment_key=payment.payment_key_res.get("token"),
>> hmac=payment.pay_req_res.get("hmac"),
>> )
>> 
>> return Response(
>> {
>> "message": "Our representative will go to the address 
>> you provided "
>> "to collect the cash from you",
>> **payment.pay_req_res,
>> }
>> )
>> 
>> 
>> Please note: the first 3 steps are wrapped into the method `prepare()`
>> the 4th step is `pay_request()`
>> 
>> 
>> the callba

Re: Retrieving data from multiple tables

2019-08-21 Thread Suraj Thapa FC
Thanks...

On Wed, 21 Aug, 2019, 6:24 PM Sundararajan Seshadri, 
wrote:

> What you need to appreciate is that the foreign key field gives you the
> full record (corresponding to the foreign key).
>
> So, if you fetch all records as course_rating.objects.all() then c.cid
> will also be an object giving you the corresponding foreign key record. So,
> you can access c.cid.cid and c.cid.course_title.(where c is one instance /
> record of the query set)
>
> Some points:
> (a) you are not following the convention. Not a crime. But if you follow
> the convention, it will prove convenient. For example. Courses will be the
> class name. (Table name can be anything)
> (b) You named the foreign-key in the second table as cid, It is, again,
> not an issue but if you followed the convention, you could have called it
> as course so that field names could have been c.course.cid and
> c.course.course_title, probably more meaningful.
>
> Again, convention is for convenience.
>
> Cheers.
> 
> On Wednesday, August 21, 2019 at 2:46:12 PM UTC+5:30, Suraj Thapa FC wrote:
>>
>> This is my model
>>
>> class courses(models.Model):
>> cid = models.UUIDField(default=uuid.uuid4, editable=True,
>> primary_key=True)
>> course_title = models.CharField(max_length=255, default="")
>>
>>
>> class course_rating(models.Model):
>> cr_id = models.BigAutoField(primary_key=True)
>> cid = models.ForeignKey(courses,on_delete=models.CASCADE)
>> userid =
>> models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
>> rating =
>> models.IntegerField(validators[MaxValueValidator(5),MinValueValidator(1)],default=1)
>>
>>
>>
>>
>> I want to fetch the course_title and cid from courses tables and want to
>> perform the average rating of courses
>> Can someone write the query set for the same
>>
> --
> You received this message because you are subscribed to the Google Groups
> "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/f49660db-c157-43df-8563-3e9c2369a8dd%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/CAPjsHcHkga3HSeBBTWSaRokmf-qNJq0txwOF6JvwjjsBOg_w_g%40mail.gmail.com.


Re: DRF with Rich Text

2019-08-21 Thread Yoo
Hi,
Thanks for the prompt response (and sorry for such a late one). I suppose 
I'm simply asking about JSON in general and DRF validation. Using the 
general serializer (serializer.Serializers), DRF validates the JSON itself, 
right? So, if some malicious person sent Python code via the JSON using 
some kind of escape char, then DRF responds with an error, right?

Otherwise, is there some Django util that can deal with this? Because the 
API is just an endpoint. All someone has to do (at least in this project) 
is send a JWT Access token alongside some throttling. Can you point out 
some Headers that I can use? Is it possible to use some kind of app (i.e. 
android + iOS) signature?

Thank you! 

On Tuesday, August 20, 2019 at 11:46:24 PM UTC-4, Aditya Singh wrote:
>
> Hi,
> Hope you are good.
> Django ships with top of the line CSRF protection first of all, Secondly, 
> you may specify domain specific headers and strictly restrict the expected 
> type of data, cookies timeout, response data type from the server to the 
> client. Also, you may leverage several robust django compatible packages 
> which relate to security and prevent any requests to the API whiah are 
> unauthorized. From unauthorized, I feel obliged to mention that you must 
> make sure that all the endpoints in your api are well defined and that all 
> the methods being executed on those corresponding endpoints need strong 
> authentication.
> Hope, I could be of some help,
> Kind regards,
> Aditya
>
> On Wed, Aug 21, 2019, 9:11 AM Yoo > 
> wrote:
>
>> Hi, I'm gonna be using Django Rest Framework for API with a Postgres 
>> stack and not developing with website. Coding apps in Swift and Androidx 
>> Java. Users can POST rich text, or text that uses HTML, to the server, and 
>> then other users can GET that HTML and view it in (ui)TextView.
>>
>> Based on previous experience, it seemed like Android's TextView wouldn't 
>> have any trouble with XSS or the like. Not sure about Swift, so can someone 
>> tell me if I should worry on the iOS side? 
>>
>> Last thing. Because this is just an API, how does DRF protect my server 
>> against some malicious JSON POST request? A request that isn't sent from 
>> the designated app or is hand-crafted. If DRF doesn't somehow serialize 
>> correctly, then there would be some server issues, right? Gah worrying.
>>
>> TL;DR. Programming mobile with DRF. Should I worry about Rich Text (HTML 
>> Editing) on client and/or server side?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6c6b92e2-7e49-42f8-abe5-d05b1d0f4619%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/a6ea2741-061c-4392-af73-6e9ff4dc5a16%40googlegroups.com.


Re: DRF with Rich Text

2019-08-21 Thread Jonathan Mrutu
You must secure your endpoints with authentication mechanism and on top of
that you might consider using
 django-rest-knox

//Jona

On Wed, Aug 21, 2019 at 5:57 PM Yoo  wrote:

> Hi,
> Thanks for the prompt response (and sorry for such a late one). I suppose
> I'm simply asking about JSON in general and DRF validation. Using the
> general serializer (serializer.Serializers), DRF validates the JSON itself,
> right? So, if some malicious person sent Python code via the JSON using
> some kind of escape char, then DRF responds with an error, right?
>
> Otherwise, is there some Django util that can deal with this? Because the
> API is just an endpoint. All someone has to do (at least in this project)
> is send a JWT Access token alongside some throttling. Can you point out
> some Headers that I can use? Is it possible to use some kind of app (i.e.
> android + iOS) signature?
>
> Thank you!
>
> On Tuesday, August 20, 2019 at 11:46:24 PM UTC-4, Aditya Singh wrote:
>>
>> Hi,
>> Hope you are good.
>> Django ships with top of the line CSRF protection first of all, Secondly,
>> you may specify domain specific headers and strictly restrict the expected
>> type of data, cookies timeout, response data type from the server to the
>> client. Also, you may leverage several robust django compatible packages
>> which relate to security and prevent any requests to the API whiah are
>> unauthorized. From unauthorized, I feel obliged to mention that you must
>> make sure that all the endpoints in your api are well defined and that all
>> the methods being executed on those corresponding endpoints need strong
>> authentication.
>> Hope, I could be of some help,
>> Kind regards,
>> Aditya
>>
>> On Wed, Aug 21, 2019, 9:11 AM Yoo  wrote:
>>
>>> Hi, I'm gonna be using Django Rest Framework for API with a Postgres
>>> stack and not developing with website. Coding apps in Swift and Androidx
>>> Java. Users can POST rich text, or text that uses HTML, to the server, and
>>> then other users can GET that HTML and view it in (ui)TextView.
>>>
>>> Based on previous experience, it seemed like Android's TextView wouldn't
>>> have any trouble with XSS or the like. Not sure about Swift, so can someone
>>> tell me if I should worry on the iOS side?
>>>
>>> Last thing. Because this is just an API, how does DRF protect my server
>>> against some malicious JSON POST request? A request that isn't sent from
>>> the designated app or is hand-crafted. If DRF doesn't somehow serialize
>>> correctly, then there would be some server issues, right? Gah worrying.
>>>
>>> TL;DR. Programming mobile with DRF. Should I worry about Rich Text (HTML
>>> Editing) on client and/or server side?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/6c6b92e2-7e49-42f8-abe5-d05b1d0f4619%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/a6ea2741-061c-4392-af73-6e9ff4dc5a16%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/CAD9jLPK2YyjuLn%3D6HP3fM2aLU9PbBeMg_3CWHYiKuafMObYu%2BA%40mail.gmail.com.


Re: Problem with SQLite and migrations

2019-08-21 Thread Jonathan Mrutu
Hi Jaemin,

You can try to post this question on stack overflow, but why don't you use
PostgreSQL this is recommended.
SQLite as the name implies it's more for testing purpose in a small project
environment.
//Jona


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Aug 21, 2019 at 2:48 PM Jaemin Noh  wrote:

> Hello.
>
> My application is currently in a development state, so it's using SQLite
> as a database backend at the moment.
>
> Due to the bad design decisions, my application has a migration with raw
> CREATE VIEW statements and unmanaged models. These VIEWs refer other tables
> with JOIN clauses.
> The problem is, when a column is being added to or removed from a table
> with a migration, Django remakes table(
> https://github.com/django/django/blob/1e429df748867097451bf0b45d1080ae6828d921/django/db/backends/sqlite3/schema.py#L320-L346),
> and VIEW throws a 'no such table' error when joined table is being deleted.
>
> Maybe this is SQLite's problem since table is being deleted inside a
> transaction and this should not cause any problem in theory. Maybe it can
> be fixed in Django to use ALTER TABLE statement.
> Ultimately, I can just get away with this problem if I switch to MySQL or
> PostgreSQL.
>
> So, what should I do? Where should I report this 'bug' or 'problem'?
> SQLite? Django?
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/21c59661-bdba-43f6-9551-de1a6bf278de%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/CAD9jLPLTvpG%3D1-Psj%2BxdfORgy1ASov-Ue6RDU8UiwRNGM6tk1w%40mail.gmail.com.


Best DRF Cheatsheet?

2019-08-21 Thread Charles Thayer
I've been using Django with DRF off and on for probably over 5 years now. 
There are still parts that I'm always needing to look up and review. Anyone 
know of a one-pager cheatsheet that covers all the annoying details well, 
like read_only vs write_only vs required, and nesting serializers, etc.?

Thanks,
/charles

-- 
You received this message because you are subscribed to the Google Groups 
"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/d768f5b6-c52d-4831-bf0a-aa27ca366d47%40googlegroups.com.


Re: Problem with SQLite and migrations

2019-08-21 Thread 'Amitesh Sahay' via Django users
Generally SqlLite is enough for any testing. However, if you are planning to 
test it with par the other regular DBs, then do not do it. I have seen your 
GIT-HUB code. Use postgres, you will be happy . 

On Wednesday, 21 August, 2019, 10:12:38 pm IST, Jonathan Mrutu 
 wrote:  
 
 Hi Jaemin,
You can try to post this question on stack overflow, but why don't you use 
PostgreSQL this is recommended. 
SQLite as the name implies it's more for testing purpose in a small project 
environment.//Jona


|  | Virus-free. www.avast.com  |


On Wed, Aug 21, 2019 at 2:48 PM Jaemin Noh  wrote:

Hello.

My application is currently in a development state, so it's using SQLite as a 
database backend at the moment.
Due to the bad design decisions, my application has a migration with raw CREATE 
VIEW statements and unmanaged models. These VIEWs refer other tables with JOIN 
clauses.The problem is, when a column is being added to or removed from a table 
with a migration, Django remakes 
table(https://github.com/django/django/blob/1e429df748867097451bf0b45d1080ae6828d921/django/db/backends/sqlite3/schema.py#L320-L346),
 and VIEW throws a 'no such table' error when joined table is being deleted.

Maybe this is SQLite's problem since table is being deleted inside a 
transaction and this should not cause any problem in theory. Maybe it can be 
fixed in Django to use ALTER TABLE statement.
Ultimately, I can just get away with this problem if I switch to MySQL or 
PostgreSQL.
So, what should I do? Where should I report this 'bug' or 'problem'? SQLite? 
Django?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21c59661-bdba-43f6-9551-de1a6bf278de%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/CAD9jLPLTvpG%3D1-Psj%2BxdfORgy1ASov-Ue6RDU8UiwRNGM6tk1w%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/1897926499.413486.1566407846657%40mail.yahoo.com.


Re: Retrieving data from multiple tables

2019-08-21 Thread 'Amitesh Sahay' via Django users
I am not much of a database guy. But if you wish to get something from 
different table, then there has to be some foreignkey there I guess your 
"courses" table should have CID as foreignkey. May be I am wrong. 

On Wednesday, 21 August, 2019, 08:26:52 pm IST, Suraj Thapa FC 
 wrote:  
 
 Thanks... 
On Wed, 21 Aug, 2019, 6:24 PM Sundararajan Seshadri,  wrote:

What you need to appreciate is that the foreign key field gives you the full 
record (corresponding to the foreign key).
So, if you fetch all records as course_rating.objects.all() then c.cid will 
also be an object giving you the corresponding foreign key record. So, you can 
access c.cid.cid and c.cid.course_title.(where c is one instance / record of 
the query set)
Some points:(a) you are not following the convention. Not a crime. But if you 
follow the convention, it will prove convenient. For example. Courses will be 
the class name. (Table name can be anything)(b) You named the foreign-key in 
the second table as cid, It is, again, not an issue but if you followed the 
convention, you could have called it as course so that field names could have 
been c.course.cid and c.course.course_title, probably more meaningful.
Again, convention is for convenience. 
Cheers.
On Wednesday, August 21, 2019 at 2:46:12 PM UTC+5:30, Suraj Thapa FC wrote:
This is my model
class courses(models.Model): cid = models.UUIDField(default=uuid.uuid4, 
editable=True, primary_key=True) course_title = 
models.CharField(max_length=255, default="")

class course_rating(models.Model):cr_id = 
models.BigAutoField(primary_key=True)cid = 
models.ForeignKey(courses,on_delete=models.CASCADE)userid = 
models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)rating = 
models.IntegerField(validators[MaxValueValidator(5),MinValueValidator(1)],default=1)



I want to fetch the course_title and cid from courses tables and want to 
perform the average rating of courses Can someone write the query set for the 
same


-- 
You received this message because you are subscribed to the Google Groups 
"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/f49660db-c157-43df-8563-3e9c2369a8dd%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/CAPjsHcHkga3HSeBBTWSaRokmf-qNJq0txwOF6JvwjjsBOg_w_g%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/393408531.415507.1566408059600%40mail.yahoo.com.


Re: Regarding to suggestion for registration page

2019-08-21 Thread 'Amitesh Sahay' via Django users
I guess you have forgotten to mention the APP name under which the pages are 
created. Please cross-verify on my observation .


Regards,
Amitesh Sahay91-750 797 8619 

On Wednesday, 21 August, 2019, 12:35:28 pm IST, RONAK JAIN 
 wrote:  
 
 Hey I tried but still getting like that...
Attached screenshots take a look..


Thanks 
On Wed, Aug 21, 2019 at 12:23 PM Tosin Ayoola  wrote:

Using httpRedirect to d view 4 the URL u want user to b redirected to 
On Aug 21, 2019 06:21, "RONAK JAIN"  wrote:

I am trying to redirect my registration page but, I am not getting please check 
my attached screenshot and please let me know where I am doing wrong...


On Tue, Aug 20, 2019 at 10:26 AM Sipum  wrote:

Hey Ronit,
It is very simple. Just do return redirect ('/name used in url')
If ur url for home page be like,  path('home', views.index, name='home')
Then u hv to write as redirect('/home'). 

On Tue, 20 Aug, 2019, 9:43 AM Ronit Mishra,  wrote:

Hi,

If I've understood your issue correctly, you probably just need to add this 
lil' snippet in your settings.py

LOGIN_REDIRECT_URL = '/' (or wherever you wanna redirect after login)

Let me know if it works out for you!

Regards,
Ronnie
On Tue, Aug 20, 2019 at 2:40 AM Smovie Makers Club  wrote:

return redirect('{{ request.scheme }}://{{ request.get_host }}') This will 
redirect to home page
On Mon, 19 Aug 2019, 3:52 pm RONAK JAIN,  wrote:

Hello Django developers,
I am trying to redirect my registration page on the home page but, I am not 
getting when I am trying with a registration page it will work for registration 
but when I am doing with the home page so I am not getting.
Home Page : localhost:8000
Could you help me out with this problem?
Attached screenshots for Better Understanding please check it out.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BAqMUeYs7CALaGOmfFfJ%2BHp%3DWoKMyrjvYcOc8Za3JkTLFY_CQ%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/CAKqY%3DSTmdtAMa9N_zfcjgai_3XP7iGuXQgNsyPT2h5EuGCE7KQ%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/CACh0Ehx0QcsmJaU2NoV47WpJDgkSM-dpX9gkvvffgvD57uqoQA%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/CAGHZBzxwT7a_hPPSQ5XwE%3DaiDZv7nszXZZzcviKskyCHxSQGiQ%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/CA%2BAqMUfr2GkV1bxR9HOWH1Lv5FdknZcbULmAuWXrkCqiZDQS3g%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/CAHLKn72u3TFpjakgZ9GhzEv2DYZtFHLCKCmDwQbGbr%3D0htwfnw%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/CA%2BAqMUdmuRmA%2Br6P%2B4jmVsAe38XWkrpc6-q7D%2B9kjOr6_oe9og%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/1061381560.409727.1566408332049%40mail.yahoo.com.


UI for python windows applications

2019-08-21 Thread ARAVIND BALAKRISHNAN
Can anyone suggest me any modern UIs for python application in windows
other than electron

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


Re: Best DRF Cheatsheet?

2019-08-21 Thread mohammed habib
Maybe we should make one 


> On 21 Aug 2019, at 19:58, Charles Thayer  wrote:
> 
> I've been using Django with DRF off and on for probably over 5 years now. 
> There are still parts that I'm always needing to look up and review. Anyone 
> know of a one-pager cheatsheet that covers all the annoying details well, 
> like read_only vs write_only vs required, and nesting serializers, etc.?
> 
> Thanks,
> /charles
> -- 
> You received this message because you are subscribed to the Google Groups 
> "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/d768f5b6-c52d-4831-bf0a-aa27ca366d47%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/0373C37E-00AD-4397-A41A-9A9F90A91779%40gmail.com.


Looking for Django registration API

2019-08-21 Thread Sandip Nath
Are there any ready to use user authentication API for Django where user 
can register not only with username, password and email but also with date 
of birth, profile-url, picture etc?

-- 
You received this message because you are subscribed to the Google Groups 
"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/0cef9c81-2a80-48d9-a217-d9418fe94dfb%40googlegroups.com.


Re: Best DRF Cheatsheet?

2019-08-21 Thread Jani Tiainen
Hi.

Wouldn't it be much better to improve DRF documentation itself rather than
create yet an another documentation that you have to maintain?

ke 21. elok. 2019 klo 19.58 Charles Thayer  kirjoitti:

> I've been using Django with DRF off and on for probably over 5 years now.
> There are still parts that I'm always needing to look up and review. Anyone
> know of a one-pager cheatsheet that covers all the annoying details well,
> like read_only vs write_only vs required, and nesting serializers, etc.?
>
> Thanks,
> /charles
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/d768f5b6-c52d-4831-bf0a-aa27ca366d47%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/CAHn91ocpv2RH4b1DTd1QHReC965bAWvNYb6wfo8KHDYehMKXFg%40mail.gmail.com.


JWT Token

2019-08-21 Thread Mohammad Kokhaee
Hello guys
I've created token by JWT and 
My questions
 1-how to access to user information by token  ?
2-Is that the Right way and is that secure?

-- 
You received this message because you are subscribed to the Google Groups 
"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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%40googlegroups.com.


Re: JWT Token

2019-08-21 Thread Ronit Mishra
Hi,

First step is to authenticate and obtain the token. For instance, lets say
your endpoint is /api/token, so it'll only accepts POST requests.

>> post http://127.0.0.1:8000/api/token/ username=mohammad password=123

You can use cURL, or HTTPie or Python's requests module to test this.. Heck
you can go full commando on this, by building an Angular front..

The response will be of form:

{
"access":
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjU5LCJqdGkiOiIyYmQ1NjI3MmIzYjI0YjNmOGI1MjJlNThjMzdjMTdlMSIsInVzZXJfaWQiOjF9.D92tTuVi_YcNkJtiLGHtcn6tBcxLCBxz9FKD3qzhUg8",

"refresh":
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU0NTMxMDM1OSwianRpIjoiMjk2ZDc1ZDA3Nzc2NDE0ZjkxYjhiOTY4MzI4NGRmOTUiLCJ1c2VyX2lkIjoxfQ.rA-mnGRg71NEW_ga0sJoaMODS5ABjE5HnxJDb0F8xAo"
}

After that you are going to store both the access token and the refresh
token on the client side, usually in the localStorage.

In order to access the protected views on the backend (i.e., the API
endpoints that require authentication), you should include the access token
in the header of all requests, like this:

http://127.0.0.1:8000/hello/ "Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjAwLCJqdGkiOiJlMGQxZDY2MjE5ODc0ZTY3OWY0NjM0ZWU2NTQ2YTIwMCIsInVzZXJfaWQiOjF9.9eHat3CvRQYnb5EdcgYFzUyMobXzxlAVh_IAgqyvzCE"


Thats it!

And yes its the proper way of doing things!

Cheers, Ronnie


On Thu, Aug 22, 2019 at 3:46 AM Mohammad Kokhaee  wrote:

> Hello guys
> I've created token by JWT and
> My questions
>  1-how to access to user information by token  ?
> 2-Is that the Right way and is that secure?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%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/CACh0Ehy%3DmojgF_jb4EZPcb2%3D1TV75%2BBm6FLODFhaqS7%3DJYL67Q%40mail.gmail.com.


Re: JWT Token

2019-08-21 Thread Mohammad Kokhaee
Thanks for your explanation
 After the user send the token to server
What Should I do with the token to access to user id and user name and etc .
This is  project is mostly like blog web and when the user authenticate API
returns just post of this user .
I don't know how to reach user information with token in views or
serializer.

On Thu, Aug 22, 2019, 3:14 AM Ronit Mishra 
wrote:

> Hi,
>
> First step is to authenticate and obtain the token. For instance, lets
> say your endpoint is /api/token, so it'll only accepts POST requests.
>
> >> post http://127.0.0.1:8000/api/token/ username=mohammad password=123
>
> You can use cURL, or HTTPie or Python's requests module to test this..
> Heck you can go full commando on this, by building an Angular front..
>
> The response will be of form:
>
> {
> "access":
> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjU5LCJqdGkiOiIyYmQ1NjI3MmIzYjI0YjNmOGI1MjJlNThjMzdjMTdlMSIsInVzZXJfaWQiOjF9.D92tTuVi_YcNkJtiLGHtcn6tBcxLCBxz9FKD3qzhUg8",
>
> "refresh":
> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU0NTMxMDM1OSwianRpIjoiMjk2ZDc1ZDA3Nzc2NDE0ZjkxYjhiOTY4MzI4NGRmOTUiLCJ1c2VyX2lkIjoxfQ.rA-mnGRg71NEW_ga0sJoaMODS5ABjE5HnxJDb0F8xAo"
> }
>
> After that you are going to store both the access token and the refresh
> token on the client side, usually in the localStorage.
>
> In order to access the protected views on the backend (i.e., the API
> endpoints that require authentication), you should include the access token
> in the header of all requests, like this:
>
> http://127.0.0.1:8000/hello/ "Authorization: Bearer
> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjAwLCJqdGkiOiJlMGQxZDY2MjE5ODc0ZTY3OWY0NjM0ZWU2NTQ2YTIwMCIsInVzZXJfaWQiOjF9.9eHat3CvRQYnb5EdcgYFzUyMobXzxlAVh_IAgqyvzCE"
>
>
> Thats it!
>
> And yes its the proper way of doing things!
>
> Cheers, Ronnie
>
>
> On Thu, Aug 22, 2019 at 3:46 AM Mohammad Kokhaee 
> wrote:
>
>> Hello guys
>> I've created token by JWT and
>> My questions
>>  1-how to access to user information by token  ?
>> 2-Is that the Right way and is that secure?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%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/CACh0Ehy%3DmojgF_jb4EZPcb2%3D1TV75%2BBm6FLODFhaqS7%3DJYL67Q%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/CAHdYFMMeZos2z-yPhHJ3kk_pwY0vORfUNK%2BZeTMQ%3D-%2BVt61MMA%40mail.gmail.com.


Re: JWT Token

2019-08-21 Thread Ronit Mishra
You woulld be having some api/profile endpoint, in your project where user
details would be available. Send a post request with access token just like
I explained in the previous email and you should get the response with
profile details.

On Thu, Aug 22, 2019 at 5:13 AM Mohammad Kokhaee  wrote:

> Thanks for your explanation
>  After the user send the token to server
> What Should I do with the token to access to user id and user name and etc
> .
> This is  project is mostly like blog web and when the user authenticate
> API returns just post of this user .
> I don't know how to reach user information with token in views or
> serializer.
>
> On Thu, Aug 22, 2019, 3:14 AM Ronit Mishra 
> wrote:
>
>> Hi,
>>
>> First step is to authenticate and obtain the token. For instance, lets
>> say your endpoint is /api/token, so it'll only accepts POST requests.
>>
>> >> post http://127.0.0.1:8000/api/token/ username=mohammad password=123
>>
>> You can use cURL, or HTTPie or Python's requests module to test this..
>> Heck you can go full commando on this, by building an Angular front..
>>
>> The response will be of form:
>>
>> {
>> "access":
>> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjU5LCJqdGkiOiIyYmQ1NjI3MmIzYjI0YjNmOGI1MjJlNThjMzdjMTdlMSIsInVzZXJfaWQiOjF9.D92tTuVi_YcNkJtiLGHtcn6tBcxLCBxz9FKD3qzhUg8",
>>
>> "refresh":
>> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU0NTMxMDM1OSwianRpIjoiMjk2ZDc1ZDA3Nzc2NDE0ZjkxYjhiOTY4MzI4NGRmOTUiLCJ1c2VyX2lkIjoxfQ.rA-mnGRg71NEW_ga0sJoaMODS5ABjE5HnxJDb0F8xAo"
>> }
>>
>> After that you are going to store both the access token and the refresh
>> token on the client side, usually in the localStorage.
>>
>> In order to access the protected views on the backend (i.e., the API
>> endpoints that require authentication), you should include the access token
>> in the header of all requests, like this:
>>
>> http://127.0.0.1:8000/hello/ "Authorization: Bearer
>> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjAwLCJqdGkiOiJlMGQxZDY2MjE5ODc0ZTY3OWY0NjM0ZWU2NTQ2YTIwMCIsInVzZXJfaWQiOjF9.9eHat3CvRQYnb5EdcgYFzUyMobXzxlAVh_IAgqyvzCE"
>>
>>
>> Thats it!
>>
>> And yes its the proper way of doing things!
>>
>> Cheers, Ronnie
>>
>>
>> On Thu, Aug 22, 2019 at 3:46 AM Mohammad Kokhaee 
>> wrote:
>>
>>> Hello guys
>>> I've created token by JWT and
>>> My questions
>>>  1-how to access to user information by token  ?
>>> 2-Is that the Right way and is that secure?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%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/CACh0Ehy%3DmojgF_jb4EZPcb2%3D1TV75%2BBm6FLODFhaqS7%3DJYL67Q%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/CAHdYFMMeZos2z-yPhHJ3kk_pwY0vORfUNK%2BZeTMQ%3D-%2BVt61MMA%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/CACh0EhyvL%2BhGX3XK_51ZHe%2BL2j_mf0KeFQ7QEt84WwiwjseuMA%40mail.gmail.com.


Re: JWT Token

2019-08-21 Thread Mohammad Kokhaee
I get that clearly
But how to get the Response
Sorry I'm new

On Thu, Aug 22, 2019, 4:37 AM Ronit Mishra 
wrote:

> You woulld be having some api/profile endpoint, in your project where user
> details would be available. Send a post request with access token just like
> I explained in the previous email and you should get the response with
> profile details.
>
> On Thu, Aug 22, 2019 at 5:13 AM Mohammad Kokhaee 
> wrote:
>
>> Thanks for your explanation
>>  After the user send the token to server
>> What Should I do with the token to access to user id and user name and
>> etc .
>> This is  project is mostly like blog web and when the user authenticate
>> API returns just post of this user .
>> I don't know how to reach user information with token in views or
>> serializer.
>>
>> On Thu, Aug 22, 2019, 3:14 AM Ronit Mishra 
>> wrote:
>>
>>> Hi,
>>>
>>> First step is to authenticate and obtain the token. For instance, lets
>>> say your endpoint is /api/token, so it'll only accepts POST requests.
>>>
>>> >> post http://127.0.0.1:8000/api/token/ username=mohammad password=123
>>>
>>> You can use cURL, or HTTPie or Python's requests module to test this..
>>> Heck you can go full commando on this, by building an Angular front..
>>>
>>> The response will be of form:
>>>
>>> {
>>> "access":
>>> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjU5LCJqdGkiOiIyYmQ1NjI3MmIzYjI0YjNmOGI1MjJlNThjMzdjMTdlMSIsInVzZXJfaWQiOjF9.D92tTuVi_YcNkJtiLGHtcn6tBcxLCBxz9FKD3qzhUg8",
>>>
>>> "refresh":
>>> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU0NTMxMDM1OSwianRpIjoiMjk2ZDc1ZDA3Nzc2NDE0ZjkxYjhiOTY4MzI4NGRmOTUiLCJ1c2VyX2lkIjoxfQ.rA-mnGRg71NEW_ga0sJoaMODS5ABjE5HnxJDb0F8xAo"
>>> }
>>>
>>> After that you are going to store both the access token and the refresh
>>> token on the client side, usually in the localStorage.
>>>
>>> In order to access the protected views on the backend (i.e., the API
>>> endpoints that require authentication), you should include the access token
>>> in the header of all requests, like this:
>>>
>>> http://127.0.0.1:8000/hello/ "Authorization: Bearer
>>> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjAwLCJqdGkiOiJlMGQxZDY2MjE5ODc0ZTY3OWY0NjM0ZWU2NTQ2YTIwMCIsInVzZXJfaWQiOjF9.9eHat3CvRQYnb5EdcgYFzUyMobXzxlAVh_IAgqyvzCE"
>>>
>>>
>>> Thats it!
>>>
>>> And yes its the proper way of doing things!
>>>
>>> Cheers, Ronnie
>>>
>>>
>>> On Thu, Aug 22, 2019 at 3:46 AM Mohammad Kokhaee 
>>> wrote:
>>>
 Hello guys
 I've created token by JWT and
 My questions
  1-how to access to user information by token  ?
 2-Is that the Right way and is that secure?

 --
 You received this message because you are subscribed to the Google
 Groups "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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%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/CACh0Ehy%3DmojgF_jb4EZPcb2%3D1TV75%2BBm6FLODFhaqS7%3DJYL67Q%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/CAHdYFMMeZos2z-yPhHJ3kk_pwY0vORfUNK%2BZeTMQ%3D-%2BVt61MMA%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/CACh0EhyvL%2BhGX3XK_51ZHe%2BL2j_mf0KeFQ7QEt84WwiwjseuMA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe fro

Re: Regarding to suggestion for registration page

2019-08-21 Thread 'Gaurav Ravindra Bole' via Django users
in register method
add user.set_password = request.POST.get('password') before user.save()

On Wed, Aug 21, 2019 at 10:56 PM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> I guess you have forgotten to mention the APP name under which the pages
> are created. Please cross-verify on my observation .
>
> Regards,
> Amitesh Sahay
> *91-750 797 8619*
>
>
> On Wednesday, 21 August, 2019, 12:35:28 pm IST, RONAK JAIN <
> jainronak...@gmail.com> wrote:
>
>
> Hey
> I tried but still getting like that...
>
> Attached screenshots take a look..
>
>
>
> Thanks
>
> On Wed, Aug 21, 2019 at 12:23 PM Tosin Ayoola 
> wrote:
>
> Using httpRedirect to d view 4 the URL u want user to b redirected to
>
> On Aug 21, 2019 06:21, "RONAK JAIN"  wrote:
>
> I am trying to redirect my registration page but, I am not getting *please
> check my attached screenshot* and please let me know where I am doing
> wrong...
>
>
>
> On Tue, Aug 20, 2019 at 10:26 AM Sipum  wrote:
>
> Hey Ronit,
>
> It is very simple.
> Just do return redirect ('/name used in url')
>
> If ur url for home page be like,  path('home', views.index, name='home')
>
> Then u hv to write as redirect('/home').
>
>
> On Tue, 20 Aug, 2019, 9:43 AM Ronit Mishra, 
> wrote:
>
> Hi,
>
> If I've understood your issue correctly, you probably just need to add
> this lil' snippet in your settings.py
>
> LOGIN_REDIRECT_URL = '/' (or wherever you wanna redirect after login)
>
> Let me know if it works out for you!
>
> Regards,
> Ronnie
>
> On Tue, Aug 20, 2019 at 2:40 AM Smovie Makers Club 
> wrote:
>
> return redirect('{{ request.scheme }}://{{ request.get_host }}')
> This will redirect to home page
>
> On Mon, 19 Aug 2019, 3:52 pm RONAK JAIN,  wrote:
>
> Hello Django developers,
>
> I am trying to redirect my registration page on the home page but, I am
> not getting when I am trying with a registration page it will work for
> registration but when I am doing with the home page so I am not getting.
>
> *Home Page : localhost:8000*
>
> *Could you help me out with this problem?*
>
> *Attached screenshots for Better Understanding please check it out.*
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BAqMUeYs7CALaGOmfFfJ%2BHp%3DWoKMyrjvYcOc8Za3JkTLFY_CQ%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/CAKqY%3DSTmdtAMa9N_zfcjgai_3XP7iGuXQgNsyPT2h5EuGCE7KQ%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/CACh0Ehx0QcsmJaU2NoV47WpJDgkSM-dpX9gkvvffgvD57uqoQA%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/CAGHZBzxwT7a_hPPSQ5XwE%3DaiDZv7nszXZZzcviKskyCHxSQGiQ%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/CA%2BAqMUfr2GkV1bxR9HOWH1Lv5FdknZcbULmAuWXrkCqiZDQS3g%40mail.gmail.com
> 
> .
>
> --
> You received this message because you are 

Re: UI for python windows applications

2019-08-21 Thread Anish Chapagain
Have you tried Gooey https://pypi.org/project/Gooey/ ,
PyQt  https://pypi.org/project/PyQt5/



On Wed, 21 Aug 2019 at 23:31, ARAVIND BALAKRISHNAN <
aravindbalan...@gmail.com> wrote:

> Can anyone suggest me any modern UIs for python application in windows
> other than electron
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAAPzrPmrGggPErwdQ48diZVsRAgGn7MbqhvfAJJAQtNJ%2B8sxng%40mail.gmail.com
> 
> .
>


-- 
Regards,
Anish C.

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


3D Object Interaction

2019-08-21 Thread Lim Kai Wey
Greetings,

I would like to ask if anyone has a suggested way for creating a 3D object
which can be interacted with on Django. Any suggestions are welcomed.

Thanks in advance.

Regards,
Kai Wey

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


Re: Regarding to suggestion for registration page

2019-08-21 Thread Sipum
Hey Ronak,

At first u did wrong in import.

Do as below and compare what u have done.

>From django.contrib.auth.models import User
>From django.contrib import auth

Then when u are creating user do as-
 user = User.objects.create_user(uanme,pwd,email)

THEN for login after sign up use as below -
auth.login(request, user)

On Thu, 22 Aug, 2019, 10:02 AM 'Gaurav Ravindra Bole' via Django users, <
django-users@googlegroups.com> wrote:

> in register method
> add user.set_password = request.POST.get('password') before user.save()
>
> On Wed, Aug 21, 2019 at 10:56 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> I guess you have forgotten to mention the APP name under which the pages
>> are created. Please cross-verify on my observation .
>>
>> Regards,
>> Amitesh Sahay
>> *91-750 797 8619*
>>
>>
>> On Wednesday, 21 August, 2019, 12:35:28 pm IST, RONAK JAIN <
>> jainronak...@gmail.com> wrote:
>>
>>
>> Hey
>> I tried but still getting like that...
>>
>> Attached screenshots take a look..
>>
>>
>>
>> Thanks
>>
>> On Wed, Aug 21, 2019 at 12:23 PM Tosin Ayoola 
>> wrote:
>>
>> Using httpRedirect to d view 4 the URL u want user to b redirected to
>>
>> On Aug 21, 2019 06:21, "RONAK JAIN"  wrote:
>>
>> I am trying to redirect my registration page but, I am not getting *please
>> check my attached screenshot* and please let me know where I am doing
>> wrong...
>>
>>
>>
>> On Tue, Aug 20, 2019 at 10:26 AM Sipum  wrote:
>>
>> Hey Ronit,
>>
>> It is very simple.
>> Just do return redirect ('/name used in url')
>>
>> If ur url for home page be like,  path('home', views.index, name='home')
>>
>> Then u hv to write as redirect('/home').
>>
>>
>> On Tue, 20 Aug, 2019, 9:43 AM Ronit Mishra, 
>> wrote:
>>
>> Hi,
>>
>> If I've understood your issue correctly, you probably just need to add
>> this lil' snippet in your settings.py
>>
>> LOGIN_REDIRECT_URL = '/' (or wherever you wanna redirect after login)
>>
>> Let me know if it works out for you!
>>
>> Regards,
>> Ronnie
>>
>> On Tue, Aug 20, 2019 at 2:40 AM Smovie Makers Club 
>> wrote:
>>
>> return redirect('{{ request.scheme }}://{{ request.get_host }}')
>> This will redirect to home page
>>
>> On Mon, 19 Aug 2019, 3:52 pm RONAK JAIN,  wrote:
>>
>> Hello Django developers,
>>
>> I am trying to redirect my registration page on the home page but, I am
>> not getting when I am trying with a registration page it will work for
>> registration but when I am doing with the home page so I am not getting.
>>
>> *Home Page : localhost:8000*
>>
>> *Could you help me out with this problem?*
>>
>> *Attached screenshots for Better Understanding please check it out.*
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2BAqMUeYs7CALaGOmfFfJ%2BHp%3DWoKMyrjvYcOc8Za3JkTLFY_CQ%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/CAKqY%3DSTmdtAMa9N_zfcjgai_3XP7iGuXQgNsyPT2h5EuGCE7KQ%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/CACh0Ehx0QcsmJaU2NoV47WpJDgkSM-dpX9gkvvffgvD57uqoQA%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/CAGHZBzxwT7a_hPPSQ5XwE%3DaiDZv7nszXZZzcviKskyCHxSQGiQ%40mail.gmail.com
>> 
>> .
>>
>> --
>> You received this message beca

Re: JWT Token

2019-08-21 Thread Suraj Thapa FC
token = request. Meta['HTTP_AUTHORIZATION']
data = {'token' : token}
payload_decoded = jwt.decode(token, settings.SECRET_KEY)
try:
  valid_data = VerifyJSONWebTokenSerilaizer().validate(data)

 user = valid_data['user']
 self.request.user = user
except:
  pass



On Thu, 22 Aug, 2019, 5:41 AM Mohammad Kokhaee,  wrote:

> I get that clearly
> But how to get the Response
> Sorry I'm new
>
> On Thu, Aug 22, 2019, 4:37 AM Ronit Mishra 
> wrote:
>
>> You woulld be having some api/profile endpoint, in your project where
>> user details would be available. Send a post request with access token just
>> like I explained in the previous email and you should get the response with
>> profile details.
>>
>> On Thu, Aug 22, 2019 at 5:13 AM Mohammad Kokhaee 
>> wrote:
>>
>>> Thanks for your explanation
>>>  After the user send the token to server
>>> What Should I do with the token to access to user id and user name and
>>> etc .
>>> This is  project is mostly like blog web and when the user authenticate
>>> API returns just post of this user .
>>> I don't know how to reach user information with token in views or
>>> serializer.
>>>
>>> On Thu, Aug 22, 2019, 3:14 AM Ronit Mishra 
>>> wrote:
>>>
 Hi,

 First step is to authenticate and obtain the token. For instance, lets
 say your endpoint is /api/token, so it'll only accepts POST requests.

 >> post http://127.0.0.1:8000/api/token/ username=mohammad password=123

 You can use cURL, or HTTPie or Python's requests module to test this..
 Heck you can go full commando on this, by building an Angular front..

 The response will be of form:

 {
 "access":
 "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjU5LCJqdGkiOiIyYmQ1NjI3MmIzYjI0YjNmOGI1MjJlNThjMzdjMTdlMSIsInVzZXJfaWQiOjF9.D92tTuVi_YcNkJtiLGHtcn6tBcxLCBxz9FKD3qzhUg8",

 "refresh":
 "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU0NTMxMDM1OSwianRpIjoiMjk2ZDc1ZDA3Nzc2NDE0ZjkxYjhiOTY4MzI4NGRmOTUiLCJ1c2VyX2lkIjoxfQ.rA-mnGRg71NEW_ga0sJoaMODS5ABjE5HnxJDb0F8xAo"
 }

 After that you are going to store both the access token and the refresh
 token on the client side, usually in the localStorage.

 In order to access the protected views on the backend (i.e., the API
 endpoints that require authentication), you should include the access token
 in the header of all requests, like this:

 http://127.0.0.1:8000/hello/ "Authorization: Bearer
 eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTQ1MjI0MjAwLCJqdGkiOiJlMGQxZDY2MjE5ODc0ZTY3OWY0NjM0ZWU2NTQ2YTIwMCIsInVzZXJfaWQiOjF9.9eHat3CvRQYnb5EdcgYFzUyMobXzxlAVh_IAgqyvzCE"


 Thats it!

 And yes its the proper way of doing things!

 Cheers, Ronnie


 On Thu, Aug 22, 2019 at 3:46 AM Mohammad Kokhaee 
 wrote:

> Hello guys
> I've created token by JWT and
> My questions
>  1-how to access to user information by token  ?
> 2-Is that the Right way and is that secure?
>
> --
> You received this message because you are subscribed to the Google
> Groups "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/b766250f-2fa7-4cb0-afc5-2e4a442dad1a%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/CACh0Ehy%3DmojgF_jb4EZPcb2%3D1TV75%2BBm6FLODFhaqS7%3DJYL67Q%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/CAHdYFMMeZos2z-yPhHJ3kk_pwY0vORfUNK%2BZeTMQ%3D-%2BVt61MMA%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.

Re: Retrieving data from multiple tables

2019-08-21 Thread Suraj Thapa FC
Yes it has

Can you write the query for the above question asked

On Wed, 21 Aug, 2019, 10:51 PM 'Amitesh Sahay' via Django users, <
django-users@googlegroups.com> wrote:

> I am not much of a database guy. But if you wish to get something from
> different table, then there has to be some foreignkey there I guess your
> "courses" table should have CID as foreignkey. May be I am wrong.
>
>
> On Wednesday, 21 August, 2019, 08:26:52 pm IST, Suraj Thapa FC <
> surajthap...@gmail.com> wrote:
>
>
> Thanks...
>
> On Wed, 21 Aug, 2019, 6:24 PM Sundararajan Seshadri, 
> wrote:
>
> What you need to appreciate is that the foreign key field gives you the
> full record (corresponding to the foreign key).
>
> So, if you fetch all records as course_rating.objects.all() then c.cid
> will also be an object giving you the corresponding foreign key record. So,
> you can access c.cid.cid and c.cid.course_title.(where c is one instance /
> record of the query set)
>
> Some points:
> (a) you are not following the convention. Not a crime. But if you follow
> the convention, it will prove convenient. For example. Courses will be the
> class name. (Table name can be anything)
> (b) You named the foreign-key in the second table as cid, It is, again,
> not an issue but if you followed the convention, you could have called it
> as course so that field names could have been c.course.cid and
> c.course.course_title, probably more meaningful.
>
> Again, convention is for convenience.
>
> Cheers.
> 
> On Wednesday, August 21, 2019 at 2:46:12 PM UTC+5:30, Suraj Thapa FC wrote:
>
> This is my model
>
> class courses(models.Model):
> cid = models.UUIDField(default=uuid.uuid4, editable=True, primary_key=True)
> course_title = models.CharField(max_length=255, default="")
>
>
> class course_rating(models.Model):
> cr_id = models.BigAutoField(primary_key=True)
> cid = models.ForeignKey(courses,on_delete=models.CASCADE)
> userid =
> models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
> rating =
> models.IntegerField(validators[MaxValueValidator(5),MinValueValidator(1)],default=1)
>
>
>
>
> I want to fetch the course_title and cid from courses tables and want to
> perform the average rating of courses
> Can someone write the query set for the same
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/f49660db-c157-43df-8563-3e9c2369a8dd%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/CAPjsHcHkga3HSeBBTWSaRokmf-qNJq0txwOF6JvwjjsBOg_w_g%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/393408531.415507.1566408059600%40mail.yahoo.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/CAPjsHcFC0fxEEJ0vfjkFH9go4K0AT9B%3D3rrJ9NTHXfH84AKqpw%40mail.gmail.com.


Re: Regarding to suggestion for registration page

2019-08-21 Thread RONAK JAIN
Thank you so much all of you for your kind of help.


I have done this Task.


Thanks





On Thu, Aug 22, 2019 at 10:21 AM Sipum  wrote:

> Hey Ronak,
>
> At first u did wrong in import.
>
> Do as below and compare what u have done.
>
> From django.contrib.auth.models import User
> From django.contrib import auth
>
> Then when u are creating user do as-
>  user = User.objects.create_user(uanme,pwd,email)
>
> THEN for login after sign up use as below -
> auth.login(request, user)
>
> On Thu, 22 Aug, 2019, 10:02 AM 'Gaurav Ravindra Bole' via Django users, <
> django-users@googlegroups.com> wrote:
>
>> in register method
>> add user.set_password = request.POST.get('password') before user.save()
>>
>> On Wed, Aug 21, 2019 at 10:56 PM 'Amitesh Sahay' via Django users <
>> django-users@googlegroups.com> wrote:
>>
>>> I guess you have forgotten to mention the APP name under which the pages
>>> are created. Please cross-verify on my observation .
>>>
>>> Regards,
>>> Amitesh Sahay
>>> *91-750 797 8619*
>>>
>>>
>>> On Wednesday, 21 August, 2019, 12:35:28 pm IST, RONAK JAIN <
>>> jainronak...@gmail.com> wrote:
>>>
>>>
>>> Hey
>>> I tried but still getting like that...
>>>
>>> Attached screenshots take a look..
>>>
>>>
>>>
>>> Thanks
>>>
>>> On Wed, Aug 21, 2019 at 12:23 PM Tosin Ayoola 
>>> wrote:
>>>
>>> Using httpRedirect to d view 4 the URL u want user to b redirected to
>>>
>>> On Aug 21, 2019 06:21, "RONAK JAIN"  wrote:
>>>
>>> I am trying to redirect my registration page but, I am not getting *please
>>> check my attached screenshot* and please let me know where I am doing
>>> wrong...
>>>
>>>
>>>
>>> On Tue, Aug 20, 2019 at 10:26 AM Sipum  wrote:
>>>
>>> Hey Ronit,
>>>
>>> It is very simple.
>>> Just do return redirect ('/name used in url')
>>>
>>> If ur url for home page be like,  path('home', views.index, name='home')
>>>
>>> Then u hv to write as redirect('/home').
>>>
>>>
>>> On Tue, 20 Aug, 2019, 9:43 AM Ronit Mishra, 
>>> wrote:
>>>
>>> Hi,
>>>
>>> If I've understood your issue correctly, you probably just need to add
>>> this lil' snippet in your settings.py
>>>
>>> LOGIN_REDIRECT_URL = '/' (or wherever you wanna redirect after login)
>>>
>>> Let me know if it works out for you!
>>>
>>> Regards,
>>> Ronnie
>>>
>>> On Tue, Aug 20, 2019 at 2:40 AM Smovie Makers Club 
>>> wrote:
>>>
>>> return redirect('{{ request.scheme }}://{{ request.get_host }}')
>>> This will redirect to home page
>>>
>>> On Mon, 19 Aug 2019, 3:52 pm RONAK JAIN,  wrote:
>>>
>>> Hello Django developers,
>>>
>>> I am trying to redirect my registration page on the home page but, I am
>>> not getting when I am trying with a registration page it will work for
>>> registration but when I am doing with the home page so I am not getting.
>>>
>>> *Home Page : localhost:8000*
>>>
>>> *Could you help me out with this problem?*
>>>
>>> *Attached screenshots for Better Understanding please check it out.*
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2BAqMUeYs7CALaGOmfFfJ%2BHp%3DWoKMyrjvYcOc8Za3JkTLFY_CQ%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/CAKqY%3DSTmdtAMa9N_zfcjgai_3XP7iGuXQgNsyPT2h5EuGCE7KQ%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/CACh0Ehx0QcsmJaU2NoV47WpJDgkSM-dpX9gkvvffgvD57uqoQA%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/msgi

Re: Regarding to suggestion for registration page

2019-08-21 Thread Sipum
Can u plz tell what you have done so we can learn also.

On Thu, 22 Aug, 2019, 11:16 AM RONAK JAIN,  wrote:

> Thank you so much all of you for your kind of help.
>
>
> I have done this Task.
>
>
> Thanks
>
>
>
>
>
> On Thu, Aug 22, 2019 at 10:21 AM Sipum  wrote:
>
>> Hey Ronak,
>>
>> At first u did wrong in import.
>>
>> Do as below and compare what u have done.
>>
>> From django.contrib.auth.models import User
>> From django.contrib import auth
>>
>> Then when u are creating user do as-
>>  user = User.objects.create_user(uanme,pwd,email)
>>
>> THEN for login after sign up use as below -
>> auth.login(request, user)
>>
>> On Thu, 22 Aug, 2019, 10:02 AM 'Gaurav Ravindra Bole' via Django users, <
>> django-users@googlegroups.com> wrote:
>>
>>> in register method
>>> add user.set_password = request.POST.get('password') before user.save()
>>>
>>> On Wed, Aug 21, 2019 at 10:56 PM 'Amitesh Sahay' via Django users <
>>> django-users@googlegroups.com> wrote:
>>>
 I guess you have forgotten to mention the APP name under which the
 pages are created. Please cross-verify on my observation .

 Regards,
 Amitesh Sahay
 *91-750 797 8619*


 On Wednesday, 21 August, 2019, 12:35:28 pm IST, RONAK JAIN <
 jainronak...@gmail.com> wrote:


 Hey
 I tried but still getting like that...

 Attached screenshots take a look..



 Thanks

 On Wed, Aug 21, 2019 at 12:23 PM Tosin Ayoola 
 wrote:

 Using httpRedirect to d view 4 the URL u want user to b redirected to

 On Aug 21, 2019 06:21, "RONAK JAIN"  wrote:

 I am trying to redirect my registration page but, I am not getting *please
 check my attached screenshot* and please let me know where I am doing
 wrong...



 On Tue, Aug 20, 2019 at 10:26 AM Sipum  wrote:

 Hey Ronit,

 It is very simple.
 Just do return redirect ('/name used in url')

 If ur url for home page be like,  path('home', views.index, name='home')

 Then u hv to write as redirect('/home').


 On Tue, 20 Aug, 2019, 9:43 AM Ronit Mishra, 
 wrote:

 Hi,

 If I've understood your issue correctly, you probably just need to add
 this lil' snippet in your settings.py

 LOGIN_REDIRECT_URL = '/' (or wherever you wanna redirect after login)

 Let me know if it works out for you!

 Regards,
 Ronnie

 On Tue, Aug 20, 2019 at 2:40 AM Smovie Makers Club 
 wrote:

 return redirect('{{ request.scheme }}://{{ request.get_host }}')
 This will redirect to home page

 On Mon, 19 Aug 2019, 3:52 pm RONAK JAIN, 
 wrote:

 Hello Django developers,

 I am trying to redirect my registration page on the home page but, I am
 not getting when I am trying with a registration page it will work for
 registration but when I am doing with the home page so I am not getting.

 *Home Page : localhost:8000*

 *Could you help me out with this problem?*

 *Attached screenshots for Better Understanding please check it out.*


 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CA%2BAqMUeYs7CALaGOmfFfJ%2BHp%3DWoKMyrjvYcOc8Za3JkTLFY_CQ%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/CAKqY%3DSTmdtAMa9N_zfcjgai_3XP7iGuXQgNsyPT2h5EuGCE7KQ%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/CACh0Ehx0QcsmJaU2NoV47WpJDgkSM-dpX9gkvvffgvD57uqoQA%40mail.gmail.com
 
 .

 --
 You received this message because you are sub

Django Template url mapping

2019-08-21 Thread RONAK JAIN
Hi

I am new in Django I am doing struggle with add  Django templates using by
inheritance.


so when I am trying within *Example::  index.html  add inside the blog.html
but, *I am getting the direct blog.html, not index.html on the index page.


so I used simply in index.html.

*index.html:*

{%. include  "blog.html"   %}

*view.py*

class blog(TemplateView):
template_name = "blog.html"


*or Can I use templateview for dynamically ?*



can you help me with that? how can I render dynamically my blog.html file?.


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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BAqMUdZDk3ce7HY5WTTB0uVNA%3DYsnx3OxUj3x4rf3%3D-2AfMBA%40mail.gmail.com.