default_renderer is not accessible in BaseForm

2023-04-30 Thread Ryan Burt
Hi all,

I upgraded from Django 3.2 to Django 4.2 and somewhere along the way, 
access to an overridden default_renderer in my ModelForm has been lost. 

settings.py:

FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
 
my_app/forms.py:

class MyModelForm(forms.ModelForm):
default_renderer = CustomRenderer

class Meta:
model = MyModel

The custom renderer adds some extra divs and formatting with row and column 
css classes and I only apply it to certain widgets on certain forms within 
one of my apps. I just point specific widgets to a custom html file. 

This worked prior to the upgrade. I think the issue is in the forms api. 
Each time the code hits the following block in BaseForm.__init__(), 
renderer is always not none, regardless of if FORM_RENDERER is set 
explicitly or not:

(line 120 in forms/forms.py)
# Initialize form renderer. Use a global default if not specified
# either as an argument or as self.default_renderer.
if renderer is None:
if self.default_renderer is None:
renderer = get_default_renderer()
else:
renderer = self.default_renderer
if isinstance(self.default_renderer, type):
renderer = renderer()
self.renderer = renderer

The code inside the if statement is never reached (granted I have only 
tried some non-exhaustive combinations). 

I can see three solutions to this
1. Override the init in my model form and set renderer = None explicitly, 
so that the default_renderer is picked up instead (shameless dirty hack)

2. Make pr with a change to look for the default_renderer first:
# Initialize form renderer. Use a global default if not specified
# either as an argument or as self.default_renderer.
if self.default_renderer:
if isinstance(self.default_renderer, type):
renderer = self.default_renderer()
else:
renderer = self.default_renderer
elif renderer is None:
renderer = get_default_renderer()
self.renderer = renderer 

3. change the project settings in the event that I have missed some crucial 
change between 3.2 and 4.2 that explains why the renderer is always not not 
in the BaseForm init.

I'd appreciate any help from any forms api experts that can point me in the 
right direction.

Cheers,
Ryan.

-- 
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/ef5146e1-4ee4-408e-967f-33e748b1092an%40googlegroups.com.


Re: Digest for django-users@googlegroups.com - 1 update in 1 topic

2023-02-18 Thread Ryan Austin
If I had to rephrase your question, it appears that you might want to:

1. Query your Attendance model for some specific object.
2. If the object is not present, create it.

If my interpretation is correct, the ORM has an abstraction that you can use 
called get_or_create().

In your example, you could use:

Attendance.object.get_or_create(user=emp,date=enddate,crea_date=strdate)


Which will return a tuple with in the form (your_object, bool), where 
‘your_object’ is the object returned from the db and ‘bool’ is the result of 
whether is was created (true) or retrieved (false). A more ideal way then to 
use this would be to pass multiple variables which python will unpack 
accordingly. Do this:

Attendance, created = 
Attendance.object.get_or_create(user=emp,date=enddate,crea_date=strdate)


For a deeper understanding try diving into the Django docs, there’s also a good 
post on this blog: 
https://nsikakimoh.com/blog/learn-about-get_or_create-and-update_or_create.

Hope that helps.
On Feb 18, 2023, 8:01 AM -0500, django-users@googlegroups.com, wrote:
> django-users@googlegroups.com Google Groups
> Topic digest
> View all topics
>
> • Orm query - 1 Update
>
> Orm query
> Prashanth Patelc : Feb 17 06:40PM +0530
>
> Hi all,
>
> This is my model if model contain previous month dates I need to and store
> the data If user is new previous data is not available I need to store
> directly to db .
> How to write orm query?
>
>
> Attendance.object.filter(user=emp,date=enddate,crea_date=strdate)
>
>
>
> If dates is not available in attendance model how to write orm query?
> Back to top
> You received this digest because you're subscribed to updates for this group. 
> You can change your settings on the group membership page.
> To unsubscribe from this group and stop receiving emails from it send an 
> email to django-users+unsubscr...@googlegroups.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/bc7619c2-2b4e-4bb7-b158-fd682bc4c6ac%40Spark.


Re: Hashing user emails

2022-09-15 Thread Ryan Nowakowski
I'm not sure a hash will meet your needs. What kinds of things are you trying 
to secure against? Examples:

1. I want to make sure that if the data in my database is stolen that the email 
addresses won't be able to be read.

2. I want to obscure the sender and receiver email addresses so that the sender 
can't see the receiver's email address and the receiver can't see the sender's 
email address.

3. I want to meet the regulatory obligations in whatever jurisdiction I'm 
operating in.


On September 14, 2022 11:33:39 AM CDT, Robert Bender  
wrote:
>I am trying to find the best way to secure email address for user to user 
>emails.  Thanks for your help.
>-Robert 
>
>-- 
>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/AB086E00-AB1E-4B90-A92D-1B973830E902%40gmail.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/907A3F61-8DEA-4428-B3F5-E0E97FFBEC92%40fattuba.com.


Re: Migrate to mongodb is failing

2022-09-12 Thread Ryan Nowakowski



On September 12, 2022 7:38:21 AM EST, "Fábio Barboza de Freitas" 
 wrote:
>I'm trying to migrate the django tables to mongo, but it is the error I get:
>
>Applying contenttypes.0002_remove_content_type_name...This version of 
>djongo does not support "DROP CASCADE" fully. Visit 
>https://nesdis.github.io/djongo/support/

Any luck with the documentation on that support page?

-- 
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/9309410B-06E1-4AFF-96EF-8B9A76C72AD1%40fattuba.com.


Re: Negative Stock Prevention

2022-09-01 Thread Ryan Nowakowski
If you get this error during migration you likely have some existing Stock rows 
in your database with quantity that is less than 0. If this site is in 
production already, you'll need to create a data migration to change your 
negative quantities to zero.

https://docs.djangoproject.com/en/4.1/topics/migrations/#data-migrations

If this project isn't in production yet, just delete your database and 
migrations and start from ground zero.

On September 1, 2022 12:18:22 AM CDT, tech george  wrote:
>Hello,
>
>Sorry the error is:
>
>django.db.utils.IntegrityError: CHECK constraint failed: quantity
>
>
>
>On Thu, Sep 1, 2022 at 3:45 AM Ryan Nowakowski  wrote:
>
>> I don't see any error. Did you forget to post it?
>>
>> On August 31, 2022 5:57:32 AM CDT, tech george 
>> wrote:
>>>
>>> Hello,
>>>
>>> Sorry for the late reply.
>>>
>>> I changed the models as below and added checkConstraint , But when I
>>> migrate I get the below error.
>>>
>>> What am I still doing wrong?
>>>
>>> class Stock(models.Model):
>>> quantity = models.PositiveIntegerField(default='0', blank=True,
>>> null=True)
>>> reorder_level = models.PositiveIntegerField(default='0', blank=True,
>>> null=True)
>>>
>>> class Meta:
>>> CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>>>
>>>
>>>
>>> On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>>>
>>>> I don't see where you define the quantity variable, should that be
>>>> instance.quantity? Also, presumably you want to check if quantity is
>>>> greater than or equal to qu rather than 0.
>>>> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>>>>
>>>>
>>>> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>>>>
>>>>> On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
>>>>> > Please help crack the below code, I want to prevent negative stock,
>>>>> and if
>>>>> > the stock is == 0, deduct it from reorder_level instead.
>>>>> > Currently, the stock goes negative.
>>>>> >
>>>>> > models.py
>>>>> >
>>>>> > class Stock(models.Model):
>>>>> > quantity = models.IntegerField(default='0', blank=True, null=True)
>>>>> > reorder_level = models.IntegerField(default='0', blank=True,
>>>>> null=True)
>>>>> >
>>>>> > class Dispense(models.Model):
>>>>> > drug_id = models.ForeignKey(Stock,
>>>>> > on_delete=models.SET_NULL,null=True,blank=False)
>>>>> > dispense_quantity = models.PositiveIntegerField(default='1',
>>>>> > blank=False, null=True)
>>>>> > taken=models.CharField(max_length=300,null=True, blank=True)
>>>>>
>>>>> Maybe change quantity and reorder_level to PositiveIntegerField?
>>>>>
>>>> --
>>>> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> 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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.com
>> <https://groups.google.com/d/msgid/django-users/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>-- 
>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/CADYG20H6Yv_Y0vkgqVzOU90emRP%3DnvUw7vRrM--HGNbb0zZCAA%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/5FF4241B-B0E2-4082-9537-F1CDE9AF821D%40fattuba.com.


Re: Performance regression when moving from 3.1 to 3.2 (same with 4)

2022-09-01 Thread Ryan Nowakowski
Can you dump the generated sql from both Django versions?

https://docs.djangoproject.com/en/4.1/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running

On September 1, 2022 8:58:08 AM CDT, Marc Parizeau  wrote:
>Hi,
>
>I am seing a sharp increase in execution time for some of my queries when 
>moving from Django 3.1 to 3.2. And the performance hit appears to be the 
>same for Django 4.
>
>My backend is Postgres 14.2. 
>
>My Django project has forums for different types of content. The forum app 
>consists essentially of 5 tables:
>
>   1. a Post table that contains forum posts (essentially a text field);
>   2. a Thread table where rows point to a specific content and post;
>   3. a FollowUp table where rows point to a specific thread and post;
>   4. a ThreadEntry table where rows point to a thread, a user, and the 
>   last seen thread post for this user;
>   5. a FollowUpEntry table where rows point to a followup, a user, and the 
>   last seen followup post for this user.
>
>Here is an example query that executes 2 times slower on 3.2 than on 3.1:
>Content.objects.all().annotate(
>  has_unread_posts=Greatest(
># a content is unread if at least one condition is true
>Exists(
>  # a thread has never been read (has no user entry)
>  Thread.objects.filter(
>content=OuterRef('pk'),
>  ).exclude(threadentry__user=user)
>),
>Exists(
>  # a thread entry is not up-to-date
>  ThreadEntry.objects.filter(
>thread__content=OuterRef('pk'),
>user=user,
>  ).exclude(post=F('thread__post'))
>),
>Exists(
>  # a followup has no user entry
>  FollowUp.objects.filter(
>thread__content=OuterRef('pk')
>  ).exclude(followupentry__user=user)
>),
>Exists(
>  # a followup entry is not up-to-date
>  FollowUpEntry.objects.filter(
>followup__thread__content=OuterRef('pk'),
>user=user,
>  ).exclude(post=F('followup__post'))
>),
>  )
>).filter(
>  has_unread_posts=True,
>).order_by(
>  'course__uid',
>  '-version__start',
>).select_related(
>  'course',
>  'version',
>)
>
>Course and Version are other tables related to Content.
>
>I want to know with this query, for each of the user's content, whether or 
>not there is something new in the corresponding forum.  There is something 
>new if any one of the following condition is true:
>
>   1. there exists a thread for which the user has no thread entry (an 
>   entry is added when the thread is first read by the user);
>   2. there exists a user thread entry for which the last read post is not 
>   up to date with the current thread post (the thread owner has modified the 
>   post since);
>   3. there exists a followup for which the user has no followup entry (an 
>   entry is added when the followup is first read by the user);
>   4. there exists a user followup entry for which the last read post is 
>   not up to date with the followup post (the followup owner has modified the 
>   post since).
>
>On my machine, just by changing the Django version using pip, and nothing 
>else, this query takes about 1 second of execution on Django 3.1.14, and a 
>little more than 2 seconds on Django 3.2.15, so about a 2x increase. Here 
>are the current table sizes for these execution times:
>
>   1. Content: 33
>   2. Thread: ~30K
>   3. FollowUp: ~46K
>   4. ThreadEntry: ~1.3M
>   5. FollowUpEntry: ~4.5M
>   6. Post: ~103K
>
>Am I the only one observing such performance regressions with Django 3.2? 
>On other more complex queries that contain subqueries inside subqueries, I 
>have seen up to 30x execution time increases. 
>
>Did something major happen in SQL generation from 3.1 to 3.2?
>
>Am I doing something wrong? How can this happen?
>
>Any help on understanding what is going on with Django 3.2 would be much 
>appreciated.
>
>Best regards,
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/54287aec-dcf2-4179-b939-f099876e05a9n%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/34B8F624-61B9-4930-A127-8E2384AC3B30%40fattuba.com.


Re: Negative Stock Prevention

2022-08-31 Thread Ryan Nowakowski
I don't see any error. Did you forget to post it?

On August 31, 2022 5:57:32 AM CDT, tech george  wrote:
>Hello,
>
>Sorry for the late reply.
>
>I changed the models as below and added checkConstraint , But when I
>migrate I get the below error.
>
>What am I still doing wrong?
>
>class Stock(models.Model):
>quantity = models.PositiveIntegerField(default='0', blank=True,
>null=True)
>reorder_level = models.PositiveIntegerField(default='0', blank=True,
>null=True)
>
>class Meta:
>CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>
>
>
>On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>
>> I don't see where you define the quantity variable, should that be
>> instance.quantity? Also, presumably you want to check if quantity is
>> greater than or equal to qu rather than 0.
>> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>>
>>
>> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>>
>>> On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
>>> > Please help crack the below code, I want to prevent negative stock, and
>>> if
>>> > the stock is == 0, deduct it from reorder_level instead.
>>> > Currently, the stock goes negative.
>>> >
>>> > models.py
>>> >
>>> > class Stock(models.Model):
>>> > quantity = models.IntegerField(default='0', blank=True, null=True)
>>> > reorder_level = models.IntegerField(default='0', blank=True, null=True)
>>> >
>>> > class Dispense(models.Model):
>>> > drug_id = models.ForeignKey(Stock,
>>> > on_delete=models.SET_NULL,null=True,blank=False)
>>> > dispense_quantity = models.PositiveIntegerField(default='1',
>>> > blank=False, null=True)
>>> > taken=models.CharField(max_length=300,null=True, blank=True)
>>>
>>> Maybe change quantity and reorder_level to PositiveIntegerField?
>>>
>> --
>> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>-- 
>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/CADYG20F0occUAajR%3DSseRtiW%2Bzjh4THmgN6FEFbFsGcpsmMLZg%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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.com.


Re: Negative Stock Prevention

2022-08-30 Thread Ryan Nowakowski
On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
> Please help crack the below code, I want to prevent negative stock, and if
> the stock is == 0, deduct it from reorder_level instead.
> Currently, the stock goes negative.
> 
> models.py
> 
> class Stock(models.Model):
> quantity = models.IntegerField(default='0', blank=True, null=True)
> reorder_level = models.IntegerField(default='0', blank=True, null=True)
> 
> class Dispense(models.Model):
> drug_id = models.ForeignKey(Stock,
> on_delete=models.SET_NULL,null=True,blank=False)
> dispense_quantity = models.PositiveIntegerField(default='1',
> blank=False, null=True)
> taken=models.CharField(max_length=300,null=True, blank=True)

Maybe change quantity and reorder_level to PositiveIntegerField?

-- 
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/20220830144358.GE1858%40fattuba.com.


Re: What Programming Language should i learn

2022-08-30 Thread Ryan Nowakowski
On Tue, Aug 30, 2022 at 03:35:26PM +0100, fawemimo olawale wrote:
> Which of these  programming language should i learn
> 
> Please I need counselling on this two language though i have prior
> knowledge on Python Web Framework (Django) as a beginner's but i want
> Backend Language
> 
> JAVA or ASP.Net

Python!  But of course this list is biased :)

-- 
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/20220830144155.GD1858%40fattuba.com.


Re: How to use same Models for all apps?

2022-08-27 Thread Ryan Nowakowski
You can use a model from one app in other apps. Simply import it in the apps 
where you need it. 

On August 27, 2022 5:43:40 PM CDT, "Javier L. Camacaro" 
 wrote:
>Do i need to repeat the models for each app?, Can I use same model for all 
>the apps in my project?
>
>
>I'm a new a DJango programmer, sorry for that
>
>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/d5d42018-14db-42dc-b682-fce739950eb0n%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/73650ACB-95FB-4727-A1B7-893B0812356C%40fattuba.com.


Re: Chat app using django

2022-08-25 Thread Ryan Nowakowski
On Wed, Jul 20, 2022 at 06:11:08AM +0530, Lakshyaraj Dash wrote:
> I'm having a discussion website in django with some sort of user
> authentication and I want to inject chat app with rooms made by the users
> themselves. I don't want any js framework in the frontend. Just tell me how
> to make this type of chat app using django (not Django channels).

Instead of using Channels, you can HTTP poll.  You can always migrate to
Channels later.

-- 
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/20220826032440.GH7295%40fattuba.com.


Re: Why do we need Django rest framework when our conventional django do what we want?

2022-08-25 Thread Ryan Nowakowski
On Sun, Jul 31, 2022 at 12:55:46AM -0700, Joseph Bashorun wrote:
> I am stuck in a loop of confusion. I am trying to build an ecommerce 
> website and make it production ready. Do i need to build an API for it?

No   https://twitter.com/htmx_org/status/1561808410856898561

-- 
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/20220826031841.GG7295%40fattuba.com.


