Re: IMPORT PROBLEM

2024-09-03 Thread Olatide Joseph
There's no file named views.py in that directory

On Mon, Sep 2, 2024, 2:03 PM Talha Malik  wrote:

> Send the screenshot of folder structure, in which file you are importing
> and how you are importing?
>
> On Mon, 2 Sept 2024, 11:46 am Augusto Domingos, <
> augustodomingosva...@gmail.com> wrote:
>
>>
>> can you send some screenshots showings how you are importing the view?
>> Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo
>> escreveu:
>>
>>> My project url cannot import views from the app folder, what ks the
>>> problem?
>>>
>> --
>> 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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/CAL1qS4dto%2BDDAjdy3_4RZQ-i1AMvfR9raPCBW2izeoWYV1pWrQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAL1qS4dto%2BDDAjdy3_4RZQ-i1AMvfR9raPCBW2izeoWYV1pWrQ%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/CAJ3Tobb6ajwCVcoXYASWAqUCp6UbaPoBL%2B%2B-fNrcRvMoD6_Ndw%40mail.gmail.com.


Re: IMPORT PROBLEM

2024-09-02 Thread Talha Malik
Is views.py in the same folder of urls.py or is views.py in the parent
folder of urls folder?

On Mon, 2 Sept 2024, 12:44 pm Heman Okumbo,  wrote:

> Homeland is my project directory,there is another folder in the same
> directory with the same name,my apps directory is named land and its where
> i am trying to import views from.
> I get the below traceback error when i try the import.
>
> On Mon, Sep 2, 2024, 09:46 Augusto Domingos <
> augustodomingosva...@gmail.com> wrote:
>
>>
>> can you send some screenshots showings how you are importing the view?
>> Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo
>> escreveu:
>>
>>> My project url cannot import views from the app folder, what ks the
>>> problem?
>>>
>> --
>> 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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/CAJt9CbgRWLxuLN4BsLhSSo1t4frUEkrSdhY91DbZ7aNQSGYt_g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJt9CbgRWLxuLN4BsLhSSo1t4frUEkrSdhY91DbZ7aNQSGYt_g%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/CAL1qS4cURZGd1G%3D_XaODgqjvWVmCBdSnXyxD42n2ekmrc0nsvg%40mail.gmail.com.


Re: IMPORT PROBLEM

2024-09-02 Thread Talha Malik
Send the screenshot of folder structure, in which file you are importing
and how you are importing?

On Mon, 2 Sept 2024, 11:46 am Augusto Domingos, <
augustodomingosva...@gmail.com> wrote:

>
> can you send some screenshots showings how you are importing the view?
> Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo
> escreveu:
>
>> My project url cannot import views from the app folder, what ks the
>> problem?
>>
> --
> 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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/CAL1qS4dto%2BDDAjdy3_4RZQ-i1AMvfR9raPCBW2izeoWYV1pWrQ%40mail.gmail.com.


Re: IMPORT PROBLEM

2024-09-02 Thread Prashanth Patelc
Use like this
path('pen/',views.land,name='pen'),

On Mon, Sep 2, 2024, 1:14 PM Heman Okumbo  wrote:

> Homeland is my project directory,there is another folder in the same
> directory with the same name,my apps directory is named land and its where
> i am trying to import views from.
> I get the below traceback error when i try the import.
>
> On Mon, Sep 2, 2024, 09:46 Augusto Domingos <
> augustodomingosva...@gmail.com> wrote:
>
>>
>> can you send some screenshots showings how you are importing the view?
>> Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo
>> escreveu:
>>
>>> My project url cannot import views from the app folder, what ks the
>>> problem?
>>>
>> --
>> 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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/CAJt9CbgRWLxuLN4BsLhSSo1t4frUEkrSdhY91DbZ7aNQSGYt_g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJt9CbgRWLxuLN4BsLhSSo1t4frUEkrSdhY91DbZ7aNQSGYt_g%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/CAMCU6Cq4O56%3Dw8mEHpMpW0Lu5YwCECMAERdXMXoQf5YCRgvdCw%40mail.gmail.com.


Re: IMPORT PROBLEM

2024-09-02 Thread Heman Okumbo
Thanks for the tip,what can be the problem if Django is not importing a
function from the app directory ie from land import views,the function in
views is pen, error traceback states there is no pen function in views.

On Mon, Sep 2, 2024, 12:12 Augusto Domingos 
wrote:

> Good... it's just a path issue.
>
> Instead of doing '*from . import views*', try this: '*from {app_name}
> import views*'.
>
> In your case, you have an app named *'land*', so it would look something
> like this:
>
> '*from land import views*'.
>
> You need to specify the app name because of the directory structure. When
> you use 'from . import', you're telling Django to import something from the
> current directory, which in your case is 'homeland'. However, 'homeland'
> typically doesn't contain an app directory.
>
> And please make sure you actually created app with *manage.py startapp
> {app_name}* and included the app in your *settings.py*:
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'land.apps.LandConfig' # your app
>
> ]
> Em segunda-feira, 2 de setembro de 2024 às 09:44:46 UTC+2, Heman Okumbo
> escreveu:
>
> Homeland is my project directory,there is another folder in the same
> directory with the same name,my apps directory is named land and its where
> i am trying to import views from.
> I get the below traceback error when i try the import.
>
> On Mon, Sep 2, 2024, 09:46 Augusto Domingos 
> wrote:
>
>
> can you send some screenshots showings how you are importing the view?
> Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo
> escreveu:
>
> My project url cannot import views from the app folder, what ks the
> problem?
>
> --
> 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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/da36e2df-a452-43e6-b02d-0f7621aaed65n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/da36e2df-a452-43e6-b02d-0f7621aaed65n%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/CAJt9Cbggz0uSPy7A9VOhZfEuFppRoWbrHmr%3D3etBTJZgbWmiEA%40mail.gmail.com.


Re: IMPORT PROBLEM

2024-09-02 Thread Augusto Domingos


Good... it's just a path issue.

Instead of doing '*from . import views*', try this: '*from {app_name} 
import views*'.

In your case, you have an app named *'land*', so it would look something 
like this:

'*from land import views*'.

You need to specify the app name because of the directory structure. When 
you use 'from . import', you're telling Django to import something from the 
current directory, which in your case is 'homeland'. However, 'homeland' 
typically doesn't contain an app directory.

And please make sure you actually created app with *manage.py startapp 
{app_name}* and included the app in your *settings.py*:
INSTALLED_APPS = [
'django.contrib.admin',
'land.apps.LandConfig' # your app
 
] 
Em segunda-feira, 2 de setembro de 2024 às 09:44:46 UTC+2, Heman Okumbo 
escreveu:

Homeland is my project directory,there is another folder in the same 
directory with the same name,my apps directory is named land and its where 
i am trying to import views from.
I get the below traceback error when i try the import.

On Mon, Sep 2, 2024, 09:46 Augusto Domingos  wrote:


can you send some screenshots showings how you are importing the view?
Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo 
escreveu:

My project url cannot import views from the app folder, what ks the problem?

-- 
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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/64c28c86-41d4-4242-a8bf-05862a4b18fbn%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/da36e2df-a452-43e6-b02d-0f7621aaed65n%40googlegroups.com.


Re: IMPORT PROBLEM

2024-09-01 Thread Augusto Domingos

can you send some screenshots showings how you are importing the view?
Em segunda-feira, 2 de setembro de 2024 às 07:50:38 UTC+2, Heman Okumbo 
escreveu:

> My project url cannot import views from the app folder, what ks the 
> problem?
>

-- 
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/64c28c86-41d4-4242-a8bf-05862a4b18fbn%40googlegroups.com.


IMPORT PROBLEM

2024-09-01 Thread Heman Okumbo
My project url cannot import views from the app folder, what ks the problem?

-- 
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/CAJt9Cbh1%2B7aMiVne8SJwu%3DqygNtfMDd%3DvN0b8mBF3E8s6aHbbA%40mail.gmail.com.


Re: How to import UGETTEXT_LAZY ON DJANGO 4.0

2024-08-29 Thread joseph Nwani
please I change all my ugetext_lazy to gettext_lazy and am still getting 
the same error please how can you help me.

On Friday 10 December 2021 at 18:46:41 UTC+4 Jason wrote:

