Re: Bug using Admin with Stripe - but whose is it?

2022-05-06 Thread Ahmed omar miladi
Hello mike i hope you are doing well can we make a video call to solve this
problem i can be helpfull

On Sat, 7 May 2022 at 01:56, Mike Dewhirst  wrote:

> OK - don't worry about this for the time being. The problem is obviously
> where I haven't yet looked. So I'm now going to simplify every bit of
> code/html/css following the successful acquisition of the Stripe token
> to see if it suddenly starts working.
>
> M
>
> On 6/05/2022 6:07 pm, Mike Dewhirst wrote:
> > I'm obviously at fault but I'm not smart enough to figure it out. Any
> > help is appreciated.
> >
> > The mechanism below exhibits no errors at the Stripe end. Stripe
> > returns the necessary payment token. I have tried brutally stripping
> > of the "/change/payment" and while it silences the error, the form
> > just re-shows itself.
> >
> >  I see a similar problem in 32-bit iOS Safari which doesn't
> > seem to like the svg tick symbol displayed in the Admin change screen
> > success message. The only symptom is the tick doesn't appear and the
> > user is none the wiser. But it generates an error email Field 'id'
> > expected a number but got '55/img/icon-yes.svg' 
> >
> >
> >  ValueError at /admin/chemical/chemical/20/change/payment/change/
> >
> > Field 'id' expected a number but got '20/change/payment'.
> >
> > Request Method: GET
> > Request URL:
> > http://localhost:8088/admin/chemical/chemical/20/change/payment/change/
> > Django Version: 3.2.13
> > Exception Type: ValueError
> > Exception Value:
> >
> > Field 'id' expected a number but got '20/change/payment'.
> >
> > Exception Location:
> >
> D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py,
>
> > line 1825, in get_prep_value
> > Python Executable: D:\Users\mike\envs\xxai\Scripts\python.exe
> > Python Version: 3.8.3
> >
> >
> > Here is the ChemicalAdmin.change_view(). I filled in the docstring a
> > year ago when debugging previously.
> >
> > def change_view(self, request, object_id, form_url="",
> > extra_context=None):
> > """
> > self = ChemicalAdmin
> > object_id = chemical
> > form_url is passed through to self.render_change_form() via
> > self.get_preserved_filters(request) and then added to context
> > extra_context = dict of apps, models, admin_urls and
> > permissions. Ensure
> > self.change_form_template = None so next time it doesn't use
> > payment.html
> > """
> > extra_context = extra_context or {}
> > self.change_form_template = None
> > chemical = Chemical.objects.get(id=object_id)
> > intro = chemical.get_introduction()
> > if intro and not chemical.token:
> > if intro.category in CHARGE:
> > self.change_form_template = "payment.html"
> > context = collect_gateway_context(chemical)
> > extra_context.update(self.admin_site.each_context(request))
> > extra_context.update(context)
> > self.admin_site.admin_view(
> > payment_view(request, chemical,
> > context=extra_context)
> > )
> > return super().change_view(request, object_id, form_url,
> > extra_context)
> >
> > And the url config ...
> >
> > re_path(r"invoice/(?P\d+)/$", billing_views.invoice_view,
> > name="invoice_view"),
> > re_path(r"payment/$", billing_views.payment_view,
> > name="payment_view"),
> > re_path(r"success/$", billing_views.success_view,
> > name="success_view"),
> >
> > And the payment.html form ...
> >
> > 
> > {% csrf_token %}
> > {% if form.errors or form.non_field_errors %}
> > {{ form.errors }}
> > {{ form.non_field_errors }}
> > {% endif %}
> > {% for field in form %}
> > {% if field.name == "chemical_id" %}
> >  > id="id_chemical_id" value="{{ chemical.id }}" />
> > {% else %}
> > {{ field }}
> > {% endif %}
> > {% endfor %}
> >  >   src="https://checkout.stripe.com/checkout.js";
> > class="stripe-button"
> >   data-key="{{ data_key }}"
> >   data-amount="{{ data_amount }}"
> >   data-name="{{ data_name }}"
> >   data-description="{{ data_description }}"
> >   data-image="{{ data_image }}"
> >   data-locale="{{ data_locale }}"
> >   data-currency="{{ data_currency | lower }}"
> >   data-zip-code="true"
> >   data-panel-label="Pay">
> > 
> > 
> >
> > Thanks
> >
> > Mike
> >
> >
> >
>
>
> --
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
> --
> You received this message b