Re: How to Manage User & Create a Model

2022-08-25 Thread Ryan Nowakowski
On Wed, Aug 24, 2022 at 12:48:26AM -0700, Aakash Bhaikatti wrote:
> As a User
> 
>- I can signup either as LIBRARIAN and MEMBER using username and password
>- I can login using username/password and get JWT access token
>
> As a Librarian
> 
>- I can add, update, and remove Books from the system
>- I can add, update, view, and remove Member from the system
> 
> As a Member
> 
>- I can view, borrow, and return available Books
>- Once a book is borrowed, its status will change to BORROWED
>- Once a book is returned, its status will change to AVAILABLE
>- I can delete my own account
> 
> As i'm a newbie. Can anyone Please help in how can I create the models of 
> these. Thank you

You can use the Django User model[1] since it already has username and
password.  To distinguish between librarian and member you can create
librarian and member groups using Django's Group model[2].

Then for the book, you can do something like:

class Book(models.Model):

STATUS_CHOICES = [
('BORROWED', 'Borrowed'),
('AVAILABLE', 'Available'),
]

title = models.CharField(max_length=200)
status = models.CharField(max_length=20, choices=STATUS_CHOICES, 
default='AVAILABLE')
borrower = models.ForeignKey(User, null=True, blank=True)

class Meta:
permissions = [
('borrow_book', 'Can borrow a book'),
('return_book', 'Can return a book'),
]

def __str__(self):
 return self.title


You'll add the following permissions[3] to the member group assuming
your Django app is called "library":

   * library.view_book
   * library.borrow_book
   * library.return_book

You can create these permissions[4] for member:

   * library.view_member
   * library.add_member
   * library.update_member
   * library.delete_member

You can then add permissions to the librarian group:

   * library.view_member
   * library.add_member
   * library.update_member
   * library.delete_member
   * library.add_book
   * library.update_book
   * library.delete_book


You can use the permission_required[5] decorator around your view
functions to control access.


[1] https://docs.djangoproject.com/en/4.1/ref/contrib/auth/#user-model
[2] https://docs.djangoproject.com/en/4.1/ref/contrib/auth/#group-model
[3] 
https://docs.djangoproject.com/en/4.1/topics/auth/default/#default-permissions
[4] 
https://docs.djangoproject.com/en/4.1/topics/auth/default/#programmatically-creating-permissions
[5] 
https://docs.djangoproject.com/en/4.1/topics/auth/default/#the-permission-required-decorator

-- 
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/20220826031109.GF7295%40fattuba.com.


Re: I want to fetch the value of radio field for updation but it only doesn't fetch even i use condition and value does comes but doesn't checked

2022-08-23 Thread Ryan Nowakowski
On Mon, Aug 22, 2022 at 12:26:40PM +0530, Abhinandan K wrote:
>  checked{% endif %} >Male
>  checked{% endif %}>Female
> 

Do you need quotes around Male/Female like this?

{% if val_gen == 'Male' %}

-- 
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/20220823133115.GE7295%40fattuba.com.


Re: One model field map to two database columns

2022-08-23 Thread Ryan Nowakowski
On Mon, Aug 22, 2022 at 05:56:00AM -0700, Dann Luciano wrote:
> It is possible to map one field in a Model to two or more database columns? 
> For example:
> 
> class User(models.Model):
> encrypted_hash_email = EncryptedHash()
> 
> then in database we have
> 
> encrypted_email and hash_email columns?

The django-money package stores the value in a DecimalField and the
currency in a CharField but abstracts both behind a single MoneyField[1].

[1] 
https://github.com/django-money/django-money/blob/main/djmoney/models/fields.py#L168

-- 
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/20220823132922.GD7295%40fattuba.com.


Re: converting CURL command

2022-08-21 Thread Ryan Nowakowski
In the past I've used subprocess.run to shell out and run curl. Those were 
weird circumstances though. Typically I use the requests library instead.

On August 21, 2022 2:27:02 PM PDT, "lone...@gmail.com"  
wrote:
>Hello all,
>
>   I am interested in converting the CURL command of:
>
>curl 'https://www.walmart.com/chcwebapp/api/receipts' \ -H 'sec-ch-ua: 
>"Chromium";v="98", " Not A;Brand";v="99", "Google Chrome";v="98"' \ -H 
>'accept: application/json' \ -H 'Referer: 
>https://www.walmart.com/receipt-lookup' \ -H 'content-type: 
>application/json' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'User-Agent: Mozilla/5.0 
>(Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) 
>Chrome/98.0.4758.102 Safari/537.36' \ -H 'sec-ch-ua-platform: "Mac OS X"' \ 
>--data-raw 
>'{"storeId":"123","purchaseDate":"02-19-2022","cardType":"visa","total":"100.00","lastFourDigits":"1234"}'
> 
>\ --compressed
>
>to a management command in Django.  Anyone have any documentation on how to 
>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/53723979-3323-4563-9799-9091354d87a9n%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/EBE48913-ABB4-4343-84A4-809A2355A53E%40fattuba.com.


Re: DeleteView Class

2022-08-21 Thread Ryan Nowakowski
It looks like you can override the delete method to get rid of the redirect 
behavior:

http://ccbv.co.uk/projects/Django/4.0/django.views.generic.edit/DeleteView/#delete

On August 20, 2022 2:39:46 AM CDT, Hussein Ahmad  wrote:
>hi.. i dont want my delete button to redirect to a success url,how  can i 
>do that
>this is my code:
>class ChatMessageDeleteView(LoginRequiredMixin, generic.DeleteView, 
>UserPassesTestMixin):
>model = ChatMessage
># success_url = ''
>def test_func(self):
>message = self.get_object()
>if self.request.user == message.user:
>return True
>return False
>
> def get_success_url(self) -> str:
> msg = self.get_object()
> chat = msg.channel.id
> return reverse('chat:chat-channel', args=[chat])
>
>
>*my button is working but its also sending DELETE method request to the 
>success url also*
>*im using htmx to send the delete request.*
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/f13638c1-f388-45a3-9eee-16b4f48ede0dn%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/266942E0-B218-4B35-9AD4-FA649BA7E3C8%40fattuba.com.


Re: remove user from a specific group in django

2022-08-17 Thread Ryan Nowakowski
usuario isn't a username, it's a QuerySet so I don't think:

User.objects.get(username=usuario)

... will work.

Please post the specific error you're getting including any traceback.

On August 16, 2022 3:30:46 PM CDT, "José Ángel Encinas" 
 wrote:
>hi guys, im trying to remove user from a specific group using a function in 
>django but can to do it, can help me someone?
>
>this is the function
>def accesstosystem(request):
>usuario = User.objects.filter(groups__name='revisión')
>user = User.objects.get(username=usuario)
>group = Group.objects.get(name='revisión')
>user.groups.remove(group)
>
>kind regards 
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/django-users/d36d5c76-9824-4971-94ed-a2288827b656n%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/482D57FC-EA71-4681-B824-92517C65770A%40fattuba.com.


Re: data model question

2022-08-17 Thread Ryan Nowakowski
How much data are you expecting from each data source? The volume of data will 
partially determine your solution.

On August 17, 2022 7:13:14 AM CDT, yaron amir  wrote:
>we are developing a control system that looks at data from multiple sources.
>some of the data is extracted from AWS, some from postgres databases, some 
>from hibob (human management reources)
>the question is this,
>here are my 
>1. do I use a disconnected external ETL process or use django for everything
>2. do I create all data resources using django data modeling or use the 
>internal management using django and some create manually 
>thanks
>
>Yaron
>
>-- 
>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/4cd6bb3e-c749-4b75-af6e-9a607fa90c92n%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/280A30DC-51D3-4BFE-8707-BCCB8C410FBC%40fattuba.com.


Re: Generating Calendar files for iPhone and Android with Pthon3/django

2022-08-02 Thread Ryan Nowakowski
The standard is called iCal. There are a few different python libraries to 
choose from.

On August 1, 2022 2:51:34 PM CDT, "lone...@gmail.com"  
wrote:
>Hello all,
>
> I want to generate calendar files for both Android and iPhone.  I do 
>not want to connect to the Google or Apple APIs to do this.  I just want 
>static files that are downloaded from my webapp to the mobile device.  How 
>and can this be done?
>
>Thank you.
>
>-- 
>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/b88bf3da-a699-484e-84dd-61fb929e4e8dn%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/2EA93618-AB3C-497B-A565-7EEBC4B3C421%40fattuba.com.


Re: ForeignKey Reverse Relation Fail

2022-07-31 Thread Ryan Nowakowski

Since this is a question about your models, please post your models.py.

On 7/27/22 5:18 AM, Malik Rumi wrote:
I have a model with a recursive foreign key to 'self'. This is 
intended to model a parent child
relation among instances. The forward relation, on a field called 
'childof', works as expected.
The reverse relation, using the related_name 'parent', comes up as a 
RelatedManager,
again as expected. However, parent.count(), parent.all(), etc., always 
give me the "Manager is
not accessible on instances" error. Many of these parent instances 
will themselves also be a
childof some other instance, and apparently, that's my problem. I 
don't know how to make Django
recognize the dual nature of some instances. Is there a way to hack 
the RelatedManager to fix this?


I am not getting any accessor errors from manage.py check.

I posted this to Django Forum, but the respondent was not able to 
duplicate my issue - i.e.,