>
> https://docs.djangoproject.com/en/4.0/releases/3.0/#id3
> On Friday, December 10, 2021 at 12:01:03 AM UTC-5 ngal...@gmail.com wrote:
>
>> Thanks hopefully the same to ugettext
>>
>>  
>>
>> Kind Regards
>>
>>  
>>
>> Ngallen Ramadhan
>>
>> T: +255 765 889 960 <+255%20765%20889%20960> | Emial: ngal...@gmail.com 
>> | Skype: ngallen2
>>
>>  
>>
>> *From:* django...@googlegroups.com  *On 
>> Behalf Of *David Nugent
>> *Sent:* 10 December 2021 07:50
>> *To:* django...@googlegroups.com
>> *Subject:* Re: How to import UGETTEXT_LAZY ON DJANGO 4.0
>>
>>  
>>
>> Simply change it to gettext_lazy. You don't need the deprecated 
>> functions, they were for python 2.
>>
>>  
>>
>> Regards, David
>>
>>  
>>
>> On Fri, Dec 10, 2021 at 3:43 PM  wrote:
>>
>> It seems Django has removed ‘ugettext_lazy`(from django.utils.translation 
>> import ugettext_lazy as _) from Django version 4.0.x
>>
>> How can I handle translation on Django version 4.0.x?
>>
>>  
>>
>> -- 
>> 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/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.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...@googlegroups.com.
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%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/a7fc530c-31b3-4ece-931d-15979b1acdd2n%40googlegroups.com.


Re: Form does not import current data from data base

2023-11-13 Thread Stefan Kusmierz
Dear community,
I'd like to inform you how I overcame the problem:
instead of using
"List.objects.last().a"
to access field "a" of the last instance of class List, I did it like so:
m=List.objects.last().pk
List.objects.get(pk=m).a
Best regards,
Stefan


Kani Sbt schrieb am Donnerstag, 26. Oktober 2023 um 12:08:37 UTC+2:

> in django how to do phonepay integration any know or any blog or video 
> anything , could you tell me !!! , i need  to do that payment integration 
> in phonepay 
>
> On Thu, 26 Oct 2023 at 14:30, Stefan Kusmierz  
> wrote:
>
>> Hi Migui, thanks for your input. It didn't work.
>>
>>
>> Migui Galan schrieb am Donnerstag, 26. Oktober 2023 um 09:27:48 UTC+2:
>>
>>> Hi Stefan, sorry i thought the process you are working is in POST 
>>> request. Try to place your func() after formchoices3.
>>>
>>> On Wed, Oct 25, 2023 at 4:10 PM Stefan Kusmierz  
>>> wrote:
>>>
 Hi Migui, 
 I'm enchanted to receive such a quick answer.
 1. It's MyForm1_2_3_4() because it's the answer to the first Get 
 request while the page is opened
 2. Why would I try to save the form to the data base?
 Best regards, Stefan


 Migui Galan schrieb am Mittwoch, 25. Oktober 2023 um 03:39:16 UTC+2:

> Hi Stefan!
> it should be form = MyForm1_2_3_4(request.POST) where POST request 
> will place/process the data to your form then after form.save()
>
> On Wed, Oct 25, 2023 at 12:29 AM Stefan Kusmierz  
> wrote:
>
>> Dear community,
>> this looks like a django bug to me:
>> 1. (see first image)
>> By api query I confirm that the last object of class List has the 
>> value "Startwert_neu2" in its field a, which was expected.
>> 2. (see second image)
>> The form "MyForm1_2_3_4" is instantiated using exactly the same 
>> command ("List.objects.last().a") to build formchoices3 which enter the 
>> corresponding choicefield furtherdown in "MyForm1_2_3_4" (not shown in 
>> the 
>> image)
>> 3. While running the app my print out (to find the problem) states, 
>> that formchoices3 does not contain the expected data "Startwert_neu2" 
>> but 
>> "mCP purity", which is old data from older objects. So the rendered Form 
>> also contains the old data.
>> To complete the information I also added snippets of views (fourth 
>> image) and models (fifth image).
>> Is this a known issue? 
>> Thanks in advance,
>> Stefan
>>
>> [image: DB-Query.jpg][image: Form.jpg][image: print out while 
>> running.jpg][image: snippet from views.jpg][image: snippet from 
>> models.jpg]
>>
>> -- 
>> 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/085fcd6d-13aa-422b-86f9-1e15c2549ac8n%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/43b913ef-c9a3-4705-9b58-a889f2667426n%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/6730a25f-6a75-42ea-bb69-6742dfed5bc8n%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/c4b0f039-d132-4271-b698-5cdf1a208d33n%40googlegroups.com.


Re: Form does not import current data from data base

2023-10-26 Thread Kani Sbt
in django how to do phonepay integration any know or any blog or video
anything , could you tell me !!! , i need  to do that payment integration
in phonepay

On Thu, 26 Oct 2023 at 14:30, Stefan Kusmierz 
wrote:

> Hi Migui, thanks for your input. It didn't work.
>
>
> Migui Galan schrieb am Donnerstag, 26. Oktober 2023 um 09:27:48 UTC+2:
>
>> Hi Stefan, sorry i thought the process you are working is in POST
>> request. Try to place your func() after formchoices3.
>>
>> On Wed, Oct 25, 2023 at 4:10 PM Stefan Kusmierz 
>> wrote:
>>
>>> Hi Migui,
>>> I'm enchanted to receive such a quick answer.
>>> 1. It's MyForm1_2_3_4() because it's the answer to the first Get request
>>> while the page is opened
>>> 2. Why would I try to save the form to the data base?
>>> Best regards, Stefan
>>>
>>>
>>> Migui Galan schrieb am Mittwoch, 25. Oktober 2023 um 03:39:16 UTC+2:
>>>
 Hi Stefan!
 it should be form = MyForm1_2_3_4(request.POST) where POST request will
 place/process the data to your form then after form.save()

 On Wed, Oct 25, 2023 at 12:29 AM Stefan Kusmierz 
 wrote:

> Dear community,
> this looks like a django bug to me:
> 1. (see first image)
> By api query I confirm that the last object of class List has the
> value "Startwert_neu2" in its field a, which was expected.
> 2. (see second image)
> The form "MyForm1_2_3_4" is instantiated using exactly the same
> command ("List.objects.last().a") to build formchoices3 which enter the
> corresponding choicefield furtherdown in "MyForm1_2_3_4" (not shown in the
> image)
> 3. While running the app my print out (to find the problem) states,
> that formchoices3 does not contain the expected data "Startwert_neu2" but
> "mCP purity", which is old data from older objects. So the rendered Form
> also contains the old data.
> To complete the information I also added snippets of views (fourth
> image) and models (fifth image).
> Is this a known issue?
> Thanks in advance,
> Stefan
>
> [image: DB-Query.jpg][image: Form.jpg][image: print out while
> running.jpg][image: snippet from views.jpg][image: snippet from
> models.jpg]
>
> --
> 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/085fcd6d-13aa-422b-86f9-1e15c2549ac8n%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/43b913ef-c9a3-4705-9b58-a889f2667426n%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/6730a25f-6a75-42ea-bb69-6742dfed5bc8n%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/CAKJFrTRYuvX3gm_jjdrtgHA%2BtX0EEfzSNQpQBPnOYx-iWVxODA%40mail.gmail.com.


Re: Form does not import current data from data base

2023-10-26 Thread Stefan Kusmierz
Hi Migui, thanks for your input. It didn't work.


Migui Galan schrieb am Donnerstag, 26. Oktober 2023 um 09:27:48 UTC+2:

> Hi Stefan, sorry i thought the process you are working is in POST request. 
> Try to place your func() after formchoices3.
>
> On Wed, Oct 25, 2023 at 4:10 PM Stefan Kusmierz  
> wrote:
>
>> Hi Migui, 
>> I'm enchanted to receive such a quick answer.
>> 1. It's MyForm1_2_3_4() because it's the answer to the first Get request 
>> while the page is opened
>> 2. Why would I try to save the form to the data base?
>> Best regards, Stefan
>>
>>
>> Migui Galan schrieb am Mittwoch, 25. Oktober 2023 um 03:39:16 UTC+2:
>>
>>> Hi Stefan!
>>> it should be form = MyForm1_2_3_4(request.POST) where POST request will 
>>> place/process the data to your form then after form.save()
>>>
>>> On Wed, Oct 25, 2023 at 12:29 AM Stefan Kusmierz  
>>> wrote:
>>>
 Dear community,
 this looks like a django bug to me:
 1. (see first image)
 By api query I confirm that the last object of class List has the value 
 "Startwert_neu2" in its field a, which was expected.
 2. (see second image)
 The form "MyForm1_2_3_4" is instantiated using exactly the same command 
 ("List.objects.last().a") to build formchoices3 which enter the 
 corresponding choicefield furtherdown in "MyForm1_2_3_4" (not shown in the 
 image)
 3. While running the app my print out (to find the problem) states, 
 that formchoices3 does not contain the expected data "Startwert_neu2" but 
 "mCP purity", which is old data from older objects. So the rendered Form 
 also contains the old data.
 To complete the information I also added snippets of views (fourth 
 image) and models (fifth image).
 Is this a known issue? 
 Thanks in advance,
 Stefan

 [image: DB-Query.jpg][image: Form.jpg][image: print out while 
 running.jpg][image: snippet from views.jpg][image: snippet from 
 models.jpg]

 -- 
 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/085fcd6d-13aa-422b-86f9-1e15c2549ac8n%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/43b913ef-c9a3-4705-9b58-a889f2667426n%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/6730a25f-6a75-42ea-bb69-6742dfed5bc8n%40googlegroups.com.


Re: Form does not import current data from data base

2023-10-26 Thread Migui Galan
Hi Stefan, sorry i thought the process you are working is in POST request.
Try to place your func() after formchoices3.

On Wed, Oct 25, 2023 at 4:10 PM Stefan Kusmierz 
wrote:

> Hi Migui,
> I'm enchanted to receive such a quick answer.
> 1. It's MyForm1_2_3_4() because it's the answer to the first Get request
> while the page is opened
> 2. Why would I try to save the form to the data base?
> Best regards, Stefan
>
>
> Migui Galan schrieb am Mittwoch, 25. Oktober 2023 um 03:39:16 UTC+2:
>
>> Hi Stefan!
>> it should be form = MyForm1_2_3_4(request.POST) where POST request will
>> place/process the data to your form then after form.save()
>>
>> On Wed, Oct 25, 2023 at 12:29 AM Stefan Kusmierz 
>> wrote:
>>
>>> Dear community,
>>> this looks like a django bug to me:
>>> 1. (see first image)
>>> By api query I confirm that the last object of class List has the value
>>> "Startwert_neu2" in its field a, which was expected.
>>> 2. (see second image)
>>> The form "MyForm1_2_3_4" is instantiated using exactly the same command
>>> ("List.objects.last().a") to build formchoices3 which enter the
>>> corresponding choicefield furtherdown in "MyForm1_2_3_4" (not shown in the
>>> image)
>>> 3. While running the app my print out (to find the problem) states, that
>>> formchoices3 does not contain the expected data "Startwert_neu2" but "mCP
>>> purity", which is old data from older objects. So the rendered Form also
>>> contains the old data.
>>> To complete the information I also added snippets of views (fourth
>>> image) and models (fifth image).
>>> Is this a known issue?
>>> Thanks in advance,
>>> Stefan
>>>
>>> [image: DB-Query.jpg][image: Form.jpg][image: print out while
>>> running.jpg][image: snippet from views.jpg][image: snippet from
>>> models.jpg]
>>>
>>> --
>>> 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/085fcd6d-13aa-422b-86f9-1e15c2549ac8n%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/43b913ef-c9a3-4705-9b58-a889f2667426n%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/CAKKJMPOoEjOge6ct6qTvq6fNkZTDRJ4gAc-kvAtNzjN4Vu47XQ%40mail.gmail.com.


Re: Form does not import current data from data base

2023-10-25 Thread Stefan Kusmierz
Hi Migui, 
I'm enchanted to receive such a quick answer.
1. It's MyForm1_2_3_4() because it's the answer to the first Get request 
while the page is opened
2. Why would I try to save the form to the data base?
Best regards, Stefan


Migui Galan schrieb am Mittwoch, 25. Oktober 2023 um 03:39:16 UTC+2:

> Hi Stefan!
> it should be form = MyForm1_2_3_4(request.POST) where POST request will 
> place/process the data to your form then after form.save()
>
> On Wed, Oct 25, 2023 at 12:29 AM Stefan Kusmierz  
> wrote:
>
>> Dear community,
>> this looks like a django bug to me:
>> 1. (see first image)
>> By api query I confirm that the last object of class List has the value 
>> "Startwert_neu2" in its field a, which was expected.
>> 2. (see second image)
>> The form "MyForm1_2_3_4" is instantiated using exactly the same command 
>> ("List.objects.last().a") to build formchoices3 which enter the 
>> corresponding choicefield furtherdown in "MyForm1_2_3_4" (not shown in the 
>> image)
>> 3. While running the app my print out (to find the problem) states, that 
>> formchoices3 does not contain the expected data "Startwert_neu2" but "mCP 
>> purity", which is old data from older objects. So the rendered Form also 
>> contains the old data.
>> To complete the information I also added snippets of views (fourth image) 
>> and models (fifth image).
>> Is this a known issue? 
>> Thanks in advance,
>> Stefan
>>
>> [image: DB-Query.jpg][image: Form.jpg][image: print out while 
>> running.jpg][image: snippet from views.jpg][image: snippet from 
>> models.jpg]
>>
>> -- 
>> 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/085fcd6d-13aa-422b-86f9-1e15c2549ac8n%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/43b913ef-c9a3-4705-9b58-a889f2667426n%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-29 Thread Michael Starr
And yeah, django is installed in the venv.
Michael

On Saturday, April 29, 2023 at 10:40:01 AM UTC-7 Michael Starr wrote:

> Thanks. I already have a venv, to answer the first post, and the second, 
> yes, it says 3.11.2. I think VSCode just has a bug. It doesn't bother me 
> and my app works in all other respects. Thank you for the input.
>
> Michael
>
> On Friday, April 28, 2023 at 7:11:57 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:
>
>> This is a wild suggestion, but as someone here mentioned, your vscode 
>> might be pointing to the wrong interpreter.
>>
>> Check at the bottom bar of your vscode with a .py file open. Next to 
>> {}python you should see what environment you are using. 
>>
>> eg. 3.11.3 64-bit or 3.11.3('.venv':venv)
>>
>> The latter is what you are looking for. If it's not, click on whatever is 
>> there and on popup, select the appropriate. 
>>
>>
>>
>> Best Regards,
>>
>> Albert Ashaba Aheebwa
>> +256 781 435857 <+256%20781%20435857>
>>
>> On Thu, 27 Apr 2023, 23:48 Michael Starr,  wrote:
>>
>>> I did pip install django on my venv, which is activated, and it reported 
>>> already installed. But the following modules are reporting the error in the 
>>> subject line:
>>> django.db
>>> models
>>> django.utils.crypto
>>> django.urls
>>> django.contrib
>>> admin
>>> django.shortcuts
>>> django.views.generic
>>>
>>> I don't know what's wrong. My server runs in development mode (not in 
>>> production yet), but there havev been some bugs that are hard to imagine 
>>> are caused by this, but still (images not loading, CSS not loading).
>>>
>>> Thanks.
>>>
>>> Michael
>>>
>>> -- 
>>>
>> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/f310b434-83df-44ed-b847-0676d36c3441n%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-29 Thread Michael Starr
Thanks. I already have a venv, to answer the first post, and the second, 
yes, it says 3.11.2. I think VSCode just has a bug. It doesn't bother me 
and my app works in all other respects. Thank you for the input.

Michael

On Friday, April 28, 2023 at 7:11:57 AM UTC-7 ALBERT ASHABA AHEEBWA wrote:

> This is a wild suggestion, but as someone here mentioned, your vscode 
> might be pointing to the wrong interpreter.
>
> Check at the bottom bar of your vscode with a .py file open. Next to 
> {}python you should see what environment you are using. 
>
> eg. 3.11.3 64-bit or 3.11.3('.venv':venv)
>
> The latter is what you are looking for. If it's not, click on whatever is 
> there and on popup, select the appropriate. 
>
>
>
> Best Regards,
>
> Albert Ashaba Aheebwa
> +256 781 435857 <+256%20781%20435857>
>
> On Thu, 27 Apr 2023, 23:48 Michael Starr,  wrote:
>
>> I did pip install django on my venv, which is activated, and it reported 
>> already installed. But the following modules are reporting the error in the 
>> subject line:
>> django.db
>> models
>> django.utils.crypto
>> django.urls
>> django.contrib
>> admin
>> django.shortcuts
>> django.views.generic
>>
>> I don't know what's wrong. My server runs in development mode (not in 
>> production yet), but there havev been some bugs that are hard to imagine 
>> are caused by this, but still (images not loading, CSS not loading).
>>
>> Thanks.
>>
>> Michael
>>
>> -- 
>>
> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/8bfb55ff-a550-4fe1-9ec5-73074f3de264n%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-28 Thread ALBERT ASHABA AHEEBWA
This is a wild suggestion, but as someone here mentioned, your vscode might
be pointing to the wrong interpreter.

Check at the bottom bar of your vscode with a .py file open. Next to
{}python you should see what environment you are using.

eg. 3.11.3 64-bit or 3.11.3('.venv':venv)

The latter is what you are looking for. If it's not, click on whatever is
there and on popup, select the appropriate.



Best Regards,

Albert Ashaba Aheebwa
+256 781 435857

On Thu, 27 Apr 2023, 23:48 Michael Starr, 
wrote:

> I did pip install django on my venv, which is activated, and it reported
> already installed. But the following modules are reporting the error in the
> subject line:
> django.db
> models
> django.utils.crypto
> django.urls
> django.contrib
> admin
> django.shortcuts
> django.views.generic
>
> I don't know what's wrong. My server runs in development mode (not in
> production yet), but there havev been some bugs that are hard to imagine
> are caused by this, but still (images not loading, CSS not loading).
>
> Thanks.
>
> Michael
>
> --
> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/CAAQecPex9WvQ%3D4Yq3UKQPiY9U8otmNvRwpwTkfekzcsZeV8xNg%40mail.gmail.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-28 Thread Emalexogah Ogah
If you felt the problem was vs code, I have a suggestion. Try it out and if
it works, get back to me.
Open your comman prompt terminal and input
Python -m venv venv (press enter)
Venv/static/activate (press enter)
Then install django again

On Fri, Apr 28, 2023, 3:27 AM Michael Starr 
wrote:

> Thank you for the replies. I am overwhelmed right now but will check back
> on them later.
>
> I think you two are right that it's the IDE. It's VSCode (I don't know
> what version). I was just suspicious b/c there were some strange bugs in my
> django project. I won't worry about it. If it annoys me I'll redirect the
> pointers.
>
> Michael
>
> On Thursday, April 27, 2023 at 3:27:31 PM UTC-7 Khaleel Ahmed H. M.
> Shariff wrote:
>
>> Hi Michael
>>
>> May Peace, Blessings & Mercy of Almighty God be on you!
>>
>> do you know how to modify the sys.path to add the directory where the
>> listed modules are installed?
>>
>> On Linux/UNIX
>> Execute the find command to locate the directory where the modules are
>> installed and include the same in the path
>>
>> On windows
>> Execute the dir/s to locate the directory where the modules are
>> installed and include the same in the path
>>
>> Best of luck
>>
>> God Bless You!
>> God Bless India!!
>> --
>>
>> Love & Regards
>> Dr. (h.c.) Khaleel Ahmed H. M.
>>
>> +91-9845007864 <+91%2098450%2007864>
>>
>> Taming Python
>>
>>
>> https://www.amazon.in/Taming-Python-comfortable-writing-Scripts-ebook/dp/B08T6PQG7M
>>
>> ---
>>
>> Human Life is Precious
>> Koran Surah Ma'idah Chapter 5 Verse 32:
>> If anyone killed a person, not in retaliation of murder, or (and) to
>> spread mischief in the land - it would be as if he killed all mankind, & if
>> anyone saved a life, it would be as if he saved the life of all mankind.
>>
>> On Fri, 28 Apr 2023 at 2:54 AM, Reddy Tintaya  wrote:
>>
>>> Should I suppose that it appears like error only in your editor, but the
>>> app runs with no problem?
>>> I guess the error is that your IDE is not pointing to the correct python
>>> interpreter
>>>
>>>
>>> On 27 Apr 2023, at 16:05, Michael Starr  wrote:
>>>
>>> I did pip install django on my venv, which is activated, and it reported
>>> already installed. But the following modules are reporting the error in the
>>> subject line:
>>> django.db
>>> models
>>> django.utils.crypto
>>> django.urls
>>> django.contrib
>>> admin
>>> django.shortcuts
>>> django.views.generic
>>>
>>> I don't know what's wrong. My server runs in development mode (not in
>>> production yet), but there havev been some bugs that are hard to imagine
>>> are caused by this, but still (images not loading, CSS not loading).
>>>
>>> Thanks.
>>>
>>> Michael
>>>
>>>
>>>
>>> --
>>> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.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/52f5968e-2e0d-4f64-8fb3-5bbd2ef70bean%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/CALRYqKgu5HL8e3byiQQ4aam46kSzWHPkJtk3GuCLPWg%2BPw7cxw%40mail.gmail.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Michael Starr
Thank you for the replies. I am overwhelmed right now but will check back 
on them later.

I think you two are right that it's the IDE. It's VSCode (I don't know what 
version). I was just suspicious b/c there were some strange bugs in my 
django project. I won't worry about it. If it annoys me I'll redirect the 
pointers.

Michael

On Thursday, April 27, 2023 at 3:27:31 PM UTC-7 Khaleel Ahmed H. M. Shariff 
wrote:

> Hi Michael 
>
> May Peace, Blessings & Mercy of Almighty God be on you!
>
> do you know how to modify the sys.path to add the directory where the 
> listed modules are installed?
>
> On Linux/UNIX
> Execute the find command to locate the directory where the modules are 
> installed and include the same in the path
>
> On windows 
> Execute the dir/s to locate the directory where the modules are installed 
> and include the same in the path
>
> Best of luck
>
> God Bless You!
> God Bless India!!
> --
>
> Love & Regards
> Dr. (h.c.) Khaleel Ahmed H. M.
>
> +91-9845007864 <+91%2098450%2007864>
>
> Taming Python
>
>
> https://www.amazon.in/Taming-Python-comfortable-writing-Scripts-ebook/dp/B08T6PQG7M
>
> ---
>
> Human Life is Precious
> Koran Surah Ma'idah Chapter 5 Verse 32:
> If anyone killed a person, not in retaliation of murder, or (and) to 
> spread mischief in the land - it would be as if he killed all mankind, & if 
> anyone saved a life, it would be as if he saved the life of all mankind.
>
> On Fri, 28 Apr 2023 at 2:54 AM, Reddy Tintaya  wrote:
>
>> Should I suppose that it appears like error only in your editor, but the 
>> app runs with no problem?
>> I guess the error is that your IDE is not pointing to the correct python 
>> interpreter
>>
>>
>> On 27 Apr 2023, at 16:05, Michael Starr  wrote:
>>
>> I did pip install django on my venv, which is activated, and it reported 
>> already installed. But the following modules are reporting the error in the 
>> subject line:
>> django.db
>> models
>> django.utils.crypto
>> django.urls
>> django.contrib
>> admin
>> django.shortcuts
>> django.views.generic
>>
>> I don't know what's wrong. My server runs in development mode (not in 
>> production yet), but there havev been some bugs that are hard to imagine 
>> are caused by this, but still (images not loading, CSS not loading).
>>
>> Thanks.
>>
>> Michael
>>
>>
>>
>> -- 
>> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.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/52f5968e-2e0d-4f64-8fb3-5bbd2ef70bean%40googlegroups.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Khaleel Ahmed H. M. Shariff
Hi Michael

May Peace, Blessings & Mercy of Almighty God be on you!

do you know how to modify the sys.path to add the directory where the
listed modules are installed?

On Linux/UNIX
Execute the find command to locate the directory where the modules are
installed and include the same in the path

On windows
Execute the dir/s to locate the directory where the modules are installed
and include the same in the path

Best of luck

God Bless You!
God Bless India!!
--

Love & Regards
Dr. (h.c.) Khaleel Ahmed H. M.

+91-9845007864

Taming Python

https://www.amazon.in/Taming-Python-comfortable-writing-Scripts-ebook/dp/B08T6PQG7M

---

Human Life is Precious
Koran Surah Ma'idah Chapter 5 Verse 32:
If anyone killed a person, not in retaliation of murder, or (and) to spread
mischief in the land - it would be as if he killed all mankind, & if anyone
saved a life, it would be as if he saved the life of all mankind.

On Fri, 28 Apr 2023 at 2:54 AM, Reddy Tintaya  wrote:

> Should I suppose that it appears like error only in your editor, but the
> app runs with no problem?
> I guess the error is that your IDE is not pointing to the correct python
> interpreter
>
>
> On 27 Apr 2023, at 16:05, Michael Starr 
> wrote:
>
> I did pip install django on my venv, which is activated, and it reported
> already installed. But the following modules are reporting the error in the
> subject line:
> django.db
> models
> django.utils.crypto
> django.urls
> django.contrib
> admin
> django.shortcuts
> django.views.generic
>
> I don't know what's wrong. My server runs in development mode (not in
> production yet), but there havev been some bugs that are hard to imagine
> are caused by this, but still (images not loading, CSS not loading).
>
> Thanks.
>
> Michael
>
>
>
> --
> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.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/CAMjBbiBJZcKp%2Be%3DXtRpzjQWoMddtsjbH3sOhg1GiAKhnEP%2BzDg%40mail.gmail.com.


Re: Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Reddy Tintaya
Should I suppose that it appears like error only in your editor, but the app 
runs with no problem?
I guess the error is that your IDE is not pointing to the correct python 
interpreter


> On 27 Apr 2023, at 16:05, Michael Starr  wrote:
> 
> I did pip install django on my venv, which is activated, and it reported 
> already installed. But the following modules are reporting the error in the 
> subject line:
> django.db
> models
> django.utils.crypto
> django.urls
> django.contrib
> admin
> django.shortcuts
> django.views.generic
> 
> I don't know what's wrong. My server runs in development mode (not in 
> production yet), but there havev been some bugs that are hard to imagine are 
> caused by this, but still (images not loading, CSS not loading).
> 
> Thanks.
> 
> Michael
> 
> -- 
> 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/f7977c43-90ef-4423-bb36-07c550bfda52n%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/2FFAC08F-0BC9-44B6-98B2-97A8978AB3DC%40momnt.com.


Import [python django module] could not be resolved from source Pylance (reportMissingModuleSource) -- even though Django is installed in my venv

2023-04-27 Thread Michael Starr
I did pip install django on my venv, which is activated, and it reported 
already installed. But the following modules are reporting the error in the 
subject line:
django.db
models
django.utils.crypto
django.urls
django.contrib
admin
django.shortcuts
django.views.generic

I don't know what's wrong. My server runs in development mode (not in 
production yet), but there havev been some bugs that are hard to imagine 
are caused by this, but still (images not loading, CSS not loading).

Thanks.

Michael

-- 
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/f7977c43-90ef-4423-bb36-07c550bfda52n%40googlegroups.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread Luqman Lawal
Okay

On Thu, Sep 1, 2022, 4:21 PM Ashish Rawat 
wrote:

> There is error in line number 3 you are importing the module from restapi
> but you should take that from model
>
> On Thu, Sep 1, 2022, 7:30 PM Pooja Kumari  wrote:
>
>> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%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/CAJf3Dr%2Bipj0t3zXoA3C1D-FF%3DCe0BvJH-Xd1OWneYF9e%2B1Pu%2Bg%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/CAHj0e%2BT2H2KOiPFv%3DN2w%2BrJrvmfCoSvErqbwD6%3DK%3Dcm3jUXWZQ%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread M Adnan
>From webapp.models import employee

On Thu, 1 Sep 2022, 7:02 pm Pooja Kumari,  wrote:

> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2920648e-f12c-4e26-a089-59a196fd653an%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/CABNyTSqR989ABXXJj3T0iZaH595Vk31hmUR2NiJOSyyOZeBrZw%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread Shams Ulhaq
>From . models import employees
Then use in serializer

On Thu, 1 Sep 2022, 19:02 Pooja Kumari,  wrote:

> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2920648e-f12c-4e26-a089-59a196fd653an%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/CACbcXAVj1R83-VmWJ6m%3DT2VL8Lu8R%3D8T0kpx03NrCbnxexAL2g%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread Pooja Kumari
Understood.
Thank you very much

On Thu, Sep 1, 2022, 7:45 PM MAHESH KUMAR 
wrote:

> You can write  your serializers in 3rd line
>
> From .models import employees
>
> Thanks,
> Mahesh
>
> On Thu, Sep 1, 2022, 19:30 Pooja Kumari  wrote:
>
>> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/2920648e-f12c-4e26-a089-59a196fd653an%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/CAPvC_H847-a5M3fdmTmWRT%2BU3ZESG-RqHDA3h6JBQXnGFe0a_w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPvC_H847-a5M3fdmTmWRT%2BU3ZESG-RqHDA3h6JBQXnGFe0a_w%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/CAHYvwbVQ4Rywj-N0E4H%2Bnk9c8C1pNYkwWESBx2aAvo%2B29sRpAQ%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread subin
Thanks again for the info.

On Thu, Sep 1, 2022 at 4:21 PM Ashish Rawat 
wrote:

> There is error in line number 3 you are importing the module from restapi
> but you should take that from model
>
> On Thu, Sep 1, 2022, 7:30 PM Pooja Kumari  wrote:
>
>> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%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/CAJf3Dr%2Bipj0t3zXoA3C1D-FF%3DCe0BvJH-Xd1OWneYF9e%2B1Pu%2Bg%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/CAJnMy6ePf1VWGFTJgXr4mEHbm78AJMC6PoWVB98zbQL_KpDoaQ%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread Ashish Rawat
There is error in line number 3 you are importing the module from restapi
but you should take that from model

On Thu, Sep 1, 2022, 7:30 PM Pooja Kumari  wrote:

> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%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/CAJf3Dr%2Bipj0t3zXoA3C1D-FF%3DCe0BvJH-Xd1OWneYF9e%2B1Pu%2Bg%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread Akash Kundoo
>From where you're importing employees? Check that?

On Thu, 1 Sep, 2022, 7:31 pm Pooja Kumari,  wrote:

> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%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/CACTgikHJx6PUikfv6apyxe0suW%3D9tZNZCNy-0A%3D%3DXBv6%3DR2FyA%40mail.gmail.com.


Re: ImportError: cannot import name 'employees' from 'rest_framework'

2022-09-01 Thread MAHESH KUMAR
You can write  your serializers in 3rd line

>From .models import employees

Thanks,
Mahesh

On Thu, Sep 1, 2022, 19:30 Pooja Kumari  wrote:

> Can anyone explain 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/2920648e-f12c-4e26-a089-59a196fd653an%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2920648e-f12c-4e26-a089-59a196fd653an%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/CAPvC_H847-a5M3fdmTmWRT%2BU3ZESG-RqHDA3h6JBQXnGFe0a_w%40mail.gmail.com.


authentication with simply importing django.contrib.auth import authinticate didnt worked

2022-03-11 Thread things matters
how can i make authintication of custom model user in view method apart 
from default user model

-- 
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/9b5df93d-87d7-4a48-bf54-7b8dbf652519n%40googlegroups.com.


Re: Error : Circula import

2022-03-04 Thread Kasper Laudrup

On 04/03/2022 07.58, Jet Ezra wrote:

But the link tells you the details and how to solve the problem.
Anyway, I think you forgot to share the said screenshots. I can't find them.

Also, when you are asking please, don't try to direct us how we should 
solve this problem. Just detail your problem and wait for your answer.




I think you're a bit confused. I answered the original question with the 
link, so you answered the wrong person.


Not sure if GMail doesn't support threads or what else might be the 
cause of the confusion.


Anyway, no worries. Just wanted to point it out.

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/bad0faf8-dc81-c1eb-26f7-7cd4c5d5e80b%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: Error : Circula import

2022-03-03 Thread Jet Ezra
But the link tells you the details and how to solve the problem.
Anyway, I think you forgot to share the said screenshots. I can't find them.

Also, when you are asking please, don't try to direct us how we should
solve this problem. Just detail your problem and wait for your answer.

Simple.
A circular import happens when you have fileA that has something say a
class A, then another file B with also a class B
Then class A imports class B from file B which is also importing class A
from B.
So the program keeps importing and never completes the cycle.

Solution,
If you have to use the two like that, then put them in the same file. It is
always my shortcut.

On Thu, Mar 3, 2022 at 11:26 PM Kasper Laudrup 
wrote:

> On 03/03/2022 20.38, Ruzindana Kent wrote:
> > Hello everyone,
> >
> > I'm new to django and also new in the group, I wanted to know how to
> > solve circula import errors. here is a screenshot of the error from the
> > terminal.
> >
> > Any reply about that will be helpful, thank you
> >
>
> Remember that Django is a Python framework, so circular imports are
> mostly a Python thing not specific to Django:
>
> https://www.pythonpool.com/python-circular-import/
>
> 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/e259dd34-1578-7540-35c7-132550a1955c%40stacktrace.dk
> .
>


-- 
jet

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


Re: Error : Circula import

2022-03-03 Thread Kasper Laudrup

On 03/03/2022 20.38, Ruzindana Kent wrote:

Hello everyone,

I'm new to django and also new in the group, I wanted to know how to 
solve circula import errors. here is a screenshot of the error from the 
terminal.


Any reply about that will be helpful, thank you



Remember that Django is a Python framework, so circular imports are 
mostly a Python thing not specific to Django:


https://www.pythonpool.com/python-circular-import/

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/e259dd34-1578-7540-35c7-132550a1955c%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Error : Circula import

2022-03-03 Thread Ruzindana Kent
Hello everyone,

I'm new to django and also new in the group, I wanted to know how to solve 
circula import errors. here is a screenshot of the error from the terminal.

Any reply about that will be helpful, 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/a9cd0658-40f1-4d36-ad24-fc4bd162446cn%40googlegroups.com.


Re: How to import UGETTEXT_LAZY ON DJANGO 4.0

2021-12-10 Thread Jason

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3
On Friday, December 10, 2021 at 12:01:03 AM UTC-5 ngal...@gmail.com wrote:

> Thanks hopefully the same to ugettext
>
>  
>
> Kind Regards
>
>  
>
> Ngallen Ramadhan
>
> T: +255 765 889 960 <+255%20765%20889%20960> | Emial: ngal...@gmail.com | 
> Skype: ngallen2
>
>  
>
> *From:* django...@googlegroups.com  *On 
> Behalf Of *David Nugent
> *Sent:* 10 December 2021 07:50
> *To:* django...@googlegroups.com
> *Subject:* Re: How to import UGETTEXT_LAZY ON DJANGO 4.0
>
>  
>
> Simply change it to gettext_lazy. You don't need the deprecated functions, 
> they were for python 2.
>
>  
>
> Regards, David
>
>  
>
> On Fri, Dec 10, 2021 at 3:43 PM  wrote:
>
> It seems Django has removed ‘ugettext_lazy`(from django.utils.translation 
> import ugettext_lazy as _) from Django version 4.0.x
>
> How can I handle translation on Django version 4.0.x?
>
>  
>
> -- 
> 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/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.com
>  
> <https://groups.google.com/d/msgid/django-users/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.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...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%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/3c5bb795-d6f5-4831-aabf-154d6f620490n%40googlegroups.com.


RE: How to import UGETTEXT_LAZY ON DJANGO 4.0

2021-12-09 Thread ngallen4
Thanks hopefully the same to ugettext

 

Kind Regards

 

Ngallen Ramadhan

T: +255 765 889 960 | Emial:  <mailto:ngall...@gmail.com> ngall...@gmail.com | 
Skype: ngallen2

 

From: django-users@googlegroups.com  On Behalf 
Of David Nugent
Sent: 10 December 2021 07:50
To: django-users@googlegroups.com
Subject: Re: How to import UGETTEXT_LAZY ON DJANGO 4.0

 

Simply change it to gettext_lazy. You don't need the deprecated functions, they 
were for python 2.

 

Regards, David

 

On Fri, Dec 10, 2021 at 3:43 PM mailto:ngall...@gmail.com> 
> wrote:

It seems Django has removed ‘ugettext_lazy`(from django.utils.translation 
import ugettext_lazy as _) from Django version 4.0.x

How can I handle translation on Django version 4.0.x?

 

-- 
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 
<mailto:django-users+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.com
 
<https://groups.google.com/d/msgid/django-users/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.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 
<mailto:django-users+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%40mail.gmail.com
 
<https://groups.google.com/d/msgid/django-users/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%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/00b801d7ed82%24c6197ed0%24524c7c70%24%40gmail.com.


Re: How to import UGETTEXT_LAZY ON DJANGO 4.0

2021-12-09 Thread David Nugent
Simply change it to gettext_lazy. You don't need the deprecated functions,
they were for python 2.

Regards, David

On Fri, Dec 10, 2021 at 3:43 PM  wrote:

> It seems Django has removed ‘ugettext_lazy`(from django.utils.translation
> import ugettext_lazy as _) from Django version 4.0.x
>
> How can I handle translation on Django version 4.0.x?
>
>
>
> --
> 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/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.com
> <https://groups.google.com/d/msgid/django-users/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.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/CAE5VhgWHc-1AePPpLKZK5umH00fTrcRsHBefu%2Bb37um-mz%3D3kQ%40mail.gmail.com.


How to import UGETTEXT_LAZY ON DJANGO 4.0

2021-12-09 Thread ngallen4
It seems Django has removed 'ugettext_lazy`(from django.utils.translation
import ugettext_lazy as _) from Django version 4.0.x

How can I handle translation on Django version 4.0.x?

 

-- 
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/009b01d7ed80%246da44d40%2448ece7c0%24%40gmail.com.


Django Import Export, Filter ForeignKey objects connected to users

2021-11-17 Thread Gianmaria Di Fronzo
I'm building an import excel files system for every leads whit import 
export library. In the Website each user must be able to import his leads 
and make sure that they are viewed only by him. In all other cases I 
filtered the "organisation" field linked to a UserProfile model through the 
views.py. But now I don't know how to filter the field organisation for a 
specific user.At the moment I can import the excel files from the template 
but leaving the organisation field blank. Help me please I'm desperate

Models.py
class Lead(models.Model): 
nome = models.CharField(max_length=20)
 cognome = models.CharField(max_length=20)
 luogo=models.CharField(max_length=50, blank=True, null=True, 
choices=region_list) città=models.CharField(max_length=20) email = 
models.EmailField() 
phone_number = models.CharField(max_length=20)
 description = models.TextField() 
 agent = models.ForeignKey("Agent", null=True, blank=True, 
on_delete=models.SET_NULL) 
category = models.ForeignKey("Category", related_name="leads", null=True, 
blank=True, on_delete=models.SET_NULL) 
chance=models.ForeignKey("Chance",related_name="chance", null=True, 
blank=True, on_delete=models.CASCADE) 
profile_picture = models.ImageField(null=True, blank=True, 
upload_to="profile_pictures/") converted_date = 
models.DateTimeField(null=True, blank=True) 
date_added = models.DateTimeField(auto_now_add=True) 
organisation = models.ForeignKey(UserProfile, 
on_delete=models.CASCADE,null=True, blank=True) 
 objects = LeadManager() 
age = models.IntegerField(default=0) def __str__(self): return 
f"{self.nome} {self.cognome}" 
 class User(AbstractUser): 
is_organisor = models.BooleanField(default=True)
 is_agent = models.BooleanField(default=False)
 class UserProfile(models.Model): 
  user = models.OneToOneField(User, on_delete=models.CASCADE)
 def __str__(self): return self.user.username

Views.py
def simple_upload(request):
  if request.method == 'POST': 
 Lead_resource = LeadResource()
 dataset = Dataset() 
 newdoc = request.FILES['myfile'] 
 imported_data = dataset.load(newdoc.read(),format='xlsx') 
  #print(imported_data) 
  for data in imported_data: 
 value = Lead( data[0], data[2],#nome data[3],#cognome data[5],#luogo 
data[7],#città data[8],#email data[9],#numero telefono data[11],#desc ) 
value.save() 
 result = Lead_resource.import_data(dataset, dry_run=True) # Test the data 
import if not result.has_errors(): 
 Lead_resource.import_data(dataset,dry_run=False) # Actually import now 
return render(request, 'input.html')

Resources.py
class LeadResource(resources.ModelResource):
 nome = fields.Field(attribute='nome', column_name='nome') 
luogo = fields.Field(attribute='luogo', column_name='regione') 
  class Meta:
  model = Lead report_skipped=True 

admin.py
@admin.register(Lead)
class PersonAdmin(ImportExportModelAdmin): 
 readonly_fields = ('date_added',)

-- 
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/9a995f5f-c5ff-44cd-9b68-718e41e35cf5n%40googlegroups.com.


Join Two fields during Import

2021-11-15 Thread Yogesh Pawar
Hello Team, 

I am importing a CSV file from the admin panel, during import I Want to 
Create a Unique ID by combing other three to four fields and storing it 
into the id column  how to combine columns during import of CSV or excel 


Thanks and 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/25165bc9-3143-4d83-83d4-16002943caefn%40googlegroups.com.


Re: Import issue

2021-10-02 Thread Sophia Iroegbu
Thanks it works

On Sat, Oct 2, 2021, 11:47 AM Vineet Kothari 
wrote:

> Hi,
>  Did you check in python manage.py shell then try to import it and
> check.
>
> Thanks & Regards,
> Vineet Kothari
>
> On Sat, 2 Oct 2021, 10:12 am Malcolm MacKinnon, 
> wrote:
>
>> Is your module included in your installed apps in the settings.py file?
>>
>> On Fri, Oct 1, 2021 at 8:09 PM Sophia Iroegbu 
>> wrote:
>> >
>> > I noticed that each time I download a python package and import it.
>> > It imports, it works but once I run my code it runs into an error.
>> >
>> > Error message: ModuleNotFoundError.
>> >
>> >
>> > What do I do?
>> >
>> > --
>> > 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/CAEa7H7eH_O_Zsi4KXMWbK%2B6pz-VAn8a%3DC6r43FRR0xEt-hrePQ%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/CAK8W3XohjqemaRi_KMprnqoweMjsbzhNjdGNiiKOKhdKTmwgDw%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/CAAcansvZ%3DZzgu1nY%3DsOf_SgErD5hia%3DrfVWZNDLHdGNAA1tqyg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAcansvZ%3DZzgu1nY%3DsOf_SgErD5hia%3DrfVWZNDLHdGNAA1tqyg%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/CAEa7H7eEh5vXjCOsV5X7EqC6TbNT8QORVeCx0Ov_t%3DrLG4LkDA%40mail.gmail.com.


Re: Import issue

2021-10-02 Thread Vineet Kothari
Hi,
 Did you check in python manage.py shell then try to import it and
check.

Thanks & Regards,
Vineet Kothari

On Sat, 2 Oct 2021, 10:12 am Malcolm MacKinnon,  wrote:

> Is your module included in your installed apps in the settings.py file?
>
> On Fri, Oct 1, 2021 at 8:09 PM Sophia Iroegbu 
> wrote:
> >
> > I noticed that each time I download a python package and import it.
> > It imports, it works but once I run my code it runs into an error.
> >
> > Error message: ModuleNotFoundError.
> >
> >
> > What do I do?
> >
> > --
> > 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/CAEa7H7eH_O_Zsi4KXMWbK%2B6pz-VAn8a%3DC6r43FRR0xEt-hrePQ%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/CAK8W3XohjqemaRi_KMprnqoweMjsbzhNjdGNiiKOKhdKTmwgDw%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/CAAcansvZ%3DZzgu1nY%3DsOf_SgErD5hia%3DrfVWZNDLHdGNAA1tqyg%40mail.gmail.com.


Re: Import issue

2021-10-01 Thread Malcolm MacKinnon
Is your module included in your installed apps in the settings.py file?

On Fri, Oct 1, 2021 at 8:09 PM Sophia Iroegbu  wrote:
>
> I noticed that each time I download a python package and import it.
> It imports, it works but once I run my code it runs into an error.
>
> Error message: ModuleNotFoundError.
>
>
> What do I do?
>
> --
> 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/CAEa7H7eH_O_Zsi4KXMWbK%2B6pz-VAn8a%3DC6r43FRR0xEt-hrePQ%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/CAK8W3XohjqemaRi_KMprnqoweMjsbzhNjdGNiiKOKhdKTmwgDw%40mail.gmail.com.


Import issue

2021-10-01 Thread Sophia Iroegbu
I noticed that each time I download a python package and import it.
It imports, it works but once I run my code it runs into an error.

Error message: ModuleNotFoundError.


What do I do?

-- 
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/CAEa7H7eH_O_Zsi4KXMWbK%2B6pz-VAn8a%3DC6r43FRR0xEt-hrePQ%40mail.gmail.com.


Re: Error on import psycopg2

2021-09-19 Thread Felix Orinda
pip install psycopg2-binary
Should work for you. Give me feedback on whether it has worked or not

On Sep 17, 2021 21:18, "Aashish Kumar"  wrote:

install this package 👇

pip install psycopg2-binary

It works perfectly

On Wed, 15 Sep 2021 at 9:40 PM, 'Maryam Yousaf' via Django users <
django-users@googlegroups.com> wrote:

> Hello,
>
> I need psycopg2 for postgres database in django. While installing it, I am
> getting below error. I tried everything on internet but it still there.
> Kindly help me out.
>
> Error:
> "File
> "/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/__init__.py",
> line 51, in 
> from psycopg2._psycopg import ( # noqa
> ImportError:
> dlopen(/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so, 2): Symbol not found: _PQbackendPID
>   Referenced from:
> /Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so
>   Expected in: flat namespace
>  in
> /Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so"
>
> Regards,
> Maryam.
>
>
> --
> This email and any files transmitted with it contain confidential
> information and/or privileged or personal advice. This email is intended
> for the addressee(s) stated above only. If you are not the addressee of the
> email please do not copy or forward it or otherwise use it or any part of
> it in any form whatsoever. If you have received this email in error please
> notify the sender and remove the e-mail from your system. Thank you.
>
> This is an email from the company Just Eat Takeaway.com N.V., a public
> limited liability company with corporate seat in Amsterdam, the
> Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam
> <https://www.google.com/maps/search/Oosterdoksstraat+80,+1011+DK+Amsterdam?entry=gmail&source=g>,
> registered with the Dutch Chamber of Commerce with number 08142836 and
> where the context requires, includes its subsidiaries and associated
> undertakings.
>
> --
> 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/a1ed0079-ee5f-4da1-977c-a02ee5600d6dn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a1ed0079-ee5f-4da1-977c-a02ee5600d6dn%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/CACTAcrxJJ-9qqyYW%3DHmXurZypRi6Ve82QjTudOZW2gy40-yVww%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CACTAcrxJJ-9qqyYW%3DHmXurZypRi6Ve82QjTudOZW2gy40-yVww%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/CAKh5HMsBxjsHJH%3DkbM5pP%3DUKzaFeyPgZdbeHnyLCns7p-1VRsw%40mail.gmail.com.


Re: Error on import psycopg2

2021-09-17 Thread Aashish Kumar
install this package 👇

pip install psycopg2-binary

It works perfectly

On Wed, 15 Sep 2021 at 9:40 PM, 'Maryam Yousaf' via Django users <
django-users@googlegroups.com> wrote:

> Hello,
>
> I need psycopg2 for postgres database in django. While installing it, I am
> getting below error. I tried everything on internet but it still there.
> Kindly help me out.
>
> Error:
> "File
> "/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/__init__.py",
> line 51, in 
> from psycopg2._psycopg import ( # noqa
> ImportError:
> dlopen(/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so, 2): Symbol not found: _PQbackendPID
>   Referenced from:
> /Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so
>   Expected in: flat namespace
>  in
> /Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_
> psycopg.cpython-38-darwin.so"
>
> Regards,
> Maryam.
>
>
> --
> This email and any files transmitted with it contain confidential
> information and/or privileged or personal advice. This email is intended
> for the addressee(s) stated above only. If you are not the addressee of the
> email please do not copy or forward it or otherwise use it or any part of
> it in any form whatsoever. If you have received this email in error please
> notify the sender and remove the e-mail from your system. Thank you.
>
> This is an email from the company Just Eat Takeaway.com N.V., a public
> limited liability company with corporate seat in Amsterdam, the
> Netherlands, and address at Oosterdoksstraat 80, 1011 DK Amsterdam
> <https://www.google.com/maps/search/Oosterdoksstraat+80,+1011+DK+Amsterdam?entry=gmail&source=g>,
> registered with the Dutch Chamber of Commerce with number 08142836 and
> where the context requires, includes its subsidiaries and associated
> undertakings.
>
> --
> 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/a1ed0079-ee5f-4da1-977c-a02ee5600d6dn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a1ed0079-ee5f-4da1-977c-a02ee5600d6dn%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/CACTAcrxJJ-9qqyYW%3DHmXurZypRi6Ve82QjTudOZW2gy40-yVww%40mail.gmail.com.


Re: Error on import psycopg2

2021-09-17 Thread 'Maryam Yousaf' via Django users
Thank you all. It was resolved by making new virtual environment and
installing it again

On Fri, Sep 17, 2021, 6:47 PM Vinay Bagare  wrote:

> Try
>
> >> psycopg2-binary
>
> Best,
> Vinay Bagare
>
> Sent from my iPhone
>
> > On Sep 15, 2021, at 12:15 PM, Kasper Laudrup 
> wrote:
> >
> > On 15/09/2021 16.40, 'Maryam Yousaf' via Django users wrote:
> >> Hello,
> >> I need psycopg2 for postgres database in django. While installing it, I
> am getting below error. I tried everything on internet but it still there.
> Kindly help me out.
> >>
> >
> > Did you try this:
> >
> >
> https://stackoverflow.com/questions/65059310/apple-m1-install-psycopg2-package-symbol-not-found-pqbackendpid
> >
> > I don't know much about MacOSX, but I would assume you have an
> unsupported version of Postgres installed.
> >
> > 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/d667e7fa-57a7-ee16-0390-6834e0f0f006%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/1C0852B7-F4BE-4A54-AB01-033F4A2EB5E6%40gmail.com
> .
>

-- 



This email and any files transmitted with it contain confidential 
information and/or privileged or personal advice. This email is intended 
for the addressee(s) stated above only. If you are not the addressee of the 
email please do not copy or forward it or otherwise use it or any part of 
it in any form whatsoever. If you have received this email in error please 
notify the sender and remove the e-mail from your system. Thank you.


This 
is an email from the company Just Eat Takeaway.com N.V., a public limited 
liability company with corporate seat in Amsterdam, the Netherlands, and 
address at Oosterdoksstraat 80, 1011 DK Amsterdam, registered with the 
Dutch Chamber of Commerce with number 08142836 and where the context 
requires, includes its subsidiaries and associated undertakings.

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


Re: Error on import psycopg2

2021-09-17 Thread Vinay Bagare
Try 

>> psycopg2-binary

Best,
Vinay Bagare

Sent from my iPhone

> On Sep 15, 2021, at 12:15 PM, Kasper Laudrup  wrote:
> 
> On 15/09/2021 16.40, 'Maryam Yousaf' via Django users wrote:
>> Hello,
>> I need psycopg2 for postgres database in django. While installing it, I am 
>> getting below error. I tried everything on internet but it still there. 
>> Kindly help me out.
>> 
> 
> Did you try this:
> 
> https://stackoverflow.com/questions/65059310/apple-m1-install-psycopg2-package-symbol-not-found-pqbackendpid
> 
> I don't know much about MacOSX, but I would assume you have an unsupported 
> version of Postgres installed.
> 
> 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/d667e7fa-57a7-ee16-0390-6834e0f0f006%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/1C0852B7-F4BE-4A54-AB01-033F4A2EB5E6%40gmail.com.


Re: Error on import psycopg2

2021-09-15 Thread FIRDOUS BHAT
Try installing this package,

pip install psycopg2-binary

On Wed, Sep 15, 2021 at 10:45 PM Kasper Laudrup 
wrote:

> On 15/09/2021 16.40, 'Maryam Yousaf' via Django users wrote:
> > Hello,
> >
> > I need psycopg2 for postgres database in django. While installing it, I
> > am getting below error. I tried everything on internet but it still
> > there. Kindly help me out.
> >
>
> Did you try this:
>
>
> https://stackoverflow.com/questions/65059310/apple-m1-install-psycopg2-package-symbol-not-found-pqbackendpid
>
> I don't know much about MacOSX, but I would assume you have an
> unsupported version of Postgres installed.
>
> 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/d667e7fa-57a7-ee16-0390-6834e0f0f006%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/CAFB6YJrWD-Thhida0%2B1fzgzox6ca_CPSPoLgEzTveE8009VwVg%40mail.gmail.com.


Re: Error on import psycopg2

2021-09-15 Thread Kasper Laudrup

On 15/09/2021 16.40, 'Maryam Yousaf' via Django users wrote:

Hello,

I need psycopg2 for postgres database in django. While installing it, I 
am getting below error. I tried everything on internet but it still 
there. Kindly help me out.




Did you try this:

https://stackoverflow.com/questions/65059310/apple-m1-install-psycopg2-package-symbol-not-found-pqbackendpid

I don't know much about MacOSX, but I would assume you have an 
unsupported version of Postgres installed.


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/d667e7fa-57a7-ee16-0390-6834e0f0f006%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Error on import psycopg2

2021-09-15 Thread 'Maryam Yousaf' via Django users
Hello,

I need psycopg2 for postgres database in django. While installing it, I am 
getting below error. I tried everything on internet but it still there. 
Kindly help me out.

Error:
"File 
"/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/__init__.py",
 
line 51, in 
from psycopg2._psycopg import ( # noqa
ImportError: 
dlopen(/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so,
 
2): Symbol not found: _PQbackendPID
  Referenced from: 
/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
  Expected in: flat namespace
 in 
/Users/maryam.yousaf/Documents/venv/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so"

Regards,
Maryam.

-- 



This email and any files transmitted with it contain confidential 
information and/or privileged or personal advice. This email is intended 
for the addressee(s) stated above only. If you are not the addressee of the 
email please do not copy or forward it or otherwise use it or any part of 
it in any form whatsoever. If you have received this email in error please 
notify the sender and remove the e-mail from your system. Thank you.


This 
is an email from the company Just Eat Takeaway.com N.V., a public limited 
liability company with corporate seat in Amsterdam, the Netherlands, and 
address at Oosterdoksstraat 80, 1011 DK Amsterdam, registered with the 
Dutch Chamber of Commerce with number 08142836 and where the context 
requires, includes its subsidiaries and associated undertakings.

-- 
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/a1ed0079-ee5f-4da1-977c-a02ee5600d6dn%40googlegroups.com.


Re: os module import error

2021-05-31 Thread Avi shah
you could just add "import os" in settings.py file

On Mon, May 31, 2021 at 8:32 PM James Ndubuisi 
wrote:

> Good afternoon.
> It seems on creating the Django project using django-admin startproject
> command , the os module isn't imported by default, causing an 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/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%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/CALa7AFPHGEsvpgdaUDpefw1nmVp_c56n95quZUFF_Q-ur0rX%2Bg%40mail.gmail.com.


Re: os module import error

2021-05-31 Thread Antonis Christofides

Hi!

Could you show exactly which command(s) you are running, and the exact error 
message?


Regards,

Antonis Christofides
+30-6979924665 (mobile)

On 31/05/2021 17.57, James Ndubuisi wrote:

Good afternoon.
It seems on creating the Django project using django-admin startproject 
command , the os module isn't imported by default, causing an 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/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%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/cf967d61-ef98-0cdc-8f39-991641ba5728%40antonischristofides.com.


os module import error

2021-05-31 Thread James Ndubuisi
Good afternoon.
It seems on creating the Django project using django-admin startproject
command , the os module isn't imported by default, causing an 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/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%40mail.gmail.com.


Django Import and Export

2021-02-10 Thread www.forum-gh.com
Hi, I am using the django_import_export package but i am not been able to
import files, the tables are related. Please find the attached
files(models, resources and admin) for your reference.

Please help me

-- 
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/CALYpPT-j0jNMZYm7POFfW94fjjSkATEn_ZAYYn6kZx6Wyc3AfQ%40mail.gmail.com.
from django.db import models
from django.utils import timezone
from django.conf import settings
import decimal
from apps.product.models import *

#  Permit Information Analysis 
class Info(models.Model):

O_PORT = [
('Overland', 'Overland'),
('Ghana', 'Ghana'),
('By Air', 'By Air'),
('By Road', 'By Road'),
('Takoradi', 'Takoradi'),
('Tema', 'Tema'),
]


PAYMENT_TYPE = [
('Cash Against Document', 'Cash Against Document'),
('Bank Draft', 'Bank Draft'),
('Cash Against Document', 'Cash Against Document'),
('Letter of Credit', 'Letter of Credit'),
('Wire Transfer', 'Wire Transfer'),
('PrePaid', 'PrePaid'),
]

exporter = models.CharField(max_length=150)
buyer = models.CharField(max_length=150)
vessel = models.CharField(max_length=150)
date_of_transaction = models.DateField(default=timezone.now, verbose_name="Transaction Date")
originating_port = models.CharField(choices=O_PORT, max_length=8, default="Ghana")
city_destination = models.CharField(max_length=150, verbose_name="City of Destination")
country_destination = models.ForeignKey(Country, on_delete=models.CASCADE, verbose_name="Country of Destination")
contract_number = models.CharField(max_length=150, verbose_name="Contract Number")
a2_form = models.CharField(max_length=50, blank=True, null=True)
payment_type = models.CharField(max_length=100)
negotiating_bank = models.ForeignKey(Bank, on_delete=models.CASCADE)
container_or_vehicle = models.CharField(max_length=50)
driver_name = models.CharField(max_length=150, blank=True)

# records on user
added_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, editable=False, verbose_name="Added By")
updated_by = models.CharField(max_length=50, default='Admin', null=True, blank=True)
date_added = models.DateTimeField(auto_now_add=True)

permit_NUM = models.CharField(max_length=30, unique=True, verbose_name="Permit Number")

class Meta:
verbose_name = "Capture Permit Info"
verbose_name_plural = verbose_name

def __str__(self):
return self.exporter



#  Permit 
class Permit(models.Model):

CONVERSION = [
('1.', '1.'),
('0.0006', '0.0006'),
('0.0007', '0.0007'),
('0.0010', '0.0010'),
('0.0015', '0.0015'),
]

UNITS = [

('m2', 'm2'),
('m3', 'm3'),

]

CURRENCY = [
('USD', 'USD'),
('GHS', 'GHS'),
('CFA', 'CFA'),
('Euro', 'Euro'),

]

product = models.ForeignKey(Product, on_delete=models.CASCADE)
specie = models.ForeignKey(Specie, on_delete=models.CASCADE)
grade = models.ForeignKey(Grade, on_delete=models.CASCADE)
info = models.ForeignKey(Info, on_delete=models.CASCADE)

# volume
volume = models.DecimalField(max_digits=19, decimal_places=3)
conversion_factor = models.CharField(choices=CONVERSION, max_length=8)
units = models.CharField(choices=UNITS, max_length=5, default='m3')
unit_price = models.DecimalField(max_digits=19, decimal_places=2)
currency = models.CharField(max_length=15)
ex_rate = models.DecimalField(max_digits=19, decimal_places=4, verbose_name='Exchange Rate')


def __str__(self):
return self.info.exporter

@property
def my_value(self):
    val = self.volume * self.unit_price
val = round(val, 2)
return val

@property
def derived_volume(self):
dv = self.volume * decimal.Decimal(self.conversion_factor)
dv = round(dv, 3)
return dv

@property
def euro_value(self):
ev = self.volume *

Re: Import Export

2021-01-14 Thread ÖNDER YILMAZ
https://youtu.be/oZQjO0iNOwI

14 Oca 2021 Per 09:14 tarihinde www.forum-gh.com  şunu
yazdı:

> hello, please i have 4 models linked together by foreignkey how do i
> perform import using the django import_export package.
>
> 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/CALYpPT-CdhMXXaMQhjDuL7-s-kXms3Z%3Dr%2BVLR6dd0vd%3Di33eCA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALYpPT-CdhMXXaMQhjDuL7-s-kXms3Z%3Dr%2BVLR6dd0vd%3Di33eCA%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/CAB%2B4G2eV%2BJr7%3D0nUVZXsE1aOpPRiHa57P7PGR4G%2Byr-a%2Bc-4DA%40mail.gmail.com.


Import Export

2021-01-13 Thread www.forum-gh.com
hello, please i have 4 models linked together by foreignkey how do i
perform import using the django import_export package.

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/CALYpPT-CdhMXXaMQhjDuL7-s-kXms3Z%3Dr%2BVLR6dd0vd%3Di33eCA%40mail.gmail.com.


Re: import *

2021-01-10 Thread David Nugent
On 11 January 2021 at 13:14:59, Peter of the Norse 
(rahmc...@gmail.com<mailto:rahmc...@gmail.com>) wrote:
I use multiple settings.py files to do this.  Specifically, in my main one, I 
have what I consider the only acceptable instance of import *.


Slightly off-topic (subject changed to reflect that), but there are other 
exceptions as well that conform to a similar pattern.

For example, refactoring models.py to a package requires adding an import into 
__init__.py (unless you want to change all dependent code and often needlessly 
cluttering import statements). Importing `*` instead if individual submodules 
into `__init__.py` is often the way to go and leads to less changes when you 
add models in new modules.

PEP8 doesn't explicitly disallow this, but only strongly recommends against it, 
but the concern is very project specific. I just use it in django for this use 
case but rarely otherwise.


Regards,

/d

-- 
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/etPan.5ffbba84.2e2c0378.a5d6%40uniquode.io.


Re: Conversion and import of a pre-existing database

2021-01-07 Thread gabriela...@gmail.com
Perhaps there is a utility program that can do that. Something like 
converter. Have you look in web foros  ?

El jueves, 7 de enero de 2021 a las 11:58:36 UTC-3, 
pe...@oneilinteractive.com escribió:

> Jérémy,
>
> It all depends on the Database which route to take. Is it one table, 
> multiple tab;es, what are the relationship?
>
> My plan of attack would be:
>
>1. Create all models in Django as you want them to be. Use the Django 
>standards to name your new fields [1]. 
>2. Let Django handle the field naming, unless you have a really good 
>reason to overwrite this behavior. Relationships are setup to other 
> models, 
>do not add _id to these fields, Django  
>3. Create the migrations to create the models in Postgres
>4. With Django in mind write your conversion. In other words, use the 
>Django ORM to write data to your new DB, while using RAW sql to read the 
>old DB. 
>5. Write the conversion as management command. 
>6. If you have multiple tables start filling the tables that do no 
>have any relationship to other tables first and work your way up. No FK 
>Tables-> Tables with one or more FK to an already existing table
>
>
> [1] - 
> https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style
>
>
> On 1/7/21 1:05 AM, Jérémy Garniaux wrote:
>
> Hi, 
>
> I'm working on my first Django project. Already read the tutorial but 
> following along it to be sure not to miss anything. 
>
> I've been asked to rebuild a pre-existing website. It's basic in 
> functionality: various users create complete descriptions of heritage items 
> in the admin area, and the public page display the description, mostly in 
> text format, sometimes with images too. The final user can navigate the 
> items on the public page. 
>
> The data model contains many different classes and variables - it's well 
> structured and doesn't need to change. 
>
> The data is stored into a MS SQL Server database. The new website will use 
> PostgreSQL, so I need to convert the MSQSQL database and import it into 
> PostgreSQL. I'm aware of inspectdb but I decided to manually write 
> models.py from the ground to get acquainted both with the data and with 
> django models. 
>
> What I'd like to know is: 
>
> - Should I work on the conversion and import of the MSSQL database into 
> PosgreSQL without thinking about Django at this stage? 
>
> - I read that Django will add "_id" at the end of the field names. Should 
> I worry about that? Or should I leave in PgSQL the same field names there 
> was in MSSQL? How should I name my variables in models.py then? 
>
> - Any other advice will be very welcome :) 
>
> Thanks a lot for your help, 
>
> Jeremy 
>
>
>

-- 
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/eb065ec4-7e90-4755-822a-5cdb63f17244n%40googlegroups.com.


Re: Conversion and import of a pre-existing database

2021-01-07 Thread 'Peter van der Does' via Django users
Jérémy,

It all depends on the Database which route to take. Is it one table,
multiple tab;es, what are the relationship?

My plan of attack would be:

 1. Create all models in Django as you want them to be. Use the Django
standards to name your new fields [1].
 2. Let Django handle the field naming, unless you have a really good
reason to overwrite this behavior. Relationships are setup to other
models, do not add _id to these fields, Django 
 3. Create the migrations to create the models in Postgres
 4. With Django in mind write your conversion. In other words, use the
Django ORM to write data to your new DB, while using RAW sql to read
the old DB.
 5. Write the conversion as management command.
 6. If you have multiple tables start filling the tables that do no have
any relationship to other tables first and work your way up. No FK
Tables-> Tables with one or more FK to an already existing table


[1] -
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style


On 1/7/21 1:05 AM, Jérémy Garniaux wrote:
> Hi,
>
> I'm working on my first Django project. Already read the tutorial but
> following along it to be sure not to miss anything.
>
> I've been asked to rebuild a pre-existing website. It's basic in
> functionality: various users create complete descriptions of heritage
> items in the admin area, and the public page display the description,
> mostly in text format, sometimes with images too. The final user can
> navigate the items on the public page.
>
> The data model contains many different classes and variables - it's
> well structured and doesn't need to change.
>
> The data is stored into a MS SQL Server database. The new website will
> use PostgreSQL, so I need to convert the MSQSQL database and import it
> into PostgreSQL. I'm aware of inspectdb but I decided to manually
> write models.py from the ground to get acquainted both with the data
> and with django models.
>
> What I'd like to know is:
>
> - Should I work on the conversion and import of the MSSQL database
> into PosgreSQL without thinking about Django at this stage?
>
> - I read that Django will add "_id" at the end of the field names.
> Should I worry about that? Or should I leave in PgSQL the same field
> names there was in MSSQL? How should I name my variables in models.py
> then?
>
> - Any other advice will be very welcome :)
>
> Thanks a lot for your help,
>
> Jeremy
>

-- 
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/8f0a8220-a05e-d81f-781c-c30c1f4ba0c2%40oneilinteractive.com.


Conversion and import of a pre-existing database

2021-01-07 Thread Jérémy Garniaux

Hi,

I'm working on my first Django project. Already read the tutorial but 
following along it to be sure not to miss anything.


I've been asked to rebuild a pre-existing website. It's basic in 
functionality: various users create complete descriptions of heritage 
items in the admin area, and the public page display the description, 
mostly in text format, sometimes with images too. The final user can 
navigate the items on the public page.


The data model contains many different classes and variables - it's well 
structured and doesn't need to change.


The data is stored into a MS SQL Server database. The new website will 
use PostgreSQL, so I need to convert the MSQSQL database and import it 
into PostgreSQL. I'm aware of inspectdb but I decided to manually write 
models.py from the ground to get acquainted both with the data and with 
django models.


What I'd like to know is:

- Should I work on the conversion and import of the MSSQL database into 
PosgreSQL without thinking about Django at this stage?


- I read that Django will add "_id" at the end of the field names. 
Should I worry about that? Or should I leave in PgSQL the same field 
names there was in MSSQL? How should I name my variables in models.py then?


- Any other advice will be very welcome :)