Re: Bug using Admin with Stripe - but whose is it?

2022-05-06 Thread Mike Dewhirst
OK - don't worry about this for the time being. The problem is obviously 
where I haven't yet looked. So I'm now going to simplify every bit of 
code/html/css following the successful acquisition of the Stripe token 
to see if it suddenly starts working.


M

On 6/05/2022 6:07 pm, Mike Dewhirst wrote:
I'm obviously at fault but I'm not smart enough to figure it out. Any 
help is appreciated.


The mechanism below exhibits no errors at the Stripe end. Stripe 
returns the necessary payment token. I have tried brutally stripping 
of the "/change/payment" and while it silences the error, the form 
just re-shows itself.


 I see a similar problem in 32-bit iOS Safari which doesn't 
seem to like the svg tick symbol displayed in the Admin change screen 
success message. The only symptom is the tick doesn't appear and the 
user is none the wiser. But it generates an error email Field 'id' 
expected a number but got '55/img/icon-yes.svg' 



 ValueError at /admin/chemical/chemical/20/change/payment/change/

Field 'id' expected a number but got '20/change/payment'.

Request Method: GET
Request URL: 
http://localhost:8088/admin/chemical/chemical/20/change/payment/change/

Django Version: 3.2.13
Exception Type: ValueError
Exception Value:

Field 'id' expected a number but got '20/change/payment'.

Exception Location: 
D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py, 
line 1825, in get_prep_value

Python Executable: D:\Users\mike\envs\xxai\Scripts\python.exe
Python Version: 3.8.3


Here is the ChemicalAdmin.change_view(). I filled in the docstring a 
year ago when debugging previously.


    def change_view(self, request, object_id, form_url="", 
extra_context=None):

    """
    self = ChemicalAdmin
    object_id = chemical
    form_url is passed through to self.render_change_form() via
    self.get_preserved_filters(request) and then added to context
    extra_context = dict of apps, models, admin_urls and 
permissions. Ensure
    self.change_form_template = None so next time it doesn't use 
payment.html

    """
    extra_context = extra_context or {}
    self.change_form_template = None
    chemical = Chemical.objects.get(id=object_id)
    intro = chemical.get_introduction()
    if intro and not chemical.token:
    if intro.category in CHARGE:
    self.change_form_template = "payment.html"
    context = collect_gateway_context(chemical)
extra_context.update(self.admin_site.each_context(request))
    extra_context.update(context)
    self.admin_site.admin_view(
    payment_view(request, chemical, 
context=extra_context)

    )
    return super().change_view(request, object_id, form_url, 
extra_context)


And the url config ...

    re_path(r"invoice/(?P\d+)/$", billing_views.invoice_view, 
name="invoice_view"),
    re_path(r"payment/$", billing_views.payment_view, 
name="payment_view"),
    re_path(r"success/$", billing_views.success_view, 
name="success_view"),


And the payment.html form ...

    
    {% csrf_token %}
    {% if form.errors or form.non_field_errors %}
    {{ form.errors }}
    {{ form.non_field_errors }}
    {% endif %}
    {% for field in form %}
    {% if field.name == "chemical_id" %}
    id="id_chemical_id" value="{{ chemical.id }}" />

    {% else %}
    {{ field }}
    {% endif %}
    {% endfor %}
      src="https://checkout.stripe.com/checkout.js"; 
