Re: CRUD Generator

2021-01-08 Thread Noel Simela
This just went off topic and my question was not answered.

On Fri, 08 Jan 2021, 08:07 Omkar Parab  wrote:

> You can build whatever you want, using Django!
>
> On Fri, Jan 8, 2021, 11:13 AM Chandrashekhar Singh <
> chandrashekhar...@gmail.com> wrote:
>
>> Hello,
>>
>> Does anyone one know ? Is django is best framework for developing
>> delivery applications?
>>
>> Thanks
>>
>> On Thu, Jan 7, 2021, 11:39 PM Noel Simela  wrote:
>>
>>> Good day,
>>>
>>> I have explored several crud generator packages.
>>>
>>> I am looking for an opinion on the best package to adopt that has been
>>> maintained for the past few months,
>>>
>>> If you have experience in django crud generators.Please let me know the
>>> one you have used, the pros and cons.
>>>
>>> Many 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/CAGBhr7ZO4skwE7UXvth2EvGv70fX1DrCGXek5FkbgWoEtnqPVQ%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/CADNvQ1P6sDaGJT-toLSyU6p0jzGQ-GOJpx59Hw%3DquUcgnYW2%3Dw%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/CAJY8mfzmx1dfh55cLxdYJ29%2BBqVM%3Dvpp2PmLm865ryBRoN4LAA%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/CAGBhr7ZVFqiqSeEmFEFghZjGyY_Oqfj2nRvEhUCXgBCBwHeQkg%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-08 Thread Chelsea Fan
server rendering

On Fri, Jan 8, 2021 at 5:23 PM Satyajit Barik 
wrote:

> do you use API or server side rendering method?
>
> On Fri, Jan 8, 2021 at 1:34 PM Chelsea Fan 
> wrote:
>
>> yes I am using FileField and trying upload and to save it
>>
>>
>> On Thu, Jan 7, 2021 at 4:09 PM Steven Mapes 
>> wrote:
>>
>>> Within Django Admin or somewhere else?
>>> Are you using FileFields and trying to save to the models or are you
>>> just trying to POST multiple files?
>>>
>>> On Thursday, 7 January 2021 at 12:25:10 UTC allaberdi...@gmail.com
>>> wrote:
>>>
 --
>>> 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/ba3a4c6a-0788-457f-8e7d-576d612a7f61n%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/CAJwZnde38EREC%3DhrYAfGLP4QKvPD-OwC_aJb6W1-o1n6GTDrBg%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/CANd-%2BoCvYOnwxPj7rM5kdZWQtERSufab7jTwgBxqgbD2-j0%2BVw%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/CAJwZndfoNtZbsHrqvy7R1tG2Q8mwK8BtCushL2b_5M0c%2B%3DMTng%40mail.gmail.com.


Re: Django Admin, how to update select user field with my own queryset after adding new foreign object

2021-01-08 Thread Mike Dewhirst

On 9/01/2021 5:58 am, Héctor Alonso Lozada Echezuría wrote:

Best regards

I have a very simple warehouse model that is related to the 
contrib.auth.User model through the asigned_seller field

which should only allow those users with the seller role