Thanks a lot for your help,

Jeremy

--
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/15c80b11-d2eb-f933-54cd-4ca066cf6ce3%40mapper.fr.


ValueError: attempted relative import beyond top-level package

2020-10-17 Thread Abdu-H
Hello, i am getting a value error (from ..accounts.models import User. 
ValueError: attempted relative import beyond top-level package) while 
trying to import my custom user model, i have read through some post 
suggesting i create a root folder for my project, I would like to know if 
that wouldn't cause any side effect, as that will change my Django's 
default project structure. 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/7b87808a-fc28-484a-818e-f3496ccd7ab6n%40googlegroups.com.


Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Salima Begum
Thank you for your reply

I did that again I am getting this error
___
TestViews.test_product_detail_authenticated


klass = , args = (), kwargs =
{'pk': 22}, queryset = ]>

def get_object_or_404(klass, *args, **kwargs):
"""
Use get() to return an object, or raise a Http404 exception if the
object
does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more
than
one object is found.
"""
queryset = _get_queryset(klass)
if not hasattr(queryset, 'get'):
klass__name = klass.__name__ if isinstance(klass, type) else
klass.__class__.__name__
raise ValueError(
"First argument to get_object_or_404() must be a Model,
Manager, "
"or QuerySet, not '%s'." % klass__name
)
try:
>   return queryset.get(*args, **kwargs)

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\shortcuts.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

self = ]>, args =
(), kwargs = {'pk': 22}, clone = , limit = 21, num = 0

def get(self, *args, **kwargs):
"""
Perform the query and return a single object matching the given
keyword arguments.
"""
clone = self._chain() if self.query.combinator else
self.filter(*args, **kwargs)
if self.query.can_filter() and not self.query.distinct_fields:
clone = clone.order_by()
limit = None
if not clone.query.select_for_update or
connections[clone.db].features.supports_select_for_update_with_limit:
limit = MAX_GET_RESULTS
clone.query.set_limits(high=limit)
num = len(clone)
if num == 1:
return clone._result_cache[0]
if not num:
>   raise self.model.DoesNotExist(
"%s matching query does not exist." %
self.model._meta.object_name
)
E   pages.models.vk_ls_product_search.DoesNotExist:
vk_ls_product_search matching query does not exist.

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\db\models\query.py:415:
DoesNotExist

During handling of the above exception, another exception occurred:

self = 

def test_product_detail_authenticated(self):
mixer.blend('pages.vk_ls_product_search')
path = reverse('ProductDetails_ls', kwargs={'pk': 22})
request = RequestFactory().get(path)
request.user = mixer.blend(vk_customer)

>   response = onClickSearch.ProductDetails_ls(request, pk=22)

pages\tests\test_views.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _
pages\views.py:2795: in ProductDetails_ls
product_ls = get_object_or_404(vk_ls_product_search, pk=pk)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

klass = , args = (), kwargs =
{'pk': 22}, queryset = ]>

def get_object_or_404(klass, *args, **kwargs):
"""
Use get() to return an object, or raise a Http404 exception if the
object
does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more
than
one object is found.
"""
queryset = _get_queryset(klass)
if not hasattr(queryset, 'get'):
klass__name = klass.__name__ if isinstance(klass, type) else
klass.__class__.__name__
raise ValueError(
"First argument to get_object_or_404() must be a Model,
Manager, "
"or QuerySet, not '%s'." % klass__name
)
try:
return queryset.get(*args, **kwargs)
except queryset.model.DoesNotExist:
>   raise Http404('No %s matches the given query.' %
queryset.model._meta.object_name)
E   django.http.response.Http404: No vk_ls_product_search matches
the given query.

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\shortcuts.py:78:
Http404


Please can you help me to solve this error to

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Shahprogrammer
You have created a class named  onClickSearch  with method  
ProductDetails . So you can't import a method of a class. To use the method 
you need to import class.
So in place of importing  from pages.views import ProductDetails  in 
test_views.py do from pages.views import onClickSearch  & then use it's 
method as onClickSearch. ProductDetails   as per your need in your code 

On Friday, 16 October, 2020 at 3:33:11 pm UTC+5:30 
sali...@rohteksolutions.com wrote:

> Inside pages folder I already have views.py 
>
> Thanks
> ~salima
>
> On Fri, Oct 16, 2020 at 1:28 PM Akinfolarin Stephen <
> akinfolar...@gmail.com> wrote:
>
>> The problem is you are trying to import views from where you have not 
>> created it I guess the page is  a folder then create the views.py inside of 
>> it
>>
>> On Fri, Oct 16, 2020, 08:10 Salima Begum  
>> wrote:
>>
>>> urls.py
>>>
>>>  path('ProductDetails/', views.onClickSearch.ProductDetails, 
>>> name='ProductDetails'),
>>>
>>> views.py
>>>
>>>
>>> class onClickSearch():
>>>
>>> def ProductDetails(request, id):
>>> try:
>>> email = request.session.get('email')
>>> proddtls = vk_master_table.objects.filter(id=id).first()
>>> if proddtls:
>>> banners = Extras().bestDeals_cat(proddtls.category_desc)
>>>
>>> # print(banners.product_name)
>>> except Exception as e:
>>> logging.error(e)
>>> return render(request, "ProductDetails.html", {'error': 
>>> error, 'form': HomeForm(),
>>>'time': 
>>> settings.SESSION_IDLE_TIMEOUT,
>>>'name': 
>>> first_last_initial(email),
>>>'msg_count': 
>>> msg_count_cl(email),
>>>'fullname': 
>>> fullname(email), 'ProductDetails': proddtls,
>>>'signinForm': 
>>> SigninForm(), 'signupForm': CustomerForm()})
>>> return render(request, "ProductDetails.html", {'ProductDetails': 
>>> proddtls, 'fbanners': banners,
>>>'form': 
>>> HomeForm(), 'signinForm': SigninForm(),
>>>'name': 
>>> first_last_initial(email),
>>>'msg_count': 
>>> msg_count_cl(email),
>>>'fullname': 
>>> fullname(email),
>>>'time': 
>>> settings.SESSION_IDLE_TIMEOUT,
>>>'signupForm': 
>>> CustomerForm()})
>>>
>>>
>>>
>>>
>>> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:
>>>
>>>> Can you post your views.py code
>>>>
>>>> On Fri, 16 Oct 2020 at 12:26, Salima Begum  
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>> vikreya
>>>>> mysite
>>>>> .cache
>>>>> .idea
>>>>>.pytest_cache
>>>>> logs
>>>>> media
>>>>> mysite
>>>>> __init__.py
>>>>>manage.py
>>>>>settings.py
>>>>>urls.py
>>>>>wsgi.py
>>>>>  pages
>>>>> .cache
>>>>> migrations
>>>>>     static
>>>>>     templates
>>>>> tests
>>>>>     test_views.py
>>>>>__init__.py 
>>>>> admin.py
>>>>> apps.py
>>>>> cron.py
>>>>> Forms.py
>>>>>functions.py
>>>>>models.py
>>>>>   urls.py

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Salima Begum
Inside pages folder I already have views.py

Thanks
~salima

On Fri, Oct 16, 2020 at 1:28 PM Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> wrote:

> The problem is you are trying to import views from where you have not
> created it I guess the page is  a folder then create the views.py inside of
> it
>
> On Fri, Oct 16, 2020, 08:10 Salima Begum 
> wrote:
>
>> urls.py
>>
>>  path('ProductDetails/', views.onClickSearch.ProductDetails,
>> name='ProductDetails'),
>>
>> views.py
>>
>>
>> class onClickSearch():
>>
>> def ProductDetails(request, id):
>> try:
>> email = request.session.get('email')
>> proddtls = vk_master_table.objects.filter(id=id).first()
>> if proddtls:
>> banners = Extras().bestDeals_cat(proddtls.category_desc)
>>
>> # print(banners.product_name)
>> except Exception as e:
>> logging.error(e)
>> return render(request, "ProductDetails.html", {'error':
>> error, 'form': HomeForm(),
>>'time':
>> settings.SESSION_IDLE_TIMEOUT,
>>'name':
>> first_last_initial(email),
>>'msg_count':
>> msg_count_cl(email),
>>'fullname':
>> fullname(email), 'ProductDetails': proddtls,
>>'signinForm':
>> SigninForm(), 'signupForm': CustomerForm()})
>> return render(request, "ProductDetails.html", {'ProductDetails':
>> proddtls, 'fbanners': banners,
>>'form':
>> HomeForm(), 'signinForm': SigninForm(),
>>'name':
>> first_last_initial(email),
>>'msg_count':
>> msg_count_cl(email),
>>'fullname':
>> fullname(email),
>>'time':
>> settings.SESSION_IDLE_TIMEOUT,
>>'signupForm':
>> CustomerForm()})
>>
>>
>>
>>
>> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah 
>> wrote:
>>
>>> Can you post your views.py code
>>>
>>> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
>>> wrote:
>>>
>>>> Hi all,
>>>> vikreya
>>>> mysite
>>>> .cache
>>>> .idea
>>>>.pytest_cache
>>>> logs
>>>> media
>>>> mysite
>>>> __init__.py
>>>>manage.py
>>>>settings.py
>>>>urls.py
>>>>wsgi.py
>>>>  pages
>>>> .cache
>>>> migrations
>>>> static
>>>> templates
>>>> tests
>>>> test_views.py
>>>>__init__.py
>>>> admin.py
>>>>     apps.py
>>>>     cron.py
>>>> Forms.py
>>>>    functions.py
>>>>models.py
>>>>   urls.py
>>>>   views.py
>>>>
>>>> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
>>>> salim...@rohteksolutions.com> wrote:
>>>>
>>>>> Hi  @Akinfolarin Stephen,
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>>>>> akinfolarinsteph...@gmail.com> wrote:
>>>>>
>>>>>> First I will like you to tell me the folder where test.py is and
>>>>>> views.py
>>>>>>
>>>>>> On Fri, Oct 16, 2020, 06:27 Salima Begum <
>>>>>> salim...@rohteksolutions.com> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I have written test case for views

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Akinfolarin Stephen
The problem is you are trying to import views from where you have not
created it I guess the page is  a folder then create the views.py inside of
it

On Fri, Oct 16, 2020, 08:10 Salima Begum 
wrote:

> urls.py
>
>  path('ProductDetails/', views.onClickSearch.ProductDetails,
> name='ProductDetails'),
>
> views.py
>
>
> class onClickSearch():
>
> def ProductDetails(request, id):
> try:
> email = request.session.get('email')
> proddtls = vk_master_table.objects.filter(id=id).first()
> if proddtls:
> banners = Extras().bestDeals_cat(proddtls.category_desc)
>
> # print(banners.product_name)
> except Exception as e:
> logging.error(e)
> return render(request, "ProductDetails.html", {'error': error,
> 'form': HomeForm(),
>'time':
> settings.SESSION_IDLE_TIMEOUT,
>'name':
> first_last_initial(email),
>'msg_count':
> msg_count_cl(email),
>'fullname':
> fullname(email), 'ProductDetails': proddtls,
>'signinForm':
> SigninForm(), 'signupForm': CustomerForm()})
> return render(request, "ProductDetails.html", {'ProductDetails':
> proddtls, 'fbanners': banners,
>'form': HomeForm(),
> 'signinForm': SigninForm(),
>'name':
> first_last_initial(email),
>'msg_count':
> msg_count_cl(email),
>'fullname':
> fullname(email),
>'time':
> settings.SESSION_IDLE_TIMEOUT,
>'signupForm':
> CustomerForm()})
>
>
>
>
> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:
>
>> Can you post your views.py code
>>
>> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
>> wrote:
>>
>>> Hi all,
>>> vikreya
>>> mysite
>>> .cache
>>> .idea
>>>.pytest_cache
>>> logs
>>> media
>>> mysite
>>> __init__.py
>>>manage.py
>>>settings.py
>>>urls.py
>>>wsgi.py
>>>  pages
>>> .cache
>>> migrations
>>> static
>>> templates
>>> tests
>>> test_views.py
>>>__init__.py
>>> admin.py
>>> apps.py
>>> cron.py
>>> Forms.py
>>>functions.py
>>>models.py
>>>   urls.py
>>>   views.py
>>>
>>> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
>>> salim...@rohteksolutions.com> wrote:
>>>
>>>> Hi  @Akinfolarin Stephen,
>>>>
>>>>
>>>>
>>>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>>>> akinfolarinsteph...@gmail.com> wrote:
>>>>
>>>>> First I will like you to tell me the folder where test.py is and
>>>>> views.py
>>>>>
>>>>> On Fri, Oct 16, 2020, 06:27 Salima Begum 
>>>>> wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I have written test case for views for details page. Here is below
>>>>>> code I have written
>>>>>>
>>>>>> ```
>>>>>> from django.test import RequestFactory
>>>>>> from django.urls import reverse
>>>>>> from django.contrib.auth.models import User
>>>>>> from pages.models import vk_customer
>>>>>> from mixer.backend.django import mixer
>>>>>> import pytest
>>>>>>
>>>>>> from pages.views import ProductDetails
>>>>>>
>>>>>>
>>>>>> @pytest.mark.d

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Salima Begum
urls.py

 path('ProductDetails/', views.onClickSearch.ProductDetails,
name='ProductDetails'),

views.py


class onClickSearch():

def ProductDetails(request, id):
try:
email = request.session.get('email')
proddtls = vk_master_table.objects.filter(id=id).first()
if proddtls:
banners = Extras().bestDeals_cat(proddtls.category_desc)

# print(banners.product_name)
except Exception as e:
logging.error(e)
return render(request, "ProductDetails.html", {'error': error,
'form': HomeForm(),
   'time':
settings.SESSION_IDLE_TIMEOUT,
   'name':
first_last_initial(email),
   'msg_count':
msg_count_cl(email),
   'fullname':
fullname(email), 'ProductDetails': proddtls,
   'signinForm':
SigninForm(), 'signupForm': CustomerForm()})
return render(request, "ProductDetails.html", {'ProductDetails':
proddtls, 'fbanners': banners,
   'form': HomeForm(),
'signinForm': SigninForm(),
   'name':
first_last_initial(email),
   'msg_count':
msg_count_cl(email),
   'fullname':
fullname(email),
   'time':
settings.SESSION_IDLE_TIMEOUT,
   'signupForm':
CustomerForm()})




On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:

> Can you post your views.py code
>
> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
> wrote:
>
>> Hi all,
>> vikreya
>> mysite
>> .cache
>> .idea
>>.pytest_cache
>> logs
>> media
>> mysite
>> __init__.py
>>manage.py
>>settings.py
>>urls.py
>>wsgi.py
>>  pages
>> .cache
>> migrations
>> static
>> templates
>> tests
>> test_views.py
>>__init__.py
>> admin.py
>> apps.py
>> cron.py
>> Forms.py
>>functions.py
>>models.py
>>   urls.py
>>   views.py
>>
>> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
>> salim...@rohteksolutions.com> wrote:
>>
>>> Hi  @Akinfolarin Stephen,
>>>
>>>
>>>
>>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>>> akinfolarinsteph...@gmail.com> wrote:
>>>
>>>> First I will like you to tell me the folder where test.py is and
>>>> views.py
>>>>
>>>> On Fri, Oct 16, 2020, 06:27 Salima Begum 
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I have written test case for views for details page. Here is below
>>>>> code I have written
>>>>>
>>>>> ```
>>>>> from django.test import RequestFactory
>>>>> from django.urls import reverse
>>>>> from django.contrib.auth.models import User
>>>>> from pages.models import vk_customer
>>>>> from mixer.backend.django import mixer
>>>>> import pytest
>>>>>
>>>>> from pages.views import ProductDetails
>>>>>
>>>>>
>>>>> @pytest.mark.django_db
>>>>> class TestViews:
>>>>>
>>>>> def test_product_detail_authenticated(self):
>>>>> mixer.blend('pages.vk_master_table')
>>>>> path = reverse('detail', kwargs={'pk': 1516})
>>>>>     request = RequestFactory().get(path)
>>>>> request.user = mixer.blend(vk_customer)
>>>>>
>>>>> response = ProductDetails(request, pk=1516)
>>>>> print(response)
>>>>> assert response.status_code == 200
>>>>> ```
>>>>> *This the error i am getting.*
>&g

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Shahprogrammer
Can you post your code of views.py

On Friday, 16 October, 2020 at 12:27:19 pm UTC+5:30 
sali...@rohteksolutions.com wrote:

> Hi all,
> vikreya
> mysite
> .cache
> .idea
>.pytest_cache
> logs
> media
> mysite
>
> __init__.py
>manage.py
>settings.py
>urls.py
>wsgi.py
>  pages
> .cache
> migrations
> static
> templates
> tests
> test_views.py
>__init__.py 
> admin.py
> apps.py
> cron.py
> Forms.py
>functions.py
>models.py
>   urls.py
>   views.py
>
> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum  
> wrote:
>
>> Hi  @Akinfolarin Stephen,
>>
>>
>>
>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>> akinfolar...@gmail.com> wrote:
>>
>>> First I will like you to tell me the folder where test.py is and views.py
>>>
>>> On Fri, Oct 16, 2020, 06:27 Salima Begum  
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have written test case for views for details page. Here is below code 
>>>> I have written 
>>>>
>>>> ```
>>>> from django.test import RequestFactory
>>>> from django.urls import reverse
>>>> from django.contrib.auth.models import User
>>>> from pages.models import vk_customer
>>>> from mixer.backend.django import mixer
>>>> import pytest
>>>>
>>>> from pages.views import ProductDetails
>>>>
>>>>
>>>> @pytest.mark.django_db
>>>> class TestViews:
>>>>
>>>> def test_product_detail_authenticated(self):
>>>> mixer.blend('pages.vk_master_table')
>>>> path = reverse('detail', kwargs={'pk': 1516})
>>>> request = RequestFactory().get(path)
>>>> request.user = mixer.blend(vk_customer)
>>>>
>>>> response = ProductDetails(request, pk=1516)
>>>> print(response)
>>>> assert response.status_code == 200
>>>> ```
>>>> *This the error i am getting.*
>>>> ________ ERROR 
>>>> collecting pages/tests/test_views.py 
>>>> 
>>>> ImportError while importing test module 
>>>> 'H:\vikreya\mysite\pages\tests\test_views.py'.
>>>> Hint: make sure your test modules/packages have valid Python names.
>>>> Traceback:
>>>> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
>>>>  
>>>> in import_module
>>>> return _bootstrap._gcd_import(name[level:], package, level)
>>>> pages\tests\test_views.py:8: in 
>>>> from pages.views import ProductDetails
>>>> E   ImportError: cannot import name 'ProductDetails' from 'pages.views' 
>>>> (H:\vikreya\mysite\pages\views.py)
>>>>
>>>> Please help me out to solve this error,
>>>>
>>>> Thank you,
>>>> ~Salima
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to django-users...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%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/6ccb7a89-f757-4522-946e-dcc6ee0321e7n%40googlegroups.com.


Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-16 Thread Dhwanil Shah
Can you post your views.py code

On Fri, 16 Oct 2020 at 12:26, Salima Begum 
wrote:

> Hi all,
> vikreya
> mysite
> .cache
> .idea
>.pytest_cache
> logs
> media
> mysite
> __init__.py
>manage.py
>settings.py
>urls.py
>wsgi.py
>  pages
> .cache
> migrations
> static
> templates
> tests
> test_views.py
>__init__.py
> admin.py
> apps.py
> cron.py
> Forms.py
>functions.py
>models.py
>   urls.py
>   views.py
>
> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
> salim...@rohteksolutions.com> wrote:
>
>> Hi  @Akinfolarin Stephen,
>>
>>
>>
>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>> akinfolarinsteph...@gmail.com> wrote:
>>
>>> First I will like you to tell me the folder where test.py is and views.py
>>>
>>> On Fri, Oct 16, 2020, 06:27 Salima Begum 
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have written test case for views for details page. Here is below code
>>>> I have written
>>>>
>>>> ```
>>>> from django.test import RequestFactory
>>>> from django.urls import reverse
>>>> from django.contrib.auth.models import User
>>>> from pages.models import vk_customer
>>>> from mixer.backend.django import mixer
>>>> import pytest
>>>>
>>>> from pages.views import ProductDetails
>>>>
>>>>
>>>> @pytest.mark.django_db
>>>> class TestViews:
>>>>
>>>> def test_product_detail_authenticated(self):
>>>> mixer.blend('pages.vk_master_table')
>>>> path = reverse('detail', kwargs={'pk': 1516})
>>>> request = RequestFactory().get(path)
>>>> request.user = mixer.blend(vk_customer)
>>>>
>>>> response = ProductDetails(request, pk=1516)
>>>> print(response)
>>>> assert response.status_code == 200
>>>> ```
>>>> *This the error i am getting.*
>>>> ________ ERROR
>>>> collecting pages/tests/test_views.py
>>>> 
>>>> ImportError while importing test module
>>>> 'H:\vikreya\mysite\pages\tests\test_views.py'.
>>>> Hint: make sure your test modules/packages have valid Python names.
>>>> Traceback:
>>>> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
>>>> in import_module
>>>> return _bootstrap._gcd_import(name[level:], package, level)
>>>> pages\tests\test_views.py:8: in 
>>>> from pages.views import ProductDetails
>>>> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
>>>> (H:\vikreya\mysite\pages\views.py)
>>>>
>>>> Please help me out to solve this error,
>>>>
>>>> Thank you,
>>>> ~Salima
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAF

Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Salima Begum
Hi all,
vikreya
mysite
.cache
.idea
   .pytest_cache
logs
media
mysite
__init__.py
   manage.py
   settings.py
   urls.py
   wsgi.py
 pages
.cache
migrations
static
templates
tests
test_views.py
   __init__.py
admin.py
apps.py
cron.py
Forms.py
   functions.py
   models.py
  urls.py
  views.py

On Fri, Oct 16, 2020 at 12:09 PM Salima Begum 
wrote:

> Hi  @Akinfolarin Stephen,
>
>
>
> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
> akinfolarinsteph...@gmail.com> wrote:
>
>> First I will like you to tell me the folder where test.py is and views.py
>>
>> On Fri, Oct 16, 2020, 06:27 Salima Begum 
>> wrote:
>>
>>> Hi all,
>>>
>>> I have written test case for views for details page. Here is below code
>>> I have written
>>>
>>> ```
>>> from django.test import RequestFactory
>>> from django.urls import reverse
>>> from django.contrib.auth.models import User
>>> from pages.models import vk_customer
>>> from mixer.backend.django import mixer
>>> import pytest
>>>
>>> from pages.views import ProductDetails
>>>
>>>
>>> @pytest.mark.django_db
>>> class TestViews:
>>>
>>> def test_product_detail_authenticated(self):
>>> mixer.blend('pages.vk_master_table')
>>> path = reverse('detail', kwargs={'pk': 1516})
>>> request = RequestFactory().get(path)
>>> request.user = mixer.blend(vk_customer)
>>>
>>> response = ProductDetails(request, pk=1516)
>>> print(response)
>>> assert response.status_code == 200
>>> ```
>>> *This the error i am getting.*
>>>  ERROR
>>> collecting pages/tests/test_views.py
>>> 
>>> ImportError while importing test module
>>> 'H:\vikreya\mysite\pages\tests\test_views.py'.
>>> Hint: make sure your test modules/packages have valid Python names.
>>> Traceback:
>>> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
>>> in import_module
>>> return _bootstrap._gcd_import(name[level:], package, level)
>>> pages\tests\test_views.py:8: in 
>>> from pages.views import ProductDetails
>>> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
>>> (H:\vikreya\mysite\pages\views.py)
>>>
>>> Please help me out to solve this error,
>>>
>>> Thank you,
>>> ~Salima
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%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/CAMSz6bm1WKP8qjSzSz5Ouhf%2Bc2K9-pLM4Wc%3DfgSsyUek3KKmqA%40mail.gmail.com.


Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Salima Begum
Hi all,

my project structure
vikreya
mysite
.cache
.idea
.pytest_cache
logs
media
mysute
__init__.py
manage.py
settings.py
urls.py
wsgi.py
pages
.cache
migrations
static
templates
tests
test_views.py
__init__.py
admin.py
apps.py
cron.py
Forms.py
functions.py
models.py
urls.py
views.py

On Fri, Oct 16, 2020 at 12:09 PM Salima Begum 
wrote:

> Hi  @Akinfolarin Stephen,
>
>
>
> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
> akinfolarinsteph...@gmail.com> wrote:
>
>> First I will like you to tell me the folder where test.py is and views.py
>>
>> On Fri, Oct 16, 2020, 06:27 Salima Begum 
>> wrote:
>>
>>> Hi all,
>>>
>>> I have written test case for views for details page. Here is below code
>>> I have written
>>>
>>> ```
>>> from django.test import RequestFactory
>>> from django.urls import reverse
>>> from django.contrib.auth.models import User
>>> from pages.models import vk_customer
>>> from mixer.backend.django import mixer
>>> import pytest
>>>
>>> from pages.views import ProductDetails
>>>
>>>
>>> @pytest.mark.django_db
>>> class TestViews:
>>>
>>> def test_product_detail_authenticated(self):
>>> mixer.blend('pages.vk_master_table')
>>> path = reverse('detail', kwargs={'pk': 1516})
>>> request = RequestFactory().get(path)
>>> request.user = mixer.blend(vk_customer)
>>>
>>> response = ProductDetails(request, pk=1516)
>>> print(response)
>>> assert response.status_code == 200
>>> ```
>>> *This the error i am getting.*
>>>  ERROR
>>> collecting pages/tests/test_views.py
>>> 
>>> ImportError while importing test module
>>> 'H:\vikreya\mysite\pages\tests\test_views.py'.
>>> Hint: make sure your test modules/packages have valid Python names.
>>> Traceback:
>>> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
>>> in import_module
>>> return _bootstrap._gcd_import(name[level:], package, level)
>>> pages\tests\test_views.py:8: in 
>>> from pages.views import ProductDetails
>>> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
>>> (H:\vikreya\mysite\pages\views.py)
>>>
>>> Please help me out to solve this error,
>>>
>>> Thank you,
>>> ~Salima
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%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/CAMSz6b%3DbFwx8O05g0xh6Nj35iVxZu72Us6CT5aTLiTAkeUGB-A%40mail.gmail.com.


Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Salima Begum
Hi  @Akinfolarin Stephen,



On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> wrote:

> First I will like you to tell me the folder where test.py is and views.py
>
> On Fri, Oct 16, 2020, 06:27 Salima Begum 
> wrote:
>
>> Hi all,
>>
>> I have written test case for views for details page. Here is below code I
>> have written
>>
>> ```
>> from django.test import RequestFactory
>> from django.urls import reverse
>> from django.contrib.auth.models import User
>> from pages.models import vk_customer
>> from mixer.backend.django import mixer
>> import pytest
>>
>> from pages.views import ProductDetails
>>
>>
>> @pytest.mark.django_db
>> class TestViews:
>>
>> def test_product_detail_authenticated(self):
>> mixer.blend('pages.vk_master_table')
>> path = reverse('detail', kwargs={'pk': 1516})
>> request = RequestFactory().get(path)
>> request.user = mixer.blend(vk_customer)
>>
>> response = ProductDetails(request, pk=1516)
>> print(response)
>> assert response.status_code == 200
>> ```
>> *This the error i am getting.*
>>  ERROR
>> collecting pages/tests/test_views.py
>> 
>> ImportError while importing test module
>> 'H:\vikreya\mysite\pages\tests\test_views.py'.
>> Hint: make sure your test modules/packages have valid Python names.
>> Traceback:
>> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
>> in import_module
>> return _bootstrap._gcd_import(name[level:], package, level)
>> pages\tests\test_views.py:8: in 
>> from pages.views import ProductDetails
>> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
>> (H:\vikreya\mysite\pages\views.py)
>>
>> Please help me out to solve this error,
>>
>> Thank you,
>> ~Salima
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%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/CAMSz6bkTxp%3DabagmH%2BzwTzhYcusXzubYOLVOkh-6wujxb5L%2B3Q%40mail.gmail.com.


Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Akinfolarin Stephen
First I will like you to tell me the folder where test.py is and views.py

On Fri, Oct 16, 2020, 06:27 Salima Begum 
wrote:

> Hi all,
>
> I have written test case for views for details page. Here is below code I
> have written
>
> ```
> from django.test import RequestFactory
> from django.urls import reverse
> from django.contrib.auth.models import User
> from pages.models import vk_customer
> from mixer.backend.django import mixer
> import pytest
>
> from pages.views import ProductDetails
>
>
> @pytest.mark.django_db
> class TestViews:
>
> def test_product_detail_authenticated(self):
> mixer.blend('pages.vk_master_table')
> path = reverse('detail', kwargs={'pk': 1516})
> request = RequestFactory().get(path)
> request.user = mixer.blend(vk_customer)
>
> response = ProductDetails(request, pk=1516)
> print(response)
> assert response.status_code == 200
> ```
> *This the error i am getting.*
>  ERROR
> collecting pages/tests/test_views.py
> 
> ImportError while importing test module
> 'H:\vikreya\mysite\pages\tests\test_views.py'.
> Hint: make sure your test modules/packages have valid Python names.
> Traceback:
> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
> in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
> pages\tests\test_views.py:8: in 
> from pages.views import ProductDetails
> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
> (H:\vikreya\mysite\pages\views.py)
>
> Please help me out to solve this error,
>
> Thank you,
> ~Salima
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com.


ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Salima Begum
Hi all,

I have written test case for views for details page. Here is below code I
have written

```
from django.test import RequestFactory
from django.urls import reverse
from django.contrib.auth.models import User
from pages.models import vk_customer
from mixer.backend.django import mixer
import pytest

from pages.views import ProductDetails


@pytest.mark.django_db
class TestViews:

def test_product_detail_authenticated(self):
mixer.blend('pages.vk_master_table')
path = reverse('detail', kwargs={'pk': 1516})
request = RequestFactory().get(path)
request.user = mixer.blend(vk_customer)