class="stripe-button"
  data-key="{{ data_key }}"
  data-amount="{{ data_amount }}"
  data-name="{{ data_name }}"
  data-description="{{ data_description }}"
  data-image="{{ data_image }}"
  data-locale="{{ data_locale }}"
  data-currency="{{ data_currency | lower }}"
  data-zip-code="true"
  data-panel-label="Pay">
    
    

Thanks

Mike






--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
You received this message because you are subscribed to the Google Groups "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/e8daba7f-13aa-6f84-80d3-9010ec16389d%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Django 3.0 -> 3.1 performance degradation

2022-05-06 Thread Jonatan Heyman
Hi! And thanks for the reply!

I've read the release notes but couldn't see anything that popped out as 
the possible cause. But I'm going to give them another read. Currently, the 
app is running fine on 3.0, and I haven't started debugging what might be 
the cause. I started with a message to this list, hoping that this would 
sound familiar to someone else :).

Bisecting between 3.0 and 3.1 is a possibility, though it's time-consuming 
since I have to rebuild the Docker image, deploy it to the staging server 
and run the load test for a little while between each test.

I'll post an update when I make any progress!

Best,
Jonatan

On Thursday, May 5, 2022 at 2:37:06 PM UTC+2 Antonis Christofides wrote:

> Hi! This is a very interesting problem, and I'm afraid I'm not qualified 
> to answer it. What I'd like to point out is that, if I had done all the 
> work that you seem to have done, I would be tempted to start bisecting in 
> between versions 3 and 3.1 in order to find the exact commit that causes 
> the problem.
>
> (However, in order to avoid that, I might also take a second look at the 
> release notes, in case there was some information in there. And I might 
> also ask in the developers mailing list—many of those who might know the 
> answer don't read django-users.)
>
> It's possible it's a Django issue, but it's also possible it isn't. For 
> example, it could be some error in your caches or templates or other 
> configuration that happens to only manifest itself in Django>=3.1.
>
> In any case, I'm eager to learn how this plays out.
>
> Regards,
>
> Antonis
>
> On 04/05/2022 12.12, Jonatan Heyman wrote:
>
> Hi!
>
> I've recently upgraded an old Django app from Django 1.11 all the way up 
> to Django 4.0. Even though the app is pretty large, the migration went 
> smooth (or so I thought). However, when all tests passed and I deployed the 
> app to production, I saw that the response time of the app took a 
> significant hit (the response time for the 95th percentile went from about 
> 300 ms to 900 ms, and the median from about 100 ms to 250 ms). I also saw 
> that the server CPU load had increased significantly.
>
> I wrote some load tests and started downgrading Django. Now I've narrowed 
> down the problem to appear when I upgrade from Django 3.0.x to Django 
> 3.1.x, with no other significant changes to my app code.
>
> Is this something someone else has experienced, or does anyone know what 
> might be going on?
>
> Are there any known changes that might increase CPU usage? In that case, I 
> could throw more hardware at the problem.
>
> Any ideas, pointers or insights would be greatly appreciated!
>
> Best,
> Jonatan
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/5f05c06c-bd22-417b-9688-20aca9632bcbn%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/542bbe8d-c067-423e-9676-6e4b3bab2146n%40googlegroups.com.


Re: 'str' object is not callable

2022-05-06 Thread Lalit Suthar
this part of the code looks fine from a first look. Can you share the
complete view code for this

On Fri, 6 May 2022 at 12:11, Salima Begum 
wrote:

> Hi all,
> In my project I am Django messages Framework. I am always facing 'str'
> object error I dont understand how to solve this problem. Previously also I
> face same issue. Now it is reproduced.
> I am using django 4.0.4 version.
>  Python 3.9.6
> ```
>messages.success(request, "Welcome back")
> ```
> ```
> {% if messages %}
> {% for message in messages %}
> 
> 
>  style="">×
> {% if message.tags == 'error' %}
> aria-hidden="true">   
> {{
> message|safe }}  
> {% else %}
>  
>  style="color:#01ABAA;">   {{ message|safe
> }}  
> {% endif %}
> 
> 
> {% endfor %}
> {% endif %}
> ```
>
> Please help me to solve this issue.
>
> Thanks
> ~Salima
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAMSz6bkPYRUwSidJd1ay-q-GdeM5Q8CKqY%2BnYU3j7wk%2BEAmYOQ%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/CAGp2JVFj6DZ74w_Fv1an8SwtoDReG7YseridBDJ1PScuKdwUoQ%40mail.gmail.com.


double forms

2022-05-06 Thread Andy Li
Hi I'm trying to put two forms, here is my code:
```
class FrontView(LoginRequiredMixin, UserPassesTestMixin, FormView):
template_name = "template.html"
form_class = FirstForm
coupon_form = SecondForm

def get_context_data(self, **kwargs):
kwargs['second_form'] = self.second_form
return super().get_context_data(**kwargs)
```
In the template I used {{ second_form }}. However it's not showing up.

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/546d7871-29f1-4884-b84c-ecfb3599a3c5n%40googlegroups.com.


Re: Help please,

2022-05-06 Thread John McClain
connect it using your git! place the keys in your file. remember to remove
the keys when publishing to get or you will share them with the world. If
you are reading KT and still not connecting it is because you have skipped
a step. Follow your tutorial fully and it should be a very easy task (one
of the easiest task you'll have)

On Fri, 6 May 2022 at 12:03, Dexterr Jay  wrote:

> How do I make my domain be like
> https://my domain.herokuapp.com/mainapp/ when I open my Django app hosted
> on heroku
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAC32MkgXb34CcinJ9gTx6MPUcO-beqoutw3%3DeUPK4PeGtyBb9g%40mail.gmail.com
> 
> .
>


-- 
John McClain

Cell: 085-1977-823
Skype: jmcclain0129
Email: jmcclain0...@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/CAN-hv_pTjK0y9HQZtg1dY3vvVrPo-kpkv053ni7Mr%2BaQtPXhTg%40mail.gmail.com.


Help please,

2022-05-06 Thread Dexterr Jay
How do I make my domain be like
https://my domain.herokuapp.com/mainapp/ when I open my Django app hosted
on heroku

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


Re: Model Design

2022-05-06 Thread Lunga Baliwe
Also/maybe if you haven't please check
https://django-import-export.readthedocs.io/en/latest/

On Thu, May 5, 2022 at 3:59 PM 'David Turner' via Django users <
django-users@googlegroups.com> wrote:

> We receive the data every two weeks and then use django-import-export to
> import the data into our database. There is no mention of the account
> manager in these as this is something on our side. Am I missing the point
> in that by having the foreign key to the account manager this would impact
> on the import?
>
> On 5 May 2022, at 14:51, Ayser shuhaib  wrote:
>
>
> To help understand more the problem, would you please explain why adding
> an extra field to your models to be used as a foreign key, is not an option?
>
> On Thu, 05 May 2022 at 15:36, 'dtdave' via Django users <
> django-users@googlegroups.com> wrote:
>
>> We receive data from various third parties in their proprietary format in
>> excel. We then import this into our database and our models have been
>> designed around their format.
>> There is no option to change the way this data is received.
>> However, we now need to add an account manager to this data and under
>> normal circumstances this would be a case of adding a foreign key to the
>> data.
>>
>> What would be the best method of dealing with this given that we cannot
>> change the format of the data we receive nor the current models given that
>> they mirror this structure.
>> One suggestion has been to use a generic foreign key but I am not sure
>> how this would work.
>>
>> 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/97d1988f-b230-46a8-93dc-be583860467an%40googlegroups.com
>> 
>> .
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/bLKn2Dm15sU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAE0AZGKB5Mj5%3DFfuHVAASVG-GU3i7Opc1OsxySy_C9A3y0axeA%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/1AAD717E-D010-433B-8998-68FEC047E311%40googlemail.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/CANDnEWcGxZmj9AZaaYS5grwbmgrn6mRUzt65S5tXwFin-jEQWQ%40mail.gmail.com.


Re: Chaining county/cites api to models

2022-05-06 Thread Heman Okumbo
"ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
I need to chain my models  to this api such that after selecting the
city,you a get a redirect to a form so you can fill in personal details

On Fri, May 6, 2022, 12:36 Muhammad Juwaini Abdul Rahman 
wrote:

> Can you share the link of the API?
>
> On Fri, 6 May 2022 at 17:27, Heman Okumbo  wrote:
>
>> Thanks for the tip,i guess i have to dig deeper to get what exactly fits
>> my model design.
>>
>> On Fri, May 6, 2022, 04:04 Muhammad Juwaini Abdul Rahman <
>> juwa...@gmail.com> wrote:
>>
>>> Try this:
>>>
>>>
>>> https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html
>>>
>>> On Thu, 5 May 2022 at 23:46, Heman Okumbo  wrote:
>>>
 I need to have clients posting their products based on their
 countries,States and cities.I got this api that show a drop down list based
 on country, states and cities.How do I chain my models to this api? Any
 leads will be appreciated.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/CAJt9CbjDgLT-_Gj9SuWnfStwgfTnOsSCXfwK%3DNNq3DRXGQmuzQ%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/CAFKhtoS%2BjG_nmuZea%2BpgDFRaKY9t9%2BE3rvgumK_YQL%3DN5q92gA%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/CAJt9Cbjw2Aa8_6somCsm8vf3K9DaXOwjKPEmjDFuCEwrs6voRA%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/CAFKhtoT6gOk22Hf8w1S5yuPcLfXLW-c1-ytjLQsKgotchrRaGA%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/CAJt9CbgSEyY0%3Dq%3DZ69YJofGhu%2B5J-Rv6BwVK1TB1oTiPqjkznQ%40mail.gmail.com.


Re: Chaining county/cites api to models

2022-05-06 Thread Muhammad Juwaini Abdul Rahman
Can you share the link of the API?

On Fri, 6 May 2022 at 17:27, Heman Okumbo  wrote:

> Thanks for the tip,i guess i have to dig deeper to get what exactly fits
> my model design.
>
> On Fri, May 6, 2022, 04:04 Muhammad Juwaini Abdul Rahman <
> juwa...@gmail.com> wrote:
>
>> Try this:
>>
>>
>> https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html
>>
>> On Thu, 5 May 2022 at 23:46, Heman Okumbo  wrote:
>>
>>> I need to have clients posting their products based on their
>>> countries,States and cities.I got this api that show a drop down list based
>>> on country, states and cities.How do I chain my models to this api? Any
>>> leads will be appreciated.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/CAJt9CbjDgLT-_Gj9SuWnfStwgfTnOsSCXfwK%3DNNq3DRXGQmuzQ%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/CAFKhtoS%2BjG_nmuZea%2BpgDFRaKY9t9%2BE3rvgumK_YQL%3DN5q92gA%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/CAJt9Cbjw2Aa8_6somCsm8vf3K9DaXOwjKPEmjDFuCEwrs6voRA%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/CAFKhtoT6gOk22Hf8w1S5yuPcLfXLW-c1-ytjLQsKgotchrRaGA%40mail.gmail.com.


Re: Chaining county/cites api to models

2022-05-06 Thread Heman Okumbo
Thanks for the tip,i guess i have to dig deeper to get what exactly fits my
model design.

On Fri, May 6, 2022, 04:04 Muhammad Juwaini Abdul Rahman 
wrote:

> Try this:
>
>
> https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html
>
> On Thu, 5 May 2022 at 23:46, Heman Okumbo  wrote:
>
>> I need to have clients posting their products based on their
>> countries,States and cities.I got this api that show a drop down list based
>> on country, states and cities.How do I chain my models to this api? Any
>> leads will be appreciated.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/CAJt9CbjDgLT-_Gj9SuWnfStwgfTnOsSCXfwK%3DNNq3DRXGQmuzQ%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/CAFKhtoS%2BjG_nmuZea%2BpgDFRaKY9t9%2BE3rvgumK_YQL%3DN5q92gA%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/CAJt9Cbjw2Aa8_6somCsm8vf3K9DaXOwjKPEmjDFuCEwrs6voRA%40mail.gmail.com.


Bug using Admin with Stripe - but whose is it?

2022-05-06 Thread Mike Dewhirst
I'm obviously at fault but I'm not smart enough to figure it out. Any 
help is appreciated.


The mechanism below exhibits no errors at the Stripe end. Stripe returns 
the necessary payment token. I have tried brutally stripping of the 
"/change/payment" and while it silences the error, the form just 
re-shows itself.


 I see a similar problem in 32-bit iOS Safari which doesn't seem 
to like the svg tick symbol displayed in the Admin change screen success 
message. The only symptom is the tick doesn't appear and the user is 
none the wiser. But it generates an error email Field 'id' expected a 
number but got '55/img/icon-yes.svg' 



 ValueError at /admin/chemical/chemical/20/change/payment/change/

Field 'id' expected a number but got '20/change/payment'.

Request Method: GET
Request URL: 
http://localhost:8088/admin/chemical/chemical/20/change/payment/change/

Django Version: 3.2.13
Exception Type: ValueError
Exception Value:

Field 'id' expected a number but got '20/change/payment'.

Exception Location: 
D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py, 
line 1825, in get_prep_value

Python Executable:  D:\Users\mike\envs\xxai\Scripts\python.exe
Python Version: 3.8.3


Here is the ChemicalAdmin.change_view(). I filled in the docstring a 
year ago when debugging previously.


    def change_view(self, request, object_id, form_url="", 
extra_context=None):

    """
    self = ChemicalAdmin
    object_id = chemical
    form_url is passed through to self.render_change_form() via
    self.get_preserved_filters(request) and then added to context
    extra_context = dict of apps, models, admin_urls and 
permissions. Ensure
    self.change_form_template = None so next time it doesn't use 
payment.html

    """
    extra_context = extra_context or {}
    self.change_form_template = None
    chemical = Chemical.objects.get(id=object_id)
    intro = chemical.get_introduction()
    if intro and not chemical.token:
    if intro.category in CHARGE:
    self.change_form_template = "payment.html"
    context = collect_gateway_context(chemical)
extra_context.update(self.admin_site.each_context(request))
    extra_context.update(context)
    self.admin_site.admin_view(
    payment_view(request, chemical, context=extra_context)
    )
    return super().change_view(request, object_id, form_url, 
extra_context)


And the url config ...

    re_path(r"invoice/(?P\d+)/$", billing_views.invoice_view, 
name="invoice_view"),

    re_path(r"payment/$", billing_views.payment_view, name="payment_view"),
    re_path(r"success/$", billing_views.success_view, name="success_view"),

And the payment.html form ...

    
    {% csrf_token %}
    {% if form.errors or form.non_field_errors %}
    {{ form.errors }}
    {{ form.non_field_errors }}
    {% endif %}
    {% for field in form %}
    {% if field.name == "chemical_id" %}
    id="id_chemical_id" value="{{ chemical.id }}" />

    {% else %}
    {{ field }}
    {% endif %}
    {% endfor %}
      src="https://checkout.stripe.com/checkout.js"; 
class="stripe-button"
  data-key="{{ data_key }}"
  data-amount="{{ data_amount }}"
  data-name="{{ data_name }}"
  data-description="{{ data_description }}"
  data-image="{{ data_image }}"
  data-locale="{{ data_locale }}"
  data-currency="{{ data_currency | lower }}"
  data-zip-code="true"
  data-panel-label="Pay">
    
    

Thanks

Mike



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
You received this message because you are subscribed to the Google Groups "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/230a7a65-08f2-f990-131f-7879c4fbb05a%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature