Support d'aide en Django

2022-04-21 Thread Djeneba Kaba DIAKITE
Bonjour je suis nouvelle en django et j'aimerai l'utiliser avec react 
native. Et pour cela je dois combiner django et postgres . Besoin de guide 
, tout aide me sera précieuse ( support , site,  cours etc...)

Cordialement

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7f2aefca-b678-48d9-b241-94c0b77f2d93n%40googlegroups.com.


Django FormTools

2022-04-21 Thread ahmed doudou
hey everyone i'm using Django with wizard form and everithing work fine but 
i don't know how to styling inputs
and i don't know how to save data on my 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/e8535a9c-ced8-42cb-816e-2ed1f27d281an%40googlegroups.com.


quote_from_bytes() expected bytes

2022-04-21 Thread Kaya Kwinana
Hi

I am using Django 4.0.4.

I am getting the TypeError quote_from_bytes() expected bytes when I save my 
model after creating a task.

When I backspace, the create form is still there on the screen as if not 
saved.

When I go to List View or Detail View, I find that everything went OK.

The error would be an inconvenience to a user.

The suggested solution from various quarters is to have get_absolute_url 
right, but it is:

def get_absolute_url(self):
return (
reverse("internalcontrol:task_detail", kwargs={"pk": self.pk}),
)

The prior models also have the get_absolute_url like this and they work 
normally.

What could be wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5471c039-4d22-4118-9b10-d1e1b476f71fn%40googlegroups.com.


Connection timeout error with Postgres

2022-04-21 Thread Disha Patel
Hi, 
I am facing below connection timeout error while using Postgres as database 
for my Django application. 

"psycopg2.operationalerror: could not connect to server: connection timed 
out:

Solutions tried:
1. increased timeout at server end. 
2. added conn_max_age in the settings and tried multiple values ( eg. None, 
60,120)

It is a random error but occurs very frequently.
Kindly share if anyone aware about the reason for this issue and any 
solutions for the same.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b0c59297-5125-46f5-843f-55c0c00eb4acn%40googlegroups.com.


How to 301 redirect django url with multiple slashes on url path?

2022-04-21 Thread Tanata Giventa


I am trying to figure out how to redirect properly some urls that contain 
multiple slashes and create a permanent 301 redirect whenever the slug 
changes.

For example:

A - https://example.org/category/subcategory/article-name-A

B - https://example.org/category/subcategory/article-name-B

I want to redirect the A to B. I tried the default redirects app from 
django but did not work with multiple slashes. What is the correct approach 
here?!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ec14b3db-757c-48c5-ad0b-98e5ef685c50n%40googlegroups.com.


QuerySet Caching of ManyToMany fields

2022-04-21 Thread Russell Melick
Hi All,

We've been working on improving the performance of our backend recently, 
and have started analyzing the database queries generated by Django more 
thoroughly.

We quickly realized that we were mis-using our ManyToMany fields.  We had 
assumed that the results of accessing an M2M field would be cached like 
accessing a ForeignKey would.

https://docs.djangoproject.com/en/dev/topics/db/queries/#one-to-many-relationships