he said it worked as expected for him. :-(

I saw a suggestion to use an explicit junction table on Stack 
Overflow, but making a round trip - or two - to an external table 
seems like an

awful lot of overhead for this situation.

If instead of a junction table, if I made an explicit parentto field 
on the model, would that work?
Presumably the related name on the childof field would still fail like 
it does now,
but I would instead have the explicit parent field to work with. I 
still would not have the
automatic reverse relation, and I would have to come up with a script 
to fill in the parentto

field, but that might solve my problem:
# pseudocode
family = c.itertools.groupby(instance.childof)
family = c.pandas.groupby(instance.childof)
for f in family:
pop = c.objects.get(instance.childof)
OR
pop = instance.childof
c.objects.update(pop.parentto=f) # where parentto is a Postgresql 
ArrayField
OR # 
https://docs.djangoproject.com/en/4.0/ref/models/relations/#django.db.models

.fields.related.RelatedManager.add:
>>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.add(e) # Associates Entry e with Blog b
SEE ALSO: 
https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_one/


If I did this two field hack, then I don't really need either one to 
be ForeignKeys any more,
do I? They could be a CharField and an ArrayField, couldn't they? That 
breaks the extended
lookup chain - but I don't have that now, anyway - or at least, I only 
have it in one direction.


--
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/3555d391-9c9e-440f-a603-103c9ccdc858n%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/b07189e4-d38e-1832-7b90-a439722625f0%40fattuba.com.


Re: Google Authentication code

2022-07-25 Thread Ryan Nowakowski
Your question is a little unclear but I'm assuming that you are trying to add 
Google authentication to your Django project. I've used:
 https://python-social-auth.readthedocs.io/en/latest/

...with good results in the past. I've also heard good things about:

https://django-allauth.readthedocs.io/en/latest/

... but I've never actually used it.

On July 20, 2022 8:03:20 AM CDT, Ankit Chaurasia  
wrote:
>Hello Dev,
>Can anyone send me Google Authentication code or any exp ?
>
>-- 
>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/8aa229d0-3f5e-48b0-b02c-4a742bf273c8n%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/E5EC68C7-40D1-408D-B8B2-6FA88F9CFA73%40fattuba.com.


Re: Bug Request!

2022-07-25 Thread Ryan Nowakowski
You'll definitely want to include the actual exceptions and warnings that are 
occurring in your bug report.

On July 25, 2022 9:05:53 AM CDT, Ken Booo  wrote:
>Here, I caught a one bug on Django-->4.0.6
>There is no argumented support and base_dir is having exemptions causing
>warnings![image: WhatsApp Image 2022-07-18 at 11.59.01 AM.jpeg]
>
>-- 
>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/CAGiSraCtPC2oHsXL2EDy%3DhXFFt_4bPDpHrFz0RR-UzJb0wZmRQ%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/3482F39B-1437-4F43-829A-B970D1912180%40fattuba.com.


Re: Search option in website

2022-07-23 Thread Ryan Nowakowski
You mentioned you're not using models. Where are you storing the data you want 
to search?

On July 23, 2022 8:42:40 PM CDT, Mahendra  wrote:
>I am not using models using only URLs is any ways to go like using Ajax or
>JavaScript language please suggest me?
>
>On Sat, 23 Jul 2022, 22:11 Lakshyaraj Dash, 
>wrote:
>
>> You can implement search option very easily like shown in the
>> screenshot below
>> Also for more information see the following django's model queryset
>> documentation:
>>
>> https://docs.djangoproject.com/en/4.0/ref/models/querysets/
>>
>> Thanks and Regards
>> Lakshyaraj Dash
>>
>> On Sat, Jul 23, 2022, 22:09 Mahendra  wrote:
>>
>>> Hi to all,
>>> How to implement Search option in website.please any one guide me ?
>>>
>>> Thanks®ards,
>>> Mahendra Yadav
>>>
>>>
>>> --
>>> 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-6G3y6S7YPqReqa7Sn_T%2BuC%2BMnCf0WdEM5kNO02ZRYS%2BUfJw%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/CAF7qQgCVWL3YQGCtDrxA71usfgYN%2BVr0CvVmX8GYxvRiKRZRVQ%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/CAN-6G3xvFxZTpC%3D3j-%3DZVOvxpRv-%2BybkoKJjrb3CT8GNuOmGDA%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/FD28350A-8B85-4272-B121-E1F245F4E2D5%40fattuba.com.


Re: Help to implement join query in django orm

2022-07-23 Thread Ryan Nowakowski
On Fri, Jul 22, 2022 at 12:16:14PM +0530, Avi shah wrote:
> I have two tables
> Tbl 1
> &
> Tbl 2
> 
> I need to connect the two tables using a join

If these tables were created outside of Django, in other words, not
using manage.py migrate, you can use Django's legacy database support to
auto generate the models[1].  After that, each table will have a model
associated with it.  You can then use Django's ForeignKey support to query
the tables.


[1] https://docs.djangoproject.com/en/4.0/howto/legacy-databases/
 

-- 
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/20220723185935.GB15838%40fattuba.com.


Re: External Authentication with username in header

2022-07-18 Thread Ryan Nowakowski
Middleware is how Django does it.

https://docs.djangoproject.com/en/4.0/ref/middleware/#module-django.contrib.auth.middleware

On July 15, 2022 4:19:10 PM CDT, Mark Glass  wrote:
>I would like to change the link that opens a Django app. Currently the app 
>is launched with GET http://localhost:8000. I would like to include a 
>username and password in the header. The header would be intercepted 
>somehow (Middleware?) and the user marked as authenticated. The app will 
>then launch for the user with a default role.
>
>This will replace a login page and Django internal authentication. 
>
>Can I implement this using middleware? If so, how?
>
>Thank you 
>
>-- 
>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/4f1b2a47-6d3d-45e2-9c93-8bbca78d3e34n%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/35914DE5-9803-4728-9829-6E201BD2DAE3%40fattuba.com.


Re: Best digital ocean plan for a production server

2022-07-10 Thread Ryan Nowakowski
Ram,

It depends.  How many http transactions per second are you expecting?
What database are you using?   Based on your estimated http TPS, how
many database queries per second are you expecting?  What percentange of
those database queries are read vs write?

- Ryan N

On Sat, Jul 09, 2022 at 09:20:17PM -0600, Ram wrote:
> Hi,
> 
> We are planning to launch our application in production once all the
> testing is completed after deployment to our development server. We are
> using Jenkins CI automation to deploy the code to the development server
> and we will do the same in production server too, but we are currently
> doing a feasibility study to understand which options are good for Django
> web application for both Web and Mobile app.
> 
> If anyone in this Django users community is currently on any Digital
> Ocean's production server plan, could you share some details and
> suggestions.
> 
> Best 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/20220710192831.GF18918%40fattuba.com.


Re: How to roll back related objects if any error happened.

2022-07-04 Thread Ryan Nowakowski
You can use transaction.atomic:
https://docs.djangoproject.com/en/4.0/topics/db/transactions/#controlling-transactions-explicitly

On July 4, 2022 7:16:41 AM EDT, Sencer Hamarat  wrote:
>Hi,
>
>Say I have a parent and a child model.
>
>And also there is a view which is using DRF serializers to save data into
>models.
>
>The saving operation steps are:
>
>First create parent parent object
>Then, create child object with parent object relation.
>
>The view code regarding the description above:
>
>parent_data = {
>"foo": "bar",
>"baz": "bar"
>}
>
>parent_serializer = ParentSerializer(data=parent_data)
>if parent_serializer.is_valid():
>parent_serializer.save()
>
>child_data = {
>"parent_id": parent_serializer.data['id'],
>"baz": "foo":
>"bar": "baz"
>}
>
>child_serializer = ChildSerializer(data=child_data)
>if child_serializer.is_valid():
>child_serializer.save()
>
>
>if any exception is thrown while child_serializer saving, how to roll back
>the parent object, too?
>
>Is there any chance to make this happen in a transaction to roll back any
>related record?
>
>
>Kind regards,
>Sencer HAMARAT
>
>-- 
>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/CACp8TZh09RSgF2FzjcXNodbcykXYuE566UH%2B8zRtgDm_VfdtaA%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/BEE4B516-7426-4A07-B91B-9733537D4F92%40fattuba.com.


Re: How to ignoring columns on model save

2022-06-28 Thread Ryan Nowakowski



On June 27, 2022 4:36:49 AM CDT, "ro...@tonic-solutions.com" 
 wrote:
>I know I could set `something like `instance.save(update_fields=[field for 
>field in instance._meta.fields if field.name != "_search")` but it would 
>need to be set on every save for that model throughout the application, 
>which seems like a lot of technical debt and likely to trip up other 
>developers as they maintain the application.

You could override the save method on your model to always exclude _search from 
update_fields. That way you DRY.

-- 
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/83A9F868-A97E-4102-87AB-381A75FB6D88%40fattuba.com.


Re: Need some help

2022-06-28 Thread Ryan Nowakowski
Yup

On June 26, 2022 8:11:01 PM CDT, Rohit Lohar  wrote:
>Can I make a form with the help of htmx such that the whole form has a
>small container is dynamic and else whole part is static?
>
>On Mon, Jun 27, 2022, 4:07 AM Ryan Nowakowski  wrote:
>
>> If you want the initial input field value to change dynamically when the
>> select field option changes, there's a bunch of different ways to do this.
>> My current favorite is htmx
>>
>> https://htmx.org/
>>
>> - Ryan
>>
>>
>>
>> On June 26, 2022 5:10:19 AM CDT, Rohit Lohar 
>> wrote:
>>>
>>> Hi there,
>>> I am currently making a form where the user will have a option to select
>>> from the drop down and an input field next to it. So basically the drop
>>> down will have the list of products and the input field will be having an
>>> initial value depending upon the choice selected by user. The product name
>>> and price have their seperate table so how can I achieve this.
>>> Thank you
>>>
>>> --
>> 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/86BB9A38-A8CC-4029-AAB4-ED2B6E31D22D%40fattuba.com
>> <https://groups.google.com/d/msgid/django-users/86BB9A38-A8CC-4029-AAB4-ED2B6E31D22D%40fattuba.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>-- 
>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/CAFMpPbmcGQw3S%2BxXr3k%3DsUjmrHpVL203xSNj1HEYx6VUA%3DymWA%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/EB0A409C-EA6C-4CA9-8349-94DB8AD3D256%40fattuba.com.


Re: Turn Django Web App to Mobile App

2022-06-28 Thread Ryan Nowakowski
I've used Cordova before

https://cordova.apache.org/

On June 28, 2022 3:26:04 PM CDT, Lightning Bit 
 wrote:
>Hello all, 
>
>Where should one start to convert a Django Web App into a Mobile App for 
>the Play Store and Apple Store? Appreciate the help!
>
>-- 
>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/7a9ad87d-bd28-4468-9481-08edf1de5497n%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/4B65F10E-4823-4993-8620-4AC28E226091%40fattuba.com.


Re: ?? question ,its urgent

2022-06-26 Thread Ryan Nowakowski
An alternative to storing all values in a single model field is to use EAV:

https://en.m.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model

On June 20, 2022 1:46:42 AM CDT, Abhinandan K  
wrote:
>how to store the data in django databse table if user append fields
>according to their need
>for example i have 1 one field 1) name 2) age 3) salary and the sign('+)
>if user click on + sign row append one plus in form..my question is that i
>want to store the data in all appended textboxes in single field in
>database,,
>
>-- 
>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/CAA6_Mp6UPLakoi-JhcgB4U89-iKfDwAaxDWwW547tFKyk_imrg%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/EBCA9EAF-4AD3-4367-82C6-0177C7F9E66E%40fattuba.com.


Re: Need some help

2022-06-26 Thread Ryan Nowakowski
If you want the initial input field value to change dynamically when the select 
field option changes, there's a bunch of different ways to do this. My current 
favorite is htmx

https://htmx.org/

- Ryan



On June 26, 2022 5:10:19 AM CDT, Rohit Lohar  wrote:
>Hi there, 
>I am currently making a form where the user will have a option to select 
>from the drop down and an input field next to it. So basically the drop 
>down will have the list of products and the input field will be having an 
>initial value depending upon the choice selected by user. The product name 
>and price have their seperate table so how can I achieve this.
>Thank you
>
>-- 
>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/ab3f80d4-3386-41ea-9772-077acc818ac6n%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/86BB9A38-A8CC-4029-AAB4-ED2B6E31D22D%40fattuba.com.


Re: Django could not parse the remainder

2022-06-23 Thread Ryan Nowakowski
https://stackoverflow.com/questions/8252387/how-do-i-access-dictionary-keys-that-contain-hyphens-from-within-a-django-templa

On Mon, Jun 20, 2022 at 07:52:46AM -0700, Koushik Romel wrote:
> When trying to get a value from restapi in for loop to display it takes 
> hyphen(-) as minus(-). And there is no way to change the api structure 
> because it is fixed.
> Im struck in this anyone help me..
> The exact error and the expected json is given below is down below
> 
> when i try to print {{key}} the whole for loop data it displays like this
> {'_id': ObjectId('xxx'), 'date': 'jun/20/2022', 'dst-active': 
> 'false', 'gmt-offset': '+05:30', 'time': '20:19:04', 
> 'time-zone-autodetect': 'true', 'time-zone-name': 'Asia/Kolkata'}
> 
> when i specify {{key.dst-active}} it throws this error
> TemplateSyntaxError at /store/Could not parse the remainder: '-active' from 
> 'key.dst-active'

-- 
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/20220623134418.GE18918%40fattuba.com.


Re: I can't use shared server's Ip Address for run Django

2022-06-19 Thread Ryan Nowakowski
Please copy and paste that section of your settings.py and the full error 
including any traceback.

On June 16, 2022 11:54:44 PM CDT, saranphat roungkitrakran 
 wrote:
>I have to put my project to share sever for others can use it . I try to 
>change allow_host become shared server's Ip Address ,but when I run, it 
>occur "Error: That IP address can't be assigned to" ,so I want to ask how 
>to solve this problem or other solutions. 
>
>-- 
>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/dccba701-c2bf-4ced-ab86-b081b8edfa76n%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/60409746-4AD3-4FB7-A376-49BEEBAAFF56%40fattuba.com.


Re: How to achieve bulk soft delete in django?

2022-06-16 Thread Ryan Nowakowski
Add a soft delete method to a custom QuerySet, then use that as a custom 
Manager for your model.

https://docs.djangoproject.com/en/4.0/topics/db/managers/#creating-a-manager-with-queryset-methods

On June 16, 2022 5:13:29 AM CDT, Sencer Hamarat  wrote:
>Hi,
>
>The models delete methods overridden by default and has a soft delete
>mechanizm.
>
>I need to add bulk soft delete to the application. I can achieve this with
>iterating over objects to call the soft delete method. But the actual need
>is, soft delete objects filtered by id in bulk way.
>
>Can I do it without iterating the object list?
>
>Regards,
>Sencer HAMARAT
>
>-- 
>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/CACp8TZgOVycb%3DBreJ-sBPxbjaLSNfXMJyG%2B7ozNgkKKFi46%3DvA%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/45D609BA-72FA-4D93-8262-30E836ED781D%40fattuba.com.


Re: Can't login with Username

2022-06-16 Thread Ryan Nowakowski
You could use manage.py shell to set the email address of your super user.

On June 13, 2022 12:22:30 AM CDT, Sudip Khokhar 
 wrote:
>Hi All,
>
>I am practicing Django since 3 months and recently I encountered an issue 
>with my practice project as I made a super user and didn't added email to 
>it.
>Then after I set email as the USERNAME_FIELD = 'email' in my django model 
>to access the database. But not I don't know how to add email after making 
>migrations to it.
>I had also tried by commenting *USERNAME_FIELD = 'email'* and *REQUIRED_FIELDS 
>= [], *but didn't worked well and I'm unable to login to my django admin 
>database.
>
>-- 
>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/3426cc22-422d-4d2c-b845-bc90243b2e9dn%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/4A42925B-A189-46B6-B385-AC2814448F47%40fattuba.com.


Re: How to hash fields and detect changes in a record

2022-06-15 Thread Ryan Nowakowski



On June 14, 2022 10:29:40 PM CDT, Mike Dewhirst  wrote:
>On 14/06/2022 11:20 pm, Ryan Nowakowski wrote:
>> 
>> Summing the ordinal of the characters won't catch transposition:
>> 
>> >>> chars = 'ab'
>> >>> sum([ord(c) for c in chars])
>> 195
>> >>> chars = 'ba'
>> >>> sum([ord(c) for c in chars])
>> 195
>> 
>> Better to use a real hash algorithm if you're trying to detect changes.  My 
>> note above about hashing not being required is because you don't need to 
>> detect changes because you explicitly already know when changes are being 
>> made.
>> 
>
>Thanks Ryan.
>
>It is all working now. I append " - No longer relevant" to the note title if 
>any change is detected. Otherwise the note gets deleted.
>

Good to hear! Seems like an interesting project.

-- 
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/935A6EB4-032D-4264-BD83-24508764B189%40fattuba.com.


Re: I can't use accented letters in my model

2022-06-14 Thread Ryan Nowakowski
This is a good primer on bytes vs strings:

https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/


On June 14, 2022 2:43:54 AM CDT, Antonis Christofides 
 wrote:
>Exactly. The important thing to remember here is that, in Python 2, a "string" 
>is actually a list of bytes, whereas a "unicode string" is actually a list of 
>characters (not a list of unicode characters—just a list of characters). The 
>confusion arises because, when Python was created, i.e. in 1990, multi-byte 
>characters were in their infancy, and we mostly assumed that a character and a 
>byte was more or less the same thing.
>
>In Python 3, the Python 2 "strings" were renamed to "bytes", and the Python 2 
>"unicode strings" were renamed to "strings"—and the syntax for the literals of 
>these types also changed. This made it way better.
>
>More information about all this is in 
>https://djangodeployment.com/2017/06/19/encodings-part-1/.
>
>
>
>On 12/06/2022 12.07, Virgilio Ravagli wrote:
>> I found a way: book.title = titolo.decode('unicode_escape')
>> it works fine
>> 
>> Il giorno venerdì 10 giugno 2022 alle 21:45:46 UTC+2 Virgilio Ravagli ha 
>> scritto:
>> 
>> Thank you, Antonis, it works !
>> book.title = u'Verità' doesn't give any errors.
>> 
>> Just another step: suppose that the title with accented letters stays in 
>> a
>> variable, say titolo, and I want to write
>> book.title = titolo. It gives error. How can I do, when the assignment on
>> the right is not a constant ?
>> Thanks in advance
>> 
>> Il giorno venerdì 10 giugno 2022 alle 15:25:51 UTC+2 Antonis Christofides
>> ha scritto:
>> 
>> Hello,
>> 
>> try this:
>> 
>> book.title = u'Verità'
>> 
>> Regards,
>> 
>> Antonis
>> 
>> P.S. Sorry I was a bit harsh yesterday—I had drunk too much beer :-)
>> 
>> 
>> On 10/06/2022 10.50, Virgilio Ravagli wrote:
>>> I have surround book.save with a try...catch...; the exception is:
>>> You must not use 8-bit bytestrings unless you use a text_factory 
>>> that
>>> can interpret 8-bit bytestrings (like text_factory = str). It is
>>> highly recommended that you instead just switch your application to
>>> Unicode strings.
>>> Without the try...catch, here is the traceback:
>>> Environment:
>>> 
>>> 
>>> Request Method: POST
>>> Request URL: http://localhost:8000/uti/dataLoading/
>>> 
>>> Django Version: 1.8.5
>>> Python Version: 2.7.10
>>> Installed Applications:
>>> ('django.contrib.admin',
>>>  'django.contrib.auth',
>>>  'django.contrib.contenttypes',
>>>  'django.contrib.sessions',
>>>  'django.contrib.messages',
>>>  'django.contrib.staticfiles',
>>>  'uti')
>>> Installed Middleware:
>>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>>  'django.middleware.common.CommonMiddleware',
>>>  'django.middleware.csrf.CsrfViewMiddleware',
>>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>>  'django.contrib.messages.middleware.MessageMiddleware',
>>>  'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>>  'django.middleware.security.SecurityMiddleware')
>>> 
>>> 
>>> Traceback:
>>> File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
>>> get_response
>>>   132.                     response = wrapped_callback(request,
>>> *callback_args, **callback_kwargs)
>>> File
>>> "C:\Users\RavagliV\eclipse-workspace-saved\librarian\uti\views.py" 
>>> in
>>> datLoading
>>>   34.                 msg = do_dat_loading()
>>> File
>>> "C:\Users\RavagliV\eclipse-workspace-saved\librarian\uti\views.py" 
>>> in
>>> do_dat_loading
>>>   79.             book.save()
>>> File "C:\Python27\lib\site-packages\django\db\models\base.py" in 
>>> save
>>>   734.  force_update=force_update, update_fields=update_fields)
>>> File "C:\Python27\lib\site-packages\django\db\models\base.py" in
>>> save_base
>>>   762.             updated = self._save_table(raw, cls, 
>>> force_insert,
>>> force_update, using, update_fields)
>>> File "C:\Python27\lib\site-packages\django\db\models\base.py" in
>>> _save_table
>>>   827. forced_update)
>>> File "C:\Python27\lib\site-packages\django\db\models\base.py" in
>>> _do_update
>>>   877.         return filtered._update(values) > 0
>>> File "C:\Python27\lib\site-packages\django\db\models\query.py" in 
>>> _update
>>>   580.         return 
>>> query.get_compiler(self.db).execute_sql(CURSOR)
>>> 

Re: How to hash fields and detect changes in a record

2022-06-14 Thread Ryan Nowakowski

On 6/12/22 11:40 PM, Mike Dewhirst wrote:


 Original message 
From: Ryan Nowakowski 
Date: 13/6/22 07:09 (GMT+10:00)
To: django-users@googlegroups.com
Subject: Re: How to hash fields and detect changes in a record

On Sat, Jun 11, 2022 at 12:13:16AM +1000, Mike Dewhirst wrote:
> On 10/06/2022 11:24 pm, Ryan Nowakowski wrote:
> > On Fri, Jun 10, 2022 at 05:52:48PM +1000, Mike Dewhirst wrote:
> > > I think the solution might be to hash note.title and note.note 
into a new
> > > field note.hash on being auto-created. On subsequent saves, 
compare the
> > > latest hash with note.hash to decide whether to delete 
auto-inserted notes
> > > prior to generating the next set. Those subsequent saves could 
be months or

> > > years later.
> > Hashing is useful if you want to check that something has been
> > unexpectedly changed.  I assume the note can only be changed through
> > your web app so you know when a user is changing a note.
>
> These are automatically generated notes which taken together constitute
> advice on how to deal with the analysis. Users can edit them. For 
example,
> someone might record some action taken regarding the advice. I don't 
want to

> delete that. If nothing has been edited, it is safe to delete.
>
> So how do I know it is the same as when originally generated - and 
safe to

> delete - except by storing a hash of the interesting fields.

Because when the user edits a note, during the form.save()(assuming
you're using Django forms), you'll set `altered_by_user` to True.

Notes can also be altered in the Admin



You have a couple of choices then.  You could alter the note details 
view in the admin to set the altered_by_user field. Alternatively and 
more generically, you could check the pk field in your model save 
method.  If it is None, then you are creating a new note.  If the pk 
field is not None, then you are updating an existing note so you can set 
altered_by_user to True.



> And if that is the best approach, what sort of hashing will survive 
Python

> upgrades etc?

Pick a hash algorithm[1](ex: sha256).  The output will remain the same
even with Python upgrades.

So the mechanism doesn't need to be a hash - as you said.I now just 
sum ord(char) for the title and the note and keep that in a flag field.


Summing the ordinal of the characters won't catch transposition:


chars = 'ab'
sum([ord(c) for c in chars])

195

chars = 'ba'
sum([ord(c) for c in chars])

195

Better to use a real hash algorithm if you're trying to detect changes.  
My note above about hashing not being required is because you don't need 
to detect changes because you explicitly already know when changes are 
being made.


--
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/a0d61798-d885-dffd-bfbb-b23a63fbd820%40fattuba.com.


Re: Using a lazy value in a queryset filter?

2022-06-12 Thread Ryan Nowakowski
On Sun, Jun 12, 2022 at 11:46:44AM -0700, Sylvain wrote:
> Hello,
> 
> I’m trying to use the current language of the user in a queryset, but the 
> value gets resolved outside of the request-response cycle. I thought this 
> could work since querysets are lazy, but I guess that doesn’t make the 
> values they use lazy. Here’s an example of what I’m talking about:
> 
> from django.utils.translation import get_language
> 
> class MyManager(models.Manager):
> def get_queryset(self):
> return super().get_queryset().filter(language=get_language())
> 
> class MyModel(models.Model):
> ...
> objects = MyManager()
> 
> Using this in a code path that’s in the request-response cycle works (eg. 
> in a view), but using it in a form definition doesn’t (I get the default 
> language instead of the one from the request):
> 
> class MyForm(forms.Form):
> option = forms.ModelChoiceField(queryset=MyModel.objects.all())

Can you post how you're using the form?  Are you using the form in a
view?  Can you post the view code?

-- 
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/20220612211356.GB32625%40fattuba.com.


Re: How to hash fields and detect changes in a record

2022-06-12 Thread Ryan Nowakowski
On Sat, Jun 11, 2022 at 12:13:16AM +1000, Mike Dewhirst wrote:
> On 10/06/2022 11:24 pm, Ryan Nowakowski wrote:
> > On Fri, Jun 10, 2022 at 05:52:48PM +1000, Mike Dewhirst wrote:
> > > I think the solution might be to hash note.title and note.note into a new
> > > field note.hash on being auto-created. On subsequent saves, compare the
> > > latest hash with note.hash to decide whether to delete auto-inserted notes
> > > prior to generating the next set. Those subsequent saves could be months 
> > > or
> > > years later.
> > Hashing is useful if you want to check that something has been
> > unexpectedly changed.  I assume the note can only be changed through
> > your web app so you know when a user is changing a note.
> 
> These are automatically generated notes which taken together constitute
> advice on how to deal with the analysis. Users can edit them. For example,
> someone might record some action taken regarding the advice. I don't want to
> delete that. If nothing has been edited, it is safe to delete.
> 
> So how do I know it is the same as when originally generated - and safe to
> delete - except by storing a hash of the interesting fields.

Because when the user edits a note, during the form.save()(assuming
you're using Django forms), you'll set `altered_by_user` to True.

> And if that is the best approach, what sort of hashing will survive Python
> upgrades etc?

Pick a hash algorithm[1](ex: sha256).  The output will remain the same
even with Python upgrades.

[1] https://docs.python.org/3/library/hashlib.html

> > Since you're
> > expecting users to change some of the notes and you know when they do,
> > hashing might be overkill.  Instead, add a boolean `altered_by_user`
> > field to the note model.  Initially when you automatically create the
> > note altered_by_user would be set to False.  If a user changes the note,
> > set altered_by_user to True.
>
> Not sure this would work. Note creation and eventually automatic deletion is
> all driven from model methods executed on saving.

Why wouldn't this work? During note creation, altered_by_user would be
set to False automatically because that's the default.  When
automatically deleting, do:

Note.objects.filter(altered_by_user=False).delete()

-- 
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/20220612210931.GA32625%40fattuba.com.


Re: How to hash fields and detect changes in a record

2022-06-10 Thread Ryan Nowakowski
On Fri, Jun 10, 2022 at 05:52:48PM +1000, Mike Dewhirst wrote:
> The use case is auto-deletion of out-of-date records if they have not
> changed.
> 
> That might sound weird but it is the solution I have come to for a
> particular problem. My software analyses chemical properties and writes note
> records containing advice, each with a FK to the chemical.
> 
> When values change sufficiently on the chemical, the software would
> construct a set of mostly different note records. The problem is that note
> records still exist from the previous set of properties. These would
> definitely confuse the user and thereby invalidate the advice.

You might consider versioning your chemical model objects.  Then when
values change sufficiently on the chemical model object, you can create
a new version of the chemical object, leaving the old notes associated
with the old version of the chemical object.  In your web app, you could
allow the users to browse old versions of the chemical including the
notes which may have been altered.

> The workaround is for the user to delete all notes *prior* to re-saving and
> auto-generating a new correct set of notes. There is a proviso that you
> wouldn't want to delete notes altered by users. I would document that so
> users understand why the software skipped deleting those notes.
> 
> I think the solution might be to hash note.title and note.note into a new
> field note.hash on being auto-created. On subsequent saves, compare the
> latest hash with note.hash to decide whether to delete auto-inserted notes
> prior to generating the next set. Those subsequent saves could be months or
> years later.

Hashing is useful if you want to check that something has been
unexpectedly changed.  I assume the note can only be changed through
your web app so you know when a user is changing a note.  Since you're
expecting users to change some of the notes and you know when they do,
hashing might be overkill.  Instead, add a boolean `altered_by_user`
field to the note model.  Initially when you automatically create the
note altered_by_user would be set to False.  If a user changes the note,
set altered_by_user to True.

> If unchanged, the old note is safe to delete because it is no longer
> relevant.
> 
> I've googled around and there are lots of possible solutions but it seems
> the major problem might be that hashes are difficult to guarantee when the
> environment - such as the version of Python - changes.
> 
> Also, I'm not convinced I have chosen the correct strategy.
> 
> Hope I've explained the problem adequately.
 

-- 
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/20220610132452.GA18658%40fattuba.com.


Re: ComboBox

2022-06-04 Thread Ryan Nowakowski
The HTML element you probably want is a datalist[1]. There's no built-in Django 
support for datalist[2] so you'll probably need to create a custom widget.

[1] https://stackoverflow.com/a/14614750
[2] https://code.djangoproject.com/ticket/32125

On May 31, 2022 11:52:31 AM CDT, Phil Parkin  wrote:
>Hi all
>
>I am converting a desktop application to Django web application. The 
>desktop app uses comboboxes (editable dropdown/select). Is their any 
>elegant way of applying the same functionality in Django? Stack Overflow 
>etc. all seem to be about dropdown select lists only.
>
>I can see ways of doing this with a Choicefield plus a separate Charfield, 
>but is there a better way?
>
>Thanks -Phil 
>
>-- 
>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/1b7836ae-e52e-4e35-aefc-739ce6f586d0n%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/146FCD26-58D5-4A4B-898F-5F0AA1144C7D%40fattuba.com.


Re: Deploy Tailwind Template with Django

2022-06-01 Thread Ryan Nowakowski
Drop the HTML into your templates directory. Then put all the static assets ( 
CSS, js ) in your static directory. Change all the references to the static 
assets in your HTML to the new location and your static directory by using the 
staticfiles template tag.

On May 31, 2022 6:52:12 PM CDT, Ry  wrote:
>Hi I recently downloaded a template from cruip.com
>
>https://preview.cruip.com/mosaic/
>
>I'd like to integrate this template into my django site but admittedly I am 
>not sure where to begin. Does anyone have experience using templates such 
>as the dashboard above on django? In the end, I'd like to deploy to heroku. 
>Is this even possible?
>
>
>-- 
>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/3d814c66-15d5-4014-926e-a74bab2b466dn%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/43280094-201C-4B56-AD12-362BC96F625C%40fattuba.com.


Re: Auto Template Update

2022-05-31 Thread Ryan Nowakowski
There's a couple of ways to update the UI without the user doing anything. 
First, you can poll the server at a regular interval using JavaScript. Second, 
you can use a websocket to push updates from the server to the client.

On May 30, 2022 6:28:40 AM CDT, Dev femibadmus  wrote:
>fine! we can submit form with ajax, and update little tag b cant update all.
>
>*Instagram* auto update likes, new post, message or even notification 
>without any event, even if a event itself action how possible to update 
>differents post likes, notification blah blah blah blah blah..*How???*
>
>-- 
>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/0ad98d8c-a9de-4a4c-af16-484426f2f695n%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/357EBCCC-9DA6-4EC0-9EA9-72F73B183F65%40fattuba.com.


Re: Allocating items to users

2022-05-23 Thread Ryan Nowakowski
On Fri, May 13, 2022 at 09:27:48AM -0700, 'dtdave' via Django users wrote:
> I have the following code:
> from django.conf import settings
> from django.db import models
> 
> class AccountManager(models.Model):
> account_manager = models.ForeignKey(
> settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, 
> blank=True
> )
> 
> class Meta:
> verbose_name = 'Account Manager'
> verbose_name_plural = 'Account Managers'
> 
> def __str__(self):
> return str(self.account_manager)
> The view for this, effectively a profile, is as follows
> 
> from django.contrib.auth import get_user_model
> from django.shortcuts import render
> from django.views.generic import DetailView
> from django.contrib.auth.mixins import LoginRequiredMixin
> 
> from .models import AccountManager
> 
> User = get_user_model()
> 
> 
> class AccountManagerDetailView(LoginRequiredMixin, DetailView):
> model = AccountManager
> template_name = "accountmanagers/dashboard.html" 
>  
> def get_object(self, *args, **kwargs):
> return self.request.user
> 
> And the url:
> urlpatterns = [
> path('detail/', views.AccountManagerDetailView.as_view(), 
> name='accountmanagers'),
> ]
> The template then shows the relevant user details but my problem is that I 
> am stuck allocating the clients to the specific account manager. I know 
> that I am missing the point in implementing a queryset and tieing it to 
> that user.
> Any help would be appreciated.

What would you like the relationship between client and account manager
to be?  One to one?  One to many?  Many to many?

- Ryan N

-- 
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/20220523140201.GC10089%40fattuba.com.


Re: Django SMS project

2022-05-23 Thread Ryan Nowakowski
On Sun, May 22, 2022 at 09:08:27AM +0100, Tanni Seriki wrote:
> Hi guys I have a project of django to send SMS to mobile number,
> Please guys I really need your helps

I agree with the other replies that your post is a little vague.
That being said, in general when I want to send txts from Django, I use...

https://pypi.org/project/django-sms/

(disclosure: I've contributed to django-sms in the past)

- Ryan N

-- 
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/20220523135439.GB10089%40fattuba.com.


Re: Class based views with forms

2022-04-28 Thread Ryan Nowakowski
You're right, it's not very clear how to have a single class-based view 
handle both displaying details and submitting a form.  This is a 
fantastic site that shows how each class based view is set up 
inheritance-wise: https://ccbv.co.uk/


Take a look the ancestors for DetailView: 
https://ccbv.co.uk/projects/Django/4.0/django.views.generic.detail/DetailView/


... and the ancestors for FormView: 
https://ccbv.co.uk/projects/Django/4.0/django.views.generic.edit/FormView/



Maybe you can just add the FormMixin as an ancestor to your DetailView.


As another option, maybe you can create a separate FormView that you can 
POST to from your DetailView.



- Ryan N

On 4/26/22 5:25 AM, alex smolyakov wrote:

Can anyone explain me how to make send email form on page.

So my forms.py

class ContactForm(forms.Form):
    name = forms.CharField(required=True)
    last_name = forms.CharField()
    adults = forms.IntegerField() children = forms.IntegerField()
    email = forms.EmailField(required=True)
    message = forms.CharField(widget=forms.Textarea)

views.py

class TourDetailView(DetailView):
    model = models.Tour
    template_name = 'tours/tour-detail.html'
    form_class = forms.ContactForm
    success_url = 'tours.html'

As far as i understand i need to get data from request , but i dont 
know how to do it. There are a lot of information in function based 
views, but i didnt get how to do it in class based views.


And it would be nice of you to explain where should i put send_mail 
function. Any help will be appreciated.




--
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/235da153-a9d7-2582-ace4-3dbf147d17f8%40fattuba.com.


Re: I need a documentation in Thai language

2022-04-18 Thread Ryan Nowakowski
Maybe try Google translate?

https://docs-djangoproject-com.translate.goog/en/4.0/?_x_tr_sl=auto&_x_tr_tl=th&_x_tr_hl=en&_x_tr_pto=wapp

On April 9, 2022 1:08:34 PM CDT, frame fF  wrote:
> I'm not good at English in the future. documentation Thai language? 
>
>-- 
>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/5a82b305-9e75-45f1-a0de-47fbda1e86e3n%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/183CADAB-76AE-44EB-8C92-7C37F9AADBCE%40fattuba.com.


Re: Using Multiple databases

2022-04-15 Thread Ryan Nowakowski
On Wed, Apr 06, 2022 at 08:59:09AM -0700, Vasanth Mohan wrote:
> I'm building a PoC for a multi-tenant app where I'm trying to use the same 
> schema across multiple databases with Django instance. I've got a couple of 
> questions and I'd be happy to have some input
> 
> 1. Is there a way to define the *using()* function to use with Models via a 
> lib/middleware?
> 2. Is there a way to create admin users so that they have access to 
> specific databases? 

You probably want to create a custom database router[1].

[1] 
https://docs.djangoproject.com/en/4.0/topics/db/multi-db/#automatic-database-routing

-- 
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/20220415180748.GC15520%40fattuba.com.


Re: Filtering User Data/Records

2022-04-15 Thread Ryan Nowakowski
On Thu, Apr 07, 2022 at 01:08:19PM +0300, tech george wrote:
> I am trying to filter my medicine stock data so that Pharmacist 1 can only
> view their records but not  Pharmacist 's 2 records.
> 
> So far nothing is filtered and all the pharmacists can see all the
> available records, Please advise.
 
I'm assuming the view you're having problems with is manageStock3.  You
probably want to filter stocks based on the pharmacist that is logged in.  Try
something like:

stocks = Stock.objects.filter(pharmacist_id=request.user)

-- 
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/20220415180258.GB15520%40fattuba.com.


Re: How to create dynamic models in django??

2022-03-09 Thread Ryan Nowakowski
On Sun, Feb 27, 2022 at 09:10:05AM +0530, Prashanth Patelc wrote:
> How to create dynamic models in django rest framework?
> Is there any chance to create dynamic models with APIs
> 
> Any examples please send me thanks in advance..
> 
> 1) Requirement is need create table name and fields in frontend
> 2) we are  getting the data and store in to the db create db structure
> 3) get the table name and fields create table in backend &postgresql store
> to
> 4)this code don't update or add into the models
> 5)store the data into the tables
> 4)get the data into the tables using orm or any raw queries

The WQ project uses the Entity-Attribute-Value data model:

https://v1.wq.io/1.2/docs/eav-vs-relational

-- 
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/20220309235228.GH4556%40fattuba.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Ryan Nowakowski
Steven, are you using ModelFormSet?  If so, Is it the initial query
that's slow?  The form rendering?  Or is it the POST back to the server
that's slow?  You can use django-debug-toolbar[1] to profile your page
and get these metrics.

Once you figure out what part is slowest, then you can optimize.

Hope this helps!

Ryan N

[1] https://django-debug-toolbar.readthedocs.io/en/latest/

On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> Did this issue ever get resolved?  I'm experiencing the same thing.  Once 
> it hits 100 forms or so it gets pretty slow.
> 
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
> 
> > Yes, if you want speed, using javascript and ajax is probably your best 
> > bet. It will probably also reduce merge-conflicts.
> >

-- 
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/20220225222926.GH11627%40fattuba.com.


Re: How to validate xl data

2022-02-25 Thread Ryan Nowakowski
On Mon, Feb 14, 2022 at 12:04:13PM +0530, Prashanth Patelc wrote:
> i am working on xl sheets , when im uploading the xl sheet it is storing
> into the models but i need before storing into the models validate the data
> 
> eg:
> username : ,must be str not int
> reference id : ,must be int not str
> email : ,contains @gmail.com , not strt not int
> 
> i need to validate like above

You could use a Python library[1] to parse the Excel file and validate the
sheet values in a validator function[2].

[1] https://www.python-excel.org/
[2] https://docs.djangoproject.com/en/4.0/ref/validators/

-- 
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/20220225222113.GG11627%40fattuba.com.


Re: Salary Generate

2022-02-25 Thread Ryan Nowakowski
On Tue, Feb 15, 2022 at 06:32:34AM -0800, Feroz Ahmed wrote:
> i am stuck at point to generate salaries for upcoming month,
> as i already have last month January data as fields(month, name , gross 
> sal, tax deduction, net sal)
> and it has records of 35 (employees)
> in form template i have placed submit button to generate salaries for 
> February.
> 
> Plz help how to get all get data as it is from previous Month  month 
> AND new records to be as for month February
> 
> ** month field data for 35 record to be as new records and month values 
> as **February
> data file attached.
> 
> Class employee(models. Model)
> month=models.CharField(max_length=64)
>   name= models.CharField(max_length=64)
>   gross sal= models.IntegerField()
>   tax= models.IntegerField()
> net sal= models.IntegerField()
 

Hey Feroz,

Since you mentioned getting the data by "previous month", let's start
there.  Your month field is a CharField so I assume your storing the
names of the months in there.  If so, you'll need a way to figure out
what the previous month is.  Let's say the current month is February,
you could use a list of month names[1] and lookup the index of the
current month:


month_names = list(calendar.month_name)[1:]
month_index = month_names.index('February')

Then get the previous month by subtraction:

previous_month_index = (month_index - 1) % 12
previous_month = month_names[previous_month_index]

But you have another problem.  You're not keeping track of the year.
So, at most you can only store one year's worth of salary records.
So at this point, I'd recommend replacing the CharField month field with
a DateField.  That solves your problem of keeping track of the year.
Then you can also use some date math[2] to calculate the previous month.

Once you have the previous month, you can use that to: lookup that model
instance, copy it[3], update the month to the current month, then save.

As an aside, I'd rename your model class to something that makes more
sense, from 'Employee' to 'PayRecord`


Hope this helps!

Ryan N


[1] https://docs.python.org/3/library/calendar.html#calendar.month_name
[2] https://stackoverflow.com/a/9725093/226697
[3] 
https://docs.djangoproject.com/en/3.2/topics/db/queries/#copying-model-instances

-- 
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/20220225205324.GF11627%40fattuba.com.


Re: django-oscar customisation

2021-12-09 Thread Ryan Nowakowski
Try running the sandbox application:

https://django-oscar.readthedocs.io/en/stable/internals/sandbox.html

Then you can poke around that sandbox code and see how they did things.



On November 22, 2021 2:23:28 AM CST, "Hervé Edorh"  wrote:
>Hi, 
>I am new to django-oscar and i try to understand the structure of oscar. i 
>have read many times the documentation but i think there is something i 
>don't understand.
>I fork the template and customise the layout.html, base.html. but how can i 
>build my own first page, i don't see an index.html...
>
>-- 
>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/4000707d-c14e-4193-92b8-730a4d2aa5den%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/A71134F3-1FAA-4759-AF4C-E3887F45E1CC%40fattuba.com.


Re: Declarative mechanism for Django model rows

2021-12-09 Thread Ryan Nowakowski
Check out fixtures:

https://docs.djangoproject.com/en/3.2/howto/initial-data/

On December 8, 2021 1:25:45 PM CST, Alex Dehnert  wrote:
>With some frequency, I end up with models who contents are approximately 
>constant. Are there good ways of handling this?
>
>For example, I might have a set of plans that users can sign up 
>for, with various attributes -- ID, name, order in the list of plans, 
>cost, whether the purchaser needs to be a student/FOSS project/etc.. I'm 
>going to rarely add/remove/change rows, and when I do there's likely going 
>to be code changes too (eg, to change landing pages), so I'd like the 
>contents of the model (not just the schema) to be managed in the code 
>rather than through the Django admin (and consequently use pull requests 
>to manage them, make sure test deploys are in sync, etc.). I'd also like 
>it to be in the database, though, so I can select them using any column of 
>the model, filter for things like "show me any project owned by a paid 
>account", etc..
>
>I think my ideal would be something like "have a list of model instances 
>in my code, and either Django's ORM magically pretends they're actually in 
>the database, or makemigrations makes data migrations for me", but I don't 
>think that exists?
>
>The two workable approaches that come to mind are to either write data 
>migrations by hand or use regular classes (or dicts) and write whatever 
>getters and filters I actually want by hand.
>
>Data migrations give me all the Django ORM functionality I might want, but 
>any time I change a row I need to write a migration by hand, and figuring 
>out the actual state involves either looking in the Django admin or 
>looking through all the data migrations to figure out their combined 
>impact. (Oh, and if somebody accidentally deletes the objects in the 
>database (most likely on a test install...) or a migration is screwy 
>recovering will be a mess.)
>
>Just using non-ORM classes in the source is a clearer, more declarative 
>approach, but I need to add replacements for many things I might normally 
>do in the ORM (.objects.get(...), __plan__is_student, 
>.values(plan__is_student).annotate(...), etc.).
>
>Which of these approaches is better presumably depends on how much ORM 
>functionality I actually want and how often I expect to be changing 
>things.
>
>Are there other good approaches for this? Am I missing some Django feature 
>(or add-on) that makes this easier?
>
>Thanks,
>Alex
>
>P.S. I previously asked this on StackOverflow at 
>https://stackoverflow.com/questions/70204467/declarative-mechanism-for-django-model-rows,
> 
>but I'm realising this list is probably better.
>
>-- 
>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/alpine.DEB.2.21.2112081409120.12786%40novgorod.mit.edu.

-- 
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/55D126DC-6D7A-42EE-A482-423C214E7677%40fattuba.com.


Permissions Model Inefficiency Killing DB

2021-11-24 Thread Ryan Skadberg
Hi All -

  Running Django 2.2.24 (Yes, I know, we are working on moving to 3.2)

  I've noticed some stalls in startup and finally have tracked it down.  It 
appears when permissions are imported, it checks EVERY user for 
permissions, NOT just the ones in the user_user_permissions table.  When 
you have 30k users in your DB this causes at least 60k SQL calls on startup.

They all look something like this:

2021-11-24 19:04:46.725 UTC [39] LOG:  duration: 0.344 ms  statement: 
SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group" INNER JOIN 
"user_groups" ON ("auth_group"."id" = "user_groups"."group_id") WHERE 
"user_groups"."customuser_id" = 27345
2021-11-24 19:04:46.728 UTC [39] LOG:  duration: 0.379 ms  statement: 
SELECT "auth_permission"."id", "auth_permission"."name", 
"auth_permission"."content_type_id", "auth_permission"."codename" FROM 
"auth_permission" INNER JOIN "user_user_permissions" ON 
("auth_permission"."id" = "user_user_permissions"."permission_id") INNER 
JOIN "django_content_type" ON ("auth_permission"."content_type_id" = 
"django_content_type"."id") WHERE "user_user_permissions"."customuser_id" = 
27345 ORDER BY "django_content_type"."app_label" ASC, 
"django_content_type"."model" ASC, "auth_permission"."codename" ASC

 I have 677 rows in user_user_permissions with a minimum customuser_id of 0 
and a max of 27346.  When I start up my tests, instead of looking at the 
677 users that have permissions in the user_user_permissions table, it 
checks all 27346.  As there is nothing in the table for them, this is super 
super inefficient.

It appears that the SQL is doing something like:

select id from public.user

And really should be doing something like this to minimize SQL calls:

select id from public.user where id in (select customuser_id from 
user_user_permissions);

which in my case would be 1/30th of the calls, which would be HUGE for 
startup (60k to 2k or so).

Can anyone either explain why this is happening or a way to work around it 
or if I should file a bug?

Thanks!
Ryan

-- 
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/0d5aa4db-ccd7-482a-8530-1cc8d76bbcc0n%40googlegroups.com.


Re: Chained filters on Country and City Fields

2021-10-15 Thread Ryan Nowakowski
I assume you're using Django smart selects since you seem to be using chained 
foreign key. Here's the documentation on how to get this to work inside your 
own templates:

https://django-smart-selects.readthedocs.io/en/latest/usage.html#usage-in-templates

On October 11, 2021 8:36:21 AM CDT, maryam yousaf  
wrote:
>Hello,
>
>I have one model which is campaign tracking. In that mode, I have two Fk's 
>country and city. Cities are linked with country as I am using chained 
>filtering so, it is working fine on model level where user has to give 
>inputs but I also have to provide two filters on web interface Country and 
>City. In filters, I want to have this functionality that when user choose 
>any specific country from the drop down filter then in Cities filter, only 
>specific cities who belongs to the selected country should appear in drop 
>down but currently, I am getting all the cities. Any help is appreciated.
>
>See the code below.
>
>*models.py:*
>class CampaignTracking(models.Model):
>campaign_tracking_id = models.AutoField(primary_key=True)
>country = models.ForeignKey(Country, on_delete=models.PROTECT)
>city = ChainedForeignKey(
>City,
>chained_field='country',
>chained_model_field='country',
>show_all=False,
>auto_choose=False,
>sort=True,
>null=True,
>blank=True,
>on_delete=models.PROTECT
>)
>campaign_name = models.ForeignKey(Campaign, on_delete=models.CASCADE)
>campaign_category = models.ForeignKey(CampaignCategory, 
>on_delete=models.CASCADE)
>start_date = models.DateField()
>end_date = models.DateField()
>start_date_pre_campaign_period = models.DateField()
>end_date_pre_campaign_period = models.DateField()
>start_date_post_campaign_period = models.DateField()
>end_date_post_campaign_period = models.DateField()
>history = HistoricalRecords()
>
>
>*Admin.py:*
>class CountryFilter(AutocompleteFilter):
>title = 'Country'
>field_name = 'country'
>
>
>class CityFilter(AutocompleteFilter):
>title = 'City'
>field_name = 'city'
>
>class CampaignTrackingAdmin(SimpleHistoryAdmin):
>list_display = ('country',
>'city',
>'campaign_name',
>'campaign_category',
>'start_date',
>'end_date',
>'start_date_pre_campaign_period',
>'end_date_pre_campaign_period',
>'start_date_post_campaign_period',
>'end_date_post_campaign_period',
>)
>list_filter = (CountryFilter,
>CityFilter,
>)
>
>Current filter in django Web Interface:
>
>-- 
>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/bc67100a-bcdc-4b4c-a8b4-630d2a859aa2n%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/DDFCA28B-4B81-4F99-B11C-5DAE25FA1419%40fattuba.com.


Re: Python code changes are not reflecting on Django-based web server.

2021-09-30 Thread Ryan Nowakowski
You can use the ps command:

ps -aef | grep "apache\|httpd"


The process id(pid) is the second column usually.  If it changes, then
you know the process was restarted.

- Ryan N

On Thu, Aug 19, 2021 at 10:52:04PM -0400, Hasan Baig wrote:
> Yes systemctl stop and start httpd, i verified by checking the web page. How 
> can i check pid? 
> 
> Regards
> Hasan
> 
> > On Aug 19, 2021, at 8:55 AM, Ryan Nowakowski  wrote:
> > 
> > I'd verify that the systemctl commands are actually starting and stopping 
> > httpd. Does the pid change?
> > 
> >> On August 18, 2021 11:04:07 AM CDT, Hasan Baig  
> >> wrote:
> >> Hi,
> >> 
> >> I have been hosting a django-based web server (httpd with mod_wsgi 
> >> package) on Linux CentOS 7. I used to reflect the changes made in my code 
> >> by restarting the web server using the following commands:
> >> 
> >> sudo systemctl stop httpd
> >> sudo systemctl start httpd
> >> 
> >> and it would reflect the changes smoothly. Since few days back, this 
> >> strategy has not been work at all. That is, whenever I make any changes in 
> >> my python code, even simply printing a message in log file, it is not 
> >> reflected. To reflect the changes every time, I have to reboot the VM. I 
> >> tried the following things already which did not help at all:
> >> 
> >> • Clearing .pyc files
> >> • Restarting/Reloading httpd server
> >> • touch wsgi file
> >> • http is running without caching or proxying (modules have been commented 
> >> out)
> >> 
> >> 
> >> All of the above mentioned tries did not appear to work. The changes are 
> >> only reflected once when the VM is rebooted. 
> >> 
> >> What do I need to do to make the code changes reflected without rebooting 
> >> the VM every time? Any clues, help or suggestions are highly appreciated.
> >> 
> >> Thanks.
> >> 
> >> regards
> >> HB
> > 
> > -- 
> > 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/06AA5FDA-FF21-498E-A2B5-AE3AC7252333%40fattuba.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/E8974440-DC64-4082-ACD7-6FB6AFAF04E5%40gmail.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/20210930193559.GF6979%40fattuba.com.


Re: Python code changes are not reflecting on Django-based web server.

2021-08-19 Thread Ryan Nowakowski
I'd verify that the systemctl commands are actually starting and stopping 
httpd. Does the pid change?

On August 18, 2021 11:04:07 AM CDT, Hasan Baig  wrote:
>Hi,
>
>I have been hosting a django-based web server (httpd with mod_wsgi package) on 
>Linux CentOS 7. I used to reflect the changes made in my code by restarting 
>the web server using the following commands:
>
>sudo systemctl stop httpd
>sudo systemctl start httpd
>
>and it would reflect the changes smoothly. Since few days back, this strategy 
>has not been work at all. That is, whenever I make any changes in my python 
>code, even simply printing a message in log file, it is not reflected. To 
>reflect the changes every time, I have to reboot the VM. I tried the following 
>things already which did not help at all:
>
>• Clearing .pyc files
>• Restarting/Reloading httpd server
>• touch wsgi file
>• http is running without caching or proxying (modules have been commented out)
>
>
>All of the above mentioned tries did not appear to work. The changes are only 
>reflected once when the VM is rebooted. 
>
>What do I need to do to make the code changes reflected without rebooting the 
>VM every time? Any clues, help or suggestions are highly appreciated.
>
>Thanks.
>
>regards
>HB
>
>-- 
>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/9AB779C6-CE51-4410-9A27-0E8BBFAEA55B%40gmail.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/06AA5FDA-FF21-498E-A2B5-AE3AC7252333%40fattuba.com.


Re: Git Hub Project

2021-08-10 Thread Ryan Nowakowski
You might have mixed tabs and spaces. PEP8 standard is 4 spaces per level of 
indentation, IIRC.

On August 9, 2021 7:24:56 AM CDT, Rana Zain  wrote:
>
>Thank you so much everyone. It's work.
>
>I have another problem. I am facing this issue in Pycharm .  I tried
>spaces 
>& tabs.
>
>Error is :"Unindent does not match any outer indentation level""
>On Thursday, August 5, 2021 at 11:15:27 AM UTC+5 satyajit...@gmail.com 
>wrote:
>
>> what exactly you're trying to do?
>>
>> On Wed, Aug 4, 2021 at 6:41 PM Rana Zain 
>wrote:
>>
>>> Hi,
>>> Can anybody help me in running git clone django Project?
>>>
>>> -- 
>>>
>> 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/425c8297-2097-4952-b2ac-3fa299ff6011n%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/d99ee9ab-38f4-4ca7-9d9c-2a2301916b2fn%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/73A00DD0-2C21-49B4-B854-281153AD3CCC%40fattuba.com.


Re: how to question (web page item placement)

2021-07-12 Thread Ryan Nowakowski
I'm that case you might want to skip responsive design and take a look at 
relative or absolute positioning with CSS for the margin and indentation. Look 
at flexbox for the boxes.

On July 11, 2021 4:13:58 PM CDT, o1bigtenor  wrote:
>On Sun, Jul 11, 2021 at 11:05 AM Ryan Nowakowski 
>wrote:
>>
>> Do you want the indentation to be different on different screens
>sizes(mobile phone, tablet, laptop, desktop)? 3.5 cm might be too much
>on mobile devices.
>>
>Hmmm - - - main focus is NOT mobile devices - - - don't think they
>can handle the processor duty needed.
>
>Regards
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/CAPpdf5_5qWLbquwER3Cs8ExkWeqGmd06cPVhyvA%2BG4Sq%2BhC41g%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/2F93D690-60BB-4F4E-9C8A-C2E63E21642F%40fattuba.com.


Re: how to question (web page item placement)

2021-07-11 Thread Ryan Nowakowski
Do you want the indentation to be different on different screens sizes(mobile 
phone, tablet, laptop, desktop)? 3.5 cm might be too much on mobile devices.

On July 11, 2021 10:14:23 AM CDT, o1bigtenor  wrote:
>Greetings
>
>Am looking to use django for a personal application.
>
>I am one of those plagued by planning things out - - - in advance.
>
>I'm not finding direct information for how to specifically place
>things on as page.
>Vague - - - yes - - - that's html but if I want something like at 3.5
>cm down from top margin and indented 1.5 cm I want a box which when
>clicked upon I see a list containing these items (a1, a2, a3 etc and
>the list can be augmented by the user) with list items being font size
>14 bold and the box being flexible in that if the item shown is short
>the box is narrower - - - if the item is long - - - -well the box is
>wider.
>
>How do I affect precise placement in a web page?
>
>TIA
>
>-- 
>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/CAPpdf5-xvCKX6%3D1nzm1Nr8Fy9ix6mOVRzCZkivy7rwFOAtm%2Bbg%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/4594EFF2-3A01-4B54-8ED3-ED84BFC61EBE%40fattuba.com.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread Ryan Nowakowski
On Thu, Jun 24, 2021 at 07:15:09AM -0700, DJANGO DEVELOPER wrote:
> Hi Django experts.
> I am building a Django, DRF based mobile app and I want to have 
> functionality of up votes and down votes for posts that user will post.
> So what I want to say here that, if an user upvotes a post then it should 
> be get higher ranks as quora questions do. and if there are more down votes 
> than up votes then a post should be moved down ward rather than going up.
> I have applied a logic already here and shared the screenshots as well. but 
> I am sure that there is a better logic or solution for this problem.

Do you want your users to be able to change or delete their vote?
In that case, you'll need to keep track of who voted what. Maybe create
a model like this:

class VoteQuerySet(models.QuerySet):

def down(self):
"""Return only the down votes"""
return self.filter(value__lt=0)

def up(self):
"""Return only the up votes"""
return self.filter(value__gt=0)

def down_total(self):
"""Return the down vote total as a negative number"""
return self.down().aggregate(Sum('value'))['value__sum']

def up_total(self):
"""Return the up vote total as a positive number"""
return self.up().aggregate(Sum('value'))['value__sum']

def total(self):
"""Return the total of all up and down votes"""
return self.aggregate(Sum('value'))['value__sum']


class Vote(models.Model):
"""A user's up or down vote for a post

"value" should be -1 for a down vote and 1 for an up vote

"""
user = models.ForeignKey(User, on_delete=models.CASCADE)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
value = models.SmallIntegerField()

objects = VoteQuerySet.as_manager()

class Meta:
unique_together = (user, post)

def vote_up(self):
self.value = 1

def vote_down(self):
self.value = -1


You can then vote like this:

vote = Vote(user=user, post=post)
vote.vote_up()  # or vote.vote_down()
vote.save()


Here's a post's up vote count:

post.vote_set.up_total()


You can change a user's vote like this:

vote = user.vote_set.get(post=post)
vote.vote_down()

... or delete:

vote.delete()


Any finally, here's how you can sort your posts:


Post.objects.all().annotate(vote_total=Sum('vote__value')).order_by('-vote_total')


Caveat: code untested



Hope this helps!

Ryan

-- 
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/20210625155946.GC16290%40fattuba.com.


Re: Django Admin: object history not working

2021-06-22 Thread Ryan Kite

Thanks for the clarification, I didn't realize it only applied to changes 
administered directly from the Django Admin. 
Was interested in learning about an objects' change history, but in this 
case, the changes were not performed from the Django Admin. 


On Tuesday, June 22, 2021 at 5:50:10 AM UTC-7 christian...@gmail.com wrote:

> I am not sure what you are asking about.
> The history works out of the box, but only when you manipulate entries via 
> the django admin.
> When you change the model instance through your own views, you have to 
> explicitly create the log entry.
>
> On Tue, 22 Jun 2021 at 00:48, Ryan Kite  wrote:
>
>> Hello,
>>
>> The issue is when clicking the "History" button on an object from the 
>> Django admin site, it opens to the template but says "*This object 
>> doesn't have a change history. It probably wasn't added via this admin 
>> site."*
>>
>> From reading the docs it appears that: *history_view*() already exists 
>> (which is what I want)
>>
>> /// from the doc page: 
>> ModelAdmin.history_view(*request*, *object_id*, *extra_context=None*)
>> [source] 
>> <https://docs.djangoproject.com/en/1.11/_modules/django/contrib/admin/options/#ModelAdmin.history_view>
>> ¶ 
>> <https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.history_view>
>>
>>  Django view for the page that shows the modification history for a 
>> given model instance.
>>
>> ///
>>
>> We can see the change history when doing:
>>
>>  python manage.shell
>>
>> import django.contrib.admin.models import LogEntry
>> from django.contrib.contenttypes.models import ContentType
>> from app import MyModel 
>>
>>  results = 
>> LogEntry.objects.filter(content_type=ContentType.objects.get_for_model(MyModel
>>  
>> ))
>>
>> print(vars(results[1])) 
>>
>> .. shows the change details
>>
>> Please tell me what I'm missing or need to add. 
>>
>>
>>
>> -- 
>> 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/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Best Regards,
>
> Christian Ledermann
>
> Dublin, IE
> Mobile : +353 (0) 899748838
>
> https://www.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>

-- 
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/cc8975e1-8b77-4316-92df-909eecaad98cn%40googlegroups.com.


Django Admin: object history not working

2021-06-21 Thread Ryan Kite
Hello,

The issue is when clicking the "History" button on an object from the 
Django admin site, it opens to the template but says "*This object doesn't 
have a change history. It probably wasn't added via this admin site."*

>From reading the docs it appears that: *history_view*() already exists 
(which is what I want)

/// from the doc page: 
ModelAdmin.history_view(*request*, *object_id*, *extra_context=None*)
[source] 


 Django view for the page that shows the modification history for a 
given model instance.

///

We can see the change history when doing:

 python manage.shell

import django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
from app import MyModel 

 results = 
LogEntry.objects.filter(content_type=ContentType.objects.get_for_model(MyModel 
))

print(vars(results[1])) 

.. shows the change details

Please tell me what I'm missing or need to add. 



-- 
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/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com.


Re: Real-time dashboard method after delivering restapi from outside

2021-06-15 Thread Ryan Nowakowski



On June 14, 2021 1:46:29 AM CDT, "이경현"  wrote:
>It is currently returning after receiving an api request from another 
>system.

Is this API request to another system initiated from Django on the back end or 
in JavaScript on the front end? 

-- 
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/B1EC1DD4-5396-4F6A-ABDF-7E9F01E68981%40fattuba.com.


Re: DEFAULT Django Session is still using File in /tmp (Can't read from directory)

2021-06-13 Thread Ryan Nowakowski
You probably don't want to use file-based sessions if you're load
balancing your application across multiple nodes.  If your session gets
created on one application node, how will the other application nodes
have access to it?  This might work if you have access to each
file-based session on every node via NFS or something like it.  Rather
than do that, I'd recommend storing your sessions in the database or
some other service like redis.

On Tue, Jun 08, 2021 at 11:26:38PM -0700, Andre Foote wrote:
> Because this is all coming from when I enabled sessions and the server 
> admin tried to implement the application on multiple nodes.
> 
> On Wednesday, April 28, 2021 at 6:41:24 PM UTC+7 Ryan Nowakowski wrote:
> 
> > What makes you think this has anything to do with Django sessions?
> >
> >
> > On April 27, 2021 11:15:57 PM CDT, Andre Foote  
> > wrote:
> >>
> >> FileNotFoundError at /admin/region/country/process_import/
> >> [Errno 2] No such file or directory: '/tmp/tmpu31qxebf'
> >> *Request Method*: POST
> >> *Request URL*: http://myurl/admin/region/country/process_import/
> >> *Django Version*: 3.0.10
> >> *Exception Type*: FileNotFoundError
> >> *Exception Value*: 
> >> [Errno 2] No such file or directory: '/tmp/tmpu31qxebf'
> >> *Exception Location*: 
> >> /usr/local/lib/python3.8/site-packages/import_export/tmp_storages.py 
> >> in open, line 29
> >> *Python Executable*: /usr/local/bin/python
> >> *Python Version*: 3.8.3
> >>
> >> I understand from the Django docs 
> >> <https://docs.djangoproject.com/en/3.2/topics/http/sessions/#using-file-based-sessions>
> >>  that 
> >> when using File-based sessions, one must check that their "web server has 
> >> permissions to read and write to this location" (I'm not sure how/where to 
> >> enforce this, in my initial post, I tried to enforce inheritence of folder 
> >> permissions but that didn't work - any pointers would be appreciated.)
> >>
> >> However I'm using the default configuration for sessions that's supposed 
> >> to be database-backed.
> >> On Tuesday, April 27, 2021 at 9:52:03 PM UTC+2 Ryan Nowakowski wrote:
> >>
> >>>
> >>>
> >>> On April 26, 2021 11:31:24 PM CDT, Andre Foote  
> >>> wrote: 
> >>> >However, the application crashes with the error stating that it is 
> >>> >unable 
> >>> >to read the session data stored in "/tmp". 
> >>>
> >>> Please post the full error including any exception messages and the full 
> >>> Python trace back if available. 
> >>>
> >>
> 
> -- 
> 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/f4bcccbc-17b9-4507-9b17-7c477f0193aan%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/20210613220143.GC13579%40fattuba.com.


Re: django app with okta authentication --

2021-06-01 Thread Ryan Nowakowski
On Tue, Jun 01, 2021 at 10:18:24PM +0530, SNJY G wrote:
> I am running an application on django2.2 which needs to be integrated with
> okta for user authentication.
> Okta team has provided a Metadata URL which contains Okta URL, Okta Entity
> ID and Okta certificate but I am not sure where I need to configure it in
> django.
> Could someone please share steps or point me to a relevant article.

You can use either python-social-auth[1] or django-allauth[2] to be able
to login with Okta.

[1] https://python-social-auth.readthedocs.io/en/latest/backends/okta.html
[2] https://django-allauth.readthedocs.io/en/latest/providers.html#okta

-- 
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/20210601184625.GA4412%40fattuba.com.


Re: Tables missing in SQLite but viewable in admin (confusion)

2021-05-29 Thread Ryan Kite
Thanks, Antonis, you were correct. The app was not actually using the 
SQLite DB it was using a different one that was not on the local machine. 

On Saturday, May 29, 2021 at 2:59:44 AM UTC-7 Antonis Christofides wrote:

> The table name by default has the app name prepended; so the table for 
> PastSurgicalHistory will be named superhealth_pastsurgicalhistory (assuming 
> that your app is named superhealth).
>
> Other than that, I'd make absolutely sure that the database I'm examining 
> with the sqlite3 command (or whatever tool you have) is really the same as 
> the one that is being read by Django. E.g. move the database file somewhere 
> else (and restart Django) and make sure that the data in Django admin is 
> gone.
>
> Antonis Christofides+30-6979924665 <+30%20697%20992%204665> (mobile)
>
>
> On 29/05/2021 02.56, Ryan Kite wrote:
>
> Greetings! 
>
> Am very confused about why the local dev SQLite DB 'appears' to be missing 
> several tables.
>
> In the Django Admin they exist and have data. 
>
> I would be expecting to see the following tables in the DB but can't find 
> them.
> (These are the model names since I don't know what the table name look 
> like yet.) 
>
>- Model: Allergies | Table: ? 
>- Model: DoctorsAndProviders | Table: ? 
>- Model: FamilyContacts | Table: ? 
>- Model: PastSurgicalHistory | Table: ? 
>- Model: HealthProfile | Table: ? 
>
> But, I do see these two models with their tables in the DB
>
>- Model: Med | Table: meds 
>- Model: PastMedicalHistory  | Table: past_med_hx 
>
>
> The application seems to be working for the most part, we can still add 
> and remove objects. But was encountering errors when trying to build a 
> ForeignKey from the Allergies model to the HealthProfile Model that lives 
> under the Users app. The error said something along the lines about the ID 
> did not exist in the table? Which caused me to view the DB and notice this. 
>
> Any help appreciated :)
>
> screenshots attached.
>
>
> -- 
> 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/9f7fecd6-b152-4e6d-8a9e-d22508b9d975n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/9f7fecd6-b152-4e6d-8a9e-d22508b9d975n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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/8dd5d6e4-2f9d-473c-bd4e-d1617aef2a48n%40googlegroups.com.


Re: looking for an expert django developer

2021-05-23 Thread ryan yadav
https://docs.google.com/presentation/d/1V1ou6JfXUrlK1j2vyAKmeNGuN4XcCBrwiLrlcYqP-gY/edit#slide=id.p

On Sun, 23 May 2021 at 09:28, Deepak joshi  wrote:

>  hey dear you are looking for django developer ,, can you tell me your
> requirements? i am fullstack web developer i can develop whatever you want
> regarding django.
>
>
>
> --
> 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/-hNSkUNqyAo/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/CANxRnovrA_JtD5ks-76Yt%2BNntouEn2QW6HBgbSRzjrSPQdpX8g%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/CANdLXB3XGaWDYQ%2BDTB5H4b01ZLVDTGEhcwsu%2B%3DpBfqH23i%3DOXQ%40mail.gmail.com.


Re: looking for an expert django developer

2021-05-23 Thread ryan yadav
please drop me a mail 
On Sunday, 23 May 2021 at 09:28:17 UTC+5:30 joshig...@gmail.com wrote:

>  hey dear you are looking for django developer ,, can you tell me your 
> requirements? i am fullstack web developer i can develop whatever you want 
> regarding django.
>
>  
>

-- 
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/977d372f-e60b-4d29-aa3b-0bb9165e0051n%40googlegroups.com.


Re: looking for an expert django developer

2021-05-23 Thread ryan yadav
drop me a mail for requirements


On Sunday, 23 May 2021 at 09:06:29 UTC+5:30 mehdiz...@gmail.com wrote:

> Depends on what your requirements are. 
> What type of code you are doing. 
> What are your expectations - work expectations and achievables. 
>
> Please set out more information ? - or lets discuss the plan, break-down 
> the tasks and timelines; basis the code (quality, design, technique of 
> implementation etc).
>
>
> For example: 
> if you are working this on django-admin completely, your db design would 
> be a little different to accomodate it best and maintain correct 
> information. (for easy/quick development), if not you could be looking at 
> it a lot differently.
>
> Let me know.
>
> On Saturday, 22 May 2021 at 04:48:58 UTC+5:30 rahj...@gmail.com wrote:
>
>> i need an expert django developer ,who alone can build the whole platform 
>> its a medical edtech startup and i have made 30% of total development i 
>> need further collaboration to make it right on time .
>> this works is going to be contract basic or may be it can lend you a full 
>> time 
>> interested peoples please mail me rahj...@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/462e6bea-3a10-4afd-8200-e0c6ae0a1364n%40googlegroups.com.


Re: looking for an expert django developer

2021-05-22 Thread ryan yadav
hows ur expertise/grasp in django >
?


On Sat, 22 May 2021 at 16:42, Eng. Medson Naftal 
wrote:

> Hello,
>
> My name is medson, Am doing django,
>
> I was see this advert and am ready to work with you, can i see the project
> requirements?
>
> Best Regards
> medson
>
> On Sat, May 22, 2021, 2:18 AM ryan yadav  wrote:
>
>> i need an expert django developer ,who alone can build the whole platform
>> its a medical edtech startup and i have made 30% of total development i
>> need further collaboration to make it right on time .
>> this works is going to be contract basic or may be it can lend you a full
>> time
>> interested peoples please mail me rahj45...@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/77258d20-80ea-40ff-8ae5-d2272030d198n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/77258d20-80ea-40ff-8ae5-d2272030d198n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/-hNSkUNqyAo/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/CAH7nK-C7S4%3DPJ5trYMg%3DV1ofFvocP67nPj22PH1auVTtvaE5QA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAH7nK-C7S4%3DPJ5trYMg%3DV1ofFvocP67nPj22PH1auVTtvaE5QA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CANdLXB36ys4sSOqn4GCaybPXPRJq%2B1TEZNfbJ1jcdXFd%2BJNQPg%40mail.gmail.com.


looking for an expert django developer

2021-05-21 Thread ryan yadav
i need an expert django developer ,who alone can build the whole platform 
its a medical edtech startup and i have made 30% of total development i 
need further collaboration to make it right on time .
this works is going to be contract basic or may be it can lend you a full 
time 
interested peoples please mail me rahj45...@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/77258d20-80ea-40ff-8ae5-d2272030d198n%40googlegroups.com.


Re: Creating dynamic chart / graphs with Django

2021-05-16 Thread Ryan Nowakowski
I like to start with one of the free dashboard templates for a project like 
this. I've used both CoreUI and AdminLTE in the past with good success. These 
dashboard templates include some sample graphs using one of the standard 
JavaScript charting libraries. 

I look at these graph examples for how the data is loaded. Then I use Django to 
load the data that same way. I like to optimize the data on the back end 
instead of having the charting library optimize it on the front end. For 
example, I'll do the interpolation of data in Python on the back end.

This allows me to have a project that has a pretty nice looking feel by 
default. Also I don't have to go through the trouble of trying to select a 
front end stack. The template has already done that for me.

On May 15, 2021 8:27:35 AM CDT, Santhosh Kumar  
wrote:
>i too have similar requirement. I tried plotly, however the integration
>of 
>django and plotly didnt go well often with huge data in sense, loading
>time 
>was high and special channels setup was required. (i learnt from this
>video 
>).
>Currently im trying with chartjs.
>Any other better suggestions please let us know in the group.
>
>I believe (not sure) such channels implementation will be required for 
>bokeh and seaborn as well. 
>
>On Monday, April 12, 2021 at 6:30:17 PM UTC+2 tristant wrote:
>
>> Thanks Walter and Lars for the tips.
>>
>> On Mon, Apr 12, 2021 at 8:16 AM Lars Liedtke  wrote:
>>
>>> Hey,
>>>
>>> this is quite good https://bokeh.org it can create dynamic html/js
>as 
>>> well, but I don't know how the interagion into django is.
>>>
>>> Cheers
>>>
>>> Lars
>>> Am 12.04.21 um 15:32 schrieb Walter Randazzo:
>>>
>>> Hi Tristan,
>>>
>>> i have used this one just once. 
>>>
>>>
>>> https://www.highcharts.com/demo
>>>
>>> Check it, it easy to setup.
>>>
>>> Regards,
>>>
>>>
>>>
>>> El lun, 12 abr 2021 a las 10:05, tristant () 
>>> escribió:
>>>
 I am looking to build site with a variety of charts and graphs. A
>quick 
 search shows quite a lot of packages out there, as listed here
>Django 
 Packages : Charts  

 Has anyone used any of these packages and could provide some advice
>on 
 which is better? For my task, I am looking to create both typical
>2D charts 
 as well as possible 3D plots. The charts need to be interactive (
>as in 
 user can tweak inputs and expect the charts to respond).

 I have done similar charts with R Shiny. I am wondering which of
>these 
 packages can do similar things?

 I notice in the link, some packages mention "offline". Does this
>mean 
 they cannot create interactive charts?

 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...@googlegroups.com.
 To view this discussion on the web visit 

>https://groups.google.com/d/msgid/django-users/efe61d41-1e8c-4c56-899f-8164c0384bf3n%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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>>
>https://groups.google.com/d/msgid/django-users/CAL7Dry50qF%3DJ0A5f3p%3DUMpVhzhnAV2s4nRmUr4g37LZ5Qju3%3Dg%40mail.gmail.com
>
>>>
>
>>> .
>>>
>>> -- 
>>> ---punkt.de GmbH
>>> Lars Liedtke
>>> .infrastructure
>>>
>>> Kaiserallee 13a 
>>> 76133 Karlsruhe
>>>
>>> Tel. +49 721 9109 500
><+49%20721%209109500>https://infrastructure.punkt.dein...@punkt.de
>>>
>>> AG Mannheim 108285
>>> Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
>>>
>>> -- 
>>> 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/b1a86516-79e5-faf1-9d6d-87edbf3301bc%40punkt.de
>
>>>
>
>>> .
>>>
>>
>
>-- 
>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

Re: Attribute error

2021-05-13 Thread Ryan Nowakowski
It's likely that your instance of OrderItem has a product field that's null. 

On May 12, 2021 3:50:42 AM CDT, Peter Kirieny  wrote:
>can somebody help with this please, am building an ecommerce web and
>when i
>want to view my cart i get this error
>AttributeError: 'NoneType' object has no attribute 'price'
>
>here is my models.py
>class OrderItem(models.Model):
>
>product = models.ForeignKey(Product, on_delete=models.SET_NULL,
>null=True)
> order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
>quantity = models.IntegerField(default=0, null=True, blank=True)
>date_added = models.DateTimeField(auto_now_add=True)
>
>@property
>def get_total(self):
>total = self.product.price * self.quantity
>return total
>
>
>
>AttributeError at /cart/
>
>'NoneType' object has no attribute 'price'
>
>Request Method: GET
>Request URL: http://127.0.0.1:8000/cart/
>Django Version: 3.2
>Exception Type: AttributeError
>Exception Value:
>
>'NoneType' object has no attribute 'price'
>
>Exception Location:
>C:\Users\Admin\PycharmProject\MyProject\Ecommerce\shop\models.py, line
>71,
>in get_total
>Python Executable:
>C:\Users\Admin\PycharmProject\MyProject\venv\Scripts\python.exe
>Python Version: 3.8.2
>Python Path:
>
>['C:\\Users\\Admin\\PycharmProject\\MyProject\\Ecommerce',
>'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\lib',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38',
> 'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv',
>'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv\\lib\\site-packages']
>
>Server time: Wed, 12 May 2021 08:44:09 +

-- 
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/FDF6B1C2-9134-43D2-8057-EA3BCF14C2A1%40fattuba.com.


Re: Threading videos one after the other

2021-05-09 Thread Ryan Nowakowski
Note: I googled for "HTML video playlist"

On May 9, 2021 10:41:28 AM CDT, Ryan Nowakowski  wrote:
>https://stackoverflow.com/a/2552131/226697
>
>On May 8, 2021 2:12:15 PM CDT, "מוריה יצחקי" 
>wrote:
>>Hi
>>Thanks to all the helpers
>>I got from the Python file to the HTML file a list of URLs that are
>>inside 
>>the arraysrc variable
>>And I want to run all the videos one after the other ends up in the
>>same 
>>place
>>I tried to do as in the picture I attached but it runs all the videos
>>at 
>>once, one next to the other
>>I would be very happy to help
>>Thank you!!
>>[image: for.PNG]
>>
>>-- 
>>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/c3f549c8-cf27-436f-bd0c-bd781ba5c701n%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/23CD3C79-EA7A-415A-9608-6D75BBD2275E%40fattuba.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/E43F3BE7-2E74-4E3A-8810-8E6633EA4EB8%40fattuba.com.


Re: Threading videos one after the other

2021-05-09 Thread Ryan Nowakowski
https://stackoverflow.com/a/2552131/226697

On May 8, 2021 2:12:15 PM CDT, "מוריה יצחקי"  wrote:
>Hi
>Thanks to all the helpers
>I got from the Python file to the HTML file a list of URLs that are
>inside 
>the arraysrc variable
>And I want to run all the videos one after the other ends up in the
>same 
>place
>I tried to do as in the picture I attached but it runs all the videos
>at 
>once, one next to the other
>I would be very happy to help
>Thank you!!
>[image: for.PNG]
>
>-- 
>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/c3f549c8-cf27-436f-bd0c-bd781ba5c701n%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/23CD3C79-EA7A-415A-9608-6D75BBD2275E%40fattuba.com.


Re: custom commands for django-admin

2021-05-06 Thread Ryan Nowakowski



On May 6, 2021 5:35:58 PM CDT, Ilia Rk  wrote:
>
>hi how should i write custom commnads for django-admin which work with
>all 
>apps existing in project not just apps with specific defined name

When you say "work with all apps" what do you mean? Any custom management 
command can import modules from any other app. What kind of functionality are 
you looking to provide with your custom command? Maybe if you're more specific 
with your question it'll be easier to walk you through how to construct your 
command.

-- 
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/AAE1EED5-8C17-4C14-B19E-73C973F16FA9%40fattuba.com.


Re: To get object id currently modified in django administration

2021-05-02 Thread Ryan Nowakowski
While in your ModelForm, check out self.instance.id

On May 2, 2021 2:42:30 AM CDT, Serge Alard  wrote:
>Bonjour
>
>Je suis en train de faire des validations personnalisées sur des objets
>de 
>mon projet dans l'administration de Django. Pour cela j'ai créé un 
>ModelForm, mais je ne sais pas comment accéder à l'objet id en cours de
>
>modification dans l'administration de Django.
>Pourriez-vous m'aider. Merci d'avance.
>
>
>Hello
>
>Currently I do customized validations on objects of my project in the 
>Django administration. For that, I created a ModelForm but I do not
>know 
>how to get the object id currently in modification in Django
>administration.
>Could you help me. Thanks in advance.
>
>Serge Alard
>
>-- 
>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/aceba62e-5578-435f-9ae3-924f446825b0n%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/9067CD65-7B0F-43E5-A318-877FB14442B6%40fattuba.com.


Re: Loading csv data in database

2021-04-29 Thread Ryan Nowakowski
Typically you would write a custom management command for this kind of thing:

https://docs.djangoproject.com/en/3.2/howto/custom-management-commands/

On April 29, 2021 11:05:29 AM CDT, 'Muhammad Asim Khaskheli' via Django users 
 wrote:
>
>Hi,
>
>I wanted to ask how to load CSV data into the model. What steps do we
>have 
>to follow?
>
>I have made this function but how exactly to run this code because,
>python 
>manage.py load data won't work. 
>
>def import_data():
>with open('sample-dataset.csv') as f:
>reader = csv.reader(f)
>for row in reader:
>if row[0] != 'user_id':
>_, created = Funnel.objects.get_or_create(
>user_id=row[0],
>event=row[1],
>timestamp=row[2],
>session_id=row[3]
>)
>
>Now, how to run this script?
>
>
>-- 
>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/fefae867-8bc5-4d9a-a9e6-e0268d20632cn%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/65F082D0-CCBB-4FE5-9788-68716442A1D4%40fattuba.com.


Re: DEFAULT Django Session is still using File in /tmp (Can't read from directory)

2021-04-28 Thread Ryan Nowakowski
What makes you think this has anything to do with Django sessions?

On April 27, 2021 11:15:57 PM CDT, Andre Foote  wrote:
>FileNotFoundError at /admin/region/country/process_import/
>[Errno 2] No such file or directory: '/tmp/tmpu31qxebf'
>*Request Method*: POST
>*Request URL*: http://myurl/admin/region/country/process_import/
>*Django Version*: 3.0.10
>*Exception Type*: FileNotFoundError
>*Exception Value*: 
>[Errno 2] No such file or directory: '/tmp/tmpu31qxebf'
>*Exception Location*:
>/usr/local/lib/python3.8/site-packages/import_export/tmp_storages.py 
>in open, line 29
>*Python Executable*: /usr/local/bin/python
>*Python Version*: 3.8.3
>
>I understand from the Django docs 
><https://docs.djangoproject.com/en/3.2/topics/http/sessions/#using-file-based-sessions>
>that 
>when using File-based sessions, one must check that their "web server
>has 
>permissions to read and write to this location" (I'm not sure how/where
>to 
>enforce this, in my initial post, I tried to enforce inheritence of
>folder 
>permissions but that didn't work - any pointers would be appreciated.)
>
>However I'm using the default configuration for sessions that's
>supposed to 
>be database-backed.
>On Tuesday, April 27, 2021 at 9:52:03 PM UTC+2 Ryan Nowakowski wrote:
>
>>
>>
>> On April 26, 2021 11:31:24 PM CDT, Andre Foote  
>> wrote:
>> >However, the application crashes with the error stating that it is
>> >unable 
>> >to read the session data stored in "/tmp". 
>>
>> Please post the full error including any exception messages and the
>full 
>> Python trace back if available.
>>
>
>-- 
>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/23db12fb-3e30-482c-be8b-9a1f1b89c4aen%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/20A78CB6-B3C2-4AB4-9524-CFBFFB613323%40fattuba.com.


Re: DEFAULT Django Session is still using File in /tmp (Can't read from directory)

2021-04-27 Thread Ryan Nowakowski



On April 26, 2021 11:31:24 PM CDT, Andre Foote  wrote:
>However, the application crashes with the error stating that it is
>unable 
>to read the session data stored in "/tmp". 

Please post the full error including any exception messages and the full Python 
trace back if available.

-- 
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/C38C7BB7-D4D7-47CD-BEC5-076885F014E5%40fattuba.com.


Re: Assistance with Django Booking app

2021-04-21 Thread Ryan Nowakowski



On April 21, 2021 5:46:15 AM CDT, Eric 247ERICPOINTCOM  
wrote:
>I followed the steps as indicated in the README file and installed
>Django-booking successfully, but there are a couple of errors I get
>with
>this app when I run the server with: python manage.py runserver.
>
>This is what I get.
>
>(envirn) C:\Users\Eric\Desktop\Shop>python manage.py runserver
>Watching for file changes with StatReloader
>Exception in thread django-main-thread:
>Traceback (most recent call last):
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
>line 954, in _bootstrap_inner
>self.run()
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
>line 892, in run
>self._target(*self._args, **self._kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 53, in wrapper
>fn(*args, **kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\commands\runserver.py",
>line 110, in inner_run
>autoreload.raise_last_exception()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 76, in raise_last_exception
>raise _exception[1]
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\__init__.py",
>line 357, in execute
>autoreload.check_errors(django.setup)()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 53, in wrapper
>fn(*args, **kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\__init__.py",
>line 24, in setup
>apps.populate(settings.INSTALLED_APPS)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\registry.py",
>line 114, in populate
>app_config.import_models()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\config.py",
>line 211, in import_models
>self.models_module = import_module(models_module_name)
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py",
>line 127, in import_module
>return _bootstrap._gcd_import(name[level:], package, level)
>  File "", line 1030, in _gcd_import
>  File "", line 1007, in _find_and_load
>File "", line 986, in
>_find_and_load_unlocked
>  File "", line 680, in _load_unlocked
>File "", line 790, in exec_module
>  File "", line 228, in
>_call_with_frames_removed
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\booking\models.py",
>line 9, in 
>from django_libs.models_mixins import TranslationModelMixin
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django_libs\models_mixins.py",
>line 5, in 
>from django.utils.encoding import python_2_unicode_compatible
>ImportError: cannot import name 'python_2_unicode_compatible' from
>'django.utils.encoding'
>(C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\encodi
>ng.py)
>
>I have installed six
>I have also installed django.utils, but I just can't seem to run the
>server
>anymore. Is there a way I can manage to run the booking app without
>using
>django.utils

It looks like you're probably trying to run that Django booking app with a 
version of Django that it was never designed to run with. It looks like the 
author of Django booking didn't lock down the django version in requirements.txt

https://github.com/bitlabstudio/django-booking/blob/master/requirements.txt

However, based on the last commit message for requirements.txt, it looks like 
Django 1.9 was the last version used.

Since the author didn't lock down dependency versions you might have quite a 
challenging time finding versions of the dependencies that work properly.



>
>
>On Fri, Apr 9, 2021 at 12:29 AM Ryan Nowakowski 
>wrote:
>
>> On Thu, Apr 08, 2021 at 07:19:53AM -0700, Eric 247ERICPOINTCOM wrote:
>> > I am new to Python and Django, I just discovered that I can use
>Django
>> to
>> > easily implement a project that am working on.
>> >
>> > I would like to get some assistance with implementing a booking app
>into
>> my
>> > project.
>> >
>> > I came across Django-Booking but I dont know how exactly it works,
>>
>> Yup, you're in the position of wanting to leverage as much existing
>code
>> as possible, b

Re: Django Offline

2021-04-18 Thread Ryan Nowakowski
Typically JavaScript is treated as a static file:

https://docs.djangoproject.com/en/3.2/howto/static-files/

On April 18, 2021 11:25:53 AM CDT, Abid Mohamed Nadhir 
 wrote:
>Hello, I'm trying to implement a django project with service worker,
>i'm 
>wondering where to put my service worker?
>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/b82bd792-e573-4779-bf2d-66e6f1dc4a35n%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/25BB496E-59A4-4BD7-9C69-B7FB733EF238%40fattuba.com.


Re: Create email template with the click of a button

2021-04-17 Thread Ryan Nowakowski
Sorry for the weird wording below. Speech to text isn't all is cracked up to 
be. Just one more point: the JSONField allows your to easily do queries on the 
individual email addresses if your need to.

On April 17, 2021 12:52:15 PM CDT, Ryan Nowakowski  wrote:
>I've had a similar issue in the past. With the latest version of Django
>pretty much each database back in now supports JSONField. So I created
>a custom field that inherits from JSON field to take a string of comma
>delimited values, split them by comma, validate each value
>individually, then store the whole thing in the database as a JSON
>list.
>
>In your case you'll use the email validator used by the EmailField to
>validate each value.
>
>On April 15, 2021 3:21:44 PM CDT, Smiley 
>wrote:
>>Hello,
>>
>>I have another problem. 
>>
>>I am trying to get CC to accept multiple email addresses but I do not
>>seem 
>>to get it to work as it always says *Enter a valid email address*.
>I've
>>
>>searched for solutions, heard the new field *MultiValueField* but I
>>also do 
>>not know how to use this in *forms.py*.
>>
>>
>>
>>This is my *forms.py* code:
>>
>>from django import forms
>>#  from django.forms.fields import MultiValueField
>>from django.forms.widgets import EmailInput, TextInput
>>
>>
>>class ComposeForm(forms.Form):
>>email_to = forms.EmailField(label="To", widget=EmailInput(attrs
>>={"size": 76}))
>>email_cc = forms.EmailField(
>>label="CC",
>>required=False,
>>widget=EmailInput(attrs={"size": 76, "multiple": True}),
>>)
>>email_subject = forms.CharField(
>>required=False, widget=TextInput(attrs
>>={"placeholder": "Subject", "size": 76})
>>)
>>email_message = forms.CharField(
>>required=True, label="", widget=forms.Textarea(attrs
>>={"rows": 19, "cols": 78})
>>)
>>
>>
>>
>>And this is my *views.py* code:
>>
>>from django.shortcuts import render
>>
>>from .forms import ComposeForm
>>
>>
>>def email_template(request):
>>if request.method == "GET":
>>form = ComposeForm()
>>else:
>>form = ComposeForm(request.POST)
>>if form.is_valid():
>>print(form)
>>email_to = form.cleaned_data["email_to"]
>>email_cc = form.cleaned_data["email_cc"]
>>email_subject = form.cleaned_data["email_subject"]
>>email_message = form.cleaned_data["email_message"]
>>
>>print("Emails:", email_cc)
>>else:
>>print("DEBUG:", form.errors)
>>return render(request, "email_template.html", {"form": form})
>>
>>
>>
>>And this is my *email_template.html* HTML:
>>
>>
>>
>>
>>
>>
>> 
>>Home
>>
>>
>>
>>{% csrf_token %}
>>
>>{{ form.as_table }}
>>
>>
>>
>>
>>
>>
>>
>>--

Re: Create email template with the click of a button

2021-04-17 Thread Ryan Nowakowski
I've had a similar issue in the past. With the latest version of Django pretty 
much each database back in now supports JSONField. So I created a custom field 
that inherits from JSON field to take a string of comma delimited values, split 
them by comma, validate each value individually, then store the whole thing in 
the database as a JSON list.

In your case you'll use the email validator used by the EmailField to validate 
each value.

On April 15, 2021 3:21:44 PM CDT, Smiley  wrote:
>Hello,
>
>I have another problem. 
>
>I am trying to get CC to accept multiple email addresses but I do not
>seem 
>to get it to work as it always says *Enter a valid email address*. I've
>
>searched for solutions, heard the new field *MultiValueField* but I
>also do 
>not know how to use this in *forms.py*.
>
>
>
>This is my *forms.py* code:
>
>from django import forms
>#  from django.forms.fields import MultiValueField
>from django.forms.widgets import EmailInput, TextInput
>
>
>class ComposeForm(forms.Form):
>email_to = forms.EmailField(label="To", widget=EmailInput(attrs
>={"size": 76}))
>email_cc = forms.EmailField(
>label="CC",
>required=False,
>widget=EmailInput(attrs={"size": 76, "multiple": True}),
>)
>email_subject = forms.CharField(
>required=False, widget=TextInput(attrs
>={"placeholder": "Subject", "size": 76})
>)
>email_message = forms.CharField(
>required=True, label="", widget=forms.Textarea(attrs
>={"rows": 19, "cols": 78})
>)
>
>
>
>And this is my *views.py* code:
>
>from django.shortcuts import render
>
>from .forms import ComposeForm
>
>
>def email_template(request):
>if request.method == "GET":
>form = ComposeForm()
>else:
>form = ComposeForm(request.POST)
>if form.is_valid():
>print(form)
>email_to = form.cleaned_data["email_to"]
>email_cc = form.cleaned_data["email_cc"]
>email_subject = form.cleaned_data["email_subject"]
>email_message = form.cleaned_data["email_message"]
>
>print("Emails:", email_cc)
>else:
>print("DEBUG:", form.errors)
>return render(request, "email_template.html", {"form": form})
>
>
>
>And this is my *email_template.html* HTML:
>
>
>
>
>
>
> 
>Home
>
>
>
>{% csrf_token %}
>
>{{ form.as_table }}
>
>
>
>
>
>
>
>
>
>Please tell me whether it's possible to have multiple email addresses
>in 
>*email_cc* aka *CC* field in Django or do I have to use frontend
>frameworks 
>for this one job or start using one for better practice (get used to
>using 
>frameworks to build frontend side)?
>
>Please advise.
>
>Regards,
>Kristen
>
>sebasti...@gmail.com kirjutas teisipäev, 23. märts 2021 kl 22:24:01
>UTC+2:
>
>> I have implement it as a bootstrap modal where a Form with fields are
>
>> shown. When User click submit the Page load New but If you don't want
>that 
>> Page is load New you need a Ajax jquery submit to django
>>
>> Kristen  schrieb am Mo., 22. März 2021, 15:46:
>>
>>> Hello,
>>>
>>> Correct. I want to the user to click a button and have a form appear
>
>>> where the user can compose an email.
>>>
>>> Gmail uses javascript to render their form on top of the inbox
>because 
 they don't want you to have to leave the inbox page. You probably
>don't 
 have that requirement.

 Let

Re: new python dev jobs (was: Try to connect Redis Channel in Django Chat Project)

2021-04-09 Thread Ryan Nowakowski
Hey Hemanth,

Welcome to python!  Just a note... it's considered bad form to hijack an
existing mailing list thread and change the topic[1].  You should instead
send a brand new email (don't hit the reply button on an existing thread).

Now, regarding junior developer python jobs, are you looking for
something near your physical location?  Or are you looking for a job
that's totally remote?  Take a look at the Python jobs board[2] and/or the
Django jobs boards[3]

Good luck!

- Ryan N

[1] https://www.google.com/search?q=don't+hijack+a+mailing+list+thread
[2] https://www.python.org/jobs/
[3] https://www.google.com/search?q=django+jobs

On Fri, Apr 09, 2021 at 02:44:42PM +0530, hemanth hemu wrote:
> i am python developer fresher but there is no openings on python for
> freshers what i need to do is there any idea you please suggest me please
> 
> On Fri, Apr 9, 2021, 2:40 PM Andréas Kühne 
> wrote:
> 
> > You need to make sure that you have a redis server running and that you
> > have the correct connection in django settings for the channels setup.
> >
> > See more here:
> >
> > https://channels.readthedocs.io/en/stable/topics/channel_layers.html?highlight=redis#redis-channel-layer
> >
> > Regards,
> >
> > Andréas
> >
> >
> > Den fre 9 apr. 2021 kl 00:38 skrev Kylex Isasi Tech  > >:
> >
> >> How to fix this error
> >>
> >> --
> >> 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/CAM-He%3DHkAaA3CCUzmp%2BSxA-SQ%2BA9NnJRVQRqwTJB8o%2B8fPbxbA%40mail.gmail.com
> >> <https://groups.google.com/d/msgid/django-users/CAM-He%3DHkAaA3CCUzmp%2BSxA-SQ%2BA9NnJRVQRqwTJB8o%2B8fPbxbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> >> .
> >>
> > --
> > 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/CAK4qSCeqFRaT1XSHszG_k_EKcKDtZAE_8ZHUJGUx4e-qUppk9w%40mail.gmail.com
> > <https://groups.google.com/d/msgid/django-users/CAK4qSCeqFRaT1XSHszG_k_EKcKDtZAE_8ZHUJGUx4e-qUppk9w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> > .
> >
> 
> -- 
> 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/CAGau_gViuP6rpApNsBznsZgmfB5Af%3D2cJvaP93M_tGuEjdBBEQ%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/20210409193533.GS15054%40fattuba.com.


Re: License management system Refrence

2021-04-08 Thread Ryan Nowakowski
On Wed, Apr 07, 2021 at 12:43:03PM +0545, Vkash Poudel wrote:

Sorry, I don't have any reference code for you.  But here are some things
to think about.

>2. where Users can purchase KEY for a service, ie. just like (Product
>Key or Activation Key)
What payment backend will you use for the purchasing part?  Stripe?

>3. Validate that key as per their subscription, ie. (Month or Year)
Is the "service" mentioned a web service?  If so, the license key could
simply be an API key that must be included with every service API
request, perhaps in the HTTP Authorization header.  Then in Django,
check that the licence the API key is tied to hasn't expired.   You
could use django-rest-framework for the API and probably the auth.

>4. user can use service with only one device in real time
How will you determine "usage of the service"?  If device A hits the
service API at 9:00:00 and device B hits the service at 9:00:01, is that
allowed?


> On Wed, Apr 7, 2021 at 10:16 AM Ryan Nowakowski  wrote:
> 
> > What kind of product are you trying to license? A proprietary computer
> > desktop application? A mobile application for iOS or Android? A proprietary
> > self-hosted web app?
> >
> > On April 6, 2021 1:50:51 AM CDT, "bikash...@gmail.com" <
> > bikashpoud...@gmail.com> wrote:
> >>
> >> Can any one provide me reference regarding license (Serial Key) server
> >> system  in django,
> >> where ,
> >> we can generate unique serial key for products,
> >> we can validate user subscription,
> >> Clients can run demo (limited features),
> >> and with that serial key users can run with limited device,(Device lock)
> >>
> >> Hopefully can I get some reference , Pease provide me some materials in
> >> django.
> >>
> >> --
> > 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/847E6643-D082-49A8-B615-973E55B7C3B9%40fattuba.com
> > <https://groups.google.com/d/msgid/django-users/847E6643-D082-49A8-B615-973E55B7C3B9%40fattuba.com?utm_medium=email&utm_source=footer>
> > .
> >
> 
> 
> -- 
> Best Regards,
> Bikash Poudel
> 
> -- 
> 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/CAE0sOGwdBprTwBnf_HLsCXb3KPdLTSjeee6bMkadayr8zUL9%2BQ%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/20210408225821.GQ15054%40fattuba.com.


Re: Unique and null

2021-04-08 Thread Ryan Nowakowski
On Thu, Apr 08, 2021 at 11:12:51PM +0100, Roger Gammans wrote:
> On Thu, 2021-04-08 at 16:36 -0500, Ryan Nowakowski wrote:
> > On Wed, Apr 07, 2021 at 03:25:53PM +0100, Roger Gammans wrote:
> > > This is mostly (form the Django perspective) and issue with
> > > CharFields,
> > > because a CharField can store None or ''.  For values of ''
> > > in  CharField, IIRC, django will convert them to null, with
> > > null=True,
> > > blank=True. But not with blank=True,null=False.See also : 
> > > https://docs.djangoproject.com/en/3.1/ref/models/fields/#null
> > 
> > I read the documentation a bit differently.  My interpretation is
> > that
> > CharField(null=True) means that both ''(empty string) and None(null)
> > are
> > valid values.  But no implicit conversion from '' to None takes
> > place.
> > 
> > CharField(null=False) means that None(null) isn't a valid value and
> > that
> > only ''(empty string) is permitted.
> 
> I understand that reading, and the simple answer is we are both right!
> 
> See:
> https://github.com/django/django/blob/45a58c31e64dbfdecab1178b1d00a3803a90ea2d/django/db/models/fields/__init__.py#L1082
> 
> This shows the model field telling the any auto creating form field, 
> say like in the admin model, which value to prefer 'empty' values. 
> 
> Since it's not the model field, so any python code which saves '' and
> None, directed onto the model will still have those respected as '' and
> NULL.

Wh Oracle!!! *sigh* :)


find django/db/backends -name "features.py" | xargs grep 
interprets_empty_strings_as_nulls
django/db/backends/oracle/features.py:interprets_empty_strings_as_nulls 
= True
django/db/backends/base/features.py:interprets_empty_strings_as_nulls = 
False

-- 
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/20210408224331.GP15054%40fattuba.com.


Re: Assistance with Django Booking app

2021-04-08 Thread Ryan Nowakowski
On Thu, Apr 08, 2021 at 07:19:53AM -0700, Eric 247ERICPOINTCOM wrote:
> I am new to Python and Django, I just discovered that I can use Django to 
> easily implement a project that am working on. 
> 
> I would like to get some assistance with implementing a booking app into my 
> project.
> 
> I came across Django-Booking but I dont know how exactly it works,

Yup, you're in the position of wanting to leverage as much existing code
as possible, but being inexperienced enough to not know how to evaluate
the quality or usefulness of that existing code.  I feel for you for sure.
A couple of questions to hopefully help clarify things:

1. What kinds of things are you trying to book?  Rooms at a hotel,
tables at a restaurant, chairs at a barbershop?  It looks like
django-booking is set up to handle multiple people attached to a single
booking[a].  Is this something you need?

2. django-booking hasn't been updated in 5 years[b].  It looks like the
last update was for Django 1.9.  The latest Django is 3.2.  Is that a
concern for you?

3. It it weird that django-booking includes an error logging table[c]?
Django already has standard ways of reporting errors[d].  Why invent a
new one?

[a] 
https://github.com/bitlabstudio/django-booking/blob/master/booking/models.py#L336
[b] https://github.com/bitlabstudio/django-booking/commits/master
[c] https://github.com/bitlabstudio/django-booking#error-logging
[d] https://docs.djangoproject.com/en/3.1/howto/error-reporting/

> do I need to create an app for booking like a new app into my project
> or do I need to use it as a built in package only. Your help will be
> highly appreciated.

You might be able to use the django-booking app as is by just following
the directions in the README[e].  There might be no need to create your
own app.

[e] https://github.com/bitlabstudio/django-booking

-- 
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/20210408222833.GO15054%40fattuba.com.


Re: Extending with plugins remotely -at least from a frontend

2021-04-08 Thread Ryan Nowakowski
On Wed, Apr 07, 2021 at 11:42:30PM +0100, Joel Tanko wrote:
> Hi guys I have a question just one, but it houses a myriad of smaller
> questions for clarity.
> 
> So I'm building a django app that creates virtual organizations, I'm
> planning on hosting with digitalocean for reasons. My app just creates a
> droplet and host a site ( already done that)
> 
> Now I want my users ( mainly people with zero coding knowledge or ability)
> to be able to install plugins to their django site using the frontend.
> 
>  How do I get this working without users tampering with the settings.py file
> 
> > is it possible?
> > what packages would I need?
> > how would I setup the installation process?
> 
> PS: a example would be how shopify handles its plugins and installation
> from the frontend remotely - if shopify were built on django.
> 

In general, the philosophy behind Django is that programmers modify
code, editors/authors modify content.  The idea is that editors/authors
don't know enough about code and can sometimes get themselves into a
jam.  So it's best to not allow editors/authors to modify the code.
See "Wordpress plugin hell"[1] for reference.

Of course, just because Django doesn't encourage author-installed
plugins doesn't mean that you can't do it.  Django CMS has an addon
marketplace[2], for example.

One thing that might help is to note that settings.py is just a python
module.  You can call normal python code inside that module.  So, for
example, you could store all your settings in a database.  There are
some examples of this kind of thing under the heading "live
settings"[3].

[1] https://www.google.com/search?q=wordpress+plugin+hell
[2] https://marketplace.django-cms.org/en/addons/
[3] https://djangopackages.org/grids/g/live-setting/

-- 
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/20210408220519.GN15054%40fattuba.com.


Re: Listview Iterate over List

2021-04-08 Thread Ryan Nowakowski
On Wed, Apr 07, 2021 at 11:02:04AM -0700, sebasti...@gmail.com wrote:
> i want to create a Listview like this:
> 
> class HistorieListView(ListView):
> model = Address
> template_name = 'marketing/liststandardtemplate.html'
> fieldlist = ('id', 'lastname', 'firstname')
> 
> now i want in liststandardtemplate.html that i iterate in tablebody over 
> fieldlist:
> 
> 
> {%for element in object_list%}
> 
>{% for field in fieldlist %}
> 
> {{ element.field }}
> 
>{% endfor %}
> 
> {% endfor %}
> 
> 
> but   {{ element.field }} won't work. This is absolut clear why but i have 
> no idea how i can create such a template

You'll probably need to perform a getattr lookup in your template here.
Found this little solution on the ole' stackoverflow:

https://stackoverflow.com/a/1112236/226697

-- 
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/20210408214658.GM15054%40fattuba.com.


Re: Unique and null

2021-04-08 Thread Ryan Nowakowski
On Wed, Apr 07, 2021 at 03:25:53PM +0100, Roger Gammans wrote:
> This is mostly (form the Django perspective) and issue with CharFields,
> because a CharField can store None or ''.  For values of ''
> in  CharField, IIRC, django will convert them to null, with null=True,
> blank=True. But not with blank=True,null=False.See also : 
> https://docs.djangoproject.com/en/3.1/ref/models/fields/#null

I read the documentation a bit differently.  My interpretation is that
CharField(null=True) means that both ''(empty string) and None(null) are
valid values.  But no implicit conversion from '' to None takes place.

CharField(null=False) means that None(null) isn't a valid value and that
only ''(empty string) is permitted.

-- 
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/20210408213628.GL15054%40fattuba.com.


Re: Unique and null

2021-04-07 Thread Ryan Nowakowski
I'm not sure about the case with null. However, I believe that most uses of 
CharField leave null=False and use the empty string instead to represent 
"empty" value. 

On April 7, 2021 1:06:44 AM CDT, Mike Dewhirst  wrote:
>I have just made a CharField unique and Django detects duplicates
>nicely 
>but seems to ignore multiple instances where the field value is null.
>
>     arn = models.CharField(
>     max_length=MEDIUM,
>     unique=True,
>     null=True,
>     blank=True,
>     )
>
>Is this correct behaviour?
>
>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/fb02525d-773c-4ce3-43a2-f41397176a36%40dewhirst.com.au.

-- 
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/8774A769-9A6D-4BC7-AD3B-2EEDC6C5DF15%40fattuba.com.


Re: image reading

2021-04-06 Thread Ryan Nowakowski
I'm going to assume you mean "text" here and not "test".

For recognizing text in images I've used the tesseract project with pretty good 
success. For more information about this you can Google OCR or optical 
character recognition.

For parsing text in PDF, it depends on how the text is encoded in the PDF. You 
can tell by trying to copy and paste the text manually when the PDF is open in 
your PDF reader. If you can't copy and paste the text that means that it's 
probably embedded in an image inside the PDF. In that case use the tesseract 
method recommended above.

If you can copy and paste a text, that means that it's actual text in the PDF 
file itself. In that case there are a few different PDF parsing libraries and 
Python that you can try to use to grab the text.

On April 3, 2021 12:54:32 AM CDT, Aniket Gadge  
wrote:
>How to read the test from image and pdf.
>
>-- 
>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/CAAAecFt_Tr_4V-NqNY%3D%3DYLML0zjOGD31UOLWezw5DEJPb18Jig%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/AFAE5903-5200-410F-8EBE-673C1E4DD732%40fattuba.com.


Re: License management system Refrence

2021-04-06 Thread Ryan Nowakowski
What kind of product are you trying to license? A proprietary computer desktop 
application? A mobile application for iOS or Android? A proprietary self-hosted 
web app?

On April 6, 2021 1:50:51 AM CDT, "bikash...@gmail.com" 
 wrote:
>Can any one provide me reference regarding license (Serial Key) server 
>system  in django,
>where ,
>we can generate unique serial key for products,
>we can validate user subscription,
>Clients can run demo (limited features),
>and with that serial key users can run with limited device,(Device
>lock)
>
>Hopefully can I get some reference , Pease provide me some materials in
>
>django.
>
>-- 
>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/f6438e96-eed8-4fa9-957f-c2a675bd0b48n%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/847E6643-D082-49A8-B615-973E55B7C3B9%40fattuba.com.


  1   2   3   4   5   6   >