class  PersonalWarehouse(ProductsMixin,  WarehouseBase):
 channel=  models.ForeignKey(
 SalesChannel,
 verbose_name=_('Sales channel'),
 on_delete=models.PROTECT
 )
 asigned_seller=  models.ForeignKey(
 User,
 verbose_name=_('Asigned seller'),
 blank=True,
 null=True,
 on_delete=models.SET_NULL
 )
 is_close=  models.BooleanField(
 verbose_name=_('Is it close?'),
 default=False
 )
 created_at=  models.DateTimeField(
 verbose_name=_('Created at'),
 auto_now_add=True
 )
 deadline=  models.DateField(
 verbose_name=_('Deadline'),
 default=date(now.year+  now.month//  12,  now.month%  12  +  1,  1)  - 
 timedelta(1)
 )

 class  Meta:
 verbose_name=  _('Personal warehouse')
 verbose_name_plural=  _('Personal warehouses')
 permissions=  [
 ('close_personal_warehouses',  'Can close warehouse')
 ]

 def  __str__(self):
 return  self.name

 def  __repr__(self):
 return  f'http://self.name>}>'

In my admin I have.

@admin.register(PersonalWarehouse)
class  PersonalWarehouseAdmin(admin.ModelAdmin):
 change_form_template=  'change_form.html'

 exclude=  ('is_close',  )
 list_display=  ('name',  'asigned_seller',  'is_close',  'deadline',  )
 list_filter=  ('asigned_seller',  'is_close',  'created_at',  'deadline',  
)
 ordering=  ['-deadline']
 search_fields=  ['name']
 actions=  [close_personal_warehouses]

 def  formfield_for_foreignkey(self,  db_field,  request,  **kwargs):
 if  db_field.name==  'asigned_seller':
 kwargs['queryset']  =  User.objects.filter(groups__name='Seller')
 field=  super().formfield_for_foreignkey(
 db_field,  request,  **kwargs)
 field.label_from_instance=  self.get_user_label
 return  field

 return  super().formfield_for_foreignkey(db_field,  request,  **kwargs)

 def  get_user_label(self,  user):
 return  user.get_full_name()

the problem exists when I add a new user from the warehouse template, 
it is added without any role and therefore appears listed


Perhaps you need to filter the queryset itself. Here is an example of 
one of mine ...


def get_queryset(self, request):
""" Limit the chemicals visible to just those owned by the company
of which the user is an employee.
"""
company = get_user_company(request.user)
qs = super().get_queryset(request)
return qs.filter(chemical__company=company)

 

If you have a custom user, you can put the user into the correct 
group(s) on creation using


https://docs.djangoproject.com/en/2.2/ref/signals/#django.db.models.signals.post_save

Otherwise, in formfield_for_foreignkey() you can insert a line which 
tests request.user for membership of "Seller" and if not, put the user 
into that group before checking if db_field.name == 'assigned_seller'





imagen.png
imagen.png

imagen.png

after refreshing the page I get only those users with the seller role

imagen.png

So how can I refresh the select widget so that only the users with the 
seller role appear after the ajax event?


--
Héctor Alonso Lozada Echezuría

 
	Libre de virus. www.avast.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/CADTS2YysaQxyz643ZneQ-D2gbe0B%2BKDHJe7VkGLW_MiPiq3awQ%40mail.gmail.com 
.



--
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 

Re: How to use chartjs

2021-01-08 Thread David Nugent
Some googling might get you there, but I think the chartjs documentation should 
get you most of the way there.

I would suggest an ajax approach - some js code on your page to retrieve the 
data from an API you build (a django view). You could also use DRF for this, 
but DRF is overkill -  you can respond with JSON or XML without it.

It might be able to render statically also, or even provide the data to a 
template context - depends a lot on expected environment.

Just remember that you can generate javascript in 

How to use chartjs

2021-01-08 Thread Dhruvil Shah
Basically I want to use 'chartjs' for display "Clustered Bar chart", with
following things year wise

Total amount
Amount Received
Amount Left

I want to fetch data from data base and display it on chart, I have saved
data of all above field  3 fields in one table for each date and I want to
also fetch year from Datefield.

So, basically can anyone give me any resource or something for such type
of  requirement. Main things is how to display Clustered bar chart by
fetching data from database for each year.

-- 
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/CADsP_iwqys-XhALXm2CwGV20%2B9XXfRaD6TkASUBvE9COYzg_Qw%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-08 Thread Satyajit Barik
do you use API or server side rendering method?

On Fri, Jan 8, 2021 at 1:34 PM Chelsea Fan 
wrote:

> yes I am using FileField and trying upload and to save it
>
>
> On Thu, Jan 7, 2021 at 4:09 PM Steven Mapes 
> wrote:
>
>> Within Django Admin or somewhere else?
>> Are you using FileFields and trying to save to the models or are you just
>> trying to POST multiple files?
>>
>> On Thursday, 7 January 2021 at 12:25:10 UTC allaberdi...@gmail.com wrote:
>>
>>> --
>> 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/ba3a4c6a-0788-457f-8e7d-576d612a7f61n%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/CAJwZnde38EREC%3DhrYAfGLP4QKvPD-OwC_aJb6W1-o1n6GTDrBg%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/CANd-%2BoCvYOnwxPj7rM5kdZWQtERSufab7jTwgBxqgbD2-j0%2BVw%40mail.gmail.com.


Re: hello guys, how can I upload multiple images using single button? help me please

2021-01-08 Thread Chelsea Fan
yes I am using FileField and trying upload and to save it


On Thu, Jan 7, 2021 at 4:09 PM Steven Mapes  wrote:

> Within Django Admin or somewhere else?
> Are you using FileFields and trying to save to the models or are you just
> trying to POST multiple files?
>
> On Thursday, 7 January 2021 at 12:25:10 UTC allaberdi...@gmail.com wrote:
>
>> --
> 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/ba3a4c6a-0788-457f-8e7d-576d612a7f61n%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/CAJwZnde38EREC%3DhrYAfGLP4QKvPD-OwC_aJb6W1-o1n6GTDrBg%40mail.gmail.com.