This is definitely not the case, ManyToMany fields are not cached.  We went 
down a bit of a rabbit hole, including this StackOverflow 
(https://stackoverflow.com/questions/8316437/does-django-cache-related-foreignkey-and-manytomanyfield-fields-once-theyre-acc/71887338#71887338)

After a lot of digging through the docs, I finally realized that they were 
already trying to make that clear:

https://docs.djangoproject.com/en/dev/topics/db/optimization/#understand-cached-attributes

Have others run into this mistake?  Seems like either a feature request or 
a documentation update would be a good idea.

Russell

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/26c42ff1-907e-41de-ac66-2be8b1b84d5dn%40googlegroups.com.


Django

2022-04-21 Thread Abdulfarid Olakunle
Please how do I import a model from another app. Thanks, please someone
should help me out

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BccuR2D3N%2BwQeuWVUZ00Ef_d%2BxDa_a%2B4T_LEmGecV17hmn%2BUg%40mail.gmail.com.


[no subject]

2022-04-21 Thread adamlaska
adamlaska

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM0yN9_P4Eg2qJiiUzzZ-s8%3DXa2fjMA2zyqaz%2BjA%2Bvm4kqd2Sw%40mail.gmail.com.


Re: Calculated Fields

2022-04-21 Thread Ahmedrufai Otuoze
My bad. I bypassed your message completely.

Have a great day!

On Wed, 13 Apr 2022 at 18:32, Kasper Laudrup  wrote:

> On 13/04/2022 16.51, Ahmedrufai Otuoze wrote:
> > This is not a spam. I just tok a course on that aspect and wanted to
> help.
> > No strings attached.
> >
> > I may have gone against the policy and that's because I wasn't aware.
> > My intentions were genuine...
> >
>
> You were not the one I was replying to so I don't understand why you are
> replying like you were advertising this.
>
> Harsh Jain has previously been spamming this mailing list and he's the
> one I was replying to.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8f8efa76-713f-86c8-ed18-188482af2882%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA50Jbdy0HQrQhXNRk1o0KiCHHddGhYwSqX4zbBdRx3_%3D3s_1g%40mail.gmail.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 2:53 PM cseb...@gmail.com  wrote:
>
> The script should quietly exist without error.
>
> I actually have a longer script that is the real workhorse.
> I just made this tiny one to showcase the issue.
>
> I can past
>
> import datetime ; [datetime for e in [1, 2]]
>
> into a regular Python3 shell as well as the Django shell and all is fine.

$ python3
Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime ; [datetime for e in [1, 2]]
[,
]

It does not do anything.

>
> The problem I think has something to do with how I inject
> it into the Django shell via "< test".
>
> cs
> On Thursday, April 21, 2022 at 12:18:04 PM UTC-5 larry.mart...@gmail.com 
> wrote:
>>
>> On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>> >
>> > Why does this fail?...
>> >
>> > % echo "import datetime ; [datetime for e in [1, 2]]" > test
>> >
>> > % ./manage.py shell < test
>> >
>> > Traceback (most recent call last):
>> > File "./manage.py", line 8, in 
>> > django.core.management.execute_from_command_line(sys.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 381, in execute_from_command_line
>> > utility.execute()
>> > File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
>> > line 375, in execute
>> > self.fetch_command(subcommand).run_from_argv(self.argv)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 323, in run_from_argv
>> > self.execute(*args, **cmd_options)
>> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
>> > 364, in execute
>> > output = self.handle(*args, **options)
>> > File 
>> > "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
>> > line 92, in handle
>> > exec(sys.stdin.read())
>> > File "", line 1, in 
>> > File "", line 1, in 
>> > NameError: name 'datetime' is not defined
>>
>> What do you expect to happen?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/c4a36ffb-8c7a-477f-9d26-f6b898178d91n%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/CACwCsY43-xRez5dXzhQ0RxU3BVp1Dx8YARKRr7V9f1hyJSHfuA%40mail.gmail.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread cseb...@gmail.com
The script should quietly exist without error.

I actually have a longer script that is the real workhorse.  
I just made this tiny one to showcase the issue.  

I can past  

import datetime ; [datetime for e in [1, 2]]

into a regular Python3 shell as well as the Django shell and all is fine.

The problem I think has something to do with how I inject
it into the Django shell via "< test".

cs
On Thursday, April 21, 2022 at 12:18:04 PM UTC-5 larry.mart...@gmail.com 
wrote:

> On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  
> wrote:
> >
> > Why does this fail?...
> >
> > % echo "import datetime ; [datetime for e in [1, 2]]" > test
> >
> > % ./manage.py shell < test
> >
> > Traceback (most recent call last):
> > File "./manage.py", line 8, in 
> > django.core.management.execute_from_command_line(sys.argv)
> > File 
> "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 
> 381, in execute_from_command_line
> > utility.execute()
> > File 
> "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 
> 375, in execute
> > self.fetch_command(subcommand).run_from_argv(self.argv)
> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", 
> line 323, in run_from_argv
> > self.execute(*args, **cmd_options)
> > File "/usr/lib/python3/dist-packages/django/core/management/base.py", 
> line 364, in execute
> > output = self.handle(*args, **options)
> > File 
> "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
> line 92, in handle
> > exec(sys.stdin.read())
> > File "", line 1, in 
> > File "", line 1, in 
> > NameError: name 'datetime' is not defined
>
> What do you expect to happen?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c4a36ffb-8c7a-477f-9d26-f6b898178d91n%40googlegroups.com.


Re: simple command line ./manage.py shell puzzle

2022-04-21 Thread Larry Martell
On Thu, Apr 21, 2022 at 1:06 PM cseb...@gmail.com  wrote:
>
> Why does this fail?...
>
> % echo "import datetime ; [datetime for e in [1, 2]]" > test
>
> % ./manage.py shell < test
>
> Traceback (most recent call last):
>   File "./manage.py", line 8, in 
> django.core.management.execute_from_command_line(sys.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 381, in execute_from_command_line
> utility.execute()
>   File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 
> 364, in execute
> output = self.handle(*args, **options)
>   File 
> "/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
> line 92, in handle
> exec(sys.stdin.read())
>   File "", line 1, in 
>   File "", line 1, in 
> NameError: name 'datetime' is not defined

What do you expect to happen?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4%3D5kn5_ka%3DvDxXyt5P8cNWvEmHHg2%2BtWTUzNcRSWcHhg%40mail.gmail.com.


simple command line ./manage.py shell puzzle

2022-04-21 Thread cseb...@gmail.com
Why does this fail?...

% echo "import datetime ; [datetime for e in [1, 2]]" > test

% ./manage.py shell < test

Traceback (most recent call last):
  File "./manage.py", line 8, in 
django.core.management.execute_from_command_line(sys.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
line 381, in execute_from_command_line
utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", 
line 323, in run_from_argv
self.execute(*args, **cmd_options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", 
line 364, in execute
output = self.handle(*args, **options)
  File 
"/usr/lib/python3/dist-packages/django/core/management/commands/shell.py", 
line 92, in handle
exec(sys.stdin.read())
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'datetime' is not defined

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f8990c95-023a-4380-8551-8d0f3ca64fa7n%40googlegroups.com.


Re: Fetching Data Between Models

2022-04-21 Thread Derek
You've already posted the same question:
https://groups.google.com/g/django-users/c/f7ZH2pcZp0s


On Wednesday, 20 April 2022 at 16:44:19 UTC+2 techg...@gmail.com wrote:

> I have a model Staff and LeaveReportStaff, I wanted to get leave_balance 
> between Total_Leave_Days and leave_days. I already used Foreignkey for 
> staff but I'm not sure if it is right to use Foreignkey again.
>
> Please advise the best way forward.
>
> class Staff(models.Model):
> Total_Leave_Days = models.PositiveIntegerField(default=0)
> course = models.ForeignKey(Course, on_delete=models.DO_NOTHING, 
> null=True, blank=False)
> admin = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
>
>
> class LeaveReportStaff(models.Model):
> staff = models.ForeignKey(Staff, on_delete=models.CASCADE)
> start_date = models.DateField()
> end_date = models.DateField()
> leave_type = models.CharField(choices=LEAVE_TYPE, max_length=25, 
> null=True, blank=False)
>
> @property
> def leave_days(self):
> return (self.end_date - self.start_date).days
>
> @property
> def leave_balance(self):
> return (self.Total_Leave_Days - self.leave_days)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/498d046c-84e9-4ee6-914c-14a373c50625n%40googlegroups.com.