Re: Anyone used RENDER product for hosting?

2019-10-08 Thread Devender Kumar
Digital ocean


On Tue 8 Oct, 2019, 3:02 PM ram.mullapudi,  wrote:

>
> Hello,
>
> I'm looking for cheaper, secure and reliable way to host my website? The
> site is being developed on DJango FWK.  We are currently on GCP and also
> reviewed other popular vendors too. I recently came to know about Render
> platform and am wondering if anyone tried it?
>
> Regards,
> ~Ram
>
> --
> 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/62fe233b-924d-4257-9ad3-2a14a147ae0d%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/CALZ%3DbE%2B2KLmhzOfvZng3ASj_8WH5V5TDzz3E2Rs0m2tRCCwFww%40mail.gmail.com.


Daphne behavior question: Application close timeout and caching

2019-10-08 Thread DeVonte Applewhite
Hello,

I am using Daphne to run a Quart app (
https://pgjones.gitlab.io/quart/index.html#) and I wanted to use caching to 
improve performance.

I looked at the settings for Daphne and have a question about the below 
option:

  --application-close-timeout APPLICATION_CLOSE_TIMEOUT
The number of seconds an ASGI application has to 
exit
after client disconnect before it is killed

Does Daphne launch an application upon receiving a request, then kill it 
after the application gives a response every time?
If this is the case, I assume in memory caching would not work since the 
process running the app would be killed after every request.

Can someone give more information on the behavior of Daphne regarding the 
application close timeout?

-- 
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/7cf9d264-e5f3-4486-98c9-60a891eca48f%40googlegroups.com.


Re: Barcode 128Code generation with Django

2019-10-08 Thread Ehab Al-Qabbani
Hi,
If you use python3 you can install python-barcode and use it
Read its documentation:

https://pypi.org/project/python-barcode/





Warmest Regards,
Ehab


From: django-users@googlegroups.com on behalf of Shazia Nusrat 

Sent: Wednesday, October 9, 2019 12:15 AM
To: django-users@googlegroups.com
Subject: Barcode 128Code generation with Django

Hi I am looking for some help to generate a barcode for my practice project and 
I need commercial code128 generation help.

I need to add my customer ID and product ID in the barcode.

Any help would be appreciated.

Regards,
Shazia

--
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/CAD83tOzrBB5usL022V7roRQKeNyS3FLvhUW1L2opXeKtuzUJBA%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/DB7PR07MB3884403906130F5F4A0ABA44AB9A0%40DB7PR07MB3884.eurprd07.prod.outlook.com.


Barcode 128Code generation with Django

2019-10-08 Thread Shazia Nusrat
Hi I am looking for some help to generate a barcode for my practice project
and I need commercial code128 generation help.

I need to add my customer ID and product ID in the barcode.

Any help would be appreciated.

Regards,
Shazia

-- 
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/CAD83tOzrBB5usL022V7roRQKeNyS3FLvhUW1L2opXeKtuzUJBA%40mail.gmail.com.


Re: QuerySet not iterable

2019-10-08 Thread Abhijeet Viswa
Hello, 

Thank your for your reply. I'm not using Python 2. I have attached the 
traceback as is emailed by Django to the Admin. 

Traceback:
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/exception.py"
>  
> in inner
>   34. response = get_response(request)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/base.py" 
> in _get_response
>   115. response = self.process_exception_by_middleware(e, 
> request)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/base.py" 
> in _get_response
>   113. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/django/views/decorators/csrf.py"
>  
> in wrapped_view
>   54. return view_func(*args, **kwargs)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/django/views/generic/base.py" 
> in view
>   71. return self.dispatch(request, *args, **kwargs)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in 
> dispatch
>   505. response = self.handle_exception(exc)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in 
> handle_exception
>   465. self.raise_uncaught_exception(exc)
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in 
> raise_uncaught_exception
>   476. raise exc
>
> File 
> "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in 
> dispatch
>   502. response = handler(request, *args, **kwargs)
>
> File "/usr/lib/python3.6/contextlib.py" in inner
>   52. return func(*args, **kwds)
>
> File "/home/user/api/project/cashless/views/order.py" in post
>   143. order.save()
>
> File "/home/user/api/project/payment_gateway/models.py" in save
>   79. if ref_number not in transactions:
>
> Exception Type: TypeError at [ENDPOINT]
> Exception Value: argument of type 'QuerySet' is not iterable
>

I have did further testing and determined that my earlier hypothesis of 
*select_for_update* is not responsible for this error. The error persisted 
even after having removed that call. 

I also figured that it the TypeError was mapping some internal system call 
and I did further testing and I realized the error is a 
TransactionManagementError: An error occurred in the current transaction. 
You can't execute queries until the end of the 'atomic' block.
That save happens inside of an atomic transaction. There are a couple of 
other select statements that are executed before this one (also inside the 
transaction). Though, I haven't been able to figure out what's wrong though.
Any leads would be appreciated. 
Thank you. 

On Tuesday, October 8, 2019 at 5:00:05 PM UTC+5:30, Simon Charette wrote:
>
> Hello there,
>
> From looking at your code (super() calls) it seems like your are using 
> Python 2.
>
>  We've seen similar reports about stdlib functions hiding system level 
> exceptions
> instead of surfacing them[0] so that might it.
>
> It's hard to tell without the full traceback though.
>
> Best,
> Simon
>
> [0] https://code.djangoproject.com/ticket/26600
>
> Le lundi 7 octobre 2019 22:16:16 UTC-4, Abhijeet Viswa a écrit :
>>
>> Hey guys, 
>>
>> I need a help with a quirky bug while iterating over a QuerySet:
>>
>>> TypeError: argument of type 'QuerySet' is not iterable
>>
>>
>> The following is the block of code that produces the error: (the save 
>> method overrides the default save method in a Model called *Transaction*)
>>
>> def save(self, *args, **kwargs):
>> obj = self
>> if not obj.ref_number:  # the line of code throwing the error
>> transactions = Transaction.objects.values_list("ref_number", 
>> flat=True) # cache the list
>> while True:
>> ref_number = random.randint(11, 99)
>> if ref_number not in transactions:
>> obj.ref_number = ref_number
>> super(Transaction, obj).save(*args, **kwargs)
>> return
>> else:
>> super(Transaction, obj).save(*args, **kwargs)
>>
>>
>> This piece of code was working fine until we had modified (what we 
>> thought to be) an unrelated part of the source: (this is the modified line 
>> of code)
>> items = OrderItem.objects.prefetch_related('toppings').select_related(
>> 'item').select_related('item__category')
>> order = Order.objects.filter(uuid=order_uuid).prefetch_related(
>> Prefetch(
>> lookup='items',
>> queryset=items
>> )
>> ).select_related('outlet').select_related('user').select_related(
>> 'outlet__group') \
>>  .select_for_update(of=('self', 'outlet'))
>>
>>
>> We basically added a call to the *select_for_update. *This was required 
>> 

[no subject]

2019-10-08 Thread Raja Sekar Sampath
Hi,

I'm facing challenges to get the result of below problem,I have two models
in my application i.e.,


class UserMenu(models.Model):
name = models.CharField(max_length=50)

def __str__(self):
return self.name


class MenuMapping(models.Model):

user_menu = models.ManyToManyField(UserMenu, verbose_name='Menu')
user_group = models.ForeignKey(Group, related_name='user_group',
verbose_name='Department', on_delete=models.SET_NULL, null=True) # refers -
auth.group which is linked with users


def __str__(self):
return self.user_group.name



Now I want to get the list of UserMenu mapped with the user_group of logged
in user.

I could not able to get expected result with prefetch_related or
select_related,

Can anybody help ??

-- 
Thanks & Regards,

Raja Sekar Sampath
+91 9087434567.

-- 
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/CAAS5AE5yjCtcdGOgx0sGhUBpWXkrCfCirTanqYaDddXzmRbp9Q%40mail.gmail.com.


Re: Widgets not working for dynamically added formset forms

2019-10-08 Thread Dmitri S.
At first I hoped not to dive in JS and mostly use django things, but ok, 
now I see it's not that simple.
Thanks for help.

вторник, 8 октября 2019 г., 16:49:08 UTC+3 пользователь lemme smash написал:
>
> okay, i think i got it. you probably need to provide some snippet to 
> reload list of  choices to newly added form. try to look some examples of 
> using django-select2 with formsets...
> by pure js i mean not necessarily vanila js, but pure client code, without 
> rendering templates on server. all the problems you have partially (and 
> it's not only my opinion) happens because you trying to combine server-side 
> approach with client code pieces which is always buggy and hard to 
> implement and maintain.  
>

-- 
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/730d35eb-542c-4eff-9359-0dbedb054856%40googlegroups.com.


Re: text data types

2019-10-08 Thread Bill Freeman
TextField()

On Tue, Oct 8, 2019 at 12:42 PM Mohsen Pahlevanzadeh <
m.pahlevanza...@gmail.com> wrote:

> I need to create text data type in model.py, CharField() has max_len as
> mandatory, What do you recommend instead of CharField() ?
>
> --
> 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/bf337998-5544-4be6-b197-0a11eccdbe53%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/CAB%2BAj0t_FsPojxqOhEn%2Bx2sqcwcJX4yhWRZ4-F-ERgpqo-R83Q%40mail.gmail.com.


Possible bug in Media class.

2019-10-08 Thread Roman Telezhynskyi
Hello,

Today for my project I tried to find a solution for an issue with duplicate 
assets. Combining several approaches I managed to build an app to solve it. 
While debugging the app, I think, I found a bug in Media class.

File *django/forms/widgets.py*

@html_safe

class Media:
def __init__(self, media=None, css=None, js=None):
if media is not None:
css = getattr(media, 'css', {})
js = getattr(media, 'js', [])
else:
if css is None:
css = {}
if js is None:
js = []
self._css_lists = [css]
self._js_lists = [js]


These two strings seems incorrect.
css = getattr(media, 'css', {})
js = getattr(media, 'js', [])

Instead of *css* and *js* attributes they return *default values*. I feel 
like it is just a developer error. If replace strings with

css = getattr(media, '_css', {})
js = getattr(media, '_js', [])
everything works again.

Can somebody confirm my guess?

-- 
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/9fcba07c-7c12-4c6c-b266-e2a8e0318afa%40googlegroups.com.


Re: [Django] Trying to open a form on button click getting Error:Failed lookup for key [%s] in %r during template rendering

2019-10-08 Thread Dilipkumar Noone
Hi,

This issue is fixed to me by instantiating the FormHelper() in forms.py.
I referred :
https://django-crispy-forms.readthedocs.io/en/latest/crispy_tag_forms.html



class ApplyGSPForm(ModelForm):
  
*helper = FormHelper()*
class Meta:
model = ApplyGSP

fields = ['model_name', 'model_no', 'os_ver', 'chipset', 
'patch_level_to_be_applied', 'rel_cycle',
  'applied_gsp_count', 'from_sas_url', 'to_sas_url', 
'def_src_manifest', 'from_sw_version',
  'to_sw_version', 'description']
exclude = ['user', 'requested_time', 'applied_security_patch_level']


Regards,
N.Dilip Kumar.

On Monday, October 7, 2019 at 9:07:38 PM UTC+5:30, Dilipkumar Noone wrote:
>
> Dear Django User Group,
>
> I am django beginner.
>
> Please clarify the below doubt.
>
> *Implement Scenerio:*
> 1.I am developing one django app which needs a form on button click on 
> html page.
> 2.on successful submission should display the object created in the list 
> on the same web page.
>
> Below is the current implementation.
>
> when click on "Apply GSP" button getting below error:
> exc 
>
> VariableDoesNotExist('Failed lookup for key [%s] in %r', ('helper', 
>  fields=(model_name;model_no;os_ver;chipset;patch_level_to_be_applied;rel_cycle;applied_gsp_count;from_sas_url;to_sas_url;def_src_manifest;from_sw_version;to_sw_version;description)>))
>
> get_response 
>
>  >
>
> request 
>
> 
>
>
> *Note:* I am using bootstrap4 model using datatarget attribute to render 
> the crispy form using django templates on button click. 
>
> Please suggest how to resolve this issue.
>
> models.py:
> ---
>
> class ApplyGSP(models.Model):
> """
> This class is used to Apply the GoogleSecurityPatches when the user 
> requested to apply the GSP
> """
> user = models.CharField("User", max_length=100, default="")
> model_name = models.CharField(max_length=100, blank=True)
> model_no = models.CharField(max_length=100, blank=True)
> os_ver = models.ForeignKey(OSVersion, on_delete=models.CASCADE, 
> verbose_name="os Version")
> chipset = models.ManyToManyField(Chipset)
> patch_level_to_be_applied = models.CharField(max_length=200, blank=True)
> rel_cycle = models.ForeignKey(ReleaseCycle, on_delete=models.CASCADE, 
> verbose_name="Release Cycle")
> requested_time = models.DateTimeField(default=timezone.now)
> applied_gsp_count = models.IntegerField(null=True)
> applied_security_patch_level = models.TextField(default="")
> from_sas_url = models.ForeignKey(SourceSASURL, on_delete=models.CASCADE, 
> verbose_name="Source SAS URL")
> to_sas_url = models.URLField()
> def_src_manifest = models.ManyToManyField(DefaultSrcManifest)
> # from_manifest = models.CharField(max_length=200)
> # to_manifest = models.CharField(max_length=200)
> from_sw_version = models.IntegerField(null=True)
> to_sw_version = models.IntegerField(null=True)
> description = models.CharField(max_length=200)
>
> class Meta:
> verbose_name_plural = "ApplyGSPPatches"
>
> def __str__(self):
> return self.user + str(self.pk)
>
>
> forms.py:
> --
>
> class ApplyGSPForm(ModelForm):
> """
> This class is used to define the form input fields to apply the 
> google security patches for each user request
> from common SAS board:7620
> """
>
> class Meta:
> model = ApplyGSP
>
> fields = ['model_name', 'model_no', 'os_ver', 'chipset', 
> 'patch_level_to_be_applied', 'rel_cycle',
>   'applied_gsp_count', 'from_sas_url', 'to_sas_url', 
> 'def_src_manifest', 'from_sw_version',
>   'to_sw_version', 'description']
> exclude = ['user', 'requested_time', 'applied_security_patch_level']
>
>
> ApplyGSP.html:
> ---
>
> 
> {% extends 'base.html' %}
> {% load crispy_forms_tags %}
>
> {% block static %}
> {% endblock static %}
>
> {% block content %}
> 
> 
> 
>  data-toggle="modal" data-target="#myApplyGSPModal">ApplyGSP
> 
> 
> 
> 
> 
> {% csrf_token %}
> 
>
> {% crispy form %}
> 
> {% if action == "submit" %}
> Submit
> {% else %}
> Update
> {% endif %}
> 
>  aria-label="Close" data-dismiss="modal">
>Cancel
> 
> 
> 
> 
> 
> {% endblock content %}
>
> {% block scripts %}
> {% endblock scripts %}
>
>
> Myviews.py:
>
> @login_required(login_url='/gspapp/')
> def apply_gsp_request_form(request, id=None):
> """
> :param request: Accept http request
> :param id: Id of 

text data types

2019-10-08 Thread Mohsen Pahlevanzadeh
I need to create text data type in model.py, CharField() has max_len as 
mandatory, What do you recommend instead of CharField() ?

-- 
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/bf337998-5544-4be6-b197-0a11eccdbe53%40googlegroups.com.


Re: my first view

2019-10-08 Thread Motaz Hejaze
Please follow the link in my last email

On Tue, 8 Oct 2019, 5:05 pm Felipe Gregório USA, 
wrote:

> how i do this?
>
> --
> 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/9fe7430a-5b7a-4e07-8804-6f28e1d223ac%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/CAHV4E-c8r96KEeC_Q4n7PXkkO6QggfEmSCB6_jifT2ZGN%2BYmuA%40mail.gmail.com.


Re: my first view

2019-10-08 Thread Felipe Gregório USA
how i do this?

-- 
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/9fe7430a-5b7a-4e07-8804-6f28e1d223ac%40googlegroups.com.


Re: my first view

2019-10-08 Thread Motaz Hejaze
nothing wrong ,
you just need to link your view with a route ..
please go for the official django tutorial to understand the basics

https://docs.djangoproject.com/en/2.2/intro/tutorial01/

On Tue, Oct 8, 2019 at 4:36 PM Felipe Gregório USA 
wrote:

> Please tell me what is wrong with my first view
> https://github.com/Fgregorio1/ftgtraderexample.git
>
> --
> 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/60630aed-2bca-412b-8897-a54d4e9b4b45%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/CAHV4E-fpFWVXb%2BRRL7faL1X5%3D4hQhPUQ5c5-H75oT76HpkT_SQ%40mail.gmail.com.


my first view

2019-10-08 Thread Felipe Gregório USA
Please tell me what is wrong with my first view
https://github.com/Fgregorio1/ftgtraderexample.git

-- 
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/60630aed-2bca-412b-8897-a54d4e9b4b45%40googlegroups.com.


Re: ListView from 2 model

2019-10-08 Thread Jani Tiainen
Hi,

ListView and most other generic views are designed mostly to work with
single model.

There are few ways to tackle your problem depending on your needs.

to 3. lokak. 2019 klo 0.53 Yann Mbella  kirjoitti:

> hi everyone,
> I got a problem in listing two models from a listview that is,  a list of
> one model and another model together (eg Books and Authors)
>
> --
> 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/915dbb5a-78bc-4d06-9a96-b0a43fa84be7%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/CAHn91ocSWw%2BMBaBcSfsGDquFQ0uqK9zr%3DN%2B%2B2TGMhaPmpKafRg%40mail.gmail.com.


Re: ListView from 2 model

2019-10-08 Thread lemme smash
you probably may want to implement `get_context_data` method like:
def get_context_data(self):
context = super(BlogView, self).get_context_data()
context.update({
'authors': 
Author.objects.filter(posts__isnull=False).distinct(),
'tags': Tag.objects.all(),
  })
return context



On Thursday, October 3, 2019 at 12:52:34 AM UTC+3, Yann Mbella wrote:
>
> hi everyone,
> I got a problem in listing two models from a listview that is,  a list of 
> one model and another model together (eg Books and Authors)
>

-- 
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/e19dcec9-258b-4411-b14b-d1152772be53%40googlegroups.com.


Re: Widgets not working for dynamically added formset forms

2019-10-08 Thread lemme smash
okay, i think i got it. you probably need to provide some snippet to reload 
list of  choices to newly added form. try to look some examples of using 
django-select2 with formsets...
by pure js i mean not necessarily vanila js, but pure client code, without 
rendering templates on server. all the problems you have partially (and 
it's not only my opinion) happens because you trying to combine server-side 
approach with client code pieces which is always buggy and hard to 
implement and maintain.  

On Tuesday, October 1, 2019 at 11:41:28 PM UTC+3, Dmitri S. wrote:
>
> I have a formset with fields with Select2 widgets and a calendar 
> (date-picker) from django app.
>
> And I use dynamic addition of formset forms.
>
>
> When I render a template for the first time, all widgets work fine. *But 
> when I add new formset form, widgets of this new form don't work.*
>
>
> I think, this 
> 
>  ('formset:add') 
> is somehow related to my problem, but I can't figure how to use it.
>
> I also found this: 
>
> $('.django-select2').djangoSelect2();
>
> With this line dropdowns start working, but they become empty.
>
>
> For adding new form I use 'empty form' and this jQuery:
>
> 
> $('.buttons').on('click', '#add_form', function() {
> var form_idx = $('#id_resolution_set-TOTAL_FORMS').val();
> $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, 
> form_idx));
> $('#id_resolution_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
> });
> 
>
>
> Form in HTML:
>
> {% if mat_id == None %}
>  enctype="multipart/form-data" method="post">
> {% else %}
>  enctype="multipart/form-data" method="post">
> {% endif %}
>
> {% csrf_token %}
> 
> {% for field in form_matter %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> RESOLUTIONS
>
> 
> {{ formset_resolutions.management_form }}
> {% for form in formset_resolutions %}
> 
> {% for hidden in form.hidden_fields %}
> {{ hidden }}
> {% endfor %}
> {% for field in form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag 
> }}
> {{ field }}
> 
> {% endfor %}
> 
> {% endfor %}
> 
> 
> ADD
> SAVE
> 
> 
> 
> {% for field in formset_resolutions.empty_form.visible_fields %}
> 
> {% if field.errors %}
> {{ field.errors }}
> {% endif %}
> {{ field.label_tag }}
> {{ field }}
> 
> {% endfor %}
> 
> 
> 
>
>
> Other scripts:
>
> 
> 
>
> {{ form_matter.media.js }}
>
>
> {{ form_matter.media.js }} are:
>
> 
>
> 
>  src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js">
>  src="/static/admin/js/admin/DateTimeShortcuts.js">
> 
>  src="/static/django_select2/django_select2.js">
>
>

-- 
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/132d7efe-3060-430c-826c-0aa5d6eaabae%40googlegroups.com.


Re: QuerySet not iterable

2019-10-08 Thread Simon Charette
Hello there,

>From looking at your code (super() calls) it seems like your are using 
Python 2.

 We've seen similar reports about stdlib functions hiding system level 
exceptions
instead of surfacing them[0] so that might it.

It's hard to tell without the full traceback though.

Best,
Simon

[0] https://code.djangoproject.com/ticket/26600

Le lundi 7 octobre 2019 22:16:16 UTC-4, Abhijeet Viswa a écrit :
>
> Hey guys, 
>
> I need a help with a quirky bug while iterating over a QuerySet:
>
>> TypeError: argument of type 'QuerySet' is not iterable
>
>
> The following is the block of code that produces the error: (the save 
> method overrides the default save method in a Model called *Transaction*)
>
> def save(self, *args, **kwargs):
> obj = self
> if not obj.ref_number:  # the line of code throwing the error
> transactions = Transaction.objects.values_list("ref_number", 
> flat=True) # cache the list
> while True:
> ref_number = random.randint(11, 99)
> if ref_number not in transactions:
> obj.ref_number = ref_number
> super(Transaction, obj).save(*args, **kwargs)
> return
> else:
> super(Transaction, obj).save(*args, **kwargs)
>
>
> This piece of code was working fine until we had modified (what we thought 
> to be) an unrelated part of the source: (this is the modified line of code)
> items = OrderItem.objects.prefetch_related('toppings').select_related(
> 'item').select_related('item__category')
> order = Order.objects.filter(uuid=order_uuid).prefetch_related(
> Prefetch(
> lookup='items',
> queryset=items
> )
> ).select_related('outlet').select_related('user').select_related(
> 'outlet__group') \
>  .select_for_update(of=('self', 'outlet'))
>
>
> We basically added a call to the *select_for_update. *This was required 
> by us since we are modifying both the *Order *as well as *Outlet *models. 
> (Also, the *Transaction* model is a super-model for the *Order *model)
>
> My best guess is that the select_for_update locks certain rows of the the 
> *Order*, *Transaction *and a bunch of other models. This results in the 
> line of code failing because the query to list the value fails. However, I 
> tested this hypothesis out by running a *select_for_update*, populating 
> the *QuerySet *returned and then sleeping for a while while I ran a 
> different query on the Model for which rows were locked. This ran perfectly 
> fine, with no problems.
>
> We are using PostgreSQL as our backend database. Any help would be greatly 
> 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/9954ffee-6dca-42e0-9943-d73ad0137ed1%40googlegroups.com.


Anyone used RENDER product for hosting?

2019-10-08 Thread ram.mullapudi

Hello,

I'm looking for cheaper, secure and reliable way to host my website? The 
site is being developed on DJango FWK.  We are currently on GCP and also 
reviewed other popular vendors too. I recently came to know about Render 
platform and am wondering if anyone tried it?

Regards,
~Ram

-- 
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/62fe233b-924d-4257-9ad3-2a14a147ae0d%40googlegroups.com.