response = ProductDetails(request, pk=1516)
print(response)
assert response.status_code == 200
```
*This the error i am getting.*
 ERROR
collecting pages/tests/test_views.py

ImportError while importing test module
'H:\vikreya\mysite\pages\tests\test_views.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
in import_module
return _bootstrap._gcd_import(name[level:], package, level)
pages\tests\test_views.py:8: in 
from pages.views import ProductDetails
E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
(H:\vikreya\mysite\pages\views.py)

Please help me out to solve this error,

Thank you,
~Salima

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


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-12 Thread dum dum
Another problem now..

I don't know why,
in local
localhost:8000/sitemap.xml will generate sitemap.xml.

But on heroku,
domain/sitemap.xml will error h13.

Any suggestions?
Thanks.

On Wed, Sep 9, 2020 at 11:31 AM hans alexander  wrote:

> Thanks guys.. Already solved it.
> I guess the main reason of the problem is that I'm using Pycharm Community
> Edition.
> So the alert error not accurate.
>
> Anyway I tried to py manage.py with some alerts, and worked.
> for example:
> [image: image.png]
> I left it like that. And sitemap still works.
>
> But now the new problem is when I submitted my sitemap.xml to google
> search console, I got this error.
> [image: image.png]
> I don't know why.
>
> Even when I access the domain/sitemap.xml, the sitemap is showing.
>
> Any suggestions?
>
> Thanks
>
> On Wed, Sep 9, 2020 at 4:20 AM coolguy 
> wrote:
>
>> I did this long time ago and here is what i did...
>>
>> in settings.py
>> SITE_ID = 1
>> # Application definition
>> INSTALLED_APPS = [
>># ...
>>'django.contrib.sites',
>>'django.contrib.sitemaps',
>> ]
>>
>> run migration i.e.
>> >>> py manage.py migrateOR python manage.py migrate
>> after this step, sites application will be in sync with the database.
>>
>> create a file sitemaps.py in your blog application. Your sitemap.py seems
>> okay to me.
>>
>> update your main project urls.py file
>> 
>> from django.contrib.sitemaps.views import sitemap
>> from blog.sitemaps import BlogPostsSitemap
>>
>> sitemaps = {
>> 'posts' : BlogPostsSitemap,
>> }
>>
>> urlpatterns = [
>>   
>>   path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
>> name='django.contrib.sitemaps.views.sitemap'),
>> ]
>>
>> Now run the development server and open (assuming you are using default
>> configuration) http://127.0.0.1:8000/sitemap
>>
>> lets try...
>>
>> On Tuesday, September 8, 2020 at 2:53:12 PM UTC-4 hanz...@gmail.com
>> wrote:
>>
>>> I followed a tutorial for creating django sitemap, but still got
>>> problems along the way.
>>> I've seen some videos, but didn't work.
>>> Do you have any references for easy way creating django sitemap for blog
>>> posts?
>>> Sure it would help.
>>>
>>> Thanks
>>>
>>>
>>>
>>> On Wed, Sep 9, 2020 at 12:02 AM coolguy  wrote:
>>>
>>>> Not sure why you are importing this into your main project urls.py but
>>>> its very straight forward
>>>>
>>>> from blog.sitemaps import BlogPostsSitemap
>>>>
>>>> question... are you trying to map the application url here? then you
>>>> should use path('/' , Include("blog.urls"))
>>>>
>>>>
>>>>
>>>>
>>>> On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com
>>>> wrote:
>>>>
>>>>> Sorry, point no 1 needs to be revised..
>>>>> 1. In urls.py, I want to import BlogPostsSitemap
>>>>>
>>>>>
>>>>> --
>>>> 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/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%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/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%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/CANV3w%3Dak%2BvTWq0L%2B7jjKrcphEAAQRFX0ESaaO6FBjQR4PA%3Dnyw%40mail.gmail.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread hans alexander
Thanks guys.. Already solved it.
I guess the main reason of the problem is that I'm using Pycharm Community
Edition.
So the alert error not accurate.

Anyway I tried to py manage.py with some alerts, and worked.
for example:
[image: image.png]
I left it like that. And sitemap still works.

But now the new problem is when I submitted my sitemap.xml to google search
console, I got this error.
[image: image.png]
I don't know why.

Even when I access the domain/sitemap.xml, the sitemap is showing.

Any suggestions?

Thanks

On Wed, Sep 9, 2020 at 4:20 AM coolguy 
wrote:

> I did this long time ago and here is what i did...
>
> in settings.py
> SITE_ID = 1
> # Application definition
> INSTALLED_APPS = [
># ...
>'django.contrib.sites',
>'django.contrib.sitemaps',
> ]
>
> run migration i.e.
> >>> py manage.py migrateOR python manage.py migrate
> after this step, sites application will be in sync with the database.
>
> create a file sitemaps.py in your blog application. Your sitemap.py seems
> okay to me.
>
> update your main project urls.py file
> 
> from django.contrib.sitemaps.views import sitemap
> from blog.sitemaps import BlogPostsSitemap
>
> sitemaps = {
> 'posts' : BlogPostsSitemap,
> }
>
> urlpatterns = [
>   
>   path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
> name='django.contrib.sitemaps.views.sitemap'),
> ]
>
> Now run the development server and open (assuming you are using default
> configuration) http://127.0.0.1:8000/sitemap
>
> lets try...
>
> On Tuesday, September 8, 2020 at 2:53:12 PM UTC-4 hanz...@gmail.com wrote:
>
>> I followed a tutorial for creating django sitemap, but still got problems
>> along the way.
>> I've seen some videos, but didn't work.
>> Do you have any references for easy way creating django sitemap for blog
>> posts?
>> Sure it would help.
>>
>> Thanks
>>
>>
>>
>> On Wed, Sep 9, 2020 at 12:02 AM coolguy  wrote:
>>
>>> Not sure why you are importing this into your main project urls.py but
>>> its very straight forward
>>>
>>> from blog.sitemaps import BlogPostsSitemap
>>>
>>> question... are you trying to map the application url here? then you
>>> should use path('/' , Include("blog.urls"))
>>>
>>>
>>>
>>>
>>> On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com
>>> wrote:
>>>
>>>> Sorry, point no 1 needs to be revised..
>>>> 1. In urls.py, I want to import BlogPostsSitemap
>>>>
>>>>
>>>> --
>>> 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/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%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/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%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/CANV3w%3DaDYQ5tGzNsr1r5bqCbcqAe5qEfnX7uBY%2BU2OK-%3DR09iw%40mail.gmail.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread coolguy
I did this long time ago and here is what i did...

in settings.py
SITE_ID = 1
# Application definition
INSTALLED_APPS = [
   # ...
   'django.contrib.sites',
   'django.contrib.sitemaps',
]

run migration i.e. 
>>> py manage.py migrateOR python manage.py migrate
after this step, sites application will be in sync with the database.

create a file sitemaps.py in your blog application. Your sitemap.py seems 
okay to me.

update your main project urls.py file

from django.contrib.sitemaps.views import sitemap
from blog.sitemaps import BlogPostsSitemap

sitemaps = {
'posts' : BlogPostsSitemap,
}

urlpatterns = [
  
  path('sitemap.xml', sitemap, {'sitemaps': sitemaps},  
name='django.contrib.sitemaps.views.sitemap'),
]

Now run the development server and open (assuming you are using default 
configuration) http://127.0.0.1:8000/sitemap

lets try...

On Tuesday, September 8, 2020 at 2:53:12 PM UTC-4 hanz...@gmail.com wrote:

> I followed a tutorial for creating django sitemap, but still got problems 
> along the way. 
> I've seen some videos, but didn't work.  
> Do you have any references for easy way creating django sitemap for blog 
> posts?
> Sure it would help. 
>
> Thanks
>
>
>
> On Wed, Sep 9, 2020 at 12:02 AM coolguy  wrote:
>
>> Not sure why you are importing this into your main project urls.py but 
>> its very straight forward
>>
>> from blog.sitemaps import BlogPostsSitemap
>>
>> question... are you trying to map the application url here? then you 
>> should use path('/' , Include("blog.urls"))
>>
>>
>>
>>
>> On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com 
>> wrote:
>>
>>> Sorry, point no 1 needs to be revised..
>>> 1. In urls.py, I want to import BlogPostsSitemap
>>>
>>>
>>> -- 
>> 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/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%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/030f483b-fb0c-428c-ab8d-8e7d3b82eb40n%40googlegroups.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread hans alexander
I followed a tutorial for creating django sitemap, but still got problems
along the way.
I've seen some videos, but didn't work.
Do you have any references for easy way creating django sitemap for blog
posts?
Sure it would help.

Thanks



On Wed, Sep 9, 2020 at 12:02 AM coolguy 
wrote:

> Not sure why you are importing this into your main project urls.py but its
> very straight forward
>
> from blog.sitemaps import BlogPostsSitemap
>
> question... are you trying to map the application url here? then you
> should use path('/' , Include("blog.urls"))
>
>
>
>
> On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com wrote:
>
>> Sorry, point no 1 needs to be revised..
>> 1. In urls.py, I want to import BlogPostsSitemap
>>
>>
>> --
> 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/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0f74b537-3fa8-4725-8098-b602417ea41bn%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/CANV3w%3DaB3ipwfJuJQC-W3c9qq6AruPqqfqnV7ykJ%2BRjAYq1sLw%40mail.gmail.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread coolguy
Not sure why you are importing this into your main project urls.py but its 
very straight forward

from blog.sitemaps import BlogPostsSitemap

question... are you trying to map the application url here? then you should 
use path('/' , Include("blog.urls"))




On Tuesday, September 8, 2020 at 4:39:05 AM UTC-4 hanz...@gmail.com wrote:

> Sorry, point no 1 needs to be revised..
> 1. In urls.py, I want to import BlogPostsSitemap
>
>
>

-- 
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/0f74b537-3fa8-4725-8098-b602417ea41bn%40googlegroups.com.


Re: I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread hans alexander
Sorry, point no 1 needs to be revised..
1. In urls.py, I want to import BlogPostsSitemap

-- 
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/CANV3w%3Db2gom-wc_jkB_Zdgy_xPUP6CSydRxO5T_0iysfu0otJg%40mail.gmail.com.


I got this error "ValueError: attempted relative import beyond top-level package "

2020-09-08 Thread hans alexander
my structure is like this:

my_project
   blog
  
  sitemaps.py
  
   my_project
  
  urls.py
  

Inside sitemaps.py :

from django.contrib.sitemaps import Sitemap
from .models import *

class BlogPostsSitemap(Sitemap):
changefreq = 'daily'
priority = 0.9
def items(self):
return PostModel.published.all()

def lastmod(self,obj):
return obj.updated


my case:
1. In settings.py I want to import BlogPostsSitemap.
2. I tried like this
[image: image.png]

but then I got an error "ValueError: attempted relative import beyond
top-level package" when I ran the server.

Is anyone here got the solution? Or maybe some references how to
create sitemap on django?

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/CANV3w%3DYhzmvdPakW%2B%2BgwNjG%3DzGiZ61wpmuDPdDOO%2BgxFJnU%3DSQ%40mail.gmail.com.


Re: Import csv file on django view

2020-07-25 Thread Ronaldo Mata
Hi  Naresh Jonnala.

Yes, it's work to detect delimiter on csv file, But still I don't know how
to detect what is the current encoding of csv file 🤔

I need to know how to implement a good uploading csv file  view on 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/CAP%3DoziSPwdGc7UYn_WrJBqLM8sL-BZV5DjtUnu7eumsgcP0jsQ%40mail.gmail.com.


Re: Import csv file on django view

2020-07-25 Thread Naresh Jonnala
gt;>>>>> That’s probably not the proper answer, but that’s the best I can 
>>>>>>>> do. Sorry :-(
>>>>>>>>
>>>>>>>>
>>>>>>>> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata >>>>>>> > wrote:
>>>>>>>>
>>>>>>>> Yes, the problem here is that the files will be loaded by the user, 
>>>>>>>> so I don't know what delimiter I will receive. This is not a base 
>>>>>>>> command 
>>>>>>>> that I am using, it is the logic that I want to incorporate in a view
>>>>>>>>
>>>>>>>> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob (>>>>>>> >) escribió:
>>>>>>>>
>>>>>>>>> Ah, so is the problem that you don’t always know what the 
>>>>>>>>> delimiter is when you read it? If yes, what is the use case for this? 
>>>>>>>>> You 
>>>>>>>>> might not need a universal solution, maybe just put all the info into 
>>>>>>>>> a csv 
>>>>>>>>> yourself, manually.
>>>>>>>>>
>>>>>>>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata >>>>>>>> > wrote:
>>>>>>>>>
>>>>>>>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters 
>>>>>>>>> of the files, sometimes you come separated by "," others by ";" and 
>>>>>>>>> rarely 
>>>>>>>>> by "|" 
>>>>>>>>>
>>>>>>>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob (>>>>>>>> >) escribió:
>>>>>>>>>
>>>>>>>>>> Could you just use the standard python csv module?
>>>>>>>>>>
>>>>>>>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata >>>>>>>>> > wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Liu thank for your answer.
>>>>>>>>>>
>>>>>>>>>> This has been a headache, I am trying to read the file using 
>>>>>>>>>> csv.DictReader initially i had an error trying to get the dict keys 
>>>>>>>>>> when 
>>>>>>>>>> iterating by rows, and i thought it could be encoding (for this 
>>>>>>>>>> reason i 
>>>>>>>>>> wanted to prepare the view to use the correct encoding). for that 
>>>>>>>>>> reason I 
>>>>>>>>>> asked my question.
>>>>>>>>>>
>>>>>>>>>> 1) your first approach doesn't work, if i send utf-8 file, 
>>>>>>>>>> chardet returns ascii as encoding. it seems request.FILES ['file']. 
>>>>>>>>>> read () 
>>>>>>>>>> returns a binary with that encoding.
>>>>>>>>>>
>>>>>>>>>> 2) In the end I realized that the problem was the delimiter of 
>>>>>>>>>> the csv but predicting it is another problem.
>>>>>>>>>>
>>>>>>>>>> Anyway, it was a task that I had to do and that was my 
>>>>>>>>>> limitation. I think there must be a library that does all this, 
>>>>>>>>>> uploading a 
>>>>>>>>>> csv file is common practice in many web apps.
>>>>>>>>>>
>>>>>>>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (<
>>>>>>>>>> firstd...@gmail.com >) escribió:
>>>>>>>>>>
>>>>>>>>>>> Hi. First of all, I think it's impossible to perfectly detect 
>>>>>>>>>>> encoding without further information. See the answer in this SO 
>>>>>>>>>>> post: 
>>>>>>>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>>>>>>>  There 
>>>>>>>>>>> are many packages and tools to help detect encoding format, but 
>>>>>>>

Re: Import csv file on django view

2020-07-24 Thread Liu Zheng
;>>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters
>>>>>>>> of the files, sometimes you come separated by "," others by ";" and 
>>>>>>>> rarely
>>>>>>>> by "|"
>>>>>>>>
>>>>>>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob (<
>>>>>>>> kovy.ja...@gmail.com>) escribió:
>>>>>>>>
>>>>>>>>> Could you just use the standard python csv module?
>>>>>>>>>
>>>>>>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata <
>>>>>>>>> ronaldomat...@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>> Hi Liu thank for your answer.
>>>>>>>>>
>>>>>>>>> This has been a headache, I am trying to read the file using
>>>>>>>>> csv.DictReader initially i had an error trying to get the dict keys 
>>>>>>>>> when
>>>>>>>>> iterating by rows, and i thought it could be encoding (for this 
>>>>>>>>> reason i
>>>>>>>>> wanted to prepare the view to use the correct encoding). for that 
>>>>>>>>> reason I
>>>>>>>>> asked my question.
>>>>>>>>>
>>>>>>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>>>>>>>> returns ascii as encoding. it seems request.FILES ['file']. read () 
>>>>>>>>> returns
>>>>>>>>> a binary with that encoding.
>>>>>>>>>
>>>>>>>>> 2) In the end I realized that the problem was the delimiter of the
>>>>>>>>> csv but predicting it is another problem.
>>>>>>>>>
>>>>>>>>> Anyway, it was a task that I had to do and that was my
>>>>>>>>> limitation. I think there must be a library that does all this, 
>>>>>>>>> uploading a
>>>>>>>>> csv file is common practice in many web apps.
>>>>>>>>>
>>>>>>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (<
>>>>>>>>> firstday2...@gmail.com>) escribió:
>>>>>>>>>
>>>>>>>>>> Hi. First of all, I think it's impossible to perfectly detect
>>>>>>>>>> encoding without further information. See the answer in this SO post:
>>>>>>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>>>>>>  There
>>>>>>>>>> are many packages and tools to help detect encoding format, but keep 
>>>>>>>>>> in
>>>>>>>>>> mind that they are only giving educated guesses. (Most of the time, 
>>>>>>>>>> the
>>>>>>>>>> guess is correct, but do check the dev page to see whether there are 
>>>>>>>>>> known
>>>>>>>>>> issues related to your problem.)
>>>>>>>>>>
>>>>>>>>>> Now let's say you have decided to use chardet. Check its doc page
>>>>>>>>>> for the usage:
>>>>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>>>>>>>>> have more than one solutions. Here are some examples:
>>>>>>>>>>
>>>>>>>>>> 1. If the files uploaded to your server are all expected to be
>>>>>>>>>> small csv files (less than a few MB and not many users do it 
>>>>>>>>>> concurrently),
>>>>>>>>>> you can do the following:
>>>>>>>>>>
>>>>>>>>>> #in the view to handle the uploaded file: (assume file input name
>>>>>>>>>> is just "file")
>>>>>>>>>> file_content = request.FILES['file'].read()
>>>>>>>>>> chardet.detect(file_content)
>>>>

Re: Import csv file on django view

2020-07-24 Thread Ronaldo Mata
aldo Mata 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Liu thank for your answer.
>>>>>>>>
>>>>>>>> This has been a headache, I am trying to read the file using
>>>>>>>> csv.DictReader initially i had an error trying to get the dict keys 
>>>>>>>> when
>>>>>>>> iterating by rows, and i thought it could be encoding (for this reason 
>>>>>>>> i
>>>>>>>> wanted to prepare the view to use the correct encoding). for that 
>>>>>>>> reason I
>>>>>>>> asked my question.
>>>>>>>>
>>>>>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>>>>>>> returns ascii as encoding. it seems request.FILES ['file']. read () 
>>>>>>>> returns
>>>>>>>> a binary with that encoding.
>>>>>>>>
>>>>>>>> 2) In the end I realized that the problem was the delimiter of the
>>>>>>>> csv but predicting it is another problem.
>>>>>>>>
>>>>>>>> Anyway, it was a task that I had to do and that was my
>>>>>>>> limitation. I think there must be a library that does all this, 
>>>>>>>> uploading a
>>>>>>>> csv file is common practice in many web apps.
>>>>>>>>
>>>>>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (<
>>>>>>>> firstday2...@gmail.com>) escribió:
>>>>>>>>
>>>>>>>>> Hi. First of all, I think it's impossible to perfectly detect
>>>>>>>>> encoding without further information. See the answer in this SO post:
>>>>>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>>>>>  There
>>>>>>>>> are many packages and tools to help detect encoding format, but keep 
>>>>>>>>> in
>>>>>>>>> mind that they are only giving educated guesses. (Most of the time, 
>>>>>>>>> the
>>>>>>>>> guess is correct, but do check the dev page to see whether there are 
>>>>>>>>> known
>>>>>>>>> issues related to your problem.)
>>>>>>>>>
>>>>>>>>> Now let's say you have decided to use chardet. Check its doc page
>>>>>>>>> for the usage:
>>>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>>>>>>>> have more than one solutions. Here are some examples:
>>>>>>>>>
>>>>>>>>> 1. If the files uploaded to your server are all expected to be
>>>>>>>>> small csv files (less than a few MB and not many users do it 
>>>>>>>>> concurrently),
>>>>>>>>> you can do the following:
>>>>>>>>>
>>>>>>>>> #in the view to handle the uploaded file: (assume file input name
>>>>>>>>> is just "file")
>>>>>>>>> file_content = request.FILES['file'].read()
>>>>>>>>> chardet.detect(file_content)
>>>>>>>>>
>>>>>>>>> 2. Also, chardet seems to support incremental (line-by-line)
>>>>>>>>> detection
>>>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>>>>>>>
>>>>>>>>> Given this, we can also read from requests.FILES line by line and
>>>>>>>>> pass each line to chardet
>>>>>>>>>
>>>>>>>>> from chardet.universaldetector import UniversalDetector
>>>>>>>>>
>>>>>>>>> #somewhere in a view function
>>>>>>>>> detector = UniversalDetector()
>>>>>>>>> file_handle = request.FILES['file']
>>>>>>>>> for line in file_handle:
>>>>>>>>> detector.feed(line)
>>>>>>>>> if detector.done: break
>>>>>>>>> detector.cl

Re: Import csv file on django view

2020-07-24 Thread Jani Tiainen
gt;>>>>>
>>>>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>>>>>> returns ascii as encoding. it seems request.FILES ['file']. read () 
>>>>>>> returns
>>>>>>> a binary with that encoding.
>>>>>>>
>>>>>>> 2) In the end I realized that the problem was the delimiter of the
>>>>>>> csv but predicting it is another problem.
>>>>>>>
>>>>>>> Anyway, it was a task that I had to do and that was my limitation. I
>>>>>>> think there must be a library that does all this, uploading a csv file 
>>>>>>> is
>>>>>>> common practice in many web apps.
>>>>>>>
>>>>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (<
>>>>>>> firstday2...@gmail.com>) escribió:
>>>>>>>
>>>>>>>> Hi. First of all, I think it's impossible to perfectly detect
>>>>>>>> encoding without further information. See the answer in this SO post:
>>>>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>>>>  There
>>>>>>>> are many packages and tools to help detect encoding format, but keep in
>>>>>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>>>>>> guess is correct, but do check the dev page to see whether there are 
>>>>>>>> known
>>>>>>>> issues related to your problem.)
>>>>>>>>
>>>>>>>> Now let's say you have decided to use chardet. Check its doc page
>>>>>>>> for the usage:
>>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>>>>>>> have more than one solutions. Here are some examples:
>>>>>>>>
>>>>>>>> 1. If the files uploaded to your server are all expected to be
>>>>>>>> small csv files (less than a few MB and not many users do it 
>>>>>>>> concurrently),
>>>>>>>> you can do the following:
>>>>>>>>
>>>>>>>> #in the view to handle the uploaded file: (assume file input name
>>>>>>>> is just "file")
>>>>>>>> file_content = request.FILES['file'].read()
>>>>>>>> chardet.detect(file_content)
>>>>>>>>
>>>>>>>> 2. Also, chardet seems to support incremental (line-by-line)
>>>>>>>> detection
>>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>>>>>>
>>>>>>>> Given this, we can also read from requests.FILES line by line and
>>>>>>>> pass each line to chardet
>>>>>>>>
>>>>>>>> from chardet.universaldetector import UniversalDetector
>>>>>>>>
>>>>>>>> #somewhere in a view function
>>>>>>>> detector = UniversalDetector()
>>>>>>>> file_handle = request.FILES['file']
>>>>>>>> for line in file_handle:
>>>>>>>> detector.feed(line)
>>>>>>>> if detector.done: break
>>>>>>>> detector.close()
>>>>>>>> # result available as a dict at detector.result
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>>>>>>>>>
>>>>>>>>> How to deal with encoding when you try to read a csv file on view.
>>>>>>>>>
>>>>>>>>> I have a view to upload csv file, in this view I read file and
>>>>>>>>> save each row as new record.
>>>>>>>>>
>>>>>>>>> My bug is when I try to upload a csv file with a
>>>>>>>>> differente encoding (not UTF-8)
>>>>>>>>>
>>>>>>>>> how to handle this on django (using request.FILES) I was
>>>>>>>&g

Re: Import csv file on django view

2020-07-24 Thread Ronaldo Mata
all this, uploading a csv file is
>>>>>> common practice in many web apps.
>>>>>>
>>>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng ()
>>>>>> escribió:
>>>>>>
>>>>>>> Hi. First of all, I think it's impossible to perfectly detect
>>>>>>> encoding without further information. See the answer in this SO post:
>>>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>>>  There
>>>>>>> are many packages and tools to help detect encoding format, but keep in
>>>>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>>>>> guess is correct, but do check the dev page to see whether there are 
>>>>>>> known
>>>>>>> issues related to your problem.)
>>>>>>>
>>>>>>> Now let's say you have decided to use chardet. Check its doc page
>>>>>>> for the usage:
>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>>>>>> have more than one solutions. Here are some examples:
>>>>>>>
>>>>>>> 1. If the files uploaded to your server are all expected to be small
>>>>>>> csv files (less than a few MB and not many users do it concurrently), 
>>>>>>> you
>>>>>>> can do the following:
>>>>>>>
>>>>>>> #in the view to handle the uploaded file: (assume file input name is
>>>>>>> just "file")
>>>>>>> file_content = request.FILES['file'].read()
>>>>>>> chardet.detect(file_content)
>>>>>>>
>>>>>>> 2. Also, chardet seems to support incremental (line-by-line)
>>>>>>> detection
>>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>>>>>
>>>>>>> Given this, we can also read from requests.FILES line by line and
>>>>>>> pass each line to chardet
>>>>>>>
>>>>>>> from chardet.universaldetector import UniversalDetector
>>>>>>>
>>>>>>> #somewhere in a view function
>>>>>>> detector = UniversalDetector()
>>>>>>> file_handle = request.FILES['file']
>>>>>>> for line in file_handle:
>>>>>>> detector.feed(line)
>>>>>>> if detector.done: break
>>>>>>> detector.close()
>>>>>>> # result available as a dict at detector.result
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>>>>>>>>
>>>>>>>> How to deal with encoding when you try to read a csv file on view.
>>>>>>>>
>>>>>>>> I have a view to upload csv file, in this view I read file and save
>>>>>>>> each row as new record.
>>>>>>>>
>>>>>>>> My bug is when I try to upload a csv file with a
>>>>>>>> differente encoding (not UTF-8)
>>>>>>>>
>>>>>>>> how to handle this on django (using request.FILES) I was
>>>>>>>> researching and I found chardet but I don't know how to pass it a
>>>>>>>> request.FILES. I need help please.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 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/64307441-0e65-45a2-b917-ece15a4ea729o%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/django-users/64307441-0e65-45a2-b917-ece15a4ea729o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
&

Re: Import csv file on django view

2020-07-22 Thread Liu Zheng
t;  There
>>>>>> are many packages and tools to help detect encoding format, but keep in
>>>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>>>> guess is correct, but do check the dev page to see whether there are 
>>>>>> known
>>>>>> issues related to your problem.)
>>>>>>
>>>>>> Now let's say you have decided to use chardet. Check its doc page for
>>>>>> the usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>>>>> You'll
>>>>>> have more than one solutions. Here are some examples:
>>>>>>
>>>>>> 1. If the files uploaded to your server are all expected to be small
>>>>>> csv files (less than a few MB and not many users do it concurrently), you
>>>>>> can do the following:
>>>>>>
>>>>>> #in the view to handle the uploaded file: (assume file input name is
>>>>>> just "file")
>>>>>> file_content = request.FILES['file'].read()
>>>>>> chardet.detect(file_content)
>>>>>>
>>>>>> 2. Also, chardet seems to support incremental (line-by-line)
>>>>>> detection
>>>>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>>>>
>>>>>> Given this, we can also read from requests.FILES line by line and
>>>>>> pass each line to chardet
>>>>>>
>>>>>> from chardet.universaldetector import UniversalDetector
>>>>>>
>>>>>> #somewhere in a view function
>>>>>> detector = UniversalDetector()
>>>>>> file_handle = request.FILES['file']
>>>>>> for line in file_handle:
>>>>>> detector.feed(line)
>>>>>> if detector.done: break
>>>>>> detector.close()
>>>>>> # result available as a dict at detector.result
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>>>>>>>
>>>>>>> How to deal with encoding when you try to read a csv file on view.
>>>>>>>
>>>>>>> I have a view to upload csv file, in this view I read file and save
>>>>>>> each row as new record.
>>>>>>>
>>>>>>> My bug is when I try to upload a csv file with a differente encoding
>>>>>>> (not UTF-8)
>>>>>>>
>>>>>>> how to handle this on django (using request.FILES) I was researching
>>>>>>> and I found chardet but I don't know how to pass it a request.FILES. I 
>>>>>>> need
>>>>>>> help please.
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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/64307441-0e65-45a2-b917-ece15a4ea729o%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/django-users/64307441-0e65-45a2-b917-ece15a4ea729o%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/CAP%3DoziQuZyb74Wsk%2BnjngUpSccOKCYRM_C%3D7KgGX%2BgV5wRzHwQ%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAP%3DoziQuZyb74Wsk%2BnjngUpSccOKCYRM_C%3D7KgGX%2BgV5wRzHwQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>> --
>>

Re: Import csv file on django view

2020-07-22 Thread Ronaldo Mata
Hi Kovy, this is not solved. Liu Zheng but using
chardet(request.FILES['file'].read()) return encoding "ascii" is not
correct, I've uploaded a file using utf-7 as encoding for example and the
result is wrog. and then I tried
request.FILES['file'].read().decode('ascii') and not work return bad data.
Example for @ string return "+AEA-" string.

El mié., 22 jul. 2020 a las 11:16, Kovy Jacob ()
escribió:

> I’m confused. I don’t know if I can help.
>
> On Jul 22, 2020, at 11:11 AM, Liu Zheng  wrote:
>
> Hi, glad you solved the problem. Yes, both the request.FILES[‘file’] and
> the chardet file handler are binary handlers. Binary handler presents the
> raw data. chardet takes a sequence or raw data and then detect the encoding
> format. With its prediction, if you want to open that puece of data in text
> mode, you can use the .decode() method of bytes object to
> get a python string.
>
> On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob  wrote:
>
>> That’s probably not the proper answer, but that’s the best I can do.
>> Sorry :-(
>>
>>
>> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata 
>> wrote:
>>
>> Yes, the problem here is that the files will be loaded by the user, so I
>> don't know what delimiter I will receive. This is not a base command that I
>> am using, it is the logic that I want to incorporate in a view
>>
>> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ()
>> escribió:
>>
>>> Ah, so is the problem that you don’t always know what the delimiter is
>>> when you read it? If yes, what is the use case for this? You might not need
>>> a universal solution, maybe just put all the info into a csv yourself,
>>> manually.
>>>
>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
>>> wrote:
>>>
>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of
>>> the files, sometimes you come separated by "," others by ";" and rarely by
>>> "|"
>>>
>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ()
>>> escribió:
>>>
>>>> Could you just use the standard python csv module?
>>>>
>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata 
>>>> wrote:
>>>>
>>>> Hi Liu thank for your answer.
>>>>
>>>> This has been a headache, I am trying to read the file using
>>>> csv.DictReader initially i had an error trying to get the dict keys when
>>>> iterating by rows, and i thought it could be encoding (for this reason i
>>>> wanted to prepare the view to use the correct encoding). for that reason I
>>>> asked my question.
>>>>
>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>>> returns ascii as encoding. it seems request.FILES ['file']. read () returns
>>>> a binary with that encoding.
>>>>
>>>> 2) In the end I realized that the problem was the delimiter of the csv
>>>> but predicting it is another problem.
>>>>
>>>> Anyway, it was a task that I had to do and that was my limitation. I
>>>> think there must be a library that does all this, uploading a csv file is
>>>> common practice in many web apps.
>>>>
>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng ()
>>>> escribió:
>>>>
>>>>> Hi. First of all, I think it's impossible to perfectly detect encoding
>>>>> without further information. See the answer in this SO post:
>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>  There
>>>>> are many packages and tools to help detect encoding format, but keep in
>>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>>> guess is correct, but do check the dev page to see whether there are known
>>>>> issues related to your problem.)
>>>>>
>>>>> Now let's say you have decided to use chardet. Check its doc page for
>>>>> the usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>>>> You'll
>>>>> have more than one solutions. Here are some examples:
>>>>>
>>>>> 1. If the files uploaded to your server are all expected to be small
>>>>> csv files (less than a few MB and not many users do it concurrently), you
>>>>> can do the following:
>>>>>
>>>>> #in the view to 

Re: How to trace circular import error Django never solved!! Please sort this out.

2020-07-22 Thread Chaitanya Sai
Thanks for your reply guys. I figured it out. I have typo of serializer
name in serilizers.py which is causing the error.
Damn, I spend 4 hours into this.

On Wed, Jul 22, 2020 at 11:22 AM Liu Zheng  wrote:

> Hi,
>
> Probably not enough to look at urls.py files only. My guess: Do you use
> ‘reverse’ function anywhere in covid app? If so, here’s a circular import:
>
> urls.py imports covid urls -> covid urls import covid views -> one covid
> view uses reverse -> reverse import urls.py of the project (to look up the
> url with the end point name).
>
> A quick fix will be using lazy_reverse instead of reverse.
>
> On Wed, 22 Jul 2020 at 10:22 PM, sandeep kumar 
> wrote:
>
>> I have faced this issue atleast 100 times..:)
>>
>> Her are the steps (sorry, I could not find a better way):
>>
>> 1. comment urls in urls.py (inside individual app)
>> 2. check if you still have issue
>> 2a. if you do not have issue, then you probably have not defined views
>> for some of the urls
>> 2b. if you still see the error, comment 'impot views' statement.
>> 3a. if the issue is gone after commenting 'import views' then check
>> views.py file, it must have some typos (e.g., misalignment, accidental
>> copying of some special character etc.)
>> 3b. if the issue is not gone even after commenting 'import views', let me
>> know. I am not sure I have reached that stage ever..:)
>>
>> Hope this helps.
>>
>> Thanks,
>> Sandeep
>>
>> --
>> *Dr. Sandeep Kumar,*
>> Postdoctoral Researcher,
>> Lunenfeld Tanenbaum Research Institute,
>> Mount Sinai Hospital,
>> 600 University Ave,
>> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
>> Toronto, Ontario
>> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
>> Canada
>> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
>> http://individual.utoronto.ca/sandeepkumar/
>>
>>
>> On Wed, Jul 22, 2020 at 10:12 AM Chaitanya Sai 
>> wrote:
>>
>>> Hello Django users,
>>> Is there not even single person who can solve this issue??
>>>
>>>
>>> On Tue, Jul 21, 2020 at 8:09 PM Sai  wrote:
>>>
>>>> I am working Django rest framework api project, where I had multiple
>>>> apps in the project. I got a circular import error when I am adding the app
>>>> URLs to the main URLs. I Tried everything checked spellings, checked app
>>>> structure but no use. Its been really frustrating with issue..please help
>>>> to solve the problem. The app is working fine when I take off newly added
>>>> line `path("covid/", include("Covid.urls")),`
>>>>
>>>> I am using python3.6, django 3.0.4 and django-rest-framework 3.11.0
>>>>
>>>> Here is project
>>>> **urls.py**
>>>>
>>>>
>>>> from django.contrib import admin
>>>> from django.conf.urls import url
>>>> from django.urls import path, include
>>>> from rest_framework_swagger.views import get_swagger_view
>>>>
>>>> schema_view = get_swagger_view(title='TmmrwInc API Documentation')
>>>>
>>>> urlpatterns = [
>>>> path('admin/', admin.site.urls),
>>>> # path('', include('django.contrib.auth.urls')),
>>>> # path('rest_auth/', include('rest_auth.urls')),
>>>> path('api/password_reset/',
>>>> include('django_rest_passwordreset.urls',
>>>> namespace='password_reset')),
>>>> # url(r'^invitations/', include('invitations.urls',
>>>> namespace='invitations')),
>>>> path('', include('rest_invitations.urls')),
>>>> path("", include("UserAuth.urls")),
>>>> path("doctors/", include("Administration.urls")),
>>>> path("appointments/", include("Appointments.urls")),
>>>> path("messaging/", include("messaging.urls")),
>>>> path("meet/", include("meet.urls")),
>>>> path("api_documentation/", schema_view),
>>>>

Re: How to trace circular import error Django never solved!! Please sort this out.

2020-07-22 Thread Liu Zheng
Hi,

Probably not enough to look at urls.py files only. My guess: Do you use
‘reverse’ function anywhere in covid app? If so, here’s a circular import:

urls.py imports covid urls -> covid urls import covid views -> one covid
view uses reverse -> reverse import urls.py of the project (to look up the
url with the end point name).

A quick fix will be using lazy_reverse instead of reverse.

On Wed, 22 Jul 2020 at 10:22 PM, sandeep kumar 
wrote:

> I have faced this issue atleast 100 times..:)
>
> Her are the steps (sorry, I could not find a better way):
>
> 1. comment urls in urls.py (inside individual app)
> 2. check if you still have issue
> 2a. if you do not have issue, then you probably have not defined views for
> some of the urls
> 2b. if you still see the error, comment 'impot views' statement.
> 3a. if the issue is gone after commenting 'import views' then check
> views.py file, it must have some typos (e.g., misalignment, accidental
> copying of some special character etc.)
> 3b. if the issue is not gone even after commenting 'import views', let me
> know. I am not sure I have reached that stage ever..:)
>
> Hope this helps.
>
> Thanks,
> Sandeep
>
> --
> *Dr. Sandeep Kumar,*
> Postdoctoral Researcher,
> Lunenfeld Tanenbaum Research Institute,
> Mount Sinai Hospital,
> 600 University Ave,
> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
> Toronto, Ontario
> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
> Canada
> <https://www.google.com/maps/search/600+University+Ave,+Toronto,+Ontario+Canada?entry=gmail&source=g>
> http://individual.utoronto.ca/sandeepkumar/
>
>
> On Wed, Jul 22, 2020 at 10:12 AM Chaitanya Sai 
> wrote:
>
>> Hello Django users,
>> Is there not even single person who can solve this issue??
>>
>>
>> On Tue, Jul 21, 2020 at 8:09 PM Sai  wrote:
>>
>>> I am working Django rest framework api project, where I had multiple
>>> apps in the project. I got a circular import error when I am adding the app
>>> URLs to the main URLs. I Tried everything checked spellings, checked app
>>> structure but no use. Its been really frustrating with issue..please help
>>> to solve the problem. The app is working fine when I take off newly added
>>> line `path("covid/", include("Covid.urls")),`
>>>
>>> I am using python3.6, django 3.0.4 and django-rest-framework 3.11.0
>>>
>>> Here is project
>>> **urls.py**
>>>
>>>
>>> from django.contrib import admin
>>> from django.conf.urls import url
>>> from django.urls import path, include
>>> from rest_framework_swagger.views import get_swagger_view
>>>
>>> schema_view = get_swagger_view(title='TmmrwInc API Documentation')
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> # path('', include('django.contrib.auth.urls')),
>>> # path('rest_auth/', include('rest_auth.urls')),
>>> path('api/password_reset/',
>>> include('django_rest_passwordreset.urls',
>>> namespace='password_reset')),
>>> # url(r'^invitations/', include('invitations.urls',
>>> namespace='invitations')),
>>> path('', include('rest_invitations.urls')),
>>> path("", include("UserAuth.urls")),
>>> path("doctors/", include("Administration.urls")),
>>> path("appointments/", include("Appointments.urls")),
>>> path("messaging/", include("messaging.urls")),
>>> path("meet/", include("meet.urls")),
>>> path("api_documentation/", schema_view),
>>> path("covid/", include("Covid.urls")),
>>> ]
>>>
>>> This is app **urls.py** file
>>>
>>> from django.urls import path
>>> from . import views
>>>
>>> app_name = 'Covid'
>>>
>>> urlpatterns = [
>>> path('event/', views.EventBookingView.as_view()),
>>> ]
>>>
>>> **settings.py** installed apps
>>>
>>> ALLOWED_HOSTS = ['*']
>>>
>>>
>>> # 

Re: Import csv file on django view

2020-07-22 Thread Liu Zheng
What i meant was that you can only feed binary data or binary handlers to
chardet. You can decode the binary data according to the detection results
afterward.

On Wed, 22 Jul 2020 at 11:11 PM, Liu Zheng  wrote:

> Hi, glad you solved the problem. Yes, both the request.FILES[‘file’] and
> the chardet file handler are binary handlers. Binary handler presents the
> raw data. chardet takes a sequence or raw data and then detect the encoding
> format. With its prediction, if you want to open that puece of data in text
> mode, you can use the .decode() method of bytes object to
> get a python string.
>
> On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob  wrote:
>
>> That’s probably not the proper answer, but that’s the best I can do.
>> Sorry :-(
>>
>>
>> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata 
>> wrote:
>>
>> Yes, the problem here is that the files will be loaded by the user, so I
>> don't know what delimiter I will receive. This is not a base command that I
>> am using, it is the logic that I want to incorporate in a view
>>
>> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ()
>> escribió:
>>
>>> Ah, so is the problem that you don’t always know what the delimiter is
>>> when you read it? If yes, what is the use case for this? You might not need
>>> a universal solution, maybe just put all the info into a csv yourself,
>>> manually.
>>>
>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
>>> wrote:
>>>
>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of
>>> the files, sometimes you come separated by "," others by ";" and rarely by
>>> "|"
>>>
>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ()
>>> escribió:
>>>
>>>> Could you just use the standard python csv module?
>>>>
>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata 
>>>> wrote:
>>>>
>>>> Hi Liu thank for your answer.
>>>>
>>>> This has been a headache, I am trying to read the file using
>>>> csv.DictReader initially i had an error trying to get the dict keys when
>>>> iterating by rows, and i thought it could be encoding (for this reason i
>>>> wanted to prepare the view to use the correct encoding). for that reason I
>>>> asked my question.
>>>>
>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>>> returns ascii as encoding. it seems request.FILES ['file']. read () returns
>>>> a binary with that encoding.
>>>>
>>>> 2) In the end I realized that the problem was the delimiter of the csv
>>>> but predicting it is another problem.
>>>>
>>>> Anyway, it was a task that I had to do and that was my limitation. I
>>>> think there must be a library that does all this, uploading a csv file is
>>>> common practice in many web apps.
>>>>
>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng ()
>>>> escribió:
>>>>
>>>>> Hi. First of all, I think it's impossible to perfectly detect encoding
>>>>> without further information. See the answer in this SO post:
>>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>>  There
>>>>> are many packages and tools to help detect encoding format, but keep in
>>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>>> guess is correct, but do check the dev page to see whether there are known
>>>>> issues related to your problem.)
>>>>>
>>>>> Now let's say you have decided to use chardet. Check its doc page for
>>>>> the usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>>>> You'll
>>>>> have more than one solutions. Here are some examples:
>>>>>
>>>>> 1. If the files uploaded to your server are all expected to be small
>>>>> csv files (less than a few MB and not many users do it concurrently), you
>>>>> can do the following:
>>>>>
>>>>> #in the view to handle the uploaded file: (assume file input name is
>>>>> just "file")
>>>>> file_content = request.FILES['file'].read()
>>>>> chardet.detect(file_content)
>>>>>
>>>>> 2. Also, chardet seems to support incremental (line-by-line) detection
>>>>> https://ch

Re: Import csv file on django view

2020-07-22 Thread Liu Zheng
Hi, glad you solved the problem. Yes, both the request.FILES[‘file’] and
the chardet file handler are binary handlers. Binary handler presents the
raw data. chardet takes a sequence or raw data and then detect the encoding
format. With its prediction, if you want to open that puece of data in text
mode, you can use the .decode() method of bytes object to
get a python string.

On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob  wrote:

> That’s probably not the proper answer, but that’s the best I can do. Sorry
> :-(
>
>
> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata 
> wrote:
>
> Yes, the problem here is that the files will be loaded by the user, so I
> don't know what delimiter I will receive. This is not a base command that I
> am using, it is the logic that I want to incorporate in a view
>
> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ()
> escribió:
>
>> Ah, so is the problem that you don’t always know what the delimiter is
>> when you read it? If yes, what is the use case for this? You might not need
>> a universal solution, maybe just put all the info into a csv yourself,
>> manually.
>>
>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
>> wrote:
>>
>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the
>> files, sometimes you come separated by "," others by ";" and rarely by "|"
>>
>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ()
>> escribió:
>>
>>> Could you just use the standard python csv module?
>>>
>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata 
>>> wrote:
>>>
>>> Hi Liu thank for your answer.
>>>
>>> This has been a headache, I am trying to read the file using
>>> csv.DictReader initially i had an error trying to get the dict keys when
>>> iterating by rows, and i thought it could be encoding (for this reason i
>>> wanted to prepare the view to use the correct encoding). for that reason I
>>> asked my question.
>>>
>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>> returns ascii as encoding. it seems request.FILES ['file']. read () returns
>>> a binary with that encoding.
>>>
>>> 2) In the end I realized that the problem was the delimiter of the csv
>>> but predicting it is another problem.
>>>
>>> Anyway, it was a task that I had to do and that was my limitation. I
>>> think there must be a library that does all this, uploading a csv file is
>>> common practice in many web apps.
>>>
>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng ()
>>> escribió:
>>>
>>>> Hi. First of all, I think it's impossible to perfectly detect encoding
>>>> without further information. See the answer in this SO post:
>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>  There
>>>> are many packages and tools to help detect encoding format, but keep in
>>>> mind that they are only giving educated guesses. (Most of the time, the
>>>> guess is correct, but do check the dev page to see whether there are known
>>>> issues related to your problem.)
>>>>
>>>> Now let's say you have decided to use chardet. Check its doc page for
>>>> the usage: https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>>> have more than one solutions. Here are some examples:
>>>>
>>>> 1. If the files uploaded to your server are all expected to be small
>>>> csv files (less than a few MB and not many users do it concurrently), you
>>>> can do the following:
>>>>
>>>> #in the view to handle the uploaded file: (assume file input name is
>>>> just "file")
>>>> file_content = request.FILES['file'].read()
>>>> chardet.detect(file_content)
>>>>
>>>> 2. Also, chardet seems to support incremental (line-by-line) detection
>>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>>
>>>> Given this, we can also read from requests.FILES line by line and pass
>>>> each line to chardet
>>>>
>>>> from chardet.universaldetector import UniversalDetector
>>>>
>>>> #somewhere in a view function
>>>> detector = UniversalDetector()
>>>> file_handle = request.FILES['file']
>>>> for line in file_handle:
>>>> detector.feed(line)
>>>> if detector

Re: Import csv file on django view

2020-07-22 Thread Kovy Jacob
I’m confused. I don’t know if I can help.

> On Jul 22, 2020, at 11:11 AM, Liu Zheng  wrote:
> 
> Hi, glad you solved the problem. Yes, both the request.FILES[‘file’] and the 
> chardet file handler are binary handlers. Binary handler presents the raw 
> data. chardet takes a sequence or raw data and then detect the encoding 
> format. With its prediction, if you want to open that puece of data in text 
> mode, you can use the .decode() method of bytes object to 
> get a python string.
> 
> On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob  <mailto:kovy.ja...@gmail.com>> wrote:
> That’s probably not the proper answer, but that’s the best I can do. Sorry :-(
> 
> 
>> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata > <mailto:ronaldomat...@gmail.com>> wrote:
>> 
>> Yes, the problem here is that the files will be loaded by the user, so I 
>> don't know what delimiter I will receive. This is not a base command that I 
>> am using, it is the logic that I want to incorporate in a view
>> 
>> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob (> <mailto:kovy.ja...@gmail.com>>) escribió:
>> Ah, so is the problem that you don’t always know what the delimiter is when 
>> you read it? If yes, what is the use case for this? You might not need a 
>> universal solution, maybe just put all the info into a csv yourself, 
>> manually.
>> 
>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata >> <mailto:ronaldomat...@gmail.com>> wrote:
>>> 
>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the 
>>> files, sometimes you come separated by "," others by ";" and rarely by "|" 
>>> 
>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob (>> <mailto:kovy.ja...@gmail.com>>) escribió:
>>> Could you just use the standard python csv module?
>>> 
>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata >>> <mailto:ronaldomat...@gmail.com>> wrote:
>>>> 
>>>> Hi Liu thank for your answer.
>>>> 
>>>> This has been a headache, I am trying to read the file using 
>>>> csv.DictReader initially i had an error trying to get the dict keys when 
>>>> iterating by rows, and i thought it could be encoding (for this reason i 
>>>> wanted to prepare the view to use the correct encoding). for that reason I 
>>>> asked my question.
>>>> 
>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet returns 
>>>> ascii as encoding. it seems request.FILES ['file']. read () returns a 
>>>> binary with that encoding.
>>>> 
>>>> 2) In the end I realized that the problem was the delimiter of the csv but 
>>>> predicting it is another problem.
>>>> 
>>>> Anyway, it was a task that I had to do and that was my limitation. I think 
>>>> there must be a library that does all this, uploading a csv file is common 
>>>> practice in many web apps.
>>>> 
>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (>>> <mailto:firstday2...@gmail.com>>) escribió:
>>>> Hi. First of all, I think it's impossible to perfectly detect encoding 
>>>> without further information. See the answer in this SO post: 
>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>  
>>>> <https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text>
>>>>  There are many packages and tools to help detect encoding format, but 
>>>> keep in mind that they are only giving educated guesses. (Most of the 
>>>> time, the guess is correct, but do check the dev page to see whether there 
>>>> are known issues related to your problem.)
>>>> 
>>>> Now let's say you have decided to use chardet. Check its doc page for the 
>>>> usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>>> <https://chardet.readthedocs.io/en/latest/usage.html#usage> You'll have 
>>>> more than one solutions. Here are some examples:
>>>> 
>>>> 1. If the files uploaded to your server are all expected to be small csv 
>>>> files (less than a few MB and not many users do it concurrently), you can 
>>>> do the following:
>>>> 
>>>> #in the view to handle the uploaded file: (assume file input name is just 
>>>> "file")
>>>> file_content = request.FILES['file'].read()
>>>

Re: Import csv file on django view

2020-07-22 Thread Kovy Jacob
Cool! I’m so happy I was able to help you!! Good luck!

> On Jul 22, 2020, at 11:11 AM, Liu Zheng  wrote:
> 
> Hi, glad you solved the problem. Yes, both the request.FILES[‘file’] and the 
> chardet file handler are binary handlers. Binary handler presents the raw 
> data. chardet takes a sequence or raw data and then detect the encoding 
> format. With its prediction, if you want to open that puece of data in text 
> mode, you can use the .decode() method of bytes object to 
> get a python string.
> 
> On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob  <mailto:kovy.ja...@gmail.com>> wrote:
> That’s probably not the proper answer, but that’s the best I can do. Sorry :-(
> 
> 
>> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata > <mailto:ronaldomat...@gmail.com>> wrote:
>> 
>> Yes, the problem here is that the files will be loaded by the user, so I 
>> don't know what delimiter I will receive. This is not a base command that I 
>> am using, it is the logic that I want to incorporate in a view
>> 
>> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob (> <mailto:kovy.ja...@gmail.com>>) escribió:
>> Ah, so is the problem that you don’t always know what the delimiter is when 
>> you read it? If yes, what is the use case for this? You might not need a 
>> universal solution, maybe just put all the info into a csv yourself, 
>> manually.
>> 
>>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata >> <mailto:ronaldomat...@gmail.com>> wrote:
>>> 
>>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the 
>>> files, sometimes you come separated by "," others by ";" and rarely by "|" 
>>> 
>>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob (>> <mailto:kovy.ja...@gmail.com>>) escribió:
>>> Could you just use the standard python csv module?
>>> 
>>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata >>> <mailto:ronaldomat...@gmail.com>> wrote:
>>>> 
>>>> Hi Liu thank for your answer.
>>>> 
>>>> This has been a headache, I am trying to read the file using 
>>>> csv.DictReader initially i had an error trying to get the dict keys when 
>>>> iterating by rows, and i thought it could be encoding (for this reason i 
>>>> wanted to prepare the view to use the correct encoding). for that reason I 
>>>> asked my question.
>>>> 
>>>> 1) your first approach doesn't work, if i send utf-8 file, chardet returns 
>>>> ascii as encoding. it seems request.FILES ['file']. read () returns a 
>>>> binary with that encoding.
>>>> 
>>>> 2) In the end I realized that the problem was the delimiter of the csv but 
>>>> predicting it is another problem.
>>>> 
>>>> Anyway, it was a task that I had to do and that was my limitation. I think 
>>>> there must be a library that does all this, uploading a csv file is common 
>>>> practice in many web apps.
>>>> 
>>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (>>> <mailto:firstday2...@gmail.com>>) escribió:
>>>> Hi. First of all, I think it's impossible to perfectly detect encoding 
>>>> without further information. See the answer in this SO post: 
>>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>>  
>>>> <https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text>
>>>>  There are many packages and tools to help detect encoding format, but 
>>>> keep in mind that they are only giving educated guesses. (Most of the 
>>>> time, the guess is correct, but do check the dev page to see whether there 
>>>> are known issues related to your problem.)
>>>> 
>>>> Now let's say you have decided to use chardet. Check its doc page for the 
>>>> usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>>> <https://chardet.readthedocs.io/en/latest/usage.html#usage> You'll have 
>>>> more than one solutions. Here are some examples:
>>>> 
>>>> 1. If the files uploaded to your server are all expected to be small csv 
>>>> files (less than a few MB and not many users do it concurrently), you can 
>>>> do the following:
>>>> 
>>>> #in the view to handle the uploaded file: (assume file input name is just 
>>>> "file")
>>>> file_content = request.FILES['file'].r

Re: Import csv file on django view

2020-07-22 Thread Kovy Jacob
That’s probably not the proper answer, but that’s the best I can do. Sorry :-(

> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata  wrote:
> 
> Yes, the problem here is that the files will be loaded by the user, so I 
> don't know what delimiter I will receive. This is not a base command that I 
> am using, it is the logic that I want to incorporate in a view
> 
> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ( <mailto:kovy.ja...@gmail.com>>) escribió:
> Ah, so is the problem that you don’t always know what the delimiter is when 
> you read it? If yes, what is the use case for this? You might not need a 
> universal solution, maybe just put all the info into a csv yourself, manually.
> 
>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata > <mailto:ronaldomat...@gmail.com>> wrote:
>> 
>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the 
>> files, sometimes you come separated by "," others by ";" and rarely by "|" 
>> 
>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob (> <mailto:kovy.ja...@gmail.com>>) escribió:
>> Could you just use the standard python csv module?
>> 
>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata >> <mailto:ronaldomat...@gmail.com>> wrote:
>>> 
>>> Hi Liu thank for your answer.
>>> 
>>> This has been a headache, I am trying to read the file using csv.DictReader 
>>> initially i had an error trying to get the dict keys when iterating by 
>>> rows, and i thought it could be encoding (for this reason i wanted to 
>>> prepare the view to use the correct encoding). for that reason I asked my 
>>> question.
>>> 
>>> 1) your first approach doesn't work, if i send utf-8 file, chardet returns 
>>> ascii as encoding. it seems request.FILES ['file']. read () returns a 
>>> binary with that encoding.
>>> 
>>> 2) In the end I realized that the problem was the delimiter of the csv but 
>>> predicting it is another problem.
>>> 
>>> Anyway, it was a task that I had to do and that was my limitation. I think 
>>> there must be a library that does all this, uploading a csv file is common 
>>> practice in many web apps.
>>> 
>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (>> <mailto:firstday2...@gmail.com>>) escribió:
>>> Hi. First of all, I think it's impossible to perfectly detect encoding 
>>> without further information. See the answer in this SO post: 
>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>  
>>> <https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text>
>>>  There are many packages and tools to help detect encoding format, but keep 
>>> in mind that they are only giving educated guesses. (Most of the time, the 
>>> guess is correct, but do check the dev page to see whether there are known 
>>> issues related to your problem.)
>>> 
>>> Now let's say you have decided to use chardet. Check its doc page for the 
>>> usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>>> <https://chardet.readthedocs.io/en/latest/usage.html#usage> You'll have 
>>> more than one solutions. Here are some examples:
>>> 
>>> 1. If the files uploaded to your server are all expected to be small csv 
>>> files (less than a few MB and not many users do it concurrently), you can 
>>> do the following:
>>> 
>>> #in the view to handle the uploaded file: (assume file input name is just 
>>> "file")
>>> file_content = request.FILES['file'].read()
>>> chardet.detect(file_content)
>>> 
>>> 2. Also, chardet seems to support incremental (line-by-line) detection 
>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>  
>>> <https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally>
>>> 
>>> Given this, we can also read from requests.FILES line by line and pass each 
>>> line to chardet
>>> 
>>> from chardet.universaldetector import UniversalDetector
>>> 
>>> #somewhere in a view function
>>> detector = UniversalDetector()
>>> file_handle = request.FILES['file']
>>> for line in file_handle:
>>> detector.feed(line)
>>> if detector.done: break
>>> detector.close()
>>> # result available as a dict at detector.result
>>> 

Re: Import csv file on django view

2020-07-22 Thread Kovy Jacob
Maybe first use the standard file.open to save the file to a variable, search 
that variable for the different delimiters using standard string manipulation 
vichulu, and then open it using the corresponding delimiter.

> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata  wrote:
> 
> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the 
> files, sometimes you come separated by "," others by ";" and rarely by "|" 
> 
> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ( <mailto:kovy.ja...@gmail.com>>) escribió:
> Could you just use the standard python csv module?
> 
>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata > <mailto:ronaldomat...@gmail.com>> wrote:
>> 
>> Hi Liu thank for your answer.
>> 
>> This has been a headache, I am trying to read the file using csv.DictReader 
>> initially i had an error trying to get the dict keys when iterating by rows, 
>> and i thought it could be encoding (for this reason i wanted to prepare the 
>> view to use the correct encoding). for that reason I asked my question.
>> 
>> 1) your first approach doesn't work, if i send utf-8 file, chardet returns 
>> ascii as encoding. it seems request.FILES ['file']. read () returns a binary 
>> with that encoding.
>> 
>> 2) In the end I realized that the problem was the delimiter of the csv but 
>> predicting it is another problem.
>> 
>> Anyway, it was a task that I had to do and that was my limitation. I think 
>> there must be a library that does all this, uploading a csv file is common 
>> practice in many web apps.
>> 
>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (> <mailto:firstday2...@gmail.com>>) escribió:
>> Hi. First of all, I think it's impossible to perfectly detect encoding 
>> without further information. See the answer in this SO post: 
>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>  
>> <https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text>
>>  There are many packages and tools to help detect encoding format, but keep 
>> in mind that they are only giving educated guesses. (Most of the time, the 
>> guess is correct, but do check the dev page to see whether there are known 
>> issues related to your problem.)
>> 
>> Now let's say you have decided to use chardet. Check its doc page for the 
>> usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>> <https://chardet.readthedocs.io/en/latest/usage.html#usage> You'll have more 
>> than one solutions. Here are some examples:
>> 
>> 1. If the files uploaded to your server are all expected to be small csv 
>> files (less than a few MB and not many users do it concurrently), you can do 
>> the following:
>> 
>> #in the view to handle the uploaded file: (assume file input name is just 
>> "file")
>> file_content = request.FILES['file'].read()
>> chardet.detect(file_content)
>> 
>> 2. Also, chardet seems to support incremental (line-by-line) detection 
>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>  
>> <https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally>
>> 
>> Given this, we can also read from requests.FILES line by line and pass each 
>> line to chardet
>> 
>> from chardet.universaldetector import UniversalDetector
>> 
>> #somewhere in a view function
>> detector = UniversalDetector()
>> file_handle = request.FILES['file']
>> for line in file_handle:
>> detector.feed(line)
>> if detector.done: break
>> detector.close()
>> # result available as a dict at detector.result
>> 
>> 
>> 
>> 
>> 
>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>> How to deal with encoding when you try to read a csv file on view.
>> 
>> I have a view to upload csv file, in this view I read file and save each row 
>> as new record.
>> 
>> My bug is when I try to upload a csv file with a differente encoding (not 
>> UTF-8)
>> 
>> how to handle this on django (using request.FILES) I was researching and I 
>> found chardet but I don't know how to pass it a request.FILES. I need help 
>> please.
>> 
>> -- 
>> 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

Re: Import csv file on django view

2020-07-22 Thread Ronaldo Mata
Yes, the problem here is that the files will be loaded by the user, so I
don't know what delimiter I will receive. This is not a base command that I
am using, it is the logic that I want to incorporate in a view

El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ()
escribió:

> Ah, so is the problem that you don’t always know what the delimiter is
> when you read it? If yes, what is the use case for this? You might not need
> a universal solution, maybe just put all the info into a csv yourself,
> manually.
>
> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
> wrote:
>
> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the
> files, sometimes you come separated by "," others by ";" and rarely by "|"
>
> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ()
> escribió:
>
>> Could you just use the standard python csv module?
>>
>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata 
>> wrote:
>>
>> Hi Liu thank for your answer.
>>
>> This has been a headache, I am trying to read the file using
>> csv.DictReader initially i had an error trying to get the dict keys when
>> iterating by rows, and i thought it could be encoding (for this reason i
>> wanted to prepare the view to use the correct encoding). for that reason I
>> asked my question.
>>
>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>> returns ascii as encoding. it seems request.FILES ['file']. read () returns
>> a binary with that encoding.
>>
>> 2) In the end I realized that the problem was the delimiter of the csv
>> but predicting it is another problem.
>>
>> Anyway, it was a task that I had to do and that was my limitation. I
>> think there must be a library that does all this, uploading a csv file is
>> common practice in many web apps.
>>
>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng ()
>> escribió:
>>
>>> Hi. First of all, I think it's impossible to perfectly detect encoding
>>> without further information. See the answer in this SO post:
>>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>>  There
>>> are many packages and tools to help detect encoding format, but keep in
>>> mind that they are only giving educated guesses. (Most of the time, the
>>> guess is correct, but do check the dev page to see whether there are known
>>> issues related to your problem.)
>>>
>>> Now let's say you have decided to use chardet. Check its doc page for
>>> the usage: https://chardet.readthedocs.io/en/latest/usage.html#usage You'll
>>> have more than one solutions. Here are some examples:
>>>
>>> 1. If the files uploaded to your server are all expected to be small csv
>>> files (less than a few MB and not many users do it concurrently), you can
>>> do the following:
>>>
>>> #in the view to handle the uploaded file: (assume file input name is
>>> just "file")
>>> file_content = request.FILES['file'].read()
>>> chardet.detect(file_content)
>>>
>>> 2. Also, chardet seems to support incremental (line-by-line) detection
>>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>>
>>> Given this, we can also read from requests.FILES line by line and pass
>>> each line to chardet
>>>
>>> from chardet.universaldetector import UniversalDetector
>>>
>>> #somewhere in a view function
>>> detector = UniversalDetector()
>>> file_handle = request.FILES['file']
>>> for line in file_handle:
>>> detector.feed(line)
>>> if detector.done: break
>>> detector.close()
>>> # result available as a dict at detector.result
>>>
>>>
>>>
>>>
>>>
>>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>>>>
>>>> How to deal with encoding when you try to read a csv file on view.
>>>>
>>>> I have a view to upload csv file, in this view I read file and save
>>>> each row as new record.
>>>>
>>>> My bug is when I try to upload a csv file with a differente encoding
>>>> (not UTF-8)
>>>>
>>>> how to handle this on django (using request.FILES) I was researching
>>>> and I found chardet but I don't know how to pass it a request.FILES. I need
>>>> help please.
>>>>
>>>
>>> --
>>> You receiv

Re: Import csv file on django view

2020-07-22 Thread Kovy Jacob
Ah, so is the problem that you don’t always know what the delimiter is when you 
read it? If yes, what is the use case for this? You might not need a universal 
solution, maybe just put all the info into a csv yourself, manually.

> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata  wrote:
> 
> Hi Kovy, I'm using csv module, but I need to handle the delimiters of the 
> files, sometimes you come separated by "," others by ";" and rarely by "|" 
> 
> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ( <mailto:kovy.ja...@gmail.com>>) escribió:
> Could you just use the standard python csv module?
> 
>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata > <mailto:ronaldomat...@gmail.com>> wrote:
>> 
>> Hi Liu thank for your answer.
>> 
>> This has been a headache, I am trying to read the file using csv.DictReader 
>> initially i had an error trying to get the dict keys when iterating by rows, 
>> and i thought it could be encoding (for this reason i wanted to prepare the 
>> view to use the correct encoding). for that reason I asked my question.
>> 
>> 1) your first approach doesn't work, if i send utf-8 file, chardet returns 
>> ascii as encoding. it seems request.FILES ['file']. read () returns a binary 
>> with that encoding.
>> 
>> 2) In the end I realized that the problem was the delimiter of the csv but 
>> predicting it is another problem.
>> 
>> Anyway, it was a task that I had to do and that was my limitation. I think 
>> there must be a library that does all this, uploading a csv file is common 
>> practice in many web apps.
>> 
>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (> <mailto:firstday2...@gmail.com>>) escribió:
>> Hi. First of all, I think it's impossible to perfectly detect encoding 
>> without further information. See the answer in this SO post: 
>> https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
>>  
>> <https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text>
>>  There are many packages and tools to help detect encoding format, but keep 
>> in mind that they are only giving educated guesses. (Most of the time, the 
>> guess is correct, but do check the dev page to see whether there are known 
>> issues related to your problem.)
>> 
>> Now let's say you have decided to use chardet. Check its doc page for the 
>> usage: https://chardet.readthedocs.io/en/latest/usage.html#usage 
>> <https://chardet.readthedocs.io/en/latest/usage.html#usage> You'll have more 
>> than one solutions. Here are some examples:
>> 
>> 1. If the files uploaded to your server are all expected to be small csv 
>> files (less than a few MB and not many users do it concurrently), you can do 
>> the following:
>> 
>> #in the view to handle the uploaded file: (assume file input name is just 
>> "file")
>> file_content = request.FILES['file'].read()
>> chardet.detect(file_content)
>> 
>> 2. Also, chardet seems to support incremental (line-by-line) detection 
>> https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally
>>  
>> <https://chardet.readthedocs.io/en/latest/usage.html#example-detecting-encoding-incrementally>
>> 
>> Given this, we can also read from requests.FILES line by line and pass each 
>> line to chardet
>> 
>> from chardet.universaldetector import UniversalDetector
>> 
>> #somewhere in a view function
>> detector = UniversalDetector()
>> file_handle = request.FILES['file']
>> for line in file_handle:
>> detector.feed(line)
>> if detector.done: break
>> detector.close()
>> # result available as a dict at detector.result
>> 
>> 
>> 
>> 
>> 
>> On Tuesday, July 21, 2020 at 7:09:35 AM UTC+8, Ronaldo Mata wrote:
>> How to deal with encoding when you try to read a csv file on view.
>> 
>> I have a view to upload csv file, in this view I read file and save each row 
>> as new record.
>> 
>> My bug is when I try to upload a csv file with a differente encoding (not 
>> UTF-8)
>> 
>> how to handle this on django (using request.FILES) I was researching and I 
>> found chardet but I don't know how to pass it a request.FILES. I need help 
>> please.
>> 
>> -- 
>> 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 

  1   2   3   4   5   6   7   8   9   10   >