Re: Using Admin to manage users that is not in django

2022-03-20 Thread Aldian Fazrihady
Django admin is so coupled to Django models.
Django admin is customizable.

If you want some "integration" with your existing Django admin that is
already linked to your existing models,
you can edit the Django admin index page template and put the link to your
Samba AD DC management page.
Your Samba AD DC management page will be an ordinary Django app.

On Mon, Mar 21, 2022 at 9:52 AM Thiago Luiz Parolin 
wrote:

> Hi.
> I am trying to make a web app to manage samba AD DC.
> Using python bindings from samba, i can access users/groups/features of
> our directory.
> What i want is:
>  - How can i use the django admin to manage AD? Because all the user base
> is inside samba, not in django.
>  - Or i need to build my own 'admin'?
>
> Thanks for any advice.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANbmKytFbGCezptTES%2BqEBebpsVQg0wYrnM129W7jRyR50xSxA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANbmKytFbGCezptTES%2BqEBebpsVQg0wYrnM129W7jRyR50xSxA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAaYh2H6A_31ehLktAzN7-W%3DTA_0vzqNiWT34nBovMb5Pg%40mail.gmail.com.


Re: gettext vs ugettext lazy

2021-12-02 Thread Aldian Fazrihady
Use the lazy version when you know that the translation database won't be
ready when the gettext function is invoked, such as in the class variable
initialization.

Use the non-lazy version when you know the translation database is ready,
such as inside a method.

https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#lazy-translation

On Thu, Dec 2, 2021 at 5:14 PM ngal...@gmail.com  wrote:

> Hello
> Would like to know the difference and where to use
> .Model, Views, Routers, Forms e.t.c
> gettext (from django.utils.translation import gettext)
> ugettext_lazy(from django.utils.translation import ugettext_lazy)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc6e8aa7-6206-4b01-bc3f-0bf02a24770en%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fc6e8aa7-6206-4b01-bc3f-0bf02a24770en%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZE%3DfpFHxzmgGSoiv%2BBRT6MEczWYQ8dkQsVXyO7Yn_khQ%40mail.gmail.com.


Re: Django/uWSGI/nginx under load

2021-02-20 Thread Aldian Fazrihady
Check the number of open file descriptor when you experienced the slow
response.

On Sat, Feb 20, 2021 at 10:23 PM Andy Robinson  wrote:

> Hi all,
>
> We're maintaining an application that is hitting scaling problems.   It
> helps run grass-roots sporting events all over Europe, so Saturdays can
> produce large and unpredictable loads, with both logged-in users and public
> viewers. Despite a powerful server seemingly being lightly loaded (htop
> suggests just 3-6 out of24 cores typically busy, and free memory
> available), it often "hangs" for long periods - simple requests return
> after 10sec, and at times we have had to restart nginx.
>
> If anyone here has experience of this configuration under high loads, we'd
> be keen to hire an experienced expert to review and check we are not doing
> anything stupid with our nginx or uwsgi configuration.
>
> Likewise, if you really know how to cache Django with nginx, and work
> around the various cookies and language settings so that logged-in pages
> still work but anonymous ones can be cached, we'd love to get a bit of
> help
>
> Architecture is ubuntu 18.04, Django 3.0.12, with MariaDB and Mongo back
> ends used for slightly different things.
>
> Feel free to contact me by private email if you,
>
> Otherwise, if people have suggestions and questions here, I'll try to
> share what I can and am very grateful for any help...
>
> Best Regards
>
>
> Andy Robinson
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4fcc006e-37bb-4497-a692-45dfb99bfad1n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4fcc006e-37bb-4497-a692-45dfb99bfad1n%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbNUw2UEUH4g6_xf%2B4HYrvK_Vrdj5QObUE6BFbEDLMHwQ%40mail.gmail.com.


Re: DJANGO AWS: Failed to load resource: the server resp....403 (Forbidden)

2021-02-04 Thread Aldian Fazrihady
Everyone, Kasper's answer contains hint. Don't get offended.

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Fri, Feb 5, 2021, 1:16 PM Kunal Solanke 
wrote:

> Well, still its first time I read him being sarcastic or kind of fed
> up.Its hilarious 藍.
>
> On Fri, Feb 5, 2021, 11:36 Benny M  wrote:
>
>> Lightning,
>> I think what Kasper means to say is that there are a few reasons why AWS
>> isn’t authorizing your request, and the likelihood that Django is somehow
>> involved in that error is pretty much zero.
>>
>> HTTP 403 means that some authorization/permission isn’t sufficient for
>> the server to fulfill the request. Look into your AWS configs or contact
>> their support team.
>>
>> That said, I have no right to speak for Kasper, so my interpretation may,
>> in itself, generate a 403.
>>
>> > On Feb 4, 2021, at 11:36 PM, Kasper Laudrup 
>> wrote:
>> >
>> > On 05/02/2021 06.05, Lightning Bit wrote:
>> >> Does anyone know how to bypass the 403 error on AWS S3 with Django
>> where the static files are not allowed to show up on the site?
>> >>
>> >
>> > Ah, yes. The 403 error we all heard of. Everyone knows how to bypass
>> that. Everyone except 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/ff1118ea-b429-3264-5bea-8f8a01f245ef%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/CH2PR14MB39130275C1DDBA94452D89E1C0B29%40CH2PR14MB3913.namprd14.prod.outlook.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/CAOecAnw40RYyA%2BjR2ogRC8fYh0vmVNmrBkV%2BJcj5wWT8SO5hHA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOecAnw40RYyA%2BjR2ogRC8fYh0vmVNmrBkV%2BJcj5wWT8SO5hHA%40mail.gmail.com?utm_medium=email_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/CAN7EoAZV%3Dhrk2SzBbBmnV7pYcs-g-ueOv1un9x9i0YV2P19iXA%40mail.gmail.com.


Re: Intensive access and modification of database table

2020-07-19 Thread Aldian Fazrihady
Hi,
There are more than one transactional data architectures to achieve the
goals, so only Amazon, eBay, or any other big commerce employees can answer
your question.
However, if you are using transactional SQL as Django is using it by
default, you probably need to learn about horizontal partitioning.

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Min, 19 Jul 2020 18.18, tristant 
menulis:

> Hi,
>
> I am wondering if anyone could point me to any documents or readings on
> how to big eCommerce sites such as Amazon or eBay implements the following
> situation:
> - A seller posts a product with an initial quantity, 'init_qty'.
> - An unknown number of clients access the product concurrently, add it to
> their shopping cart.
> - The site needs to manage the contemporary available quantity,
> "avail_qty", and all times. And switch the product to "unavailable" if the
> quantity drop to zero.
> - However, the effective "avail_qty" is only updated permanently in the
> database if and only if the client checks out and pays.
>
> For small eCommerce sites, updating the database frequently is not a big
> deal. But if the product count and client count is large, what is the
> efficient way to implement this?
>
> 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/dd2b979b-6f63-465b-b6e7-8a831e53bf28n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/dd2b979b-6f63-465b-b6e7-8a831e53bf28n%40googlegroups.com?utm_medium=email_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/CAN7EoAYizrLBxj%2BTTsRMjP-jRa0kuD4gN0uvbgRT5Qf_JKZdVA%40mail.gmail.com.


Re: Why passwords are not encrypted automatically in Django?

2020-07-18 Thread Aldian Fazrihady
Hi. Django automatically hashes password when the backend set
password using `User.set_password` or `User.create_userr` method.
I think the best practice for password is to hash it instead of to encrypt
it. Django already done it.

On Sun, Jul 19, 2020 at 4:27 AM Ram Mullapudi 
wrote:

> Hi,
>
> We are using HTML forms in our DJango Web Application and user password is
> not auto encrypted in DJango. Do we need to write additional code to
> encrypt the password in Django backend?
>
> Best regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/46c902b1-007c-4899-8800-588826f82eb3o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/46c902b1-007c-4899-8800-588826f82eb3o%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbmy2WqJCy5hC5qN1PJF5fGEGH7-M-26VJW9RWw7mRUrA%40mail.gmail.com.


Re: Need Covid 19 Database for Experiments

2020-07-04 Thread Aldian Fazrihady
There are covid-19 datasets in Google Cloud Platform ready to be queried.
You can go to https://console.cloud.google.com/bigquery and immediately
execute a covid-19 related query, for example:
```
SELECT * FROM
`bigquery-public-data.covid19_ecdc.covid_19_geographic_distribution_worldwide`
WHERE countries_and_territories LIKE '%America%' AND date > '2020-03-01'
ORDER BY date DESC
```

On Fri, Jul 3, 2020 at 12:38 AM Balaji Shetty 
wrote:

> Hi
>
> Can anyone provide me Covid 19 Database.
> I need Covid 19 Database for Experiments
>
> Thank you
>
>
> --
> Mr Shetty Balaji
> Asst. Prof.
> IT Department
> SGGS I
> Nanded. My. India
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOuuNCY58sB1g2f_ftHtpAs3FamSq%2BBJJZ%2BA5mv_3%3Dw3NQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOuuNCY58sB1g2f_ftHtpAs3FamSq%2BBJJZ%2BA5mv_3%3Dw3NQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbY1Kr9EWw21SdnsDXWV8Cwr_FBCbAT5WtECv_gmOUjug%40mail.gmail.com.


Re: makemessages - unable to find a locale path

2020-06-12 Thread Aldian Fazrihady
makemessages should still extract texts from code and put it in po files
and store the po files somewhere? Or should it do nothing?

On Fri, Jun 12, 2020 at 4:03 PM Kai Kobschätzki 
wrote:

> No error message anymore :)
> On 6/12/20 11:00 AM, Aldian Fazrihady wrote:
>
> After django "forget" the directory, what do you expect makemessages to do?
>
> On Fri, Jun 12, 2020 at 3:41 PM Kai Kobschätzki <
> kai.kobschaet...@gmail.com> wrote:
>
>> Hi Aldian,
>>
>> thanks for your response!
>>
>> I do not want a new folder. I removed a folder and the localization don't
>> accept it..
>>
>> Greetings
>>
>> bengoshi
>>
>>
>> On 6/12/20 10:26 AM, Aldian Fazrihady wrote:
>>
>> Hi,
>>
>> you need to set LOCALE_PATHS in the settings file point to your new
>> folder.
>> For example,
>>
>> LOCALE_PATHS = [os.path.join(BASE_DIR, 'new_locale')]
>>
>>
>> On Fri, Jun 12, 2020 at 3:08 PM Kai Kobschätzki <
>> kai.kobschaet...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I have some *.po files. But now I am getting the message error „Unable
>>> to find a locale path to store translations for file $directory“.
>>>
>>> All I find with google is that I have to create a subdirectory locale in
>>> the $directory. But I removed the $directory, so I can't or I do not
>>> want to recreate the origina directory...
>>>
>>> Do anyone know how I can say django to „forget“ the directory?
>>>
>>> Thanks!
>>>
>>> bengoshi
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/7a30a9cd-4538-3295-5dc5-6a0b1cee42ed%40gmail.com
>>> .
>>>
>>
>>
>> --
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.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/CAN7EoAZ3MWwkQ32DnKrwqxt1MEmRjmzTRCPQZWY_7AP1GYimOA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN7EoAZ3MWwkQ32DnKrwqxt1MEmRjmzTRCPQZWY_7AP1GYimOA%40mail.gmail.com?utm_medium=email_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/37f6740f-b9df-f3a0-32ae-474c26202cd0%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/37f6740f-b9df-f3a0-32ae-474c26202cd0%40gmail.com?utm_medium=email_source=footer>
>> .
>>
>
>
> --
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.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/CAN7EoAarEu9Nu_Hp5LRLF7mRGMWpUe-9YK7%3DHgwsQmJraiPKgw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN7EoAarEu9Nu_Hp5LRLF7mRGMWpUe-9YK7%3DHgwsQmJraiPKgw%40mail.gmail.com?utm_medium=email_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/128ada02-6253-9354-22cb-6dd92c5153a7%40gmail.com
> <https://groups.google.com/d/msgid/django-users/128ada02-6253-9354-22cb-6dd92c5153a7%40gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbz9y%2B6%3DLWF89BTni%2By_M_HtxSNeH1wfCvy9VT9WeRf9w%40mail.gmail.com.


Re: makemessages - unable to find a locale path

2020-06-12 Thread Aldian Fazrihady
After django "forget" the directory, what do you expect makemessages to do?

On Fri, Jun 12, 2020 at 3:41 PM Kai Kobschätzki 
wrote:

> Hi Aldian,
>
> thanks for your response!
>
> I do not want a new folder. I removed a folder and the localization don't
> accept it..
>
> Greetings
>
> bengoshi
>
>
> On 6/12/20 10:26 AM, Aldian Fazrihady wrote:
>
> Hi,
>
> you need to set LOCALE_PATHS in the settings file point to your new folder.
> For example,
>
> LOCALE_PATHS = [os.path.join(BASE_DIR, 'new_locale')]
>
>
> On Fri, Jun 12, 2020 at 3:08 PM Kai Kobschätzki <
> kai.kobschaet...@gmail.com> wrote:
>
>> Hi all,
>>
>> I have some *.po files. But now I am getting the message error „Unable
>> to find a locale path to store translations for file $directory“.
>>
>> All I find with google is that I have to create a subdirectory locale in
>> the $directory. But I removed the $directory, so I can't or I do not
>> want to recreate the origina directory...
>>
>> Do anyone know how I can say django to „forget“ the directory?
>>
>> Thanks!
>>
>> bengoshi
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/7a30a9cd-4538-3295-5dc5-6a0b1cee42ed%40gmail.com
>> .
>>
>
>
> --
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.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/CAN7EoAZ3MWwkQ32DnKrwqxt1MEmRjmzTRCPQZWY_7AP1GYimOA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN7EoAZ3MWwkQ32DnKrwqxt1MEmRjmzTRCPQZWY_7AP1GYimOA%40mail.gmail.com?utm_medium=email_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/37f6740f-b9df-f3a0-32ae-474c26202cd0%40gmail.com
> <https://groups.google.com/d/msgid/django-users/37f6740f-b9df-f3a0-32ae-474c26202cd0%40gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAarEu9Nu_Hp5LRLF7mRGMWpUe-9YK7%3DHgwsQmJraiPKgw%40mail.gmail.com.


Re: makemessages - unable to find a locale path

2020-06-12 Thread Aldian Fazrihady
Hi,

you need to set LOCALE_PATHS in the settings file point to your new folder.
For example,

LOCALE_PATHS = [os.path.join(BASE_DIR, 'new_locale')]


On Fri, Jun 12, 2020 at 3:08 PM Kai Kobschätzki 
wrote:

> Hi all,
>
> I have some *.po files. But now I am getting the message error „Unable
> to find a locale path to store translations for file $directory“.
>
> All I find with google is that I have to create a subdirectory locale in
> the $directory. But I removed the $directory, so I can't or I do not
> want to recreate the origina directory...
>
> Do anyone know how I can say django to „forget“ the directory?
>
> Thanks!
>
> bengoshi
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7a30a9cd-4538-3295-5dc5-6a0b1cee42ed%40gmail.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZ3MWwkQ32DnKrwqxt1MEmRjmzTRCPQZWY_7AP1GYimOA%40mail.gmail.com.


Re: Django foreign-key cannot assign must be a instance

2020-05-19 Thread Aldian Fazrihady
replace
```
Report.objects.create(param=test_name,comp=compon,value=test_value)
```
with
```
Report.objects.create(param=test_name,comp_id=compon,value=test_value)
```

On Tue, May 19, 2020 at 2:39 PM ratnadeep ray  wrote:

> Can you please say in which line we should make that change because in so
> many places I am using comp. So in all the places should I change that ?
>
> On Tuesday, 19 May 2020 12:36:19 UTC+5:30, Aldian Fazrihady wrote:
>>
>> Use comp_id= instead of comp=
>>
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 19 Mei 2020 13.49, ratnadeep ray 
>> menulis:
>>
>>> Hi all,
>>>
>>> I am trying to add a row in the DB using the following views.py:
>>>
>>> # Create your views here.
>>>> from django.shortcuts import render
>>>> from fusioncharts.models import Component,Report
>>>> import xlrd
>>>> def pie_chart(request):
>>>> labels = []
>>>> data = []
>>>> loc = ("C:\Django_apps\QRC_Report.xlsx")
>>>> workbook = xlrd.open_workbook(loc)
>>>> worksheet = workbook.sheet_by_name('Sheet1')
>>>> num_rows = worksheet.nrows - 1
>>>> num_cols = worksheet.ncols - 1
>>>> curr_row = -1
>>>> component = []
>>>> comp = None
>>>> while curr_row < num_rows:
>>>>   curr_row += 1
>>>>   row = worksheet.row(curr_row)
>>>>   curr_col = -1
>>>>   if "Header" in worksheet.cell_value(curr_row, 0):
>>>> compon = worksheet.cell_value(curr_row, 0).strip("*")
>>>> print("The component is %s" %compon)
>>>> component.append(compon)
>>>> print("===The results of the component %s is as
>>>> follows" %compon)
>>>> Component.objects.create(comp=compon)
>>>> continue
>>>>   while curr_col < num_cols:
>>>> curr_col += 1
>>>> cell_value = worksheet.cell_value(curr_row, curr_col)
>>>> #print("Cell value = %s" %cell_value)
>>>> test_name = worksheet.cell_value(curr_row,0)
>>>> print("Test name = %s" %test_name)
>>>> test_value = worksheet.cell_value(curr_row,1)
>>>> print("Test result = %s" %test_value)
>>>> print("The component is = %s" %comp)
>>>>
>>>> *Report.objects.create(param=test_name,comp=compon,value=test_value)*
>>>> return render(request, 'pie_chart.html', {
>>>> 'labels': labels,
>>>> 'data': data,
>>>> })
>>>
>>>
>>> However the above highlighted line is throwing the following error:
>>>
>>>> Cannot assign "'Header SQL Detailed'": "Report.comp" must be a
>>>> "Component" instance.
>>>
>>>
>>> My model is as follows:
>>>
>>> from django.db import models
>>>> from django.urls import reverse
>>>> from decimal import Decimal
>>>> # Create your models here.
>>>> class Component(models.Model):
>>>> comp = models.CharField(max_length=30)
>>>> class Report(models.Model):
>>>> comp = models.ForeignKey(Component,on_delete=models.CASCADE)
>>>> param = models.CharField(max_length=30)
>>>> value =
>>>> models.DecimalField(max_digits=25,decimal_places=18,default=Decimal('0.'))
>>>
>>>
>>>
>>> Can anyone please point out what is going wrong here? What should be the
>>> correction?
>>>
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/afb5a06a-0d7d-4038-a0fc-3c2aadbbe4fc%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/afb5a06a-0d7d-4038-a0fc-3c2aadbbe4fc%40googlegroups.com?utm_medium=email_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/1425af8b-7dae-4cdb-ba8a-82d0a9fa0a74%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1425af8b-7dae-4cdb-ba8a-82d0a9fa0a74%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZ%2BnrQSbpcwx8-PbYyvTNLE1X%3DpfLH0ifVb2KrR3zRsEw%40mail.gmail.com.


Re: Django foreign-key cannot assign must be a instance

2020-05-19 Thread Aldian Fazrihady
Use comp_id= instead of comp=

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Sel, 19 Mei 2020 13.49, ratnadeep ray 
menulis:

> Hi all,
>
> I am trying to add a row in the DB using the following views.py:
>
> # Create your views here.
>> from django.shortcuts import render
>> from fusioncharts.models import Component,Report
>> import xlrd
>> def pie_chart(request):
>> labels = []
>> data = []
>> loc = ("C:\Django_apps\QRC_Report.xlsx")
>> workbook = xlrd.open_workbook(loc)
>> worksheet = workbook.sheet_by_name('Sheet1')
>> num_rows = worksheet.nrows - 1
>> num_cols = worksheet.ncols - 1
>> curr_row = -1
>> component = []
>> comp = None
>> while curr_row < num_rows:
>>   curr_row += 1
>>   row = worksheet.row(curr_row)
>>   curr_col = -1
>>   if "Header" in worksheet.cell_value(curr_row, 0):
>> compon = worksheet.cell_value(curr_row, 0).strip("*")
>> print("The component is %s" %compon)
>> component.append(compon)
>> print("===The results of the component %s is as
>> follows" %compon)
>> Component.objects.create(comp=compon)
>> continue
>>   while curr_col < num_cols:
>> curr_col += 1
>> cell_value = worksheet.cell_value(curr_row, curr_col)
>> #print("Cell value = %s" %cell_value)
>> test_name = worksheet.cell_value(curr_row,0)
>> print("Test name = %s" %test_name)
>> test_value = worksheet.cell_value(curr_row,1)
>> print("Test result = %s" %test_value)
>> print("The component is = %s" %comp)
>>
>> *Report.objects.create(param=test_name,comp=compon,value=test_value)*
>> return render(request, 'pie_chart.html', {
>> 'labels': labels,
>> 'data': data,
>> })
>
>
> However the above highlighted line is throwing the following error:
>
>> Cannot assign "'Header SQL Detailed'": "Report.comp" must be a
>> "Component" instance.
>
>
> My model is as follows:
>
> from django.db import models
>> from django.urls import reverse
>> from decimal import Decimal
>> # Create your models here.
>> class Component(models.Model):
>> comp = models.CharField(max_length=30)
>> class Report(models.Model):
>> comp = models.ForeignKey(Component,on_delete=models.CASCADE)
>> param = models.CharField(max_length=30)
>> value =
>> models.DecimalField(max_digits=25,decimal_places=18,default=Decimal('0.'))
>
>
>
> Can anyone please point out what is going wrong here? What should be the
> correction?
>
> 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/afb5a06a-0d7d-4038-a0fc-3c2aadbbe4fc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/afb5a06a-0d7d-4038-a0fc-3c2aadbbe4fc%40googlegroups.com?utm_medium=email_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/CAN7EoAYVn9nkZWF8_8BJS_Jei3pJXkigRemtSkKSVOczP1mf-g%40mail.gmail.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
Probably you need to use TransactionTestCase, which is the parent of
TestCase instead:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
That page also mentions a specific problem when using transaction on
TestCase:
```
A consequence of this, however, is that some database behaviors cannot be
tested within a Django TestCase class. For instance, you cannot test that a
block of code is executing within a transaction, as is required when using
select_for_update()
<https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update>.
In those cases, you should use TransactionTestCase.
111

On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:

> That not that simple in my case because. I'll show what I mean:
>
> from django.contrib.auth.models import User
> from django.test import TestCase
> from rolepermissions.roles import assign_role
>
> class FooTest(TestCase):
> def test_bar(self):
> u = User.objects.create_user(username="abc", password="pass")
> assign_role(u, "role_admin")
> retrieve_and_analyze_view_using_u_credentials()
>
> I am testing that my permission routines work by creating a user,
> assigning permissions to the user, retrieving the view and analyzing it.
> That "assign_role" call of django-role-permissions uses
> "transaction.atomic". Which, of course, I would not want to change, as this
> is an external library.
>
> So I can't really remove usages of "transaction.atomic"
>
>
>
> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>>
>> When testing django apps, my unit test usually accesses the django app
>> via django test client:
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>> .
>> Django test client simulates http access, so my Django tests always run
>> my Django code starting from Django views.
>> Even though there must be many django app code that has
>> `transaction.atomic` inside it, I never need to add `transaction.atomic` in
>> my unit test code.
>> If I need to simulate initial state by having some data inserted to
>> database, I did that either using factoryboy or django ORM framework, but I
>> see no point to add `transaction.atomic` to that data initialization code.
>>
>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>
>>> While this can be done in my code, there are libraries that the project
>>> use that have "transaction.atomic" in them. For example, pretty popular
>>> django-role-permissions.
>>> From what I see in the documentation, there should be no problem to use
>>> transactions within transactions in TestCase.
>>>
>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>>
>>>> I don't think the subclass of TestCase need to use transaction.atomic.
>>>> Why can't you just remove the transaction.atomic?
>>>>
>>>> Regards,
>>>>
>>>> Aldian Fazrihady
>>>> http://aldianfazrihady.com
>>>>
>>>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
>>>> menulis:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am using TestCase and trying to create an object during test.
>>>>> There is a log activated on MySQL server, so I see all the queries
>>>>> being executed there.
>>>>>
>>>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking
>>>>> that the transaction is already started. The problem is that there is no
>>>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>>>> the
>>>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>>>
>>>>> The following states that TestCase "tests within two nested atomic()
>>>>> blocks", so it should execute "TRANSACTION START"
>>>>>
>>>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>>>
>>>>>
>>>>> from django.contrib.auth.models import User
>>>>> from django.test import TestCase
>>>>>
>>>>>
>>>>> class FooTest(TestCase):
>>>>> def test_bar(self):
>>>>> with transaction.atomic():
>>>>> user = User.objects.create_user(username="abc",
>>>>> password="pass")
>>>&

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
When testing django apps, my unit test usually accesses the django app via
django test client:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client.
Django test client simulates http access, so my Django tests always run my
Django code starting from Django views.
Even though there must be many django app code that has
`transaction.atomic` inside it, I never need to add `transaction.atomic` in
my unit test code.
If I need to simulate initial state by having some data inserted to
database, I did that either using factoryboy or django ORM framework, but I
see no point to add `transaction.atomic` to that data initialization code.

On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> While this can be done in my code, there are libraries that the project
> use that have "transaction.atomic" in them. For example, pretty popular
> django-role-permissions.
> From what I see in the documentation, there should be no problem to use
> transactions within transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> I don't think the subclass of TestCase need to use transaction.atomic.
>> Why can't you just remove the transaction.atomic?
>>
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
>> menulis:
>>
>>> Hello,
>>>
>>> I am using TestCase and trying to create an object during test.
>>> There is a log activated on MySQL server, so I see all the queries being
>>> executed there.
>>>
>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking that
>>> the transaction is already started. The problem is that there is no
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic()
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>>
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> with transaction.atomic():
>>> user = User.objects.create_user(username="abc",
>>> password="pass")
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_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/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYO3N3E7Jrds9sqmnfKOUFHwtdf%3DXMra2WZ3WCiDiJfEw%40mail.gmail.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Aldian Fazrihady
I don't think the subclass of TestCase need to use transaction.atomic. Why
can't you just remove the transaction.atomic?

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  menulis:

> Hello,
>
> I am using TestCase and trying to create an object during test.
> There is a log activated on MySQL server, so I see all the queries being
> executed there.
>
> This "transaction.atomic" sets a SAVEPOINT in the database thinking that
> the transaction is already started. The problem is that there is no
> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>
> The following states that TestCase "tests within two nested atomic()
> blocks", so it should execute "TRANSACTION START"
>
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>
>
> from django.contrib.auth.models import User
> from django.test import TestCase
>
>
> class FooTest(TestCase):
> def test_bar(self):
> with transaction.atomic():
> user = User.objects.create_user(username="abc",
> password="pass")
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_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/CAN7EoAZi_aRZcppf1xZ6XLF4FGJULq3pL7pnoi33HainJa0JgQ%40mail.gmail.com.


Re: How to fork LocaleMiddleware? I need to make a small change.

2020-05-06 Thread Aldian Fazrihady
You can just extend LocaleMiddleware like this:
```
class MyLocaleMiddleware(LocaleMiddleware):

def process_request(self, request):
super().process_request(request)
# TODO: add my custom code
```
Save it to a python file, such as `middleware.py`

On the django settings file, replace the LocaleMiddleware with yours:
```
MIDDLEWARE = [
'..MyLocaleMiddleware',
]
```

On Wed, May 6, 2020 at 7:42 PM Oleg Barbos  wrote:

> When LocaleMiddleware sees the request coming in, it tries to parse the
> language from the request. See
> https://github.com/django/django/blob/92507bf3ea4dc467f68edf81a686548fac7ff0e9/django/utils/translation/trans_real.py#L46
>  for
> the regular expression used. The allowed format is: any sequence of word
> characters, and optionally a dash and more word characters, after that it
> expects either the end of the string, or a /. In my case, it matches
> id-button/, and understands that id-button is the language prefix for
> that request, causing Django to activate the id language.
>
> I need to change this behaviour, so it would check if second part like 
> "button"
> is in a whitelist of languages from SETTINGS.
> so the languages "id", "de", "zh-Hans" should work properly, but when
> slug is "id-button/" - it should get English language.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75b39a9f-05b6-430c-bf78-3b6e6cc0a641%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/75b39a9f-05b6-430c-bf78-3b6e6cc0a641%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZGU_Bk9xYZ0imxoz5tu6WrXu9i%3DRvNwtd%3DFgJymnJWSw%40mail.gmail.com.


Re: How to glue Django and React together?

2020-05-06 Thread Aldian Fazrihady
Hi,

I am using that stack for my website aldianfazrihady.com.
It uses these modules:
https://pypi.org/project/django-webpack-loader/
https://www.npmjs.com/package/react-router-dom

On web browser, open my website, and use developer tools or view source to
see how it interacts with django backend.
I am using django only as API gateway using DRF and only to load simple
page that points to JS that will initialize React.
UI rendering is done on web browser side.

On Wed, May 6, 2020 at 6:39 PM Abhiram P  wrote:

> I want to use react as front end and Django as back end. And the URL
> routing must be done by Django. How to do this
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0f786aad-14cc-4c45-99a8-8b2b7cf4c1f7%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0f786aad-14cc-4c45-99a8-8b2b7cf4c1f7%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYictmzfjR81jEmJd%2BVJfezcLp_oyaEuKdNthapveapXQ%40mail.gmail.com.


Re: hosting django app on app engine

2020-04-22 Thread Aldian Fazrihady
Hi Anirudh,

Does this link show you any meaningful error message:
https://console.cloud.google.com/errors?time=PT1H=COUNT_DESC=OPEN=ACKNOWLEDGED=anirudhmalik-274008=1=true=true
<https://console.cloud.google.com/errors?time=PT1H=COUNT_DESC=OPEN=ACKNOWLEDGED=dgc-journaling-tool=1=true=true>
 ?

On Wed, Apr 22, 2020 at 8:16 PM Anirudh choudhary <
anirudhchoudary...@gmail.com> wrote:

> hi to all! I am hosting my blogging app on google app engine in a standard
> environment. the website deploys successfully. but when I try to go to any
> other URL like anirudhmalik.in to anirudhmalik/blog/list/ it shows me 500
> server error on the server side I am using PostgreSQL instance and the logs
> message only show me the error
> projects/anirudhmalik-274008/logs/appengine.googleapis.com%2Frequest_log"
>
> but I couldn't get any hint from this message and none of the post
> requests is
> working on the website and everything is working fine in a local server or
> my local machine
>
> you can check the website on anirudhmalik.in
>
> and you can also give suggestion is google app engine is good to host your
> Django project
> and other cheap college student type hosting service
> thankyou
>
>
> main.py
>
> from annyportfolio.wsgi import application
>
> app=application
>
> app.yaml file
>
> runtime: python37
>
> handlers:
> # This configures Google App Engine to serve the files in the app's static
> # directory.
> - url: /static
> static_dir: static-storage/
>
>
> # This handler routes all requests not caught above to your main app. It is
> # required when static routes are defined, but can be omitted (along with
> # the entire handlers section) when there are no static files defined.
>
> - url: /.*
> secure: always
> redirect_http_response_code: 301
> script: auto
>
>
>
> env_variables:
> DJANGO_SETTINGS_MODULE: annyportfolio.settings
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL8_rkG8qwM491qCcX18qgukA_ao4_ZjH8%2B-K01m17vOTcTTNw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAL8_rkG8qwM491qCcX18qgukA_ao4_ZjH8%2B-K01m17vOTcTTNw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZdNYOYF2n98STXedOraydhg_u31sf0mrEhhaN00GDLVA%40mail.gmail.com.


Re: How to make Django Rest Apis Async

2020-04-20 Thread Aldian Fazrihady
Hi Mrinal,

My DRF views usually send asynchronous tasks to celery or channel workers.

On Tue, Apr 21, 2020 at 4:38 AM Mrinal Kamboj 
wrote:

> Hello Everyone,
>
> Following is my Django application configuration:
>
>
> *django = 2.2.11djangorestframework = 3.9.2*
> *Python = 3.8.2*
>
> I am exposing a set of rest apis for react js frontend, which connects to
> Postgres using a layered architecture *views (controller) - services -
> data_layer. *In data layer I fetch the data using *Connection.Cursor, *then
> transform the data fetched using *cursor.fetchall.*
>
> By default the rest apis are synchronous apis, I am trying to find a way
> to make them Async, so that system scalability can be increased,
> otherwise every call will block the main thread.
>
> I have tried the following options:
>
> 1. Using *asyncio* library, but I am unable to make the complete call
> chain Async. I generally get an error that expected return was Response /
> HttpResponse, but the method is returning Co-routine. I can find examples
> which contains running simple methods as async, but there's isn't an
> example of Django Rest API
>
> 2. Tried the following link,
> https://hackernoon.com/how-to-run-asynchronous-web-requests-in-parallel-with-python-3-5-without-aiohttp-264dc0f8546,
> which use the Threadpool executor to segregate every call on a thread in
> the controller itself, though the challenge is where to make the Asyncio
> call in the Main method as shown in the link, since these APIs are
> externally invoked.
>
> 3. Can aiohttp help, not sure, but if anyone has an example otherwise I
> have to resort to service broker design using an intermediary like Redis
> which in my view is unrequired complexity.
>
> Any help / link on the topic would be appreciated.
>
> Thanks,
>
> Mrinal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPSS-O%2Bm2vOS6D7c_fNFNDccmxBVMJqQZ58bNUtrjTd42Jdf%3Dw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPSS-O%2Bm2vOS6D7c_fNFNDccmxBVMJqQZ58bNUtrjTd42Jdf%3Dw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYdQaniByX88JoJe753MZrvLF5qLEo0eLOFn0OOaXCxYg%40mail.gmail.com.


Re: 502 Bad Gateway nginx/1.14.0 (Ubuntu)

2020-04-13 Thread Aldian Fazrihady
If you turned off gunicorn, will you still get the 502 error? If yes,
the orginal error it means your nginx cannot connect to your gunicorn.

Have you tested your app on dev server, i.e: `python manage.py runserver` ?

On Sat, Apr 11, 2020 at 11:53 PM Jagtar Singh Lakhyan <
jagtar.lakhe...@gmail.com> wrote:

> Im trying to deploy django app using nginx & gunicorn but its showing error
>
> sudo nginx -t
>
> nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
>
> nginx: configuration file /etc/nginx/nginx.conf test is successful
>
>
> sudo systemctl status gunicorn.service
>
> gunicorn.service - gunicorn service
>
>Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor
> preset:
>
>Active: *active (running)* since Sat 2020-04-11 21:19:19 IST; 11s ago
>
>  Main PID: 16326 (gunicorn)
>
> Tasks: 4 (limit: 1689)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1031a40-e33c-4bca-8764-13849c75968e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b1031a40-e33c-4bca-8764-13849c75968e%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAaeBOPBq0NbvJYYV1n%3D7ZZkKLjcvYvVE1Aiw9ero8wS%2BA%40mail.gmail.com.


Re: Translations & Internationalization in Django Rest Framework

2020-03-10 Thread Aldian Fazrihady
I am using Django translation on DRF. Here is the doc on Django translation.

On Wed, Mar 11, 2020 at 1:17 AM Alaydyn Gholechragh 
wrote:

> hi
>
> which component I can use for translation(Internationalization) in  Django
> Rest Framework ?? easy and with best documents and examples ??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1f16cbdb-469e-4928-b971-0f6303703a90%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1f16cbdb-469e-4928-b971-0f6303703a90%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZk_d-ioMwyFUnC7oawrkzmFuNNpQBaL3YOfWNQ8Wdcqw%40mail.gmail.com.


Re: Django i18n_patterns default language

2020-02-24 Thread Aldian Fazrihady
You can add a middleware to ignore the header:

class IgnoreLanguageHeaderLocaleMiddleware(LocaleMiddleware):

LANGUAGE_HEADER = 'HTTP_ACCEPT_LANGUAGE'

def process_request(self, request):
if self.LANGUAGE_HEADER in request.META:
del request.META[self.LANGUAGE_HEADER]

super(IgnoreLanguageHeaderLocaleMiddleware,
self).process_request(request)


On Mon, Feb 24, 2020 at 1:44 PM Szocs Arnold 
wrote:

> Is there any solution to add language prefix to the URL from the
> settings.LANGUAGE_CODE which is my preferred language. Instead from
>  "Accept-Language" header. I do not want to use the browser language.
>
> On Fri, Feb 21, 2020 at 4:14 PM Aldian Fazrihady 
> wrote:
>
>> A web browser has language preference setting. When a request made to
>> your Django server,  your browser reads its language preferences and it put
>> it in the request "Accept-Language" header.
>> Django will check if the request URL has language prefix in it. If it
>> doesn't it will add language prefix to the same URL and make web browser to
>> redirect to that new URL.
>>
>> You can see the flow using web browser developer tool.
>>
>> On Fri, Feb 21, 2020 at 8:43 PM Szocs Arnold 
>> wrote:
>>
>>> I am using i18n_patterns to change the language prefix in url. It s
>>> working fine ones the language cookie is set. The problem is that it's
>>> adding /en/ when I trying to access a page without the language code in
>>> private window, even though my preferred language is not en (the default
>>> one set in settings.LANGUAGE_CODE). The Django documentation says that how
>>> django discovers language prefference:
>>>
>>> Django documentation says it will use the following to choose the
>>> language:
>>>
>>> First, it looks for the language prefix in the requested URL.Failing
>>>> that, it looks for the LANGUAGE_SESSION_KEY key in the current user’s
>>>> session.Failing that, it looks for a cookie. The name of the cookie used is
>>>> set by the LANGUAGE_COOKIE_NAME setting. (The default name is
>>>> django_language.) Failing that, it looks at the Accept-Language HTTP
>>>> header. This header is sent by your browser and tells the server which
>>>> language(s) you prefer, in order by priority. Django tries each language in
>>>> the header until it finds one with available translations. Failing that, it
>>>> uses the global LANGUAGE_CODE setting.
>>>>
>>>
>>> So the reason why I get /en/ prefix in my url, when there is no any
>>> cookie set is because of the Accept-Language HTTP header. How can i solve
>>> that if somebody visits my site for the first time when there is no cookie,
>>> the i18n to go to the final step to get the language from the global
>>> LANGUAGE_CODE?
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>>
>> --
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.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/CAN7EoAbU5kUTc0UrX0etqp_s8bC4zK0L-wHpYNuoUB585DM7Og%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN7EoAbU5kUTc0UrX0etqp_s8bC4zK0L-wHpYNuoUB585DM7Og%40mail.gmail.com?utm_medium=email_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/CABRfZM%2BbayBueLk68gC8NiQhrkisG8G%2B_OktDdOr9uR%3DW2yk_w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABRfZM%2BbayBueLk68gC8NiQhrkisG8G%2B_OktDdOr9uR%3DW2yk_w%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAak5nkd9mMVGRbUXzZc5g2A885cwKfQZoPf4QTXTdxzVA%40mail.gmail.com.


Re: Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Aldian Fazrihady
I have these working module combinations, but my Python is 3.6.9:
asgiref==2.2.0
channels==2.0.2
channels_redis==2.3.0
daphne==2.1.0
Django==2.2.4
django-redis==4.10.0
redis==3.3.6
Twisted[tls,http2]
uwsgi==2.0.18
websockets==6.0

On Sat, Feb 22, 2020 at 3:25 AM Larry Martell 
wrote:

> I am in a bit of version hell. Not fun on a Friday afternoon.
>
> Django 2.0.4, python 3.5.2
>
> Trying to get channels, websockets, daphne, and asgiref working.
>
> When I installed the latest channels it did not work with my version
> of mysqlclient and some googling led me to install 2.0 of channels.
> That worked fine with the dev server, and then I wanted to deploy my
> app in prod. In prod we use nginx/uwsgi so I was going to replace
> uwsgi with daphne. When I tried to run daphne I got:
>
> ImportError: No module named 'asgiref.compatibility'
>
> Googling that I was led to upgrade asgiref to the latest version.
> After I did that I got:
>
> AttributeError: module 'asyncio.coroutines' has no attribute
> '_is_coroutine'
>
> Have not been able to get past this one.
>
> Anyone have any thoughts? Would upgrading django and python fix these
> issues? I am planning on doing that soon, but I was not planning on
> doing that now. Don't want to upgrade now and then find I still have
> issues. Can I get all this to work with my current versions and
> upgrade later?
>
> TIA!
> Larry
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY5SQzRG-7EuEM8rZvOfQor5bBOjt%3DBV1Qsbn9%2BBhMx12g%40mail.gmail.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbSAVUT%3D8sg1o-0oczCfjfRhtGwrMDE31YBt9N%2Bm96YmA%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Aldian Fazrihady
When you are using Nginx, it is assumed you are trying to make a production
environment.
On production environments you don't want your backend code execution to be
slowed down by something like serving people downloading static images.
On production environments, Django will focus on its purpose, which is to
handle application code logic.

Static files handling should be delegated to other server such as Nginx.
The static file folder will be referenced directly by Nginx.
Most of static files, such as images are so irrelevant to your backend
application logic so that they can be cached on the browser.


On Thu, Feb 20, 2020 at 11:36 PM Robert F. 
wrote:

> I'm trying to understand how static files are served up by Django using a
> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The
> website serves up templates correctly except that the templates can't see
> my CSS stylesheet.  When I go to a page, for example ```
> 127.0.0.1:8000/app1/``` <http://127.0.0.1:8000/app1/> and view the
> source, I see this in my HTML template:
>
> 
>
> If I click on the href link, I get a page "Not Found" at the address ```
> http://127.0.0.1:8000/static/css/main.css```
> <http://127.0.0.1:8000/static/css/main.css>.  This seems like it should
> be the correct link but the template can't see the main.css stylesheet as I
> would expect.
>
> Here are the relevant files in my 'mysite' project located in
> /Users/me/projects/django/django-staticfiles:
>
> ├── app1
> │   ├── templates
> │   │   └── app1
> │   │   └── index.html
> ├── mysite
> │   ├── settings.py
> │   └── wsgi.py
> ├── static
> │   └── css
> │   └── main.css
> ├── static-final
> │   ├── admin
> │   │   ├── css
> │   │   ├── fonts
> │   │   ├── img
> │   │   └── js
> │   └── css
> │   └── main.css
>
> Here are the relevant settings:
>
> # mysite/settings.py
> ...
> DEBUG = False
> ALLOWED_HOSTS = ['127.0.0.1', ]
> ...
> INSTALLED_APPS = [
> 'django.contrib.staticfiles',
> 'app1',
> ]
> ...
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
> ...
>
> I installed Gunicorn into my virtual environment and run it with this
> command:
>
> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>
> I installed Nginx using Homebrew.  Here is the part of nginx.conf that
> includes my Nginx settings:
>
> # /usr/local/etc/nginx.conf
> ...
> http {
> ...
> server {
> listen  8080;
> server_name localhost;
> }
> ...
> include server/*;
> }
>
> Here is my Nginx configuration:
>
> # /usr/local/etc/nginx/servers/django-staticfiles
> server {
> listen 80;
> server_name 127.0.0.1;
>
> location / {
> proxy_pass http://127.0.0.1:8000;
> }
>
> location /static/ {
> alias /Users/me/projects/django/django-staticfiles/static-final/;
> }
> }
>
> I should add that when I stop Gunicorn and start Django's development
> server with DEBUG = True, the app1 template accesses the main.css file
> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I
> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but
> I've just set it up so I can compare and contrast how Django manages static
> files in development versus production.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75f129a6-2dbf-47cc-b4ea-08008b30b047%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/75f129a6-2dbf-47cc-b4ea-08008b30b047%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbn3p8AcQoz3yygaqmdKz-X4Z84fZQrQcVh3Pm0eENkmA%40mail.gmail.com.


Re: Django i18n_patterns default language

2020-02-21 Thread Aldian Fazrihady
A web browser has language preference setting. When a request made to your
Django server,  your browser reads its language preferences and it put it
in the request "Accept-Language" header.
Django will check if the request URL has language prefix in it. If it
doesn't it will add language prefix to the same URL and make web browser to
redirect to that new URL.

You can see the flow using web browser developer tool.

On Fri, Feb 21, 2020 at 8:43 PM Szocs Arnold 
wrote:

> I am using i18n_patterns to change the language prefix in url. It s
> working fine ones the language cookie is set. The problem is that it's
> adding /en/ when I trying to access a page without the language code in
> private window, even though my preferred language is not en (the default
> one set in settings.LANGUAGE_CODE). The Django documentation says that how
> django discovers language prefference:
>
> Django documentation says it will use the following to choose the language:
>
> First, it looks for the language prefix in the requested URL.Failing that,
>> it looks for the LANGUAGE_SESSION_KEY key in the current user’s
>> session.Failing that, it looks for a cookie. The name of the cookie used is
>> set by the LANGUAGE_COOKIE_NAME setting. (The default name is
>> django_language.) Failing that, it looks at the Accept-Language HTTP
>> header. This header is sent by your browser and tells the server which
>> language(s) you prefer, in order by priority. Django tries each language in
>> the header until it finds one with available translations. Failing that, it
>> uses the global LANGUAGE_CODE setting.
>>
>
> So the reason why I get /en/ prefix in my url, when there is no any cookie
> set is because of the Accept-Language HTTP header. How can i solve that if
> somebody visits my site for the first time when there is no cookie, the
> i18n to go to the final step to get the language from the global
> LANGUAGE_CODE?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbU5kUTc0UrX0etqp_s8bC4zK0L-wHpYNuoUB585DM7Og%40mail.gmail.com.


Re: Production deployments and Version Control for DJango projects

2020-02-14 Thread Aldian Fazrihady
Try ansible-playbook

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Sab, 15 Feb 2020 10.34, Ram  menulis:

> Hi,
>
> I'm currently having development server with Digital Ocean for our Django
> based web site. We are currently copying new code manually to project
> folder and running makemigrations and migrate. Since this manual process is
> not sustainable in future, I would like to implement right process and
> tools for source code management and both dev & production servers
> deployments.
>
> Could someone provide me documented procedure and tools to automate the
> deployment and manage the version control. I know GIT is one option but do
> you guys any other open source tools for souce code management.
>
> Best Regards,
> ~Ram
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BOi5F0FUwTB9HJj%2BSvcaUQQabg8C9bRYmZNW%3DzDak0dywrNzA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2BOi5F0FUwTB9HJj%2BSvcaUQQabg8C9bRYmZNW%3DzDak0dywrNzA%40mail.gmail.com?utm_medium=email_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/CAN7EoAYyqaxDMPZvHnyanCMQxw_fGs5-5vQNtFYY2UXAX043cw%40mail.gmail.com.


Re: Django Simple Query very slow at thousand data.

2020-02-07 Thread Aldian Fazrihady
Using the way you specify model in your view, the resulting query won't be
efficient.
On each loop in your template, the foreign keys will be automatically
queried, which is the cause of the slowness.

You need to override the get_queryset method of your view and generate the
ORM query there.
In the ORM query, please add select_select related to the foreign keys.

On Fri, Feb 7, 2020 at 11:57 PM Eric Kiser  wrote:

> Okay so I've used django on two of my projects with the following criteria:
>
> Hosted @: PythonAnywhere
> Database: MySQL and SQLite
>
> PROBLEM: At first with a few hundred data the query is okay, but when I am
> querying 2,000 of data it takes 3 minutes to load it on a simple table.
> This is not normal because I've read that a thousand data shouldn't be a
> problem.
>
> Here are my codes:
>
> Models.py
> class Outgoing(models.Model):
> base_in = models.ForeignKey('warehouse.Incoming', related_name='out',
> on_delete = models.SET_NULL, null=True)
> trans_date = models.DateField('Date', default=timezone.now)
> trans_type = models.CharField('Type', max_length=50, choices =
> OUTGOING_TYPE)
> form_no = models.CharField('FORM No', max_length=20, default=0)
> project_site = models.ForeignKey(ProjectSite,
> related_name='out_project_site', null=True, on_delete = models.SET_NULL)
> released_by = models.ForeignKey(User, related_name='out_released_by',
> default='', on_delete = models.SET_NULL, null=True)
> released_to = models.ForeignKey(User, related_name='out_released_to',
> blank=True, null=True, on_delete = models.SET_NULL)
> released_out = models.ForeignKey(Outsider,
> related_name='outsider_released_to', blank=True, null=True, on_delete =
> models.SET_NULL)
> unit = models.ForeignKey(UnitProfile, related_name='user_unit',
> blank=True, null=True, on_delete = models.SET_NULL)
>
> quantity = models.DecimalField('Quantity', db_index=True,
> max_digits=20, decimal_places=2, default=0)
> details = models.CharField('Details', max_length=200, default='')
> attachment = models.FileField('Form', upload_to='incoming_form',
> blank=True)
>
> create_date = models.DateTimeField('Date Created', auto_now_add=True)
>
> def __str__(self):
> return "%s" %(self.trans_date)
>
> class Meta:
> verbose_name = 'Outgoing'
> verbose_name_plural = 'Outgoings'
>
>
> Views.py
> class OutgoingView(ListView):
> model = Outgoing
> template_name = 'warehouse/outgoing_page.html'
> context_object_name = 'all_out'
>
>
> outgoing_page.html
> 
> {% for outgoing in daily_out %}
> 
> {{
> outgoing.trans_date }}
> {{
> outgoing.trans_type }}
> {{
> outgoing.form_no }}
> {{
> outgoing.base_in.item }}
> {{ outgoing.quantity|intcomma }}
> {{
> outgoing.project_site }}
> {{
> outgoing.unit }}
> {{
> outgoing.released_by }}
> {{
> outgoing.released_to }}
> {{
> outgoing.released_out }}
> {{
> outgoing.details }}
> 
> 
> 
> 
> {% endfor %}
> 
>
>
> What I did:
> - simplified my views, no ordering even coz I'm told sorting takes another
> hit on the database.
> - ask help from the guys at pythonanywhere thinking I might not have
> enough workers, they told me there's no problem with my account.
> - shift from SQLite to MySQL and still the same.
>
> Help would really be nice, 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/813e339d-e9ce-45f9-a391-a497ae5d3857%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/813e339d-e9ce-45f9-a391-a497ae5d3857%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldia

Re: rest-auth vs djoser

2020-02-05 Thread Aldian Fazrihady
When chose to use djoser about a year ago, I saw it was more recently
updated than rest-auth, so I tried djoser first.
After using it, I found it is very easy to use and customize, so I stick
with djoser.

On Thu, Feb 6, 2020 at 4:28 AM Emmanuel klutse  wrote:

> Hello team,
> hope we are all doing great.
> I'm a beginner working on my first DRF project, I am trying to build an
> e-commerce site.
> I want to know the difference between django rest-auth and djoser, and
> which of them will be a good fit for my project.
>
> 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/CAAw18mBkSuSL6nat21ooewh9WXf%2B3HG%3Du-b%3DHTKrO_eEOwSzmA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAw18mBkSuSL6nat21ooewh9WXf%2B3HG%3Du-b%3DHTKrO_eEOwSzmA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYSJg9D6hpdxzb9kbtE%2B5Jnm5a2E1KTNfp7YZkizhuhpw%40mail.gmail.com.


Re: How do I use Daphne without websocket "secure"?

2020-01-30 Thread Aldian Fazrihady
I don't think you should do anything.
My daphne becomes secure/wss because it is behind nginx HTTP termination.

On Thu, Jan 30, 2020 at 3:06 PM Jeremy Wai  wrote:

> My procfile has this line:
> web: daphne APbackend.asgi:application --port $PORT --bind 0.0.0.0
>
> On Thursday, January 30, 2020 at 12:04:05 AM UTC-8, Jeremy Wai wrote:
>>
>> I have a embedded system that doesn't support the 'secure' part of
>> websocket secure, how do i disable the websocket "secure" part of my daphne
>> application? I don't see it anywhere in my code that i've actually set it
>> up.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8e6f77e6-575e-4981-ad41-11bbc3d61908%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8e6f77e6-575e-4981-ad41-11bbc3d61908%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZaG0OD7p%2BDvXy4Kk2wdZ_xfqsz7i9_hei-g%2Bui444iVQ%40mail.gmail.com.


Re: Best Django Deployment

2020-01-23 Thread Aldian Fazrihady
Google AppEngine fFex will handle everything for you, but for my
requirement, the price is too expensive, so I don't use it and I also don't
use any Google cloud product to host my Django app.
If your app code is not efficient, it means it will use more resources,
then the monthly bill of AppEngine Flex will also be higher.

Google AppEngine flex is using nginx.

On Fri, Jan 24, 2020 at 2:46 AM Motaz Hejaze  wrote:

> Any help friends ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/841a0431-f1c0-473b-85df-4e6377f2bbdd%40googlegroups.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbT10tmK87u_kLVLqYHV-JUnBgEPDziq%3DjfTwXkfjqzLA%40mail.gmail.com.


Re: Suitable Frontend for Django Ract

2019-12-21 Thread Aldian Fazrihady
matwrial-ui

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

Pada tanggal Min, 22 Des 2019 11.22, Balaji Shetty 
menulis:

> Hi
>
> I want to know suitable frontend for Django. CURRENTLY I use bootstrap for
> frontend.
>
> React or Angular  or Vuejs or any other
>
> It should be
>
>
> Easy to learn
> Provide highest security
> Easily scalable
> Can create mobile App
>
>
> --
> Mr Shetty Balaji
> Asst. Prof.
> IT Department
> SGGS I
> Nanded. My. India
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOu6GSVSDg_miPQJ2tUw8rkuh4Pq-y85GZnQznQk_BRrAw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOu6GSVSDg_miPQJ2tUw8rkuh4Pq-y85GZnQznQk_BRrAw%40mail.gmail.com?utm_medium=email_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/CAN7EoAac0nBJ0D2fN9ay8US7_qg8VKRs97a%2BR1izDQ9FRNURZQ%40mail.gmail.com.


QuerySet.first() gives me unexpected result.

2019-11-22 Thread Aldian Fazrihady
Django Users,

Can you tell me if this is bug in django or not:
[image: Screenshot from 2019-11-23 09-21-29.png]

The fact that `x.get()` doesn't throw exception tell me that QuerySet only
have one element in it.
However, `x.first()` gives me different result on `price_per_kg` field.
Instead of giving me the expected `12000`, it gives me `15000`.
-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZH2%2B3OR8i_Ci3Pe3xXbhH5rTKTaVtt2hg9VZxD4QEhaA%40mail.gmail.com.


Re: DRF UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6

2019-11-20 Thread Aldian Fazrihady
e 'split'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner
> self.run()
>   File "C:\Python37\lib\threading.py", line 865, in run
> self._target(*self._args, **self._kwargs)
>   File "C:\Python37\lib\socketserver.py", line 652, in process_request_thread
> self.handle_error(request, client_address)
>   File "C:\Python37\lib\site-packages\django\core\servers\basehttp.py", line 
> 73, in handle_error
> super().handle_error(request, client_address)
>   File "C:\Python37\lib\socketserver.py", line 380, in handle_error
> traceback.print_exc()
>   File "C:\Python37\lib\traceback.py", line 163, in print_exc
> print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
>   File "C:\Python37\lib\traceback.py", line 104, in print_exception
> type(value), value, tb, limit=limit).format(chain=chain):
>   File "C:\Python37\lib\traceback.py", line 521, in __init__
> self._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   [Previous line repeated 8 more times]
>   File "C:\Python37\lib\traceback.py", line 531, in _load_lines
> frame.line
>   File "C:\Python37\lib\traceback.py", line 285, in line
> self._line = linecache.getline(self.filename, self.lineno).strip()
>   File "C:\Python37\lib\linecache.py", line 16, in getline
> lines = getlines(filename, module_globals)
>   File "C:\Python37\lib\linecache.py", line 47, in getlines
> return updatecache(filename, module_globals)
>   File "C:\Python37\lib\linecache.py", line 137, in updatecache
> lines = fp.readlines()
>   File "C:\Python37\lib\codecs.py", line 322, in decode
> (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: 
> invalid start byte
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "C:\Python37\lib\threading.py", line 885, in _bootstrap
> self._bootstrap_inner()
>   File "C:\Python37\lib\threading.py", line 927, in _bootstrap_inner
> (self.name, _format_exc()), file=_sys.stderr)
>   File "C:\Python37\lib\traceback.py", line 167, in format_exc
> return "".join(format_exception(*sys.exc_info(), limit=limit, 
> chain=chain))
>   File "C:\Python37\lib\traceback.py", line 121, in format_exception
> type(value), value, tb, limit=limit).format(chain=chain))
>   File "C:\Python37\lib\traceback.py", line 521, in __init__
> self._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   File "C:\Python37\lib\traceback.py", line 533, in _load_lines
> self.__context__._load_lines()
>   [Previous line repeated 9 more times]
>   File "C:\Python37\lib\traceback.py", line 531, in _load_lines
> frame.line
>   File "C:\Python37\lib\traceback.py", line 285, in line
> self._line = linecache.getline(self.filename, self.lineno).strip()
>   File "C:\Python37\lib\linecache.py", line 16, in getline
> lines = getlines(filename, module_globals)
>   File "C:\Python37\lib\linecache.py", line 47, in getlines
> return updatecache(filename, module_globals)
>   File "C:\Python37\lib\linecache.py", line 137, in updatecache
> lines = fp.readlines()
>   File "C:\Python37\lib\codecs.py", line 322, in decode
> (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 1110: 
> invalid start byte
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/036fca75-1923-4628-b645-7904c1c1555f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/036fca75-1923-4628-b645-7904c1c1555f%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZPzztNAomi376%2B9wGHjm7H8VwQBQ-4J%2BfegJPknoQFMg%40mail.gmail.com.


Re: Django Admin templates not being overwritten by app templates

2019-11-10 Thread Aldian Fazrihady
You need to reorder the app list in INSTALLED_APP setting, so
`django.contrib.admin` is located lower than your app`.

On Mon, Nov 11, 2019 at 3:49 AM Alexander Beach  wrote:

> I am trying to create registration forms using Django's built in auth
> forms.  However, when using the Django admin, the Django admin templates
> are always being used.
>
> My application structure is as follows:
>
> ├── bug
> │   ├── __init__.py
> │   ├── __pycache__
> │   ├── settings.py
> │   ├── urls.py
> │   └── wsgi.py
> ├── db.sqlite3
> ├── manage.py
> └── mysite
> ├── admin.py
> ├── apps.py
> ├── __init__.py
> ├── migrations
> │   └── __init__.py
> ├── models.py
> ├── registration
> ├── templates
> │   └── registration
> │   └── password_reset_form.html
> ├── tests.py
> └── views.py
>
>
>
> My urls.py is the following:
>
>
> from django.contrib import admin
> from django.conf.urls import include, url
> from django.urls import path
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> url(r'^accounts/', include('django.contrib.auth.urls'), name="auth"),
> ]
>
>
>
> The mysite/templates/registration/password_reset_form.html is not being
> rendered.  When I navigate to localhost:8000/accounts/password_reset, i can
> see that its using the Django Admin template. See attached screenshot.  I
> am expecting my custom template for the reset form to be rendered.
>
> I am using Django version 2.2.5 and python 3.7.3
>
> Is this a bug or the expected behavior? I don't want to remove the admin
> app.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c718299d-53f6-4e56-8976-a2040f3449ac%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c718299d-53f6-4e56-8976-a2040f3449ac%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAabPjVcLDgou_Ee_aK899E3KiVvxSGSkqA0hqXhDiU1BQ%40mail.gmail.com.


Re: User Password Automatically changes after 15 days

2019-10-14 Thread Aldian Fazrihady
It doesn't make sense that something has a feature to automatically change
user's password. It is because only the user is allowed to know the plain
text of his password.
Backend can only know the hash of the password.

Please check if your deployment has a data fixtures that overrides some
existing user table.

On Mon, Oct 14, 2019 at 11:27 PM developer panther 
wrote:

> Hello all,
>
> I am facing a serious issue in production, that password of users table is
> automatically changes after 15 days or probably 2 weeks
> we are using
> server:- AWS server EC2 instance
> database:- MYSql
> Usertable :- Django auth table
>
> please look into this on priority
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1e0659bb-44d7-4c1b-8422-f10bc01c598a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1e0659bb-44d7-4c1b-8422-f10bc01c598a%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbWUR5hvtPDoiePtPk%2BXm-bw%2BTN%3DCg6KmKxMKWwZdao7w%40mail.gmail.com.


Re: Should there be separate django app for every user type in a django project?

2019-10-13 Thread Aldian Fazrihady
Hi,
a new Django app should be based on a new business feature/aspect, not user
type.
If different behavior needed for different type of user, you can check the
permission or group of the user:
https://docs.djangoproject.com/en/2.2/topics/auth/default/

On Mon, Oct 14, 2019 at 6:33 AM test user  wrote:

> Hi,
>
> I have got multiple user types(around 4 to 5) in my Django project. Should
> i make separate Django app for each user type? Each user type will have
> different interface after they log into the website.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f7dc3b18-ab79-42ea-9ba2-7d3b2b8187fb%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f7dc3b18-ab79-42ea-9ba2-7d3b2b8187fb%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAa%3DCBxyU9%2B0_JbgeF%2Berr74HQtDPhM6om1LZNhz-8kfLg%40mail.gmail.com.


Re: Micro Service Architecture

2019-10-12 Thread Aldian Fazrihady
Microservice embraces unix philosophy: "do one thing and do it well".
So you should define Django app that follows that principle.
You then wrap that Django app to be accessed behind Nginx or Apache that
exposes port 80 to be accessed by other micorservices/clients.
That nginx+django bundle can be further be containerized to be easily
deployed to cloud and managed using cloud provider API.

There is no need of Django specific microservice stack because clients only
care about standard protocols being used.

Here is an existing discussion:
https://www.reddit.com/r/django/comments/ailhhi/how_to_design_microservices_architecture_in/

On Sat, Oct 12, 2019 at 6:13 PM Motaz Hejaze  wrote:

> This is a good question , i dont know why no body answered it !!
>
> On Fri, 11 Oct 2019, 7:38 pm Uzama Zaid Mohammed Jaward, <
> uzamajaw...@gmail.com> wrote:
>
>> Hi all
>>
>> What are the tech stack is good for micro service architecture in Django
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAOHA2_2tFnyeEsKZXx2BrCTp_WitdSuLkzNVZ4%3DaJ1g3L4iYOg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAOHA2_2tFnyeEsKZXx2BrCTp_WitdSuLkzNVZ4%3DaJ1g3L4iYOg%40mail.gmail.com?utm_medium=email_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/CAHV4E-fBYQQdmKMM%3D1OO8%3DMhP7YiVfTWsx2g-rhwHJRgU%3DxiWA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHV4E-fBYQQdmKMM%3D1OO8%3DMhP7YiVfTWsx2g-rhwHJRgU%3DxiWA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAaq-sDsFQwhMxmihR9pbhVJw9HdiEmBFtr9%2B81XgMWHsA%40mail.gmail.com.


Re: How to increase file upload size in twitter in django rest api

2019-10-09 Thread Aldian Fazrihady
I haven't found any restriction on file upload size. Did you experience
errors while uploading?

On Thu, Oct 10, 2019 at 12:04 PM ajitkumar 
wrote:

> Hi,
>
> can anyone help me how to increase media upload size in django rest api,
>
>
>
>
> Thanks in advance.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/17cfe1bf-b9ee-012e-e76e-d661ed2920c4%40entityvibes.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbc9_z63kTzpO4xGfsxjELX_ATOq1VJa7gAWVLbMaFAQA%40mail.gmail.com.


Re: How to prevent empty record in admin subform

2019-10-09 Thread Aldian Fazrihady
tions_list(53)
> LIEUX = Thesaurus.options_list(44)
> com_int_dat = forms.DateTimeField(label="Date", required=False)
> com_int_typ = forms.ChoiceField(label="Type", widget=forms.Select, 
> choices=TYPES)
> com_int_rea = forms.CharField(label="si oui, interventions réalisées" , 
> widget=forms.Textarea, required=False)
> com_int_vue = forms.ChoiceField(label="La participante a-t-elle été 
> contactée/vue ?", widget=forms.Select, choices=VUES)
> com_int_rdv = forms.ChoiceField(label="Avez-vous fixé un nouveau 
> rendez-vous ?", widget=forms.Select, choices=NOUVEAUX)
> com_int_rdv_dat = forms.DateTimeField(label="Si oui, date du prochain 
> rendez-vous", required=False)
> com_int_rdv_lie = forms.ChoiceField(label="Lieu", widget=forms.Select, 
> choices=LIEUX)
>
>  class InterventionCommunautaireInline(admin.TabularInline):
>
> model = InterventionCommunautaire
> """pour qu'il n y ait pas systématiquement 3 lignes de sous-formulaire en 
> base pour une fiche suivi communautaire"""
> extra = 1
> form = InterventionCommunautaireFormAdmin
>
>  class SuiviAppuiCommunitaireFormAdmin(forms.ModelForm):
> """ A class to customised the admin form for Community. """
>
> MOTIFS = Thesaurus.options_list(51)
> com_dat = forms.DateField(label="Date de la demande",required=False)
> com_mot = forms.ChoiceField(label="Motif", widget=forms.Select, 
> choices=MOTIFS,required=False)
> com_det = forms.CharField(label="Détails",required=False)
> com_com = forms.CharField(label="", widget=forms.Textarea,required=False)
>  class SuiviAppuiCommunitaireAdmin(SimpleHistoryAdmin):
>
> list_display = ('com_ide','participante', 'com_dat',)
> search_fields = ('participante','com_dat')
> fieldsets = (
> ('SUIVI / APPUI COMMUNAUTAIRE', {
> 'classes': ('opened',),
> 'fields': ('pat', )
> }),
> ('Demande de suivi / appui communautaire', {
> 'classes': ('opened',),
> 'fields': (('com_dat','com_mot','com_det',), )
> }),
> ('Problèmes rencontrés par la participante / Commentaires libres', {
> 'classes': ('opened',),
> 'fields': (('com_com',), )
> }),
> )
> form = SuiviAppuiCommunitaireFormAdmin
> inlines = [
> InterventionCommunautaireInline,
> ]
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7cb32cb-514c-4855-8a3b-5102fb083726%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e7cb32cb-514c-4855-8a3b-5102fb083726%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZGmK32x6i0fuWdNUiEvrmvTA5pqfegZtXQs2Lpup8UGg%40mail.gmail.com.


Re: getting error when i changed database sqllite3 to mysql

2019-10-05 Thread Aldian Fazrihady
Have you created the database on MySQL?

On Sun, Oct 6, 2019 at 4:36 AM Gulsher Khan 
wrote:

> I trying to change default database(sqllite) which is given by the Django.
> I want to use mysql database. I put lots of effort but nothing went well. I
> successfully has been install mysql, mysqlclient, mysql-connector whatever
> i have read in the documentation.
>
> I'm using OS: Ubuntu 19.04
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ea48f010-5ea5-4d58-9033-2e83a3e1de06%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ea48f010-5ea5-4d58-9033-2e83a3e1de06%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZJXnYbh9-dteFP0HWj1ipnKhgSpwM0s%3DH-2-QEN-upQA%40mail.gmail.com.


Re: How to generate a unique 9 digit random id for every registered user?

2019-10-04 Thread Aldian Fazrihady
import random
import string

from django.db import models


def generate_random_code():
return ''.join(random.choices(string.ascii_uppercase + string.digits, k=9))


class MyModel(models.Model):
code = models.CharField(
max_length=9, default=generate_random_code, db_index=True
)

Hi, please try the code above.

On Fri, Oct 4, 2019 at 9:53 PM yashwanth .k  wrote:

> Hello,
>
> My model consists of user details such as username and his id which is
> auto-generated by DB(indexing).
> Apart from this, I need to assign a random unique 9 digit number for every
> user.
> The reason for assigning a random number to a registered user is to search
> a particular user using his permanent random id which we have generated.
>
> Solutions with the model description will be very 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/8eb92ef2-ffe0-431d-b4aa-3d6c5a119c3f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8eb92ef2-ffe0-431d-b4aa-3d6c5a119c3f%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYykEHF8qxAEc%2BPh71ue%3DKLzpT3P5MuE2Dw58gG2HmUEw%40mail.gmail.com.


Re: Entire Application in Django shuts down with single error

2019-10-01 Thread Aldian Fazrihady
`runserver` is a development server to help you debug your code, so
crashing is a feature.

 To use django on production/staging, please follow this guide:
https://docs.djangoproject.com/en/2.2/howto/deployment/

On Tue, Oct 1, 2019 at 6:14 PM Amit Sharma  wrote:

> I am new to Python and django , I worked on C# and php as developer
> earlier. My problem here is Entire Application in Django shuts down with
> single error.
>
> for example i start my website with "python3 manage.py runserver
> 0.0.0.0:8000" example:-- i have two pages home and register
> 1) if i make error in register page code(register.py) , It shuts down home
> page too. Is there a way to prevent that as in php and C# in both one page
> do not effect other.
> 2) how to work in django with team one errors full team hangs.
>
> 3) How to work with live working websites things may become too risky.
>
> 4) can we make django development as friendly as C#, PHP  . and
> other programming language
>
> also i am not able to find article related to this. kindly help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7d81706a-2f84-4f55-a25c-1bae726a8879%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7d81706a-2f84-4f55-a25c-1bae726a8879%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAZQKYBvkn42j9P9iv01koXAZRzyPBXWDE6KQ3yp0Ysb4w%40mail.gmail.com.


Re: Multiple user roles with permissions

2019-09-25 Thread Aldian Fazrihady
What do you need to clarify regarding this document
https://docs.djangoproject.com/en/2.2/topics/auth/default/#the-permission-required-decorator
 ?

On Wed, Sep 25, 2019 at 9:03 PM Shazia Nusrat  wrote:

> Hi,
>
> I need help to understand implementation of multiple user roles and
> permissions on views/templates/objects. If someone can point me to really
> nice project at GitHub I will be really thankful. I couldn't find one so
> far.
>
> Regards,
> Shazia
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAD83tOx6a4hftc9MAGeweDJ%3DfCuTBXSzc9VT8H6tGOZz%3DbuVQw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAD83tOx6a4hftc9MAGeweDJ%3DfCuTBXSzc9VT8H6tGOZz%3DbuVQw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbjcdkLJQtFiFWAvMVPA4XtMTSc1rfESNECYURTwRef0w%40mail.gmail.com.


Re: convert python 3 to python2

2019-09-25 Thread Aldian Fazrihady
Ankita, why would a new project be forced to use Python 2 by a (probably
old)  package? A well-maintained package must already have its Python 3
version.
Why can't we find an alternative package that uses Python 3? I am curious
about what package that is.

On Sun, Sep 22, 2019 at 12:32 AM Ankita Gupta 
wrote:

> Not related to Django, I have a project made in python3 but due to some
> package installation, i need to convert my project to python2. Is there any
> method or package to solve this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/875549f9-5bca-4280-88fd-db197ca577dc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/875549f9-5bca-4280-88fd-db197ca577dc%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAaiCDsrd3hURY9kb_h%2BA7aMU24aoZk1Dw8oHLAVfkbKTw%40mail.gmail.com.


Re: Staticfiles on S3

2019-09-16 Thread Aldian Fazrihady
Elias, please set up the CORS policy of the S3 bucket:
https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-cors-configuration.html

On Tue, Sep 17, 2019 at 3:44 AM Anthony Goslar 
wrote:

> Try using Django-storages and follow the tutorial on
> simpleisbetterthancomplex.com
>
> This looks like a permissions issue.
>
> I had similar issues with Google Buckets and sorted it out by reading the
> django-storages methods for Google buckets in the source code and then
> making sure all the settings were correct.
>
> Anthony
>
>
> On Mon, 16 Sep 2019, 22:01 Elias Coutinho, 
> wrote:
>
>> It seems that one of the problems is occurring while downloading the
>> files.
>>
>> See this error image:
>>
>> [image: image.png]
>>
>> If I go to Direct Link it usually downloads:
>>
>>
>> https://gsm-gervas.s3.amazonaws.com/static/material/fonts/roboto/fonts/Roboto-Medium.woff2
>>
>> Em qua, 4 de set de 2019 às 23:35, sachinbg sachin <
>> sachinbgsach...@gmail.com> escreveu:
>>
>>> Mention aws key value in setting
>>>
>>> On Thu, Sep 5, 2019, 2:06 AM mohammed habib 
>>> wrote:
>>>
>>>> Did you run python manage.py collectstatic
>>>>
>>>> Are you using static template tags to heed your html link href fields
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On 4 Sep 2019, at 23:06, Elias Coutinho 
>>>> wrote:
>>>>
>>>> Guys good afternoon,
>>>>
>>>> I managed to put my static folder in s3, the problem is that my effects
>>>> already lost power. lol
>>>>
>>>> The staticfiles folder where the auxiliary applications are installed
>>>> stop working, in my case it was django-material, select2 and others.
>>>>
>>>>
>>>>
>>>> If I comment this code
>>>> <https://github.com/CoutinhoElias/gsm/blob/master/gsm/settings.py#L34-L51>
>>>> that is in the settings of my project it works but does not send anything
>>>> to Amazon s3.
>>>>
>>>>
>>>>
>>>> Any suggestion?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/70f224ee-f7a4-468f-9609-db2f8a0be161%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/70f224ee-f7a4-468f-9609-db2f8a0be161%40googlegroups.com?utm_medium=email_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/D42D2706-9340-4450-BC92-35AB0D2C47DB%40gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/D42D2706-9340-4450-BC92-35AB0D2C47DB%40gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/django-users/ainBAyaKDCc/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOs61rziOACLNEH8jhT95zOcJWX6uomoxSLiQAVuU6eb43rNkQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAOs61rziOACLNEH8jhT95zOcJWX6uomoxSLiQAVuU6eb43rNkQ%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>>
>> --
>> Elias Coutinho.
>> Aprender sobre alguns assuntos é fundamental.
>> Aprender sobre Deus é indiscutivelmente o melhor conteú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

Re: Is it a good practice to store all static data dynamically in database rather?

2019-08-31 Thread Aldian Fazrihady
There are already servers that are very good at handling static files, such
as nginx, apache, or amazon S3.
Django will never be better at handling static files compared to those
servers, as on production, Django will always be put behind those web
servers.

Putting static files on database, means Django will be needed to handle
them, which is not efficient.


On Sat, Aug 31, 2019 at 3:35 AM Sapna Tomar  wrote:

> Hey! I'm making a static website (showcasing a hobby club of my college)
> using Django. I have used database for storing most of the content like
> photos, or events since they have multiple instances. Will it also be okay
> to save all the rest of the content which does not necessarily have more
> than one instance, like 'contact info' at the end of the page, or an
> 'About' of the page?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1b86e8d4-6d37-4c85-b3d4-fb7283565fed%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1b86e8d4-6d37-4c85-b3d4-fb7283565fed%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAa4TUKTbVuXFRLOZet3z-8rjkjw4_QB6W9_jP6utVc7DA%40mail.gmail.com.


Re: images in production mode. is pointed to a different path.

2019-08-26 Thread Aldian Fazrihady
On production, static files shouldn't be the burden of django server. Many
people are using Nginx to handle static file. This is the guide:
https://docs.djangoproject.com/en/2.2/howto/static-files/deployment/

On Mon, Aug 26, 2019 at 11:13 PM janderson abreu  wrote:

> Good afternoon, I'm having trouble displaying images in production mode. is 
> pointed to a different path. image src points to -> 
> https://campeonatosdejiujitsu.com/social/file.jpg and 
> https://campeonatosdejiujitsu.com/social/images/file.jpg the images are at: 
> https://campeonatosdejiujitsu.com/static/ file.jpg 
> https://campeonatosdejiujitsu.com/static/file.jpg
> follows the gist with detailing and 
> logs:https://gist.github.com/Jandersolutions/e3af7a1e66ee7b81110d2a869e9ec1c8
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f7105ee2-6236-44e5-99cc-4c2788a34e16%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f7105ee2-6236-44e5-99cc-4c2788a34e16%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYaRg9E_N66SyiEqK09ZzYQogspo_CG%3DANxSu8TwGg4aQ%40mail.gmail.com.


Re: How to customize admin page rendering?

2019-08-25 Thread Aldian Fazrihady
It is open source. Therefore, theoretically, you can customize everything.

For admin page, I have customized many things, such as main templates,
actions, validations, etc

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Sun, 25 Aug 2019, 22:55 Jani Tiainen,  wrote:

> Hi.
>
> Instead of trying that I suggest that you build your own managenent
> console where you can do all you want to.
>
> Admin is a great tool but it can't replace proper management tools. Mainly
> because admin isn't built for much of customization beyond what you can
> find from the docs.
>
> su 25. elok. 2019 klo 17.17 Pema Galey  kirjoitti:
>
>> I want to change/customize rendering of admin default page. For example,
>> in search_field, I want to add placeholder or help text for searching.
>>
>> Help me in customization.
>>
>> 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/f2544e7b-7bf8-4c73-9384-4a932233a319%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f2544e7b-7bf8-4c73-9384-4a932233a319%40googlegroups.com?utm_medium=email_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/CAHn91oeGnxv%3DwR8XQrPxsROugi5p8WRQTkLANzauqGAxSiQikw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHn91oeGnxv%3DwR8XQrPxsROugi5p8WRQTkLANzauqGAxSiQikw%40mail.gmail.com?utm_medium=email_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/CAN7EoAYNCNvOgb8RerTMjPLpeZ4%2BLDsYsrBsM2M4jOV%3DQ73rVg%40mail.gmail.com.


Re: Django Redirect Not Working

2019-08-24 Thread Aldian Fazrihady
If that API is accessed via AJAX, then your JS code needs translate status
302 and Location header to JS code that sets "location.href"

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Sat, 24 Aug 2019, 17:49 göktürk sığırtmaç,  wrote:

> Hello, my UserCreate class is create user via CreateAPIView. I want to
> check. if user is auth, auth user directly to 'profile' URI.
>
> class UserCreate(generics.CreateAPIView):
>
> serializer_class = UserCreateSerializer
> permission_classes = (~IsAuthenticated,)
> queryset = User.objects.all()
>
> def __init__(self):
> if IsAuthenticated:
> print("hello")
> redirect("profile/")
>
>
> code above is working print method but not working redirect method.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9369cce-3734-4bff-ac53-ce785918362b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d9369cce-3734-4bff-ac53-ce785918362b%40googlegroups.com?utm_medium=email_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/CAN7EoAZfY%2B%3D9_Qk%2BGC2vmCaAj_STxRqM4Hf832cEWEySi6WN0w%40mail.gmail.com.


Re: Getting data from the URL in Django get request

2019-08-13 Thread Aldian Fazrihady
Please read this
https://docs.djangoproject.com/en/2.2/topics/http/urls/#path-converters

On Tue, Aug 13, 2019 at 6:13 PM Suraj Thapa FC 
wrote:

>
> How can I fetch the particular field from. URL in get request
> For eg the URL is 192.168.0.1:3000/course/5d567hfbjy7/abc
>
> I want to fetch "5d567hfbjy7" from the url
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPjsHcHMtL7MRHxwftA3dgUha0RqW1%2BYLxROvmhErHTLuwEkdQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPjsHcHMtL7MRHxwftA3dgUha0RqW1%2BYLxROvmhErHTLuwEkdQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbEnhU0QvmX9FGbs2UOuHjMmLVDOwYAfqODt%3D4Ejpwdmg%40mail.gmail.com.


Re:

2019-07-30 Thread Aldian Fazrihady
I see. As Jani has implied, there is currently no idiomatic way to do it.
Here is one way to do it:
https://stackoverflow.com/questions/11529216/django-multiple-file-field

The official way is probably still in progress:
https://code.djangoproject.com/ticket/28554

On Tue, Jul 30, 2019 at 12:51 PM Suraj Thapa FC 
wrote:

> Actually I'm asking to store multiple files in a single model field and
> handling each of them
>
> On Mon, 29 Jul, 2019, 9:05 PM Jani Tiainen,  wrote:
>
>> My mistake.
>>
>> I thuought that OP was asking about uploading and storing multiple files
>> to model.
>>
>> First part (uploading) is easy since docs do cover that.
>>
>> Second part is tricky since it requires data structure capable of storing
>> multiple files and there are so many ways to do that.
>>
>>
>>
>> ma 29. heinäk. 2019 klo 18.22 Aldian Fazrihady 
>> kirjoitti:
>>
>>> Multiple file uploads already there for many years. The link I shared
>>> above show you how to do that the Django way.
>>>
>>> Regards,
>>>
>>> Aldian Fazrihady
>>> http://aldianfazrihady.com
>>>
>>> On Mon, 29 Jul 2019, 21:52 Jani Tiainen,  wrote:
>>>
>>>> Hi.
>>>>
>>>> TL; DR; you can't.
>>>>
>>>> You though can upload multiple files just fine you just need to handle
>>>> them manually.
>>>>
>>>> Also if you plan to keep files around your models must enable that.
>>>>
>>>>
>>>> ma 29. heinäk. 2019 klo 15.48 Suraj Thapa FC 
>>>> kirjoitti:
>>>>
>>>>> How can I create a file field which one can upload Multiple files in
>>>>> it...
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com?utm_medium=email_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/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com?utm_medium=email_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/CAN7EoAYAh%2Bou8fyzcBhyHn25SDx7%3D3Vw%2BY7OGY2%2B%3D3fjk-C0kg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAN7EoAYAh%2Bou8fyzcBhyHn25SDx7%3D3Vw%2BY7OGY2%2B%3D3fjk-C0kg%40mail.gmail.com?utm_medium=email_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/CAHn91odErG3F4HGUCBFFh6oQdmg3CEDC2N3gCLNUUeUPrm1bbw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91odErG3F4HGUCBFFh6oQdmg3CEDC2N3gCLNUUeUPrm1bbw%40mail.gmail.com?utm_medium=email_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/CAPjsHcHmsSHpz5CQ2%3DiUaBBEu7YBu-x2yQq6DFkD5jN2ZRM2rg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPjsHcHmsSHpz5CQ2%3DiUaBBEu7YBu-x2yQq6DFkD5jN2ZRM2rg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbZaPq2fs9YLN40OiY_9aWPPw%3D9JwL%3D1Etr3ugO_tVEXw%40mail.gmail.com.


Re: forms - switch off the validation

2019-07-29 Thread Aldian Fazrihady
You probably can extend the form class and override the is_valid method.
Make the new is_valid to always return True.

On Tue, Jul 30, 2019 at 11:42 AM Kai Kobschätzki 
wrote:

> Heiho,
>
> I wrote a form in forms.py with some validation stuff, especially with
> def clean_field(). All fine. But in some usecases I would prefare to
> switch off at least some of the validation. For example it make no sense
> to check for a double id when I want to delete a reccord. Is it possible
> to swith them off with reuse the form and not with write nearly the same
> form (don't repeat yourself..).
>
> Thanks and Greetings,
>
> bengoshi
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/41b2edc1-307a-a0e6-d389-a0051d38c787%40gmail.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAY8Xq7hW_9DPw0gwvLBdF9JiXuN1%2B%3DWNTBcM%2BqAVcFsFA%40mail.gmail.com.


Re: Only for specific region

2019-07-29 Thread Aldian Fazrihady
Huge app such as Netflix tries to do that, and people always can find
workaround. Why do you also want such feature?  Licensing limitation such
as Netflix?

On Tue, Jul 30, 2019 at 8:08 AM Sebastian Jung 
wrote:

> Hello,
>
> I want that my Website only German user can Open it and another User from
> Others Region a template Show, that they Not live in Germany.
>
> 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/3191e21a-4b74-415a-ba1f-8c5dee0ed606%40googlegroups.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAb_Y-usVgE41RN%3DFTx0P5hcuMgVZ_L8vuPyhjukkghcGA%40mail.gmail.com.


Re:

2019-07-29 Thread Aldian Fazrihady
Multiple file uploads already there for many years. The link I shared above
show you how to do that the Django way.

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Mon, 29 Jul 2019, 21:52 Jani Tiainen,  wrote:

> Hi.
>
> TL; DR; you can't.
>
> You though can upload multiple files just fine you just need to handle
> them manually.
>
> Also if you plan to keep files around your models must enable that.
>
>
> ma 29. heinäk. 2019 klo 15.48 Suraj Thapa FC 
> kirjoitti:
>
>> How can I create a file field which one can upload Multiple files in
>> it...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com?utm_medium=email_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/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com?utm_medium=email_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/CAN7EoAYAh%2Bou8fyzcBhyHn25SDx7%3D3Vw%2BY7OGY2%2B%3D3fjk-C0kg%40mail.gmail.com.


Re:

2019-07-29 Thread Aldian Fazrihady
https://docs.djangoproject.com/en/2.2/topics/http/file-uploads/

On Mon, Jul 29, 2019 at 7:48 PM Suraj Thapa FC 
wrote:

> How can I create a file field which one can upload Multiple files in it...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYOWne%3D0Zj3Ma3K5nJpGhUbXE59--f29HE1bnpduDW44A%40mail.gmail.com.


Re: LANGUAGE_CODE

2019-07-28 Thread Aldian Fazrihady
Hi Yves, please clear cookies and refresh your django app page afterwards.

It is possible to not use cookies at all regarding i18n if you use language
code as part of URL. I always prefer using URL for i18n.

On Mon, Jul 29, 2019 at 1:08 AM Yves de Champlain  wrote:

> HI
>
> Django translation works very well for me, except that when I try to
> change LANGUAGE_CODE in settings.py, my site remains in French. I need to
> change my OS system settings to see the English version.
>
> I have two languages, English as default and a French Translation.
>
> LANGUAGES = (
> ('en', _('English')),
> ('fr', _('French')),
> )
>
> LANGUAGE_CODE = 'en'
>
> Thanks for your insights !
>
> yves
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3a301603-3237-4674-9d8d-2f6362d3154e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3a301603-3237-4674-9d8d-2f6362d3154e%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbuxKZ%3DzrmnAMAWxGpcFe-sFvu9x16VWRQe%3DWa8NrLUPw%40mail.gmail.com.


Re: UserCreationForm decode str object has not decode attribute

2019-07-18 Thread Aldian Fazrihady
url_safe_base64_encode returns string, and strings don't have decode method.
However, bytes objects have decode method.

string.encode will change string to bytes.
bytes.decode will change bytes to string.

On Thu, Jul 18, 2019 at 8:28 PM Ahmet İnal  wrote:

>
>
> What's wrong taht code if i try register i seeing.
>
> AttributeError at /register/
>
> 'str' object has no attribute 'decode'
>
> 'uid':urlsafe_base64_encode(force_bytes(user.pk)).decode('utf-8'), whats
> problem on this line.
>
> class MyUserCreationForm(UserCreationForm):
> class Meta:
> # Yeni Model
> model = User
> # Yeni alanlar
> fields = { 'username', 'password1', 'password2', 'email',}
> exclude = ['Avatar','gender','birth_date',]
>
>
>
>
>
> def clean_username(self):
> username = self.cleaned_data['username'].lower()
> if username in blacklist:
> raise ValidationError("Lütfen başka bir kullanıcı adı seçin.")
> return username
>
> def save(self, commit=True):
> user = super(UserCreationForm, self).save(commit=True)
> current_site = Site.objects.get_current()
> mail_subject = 'Activate your blog account.'
> message = render_to_string('includes/emails/activation-mail.html', {
> 'user': user,
> 'domain': current_site.domain,
> 'uid':urlsafe_base64_encode(force_bytes(user.pk)).decode('utf-8'),
> 'token':account_activation_token.make_token(user),
> })
> to_email = form.cleaned_data.get('email')
> email = EmailMessage(
> mail_subject, message, to=[to_email]
> )
> email.send()
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0b4256b7-080a-4f85-b4e3-e741ec8447ac%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0b4256b7-080a-4f85-b4e3-e741ec8447ac%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAa3Uz%2B3911ZDYoBvbk9MX7BmGDKhoESC9%3Dp0up5DYG1XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template programming

2019-07-14 Thread Aldian Fazrihady
You need to create a template filter:
https://docs.djangoproject.com/en/2.2/howto/custom-template-tags/

Or use existing template filter:
https://docs.djangoproject.com/en/2.2/ref/templates/builtins/

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Mon, 15 Jul 2019, 00:49 Scyil sharma,  wrote:

> I have space separated words in url.
> How to replace space by an character in html file.
> I know it is easy in view. Py but how to do in html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMHmfnjsmMJ%2BzJj%2B9gZxhcjQnWkyK1boHEX8s2rRjo_6cZg%3D_A%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMHmfnjsmMJ%2BzJj%2B9gZxhcjQnWkyK1boHEX8s2rRjo_6cZg%3D_A%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: having problem in login rest API

2019-07-07 Thread Aldian Fazrihady
It is in user object instead of student object,  right?

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Mon, 8 Jul 2019, 11:12 laya,  wrote:

> Hi,
>
> Please help me in this part, I stuck in some days,
>
> My project is about a university system which professors and students can
> sign up and login. I use Custom User Django which inherits User Django
> Model. It should be mentioned that login is by identity number and
> Student-no and Professor-no.
>
> My codes are as follow:
>
> Models.py:
>
> class CustomUser(AbstractUser):
> USER_TYPE_CHOICES = ((1, 'student'),
>  (2, 'professor'),)
> username = models.CharField(max_length=50, unique=True)
> user_type = models.PositiveSmallIntegerField(choices=USER_TYPE_CHOICES, 
> null=True)
> first_name = models.CharField(max_length=50)
> last_name = models.CharField(max_length=100)
> identity_no = models.PositiveIntegerField(default=0)
> email = models.EmailField(max_length=300,
>   validators=[RegexValidator
>   
> (regex="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.["r"a-zA-Z0-9-.]+$",
>message='please enter the correct 
> format')],
>   )
> date_joined = models.DateTimeField('date joined', default=timezone.now)
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
> is_staff = models.BooleanField(default=False)
>
>
> class Student(models.Model):
> user = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
> entry_year = models.PositiveIntegerField()
> student_no = models.PositiveIntegerField()
>
> def get_full_name(self):
> return self.user.first_name +" "+ self.user.last_name
>
> def __unicode__(self):
> return self.user.first_name +" "+ self.user.last_name
>
> def __str__(self):
> return self.user.first_name +" "+  self.user.last_name
>
>
>
> serializers.py:
>
>
>
> """STUDENT LOGIN"""
> class StudentLoginSerializer(serializers.ModelSerializer):
> user = CustomUserSerializerForLogin()
>
> class Meta:
> model = Student
> fields = [
> "user",
> "student_no", ]
>
> def validate(self, data):  # validated_data
> user_data = data.pop('user', None)
> identity_no = user_data.get('identity_no')
> print("identity_no", identity_no)
> student_no = data.get("student_no")
> user = Student.objects.filter(
> Q(user__identity_no=identity_no) |
> Q(student_no=student_no)
> ).distinct()
> # user = 
> user.exclude(user__identity_no__isnull=True).exclude(user__identity_no__iexact='')
> if user.exists() and user.count() == 1:
> user_obj = user.first()
> else:
> raise ValidationError("This username or student_no is not 
> existed")
> if user_obj:
> if not user_obj.check_password(student_no):  # Return a boolean 
> of whether the raw_password was correct.
> raise ValidationError("Incorrect Credential please try again")
> return user_obj
>
> Views.py:
>
>
> class StudentLoginView(APIView):
> queryset = Student.objects.all()
> serializer_class = StudentLoginSerializer
> def post(self, request, *args, **kwargs):
> data = request.data
> serializer = StudentLoginSerializer(data=data)
> if serializer.is_valid(raise_exception=True):
> new_data = serializer.data
> return Response(new_data, status= HTTP_200_OK)
> return Response(serializer.errors, status=HTTP_400_BAD_REQUEST)
>
> Error:
>
> The error is about check_password attribute which is not existing in
> Student Object.
>
>
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5d22c291.1c69fb81.81d84.d526%40mx.google.com
> <https://group

Re: Deploying a static website

2019-07-03 Thread Aldian Fazrihady
I have never used heroku. By the way, I am using 500 MB of S3 space. I am
only billed 1 cent per month.

On Thu, Jul 4, 2019 at 9:45 AM Django Dojo  wrote:

> Thanks, but what do you think about Heroku?
>
> On Wednesday, July 3, 2019, Aldian Fazrihady  wrote:
>
>> You can also use Amazon S3 to host static website.
>>
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> On Thu, 4 Jul 2019, 09:25 Django Dojo,  wrote:
>>
>>> I’m just learning Django and was trying it out, but is it better to
>>> deploy just using simple html, css and launch using a ftp
>>>
>>> On Wednesday, July 3, 2019, Aldian Fazrihady  wrote:
>>>
>>>> Why does a static website need help from a Python web app framework
>>>> such as Django?
>>>>
>>>> On Thu, 4 Jul 2019, 08:47 Django Dojo,  wrote:
>>>>
>>>>> I’ve created a static website in Django and i would like to know the
>>>>> cheapest and best way to design ploy it.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/c2c4536d-6de9-46c4-9c37-4a233f174803%40googlegroups.com
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAN7EoAabcZpKK_fDfaoHsHikdnmjJoLTkoz8cS-Yx%2BAzBRhxvw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAN7EoAabcZpKK_fDfaoHsHikdnmjJoLTkoz8cS-Yx%2BAzBRhxvw%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CANO9Ro_OJe1ykjVFhZrYr-bSTDzN6rOgY83FRT1LYYMVRAqTXA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CANO9Ro_OJe1ykjVFhZrYr-bSTDzN6rOgY83FRT1LYYMVRAqTXA%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN7EoAb9BK-M%2BM1wT5VpQuCQVyHXHzyVg44LyiZmOy39eKOqmw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN7EoAb9BK-M%2BM1wT5VpQuCQVyHXHzyVg44LyiZmOy39eKOqmw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this g

Re: Deploying a static website

2019-07-03 Thread Aldian Fazrihady
You can also use Amazon S3 to host static website.

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

On Thu, 4 Jul 2019, 09:25 Django Dojo,  wrote:

> I’m just learning Django and was trying it out, but is it better to deploy
> just using simple html, css and launch using a ftp
>
> On Wednesday, July 3, 2019, Aldian Fazrihady  wrote:
>
>> Why does a static website need help from a Python web app framework such
>> as Django?
>>
>> On Thu, 4 Jul 2019, 08:47 Django Dojo,  wrote:
>>
>>> I’ve created a static website in Django and i would like to know the
>>> cheapest and best way to design ploy it.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/c2c4536d-6de9-46c4-9c37-4a233f174803%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN7EoAabcZpKK_fDfaoHsHikdnmjJoLTkoz8cS-Yx%2BAzBRhxvw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN7EoAabcZpKK_fDfaoHsHikdnmjJoLTkoz8cS-Yx%2BAzBRhxvw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANO9Ro_OJe1ykjVFhZrYr-bSTDzN6rOgY83FRT1LYYMVRAqTXA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANO9Ro_OJe1ykjVFhZrYr-bSTDzN6rOgY83FRT1LYYMVRAqTXA%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Deploying a static website

2019-07-03 Thread Aldian Fazrihady
Why does a static website need help from a Python web app framework such as
Django?

On Thu, 4 Jul 2019, 08:47 Django Dojo,  wrote:

> I’ve created a static website in Django and i would like to know the
> cheapest and best way to design ploy it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c2c4536d-6de9-46c4-9c37-4a233f174803%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: login page not working

2019-07-03 Thread Aldian Fazrihady
Your code shows you that it redirects on invalid login instead of
immediately rendering the same form plus error message.

On Wed, 3 Jul 2019, 23:04 KUMBHAGIRI SIVAKRISHNA, 
wrote:

> Even I was entered wrong username and  wrong password  ,but it directs to
> same login with empty spaces.
>
> On Wed, 3 Jul 2019, 8:09 pm Aldian Fazrihady,  wrote:
>
>> Redirection should only be done on successful login.
>> Invalid login should directly render the form plus error message.
>>
>> Regards,
>>
>> Aldian Fazrihady
>>
>> On Wed, 3 Jul 2019, 18:03 KUMBHAGIRI SIVAKRISHNA, <
>> kumbhagirish...@gmail.com> wrote:
>>
>>> I entered username and password ,and click submit ,then it directs same
>>> login page with empty username and password columns,  logic is correct in
>>> views.py
>>> Please help me ,give any suggestions to solve this issue
>>> views.py:
>>> ==
>>> from django.shortcuts import render ,redirect
>>> from django.contrib import messages
>>> from django.contrib.auth.models import User,auth
>>> from django.contrib.auth import authenticate, login,logout
>>> def Login(request):
>>> if request.method=='POST':
>>> username = request.POST['username']
>>> password = request.POST['password']
>>>
>>> user = auth.authenticate(username=username,password=password)
>>>
>>> if user is not None:
>>> auth.login(request, user)
>>> return redirect('/')
>>> else:
>>> messages.info(request,'invalid credentials')
>>> return redirect('Login')
>>> else:
>>> return render(request,'login.html')
>>>
>>>
>>>
>>>
>>> login.html:
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Login
>>> 
>>> 
>>> 
>>> {% csrf_token %}
>>> 
>>> >> placeholder="PASSWORD">
>>> 
>>> 
>>>
>>> 
>>> 
>>> {% for message in messages %}
>>> {{message}}
>>> {% endfor %}
>>> 
>>> 
>>>
>>>
>>>
>>> home.html:
>>> ===
>>>
>>> {% if request.user.is_authenticated %}
>>> Hello,{{user.first_name}}
>>> Logout
>>> {%else%}
>>> Register
>>> Login
>>> {%endif%}
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/c2984d46-acfb-49a5-a93a-062797e98a23%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN7EoAZPeeRZnXGsPryNQnv-iqe7nH6YLVFMNHsgiZDixP0qSA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN7EoAZPeeRZnXGsPryNQnv-iqe7nH6YLVFMNHsgiZDixP0qSA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMM5N91jxrsoKsRWjYeWBJWJMR2V_%3DP6kJ3DdS8O%3DHJXXM5xtg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMM5N91jxrsoKsRWjYeWBJWJMR2V_%3DP6kJ3DdS8O%3DHJXXM5xtg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to convert files from .bin to .png with Python or Django

2019-07-03 Thread Aldian Fazrihady
What kind of file is `.bin` file?

On Thu, Jul 4, 2019 at 6:52 AM Fernando Garrido Villalobos <
ferelise...@gmail.com> wrote:

> How to create a function that have like argument the path of a .bin file
> and returns a .png file ...
> I need your help,
> thank you so much.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b74b0c80-3af6-4791-b010-751cfd47e373%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b74b0c80-3af6-4791-b010-751cfd47e373%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAa%3D0GpUSodrDUe9h7SPMJippvtkbe-39n52bnq6Nzfh5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: login page not working

2019-07-03 Thread Aldian Fazrihady
Redirection should only be done on successful login.
Invalid login should directly render the form plus error message.

Regards,

Aldian Fazrihady

On Wed, 3 Jul 2019, 18:03 KUMBHAGIRI SIVAKRISHNA, 
wrote:

> I entered username and password ,and click submit ,then it directs same
> login page with empty username and password columns,  logic is correct in
> views.py
> Please help me ,give any suggestions to solve this issue
> views.py:
> ==
> from django.shortcuts import render ,redirect
> from django.contrib import messages
> from django.contrib.auth.models import User,auth
> from django.contrib.auth import authenticate, login,logout
> def Login(request):
> if request.method=='POST':
> username = request.POST['username']
> password = request.POST['password']
>
> user = auth.authenticate(username=username,password=password)
>
> if user is not None:
> auth.login(request, user)
> return redirect('/')
> else:
> messages.info(request,'invalid credentials')
> return redirect('Login')
> else:
> return render(request,'login.html')
>
>
>
>
> login.html:
> 
> 
> 
> 
> 
> 
> 
> Login
> 
> 
> 
> {% csrf_token %}
> 
> 
> 
> 
>
> 
> 
> {% for message in messages %}
> {{message}}
> {% endfor %}
> 
> 
>
>
>
> home.html:
> ===
>
> {% if request.user.is_authenticated %}
> Hello,{{user.first_name}}
> Logout
> {%else%}
> Register
> Login
> {%endif%}
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c2984d46-acfb-49a5-a93a-062797e98a23%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Notification system using django channels

2019-07-01 Thread Aldian Fazrihady
I am currently using
https://developers.google.com/web/ilt/pwa/introduction-to-push-notifications
for
notifications as it allows notifications to be received while my app
browser tabs are being closed.
I  use channels/websocket in my website for chatting feature.
Unfortunately, I haven't written any tutorial.

Regards,

Aldian Fazrihady
https://www.aldianfazrihady.com/

On Tue, Jul 2, 2019 at 3:39 AM mintu  wrote:

> hello guys,
> i want to know if is there any way where we can add notifications to our
> app using channels
> when ever a user clicks on a like button the post author should kind of
> get a message saying so and so person liked your post
> i can completely understand how channels work and all but i cannot connect
> the dots bettween the channesl and the database (models)
> and guys if you have any complete tutorial which does this thing or if you
> know any repostitory in github which justifies this please let me know i'll
> check that out
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3d4b5d25-a1ed-4675-a01a-dd3495d31e50%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3d4b5d25-a1ed-4675-a01a-dd3495d31e50%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAbmgt--8LH-d4pYqa-WHvR%3Dg_JfMsmY4HXDnJ6e1wwi5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: deploy django on AWS

2019-06-30 Thread Aldian Fazrihady
Experimenting on AWS features is the best way to learn. You shouldn't worry
about cost when you only experimenting 1-3 hours per day and immediately
stop your running AWS CPU resources when you are done.
Moreover,  if you are using a new AWS account,  you get 1 year of free
access to many resources.

My spot EC2 instance is relatively cheap that it costs me less than $5 a
month.

To use spot instances, you need to use autoscaling.  Autoscaling costs you
no money.

When you started to use managed computation resources,  such as RDS, or
ElastiCache,  monthly costs are starting to become expensive. You can
prevent that if you are able to manage Database and Cache on your own EC2
instances.

Once you comfortable with those items,  you try to automate deployment by
creating automation script based on git and AWS Command Line Interface.

Regards,

Aldian Fazrihady

On Sun, 30 Jun 2019, 23:37 Harshit Agarwal, 
wrote:

> Hello Django users,
> I want to host my django website on aws, This is first time that i am
> hosting a website. Can u suggest any good resource from which i can learn?
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAE%2BC-X_ROpNGnGGQKt7VDE3Bb%2BL1O8q2GAY91JWfgdwA7kKZFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE%2BC-X_ROpNGnGGQKt7VDE3Bb%2BL1O8q2GAY91JWfgdwA7kKZFQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Help me fix this chat feature

2019-06-30 Thread Aldian Fazrihady
I think if you run multiple users on the same PC,  you should use different
browsers, or at least private/incognito mode.

It is because Django gave one browser session to one user. If you are
still  using one browser,  Django thinks only one user accessing the app.

Regards,

Aldian Fazrihady

On Sun, 30 Jun 2019, 23:57 Rizqullah T,  wrote:

> This is my pet project to build a skill exchange platform. For 3 days I've
> been banging my head to make the chat working properly. Suppose I logged in
> as user A then chat to user B, I open another window then logged in as user
> B, but whenever I try to chat it will always connected to user A. Check out
> here on github https://github.com/eryzerz/skill-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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7bda08b9-f920-49b3-83f9-c51a149662e1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7bda08b9-f920-49b3-83f9-c51a149662e1%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Using OAuth2 with Django

2019-06-27 Thread Aldian Fazrihady
Hi Derek,

If you are using Django OAuth Toolkit there is authorization URL in this
path: /o/authorize Regards,

Aldian Fazrihady

On Thu, Jun 27, 2019 at 10:15 AM Derek Dong 
wrote:

> So I've been trying to learn how to authenticate users in my Django
> application with OAuth.
> The token provider has already been established, and the provided
> documentation is here:
> https://ion.readthedocs.io/en/latest/developing/oauth.html
> However, once I've followed the instructions in the "Python" part I got
> confused. I successfully logged in using my Ion account, but when I went to
> the admin page (localhost:8000/admin)
> I got __init__() missing 1 required positional argument: 'strategy'
>
> views.py:
>
> def login(request):
> oauth = OAuth2Session("SsRYDH1iY6jqLO6rSVnF3A1NtYz4Y3fiO9qUMNAX", 
> redirect_uri="http://127.0.0.1:8000/callback",scope=["read;, "write"])
> authorization_url, state = 
> oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/;)
> return redirect(authorization_url)
>
> def callback(request):
> oauth = OAuth2Session("SsRYDH1iY6jqLO6rSVnF3A1NtYz4Y3fiO9qUMNAX", 
> redirect_uri="http://127.0.0.1:8000/callback;, scope=["read", "write"])
> code = request.GET.get('code', None)
> token = oauth.fetch_token("https://ion.tjhsst.edu/oauth/token/;, 
> code=code, 
> client_secret="H78F4vUYd1uTtRSQcCWm0IrSesEhRAXNNh2JRe8KG0LyaJAPY2cPFhIQtKfzqKtMNk6vQxbuOAW2WfedjyNdJ4TLobwKh3NLfe2Am9NNL95T28XTPZWItLqRLKnJOdDu")
> return render(request, 'index.html')
>
>
> urls.py:
>
> path(r'oauth/', views.login, name='login'),
> path(r'callback/', views.callback, name='callback'),
>
>
> settings.py:
>
> INSTALLED_APPS = (
>
> ...
> 'users.apps.UsersConfig',
> 'ion_oauth',
> )
>
>
> How am I supposed to do this? I had already implemented an internal 
> login/logout system through Django's forms, but I want to authenticate it 
> through the provided servers. 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7022da04-ff84-400b-8e24-78327417d4f3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7022da04-ff84-400b-8e24-78327417d4f3%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re:

2019-06-26 Thread Aldian Fazrihady
It is quite common that Django to be treated mostly as API backend and to
deliver a very basic HTML template to inform the browser about the URL of
the Angular JavaScript.

Regards,

Aldian Fazrihady

On Wed, Jun 26, 2019 at 3:18 PM Pradeep Singh  wrote:

> Does it make sense to create an application with Django as the backend and
> Angular as the front end? I understand entire websites can be built from
> Django, so how would Angular, as a front end framework, work with Django?
> What would be the benefit of adding Angular, or is it an unnecessary
> complexity even for large websites?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANwgZcYYsxyqQugJddtTv_2M_aLvq3PeQ%2BREEYTR%2BBX4SQX-Pg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANwgZcYYsxyqQugJddtTv_2M_aLvq3PeQ%2BREEYTR%2BBX4SQX-Pg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Minimum Hardware requirement - reg

2019-06-25 Thread Aldian Fazrihady
Can you convince your client to use clouds instead of self hosting?
Cloud such as AWS or GCP is easily scriptable, allowing to create
critical/important automation scripts.

Regards,

Aldian Fazrihady

On Wed, Jun 26, 2019 at 1:19 AM Raja Sekar Sampath 
wrote:

> Hi,
>
> What are the facts to be considered while determine the server
> configuration for a Django Application?
>
> My Client preferring self hosting, the project having 8 different (apps)
> modules and we expect 20 to 30 users concurrently login into the system and
> Its having automated cron jobs
>
> Thanks & Regards,
> Raja Sekar Sampath
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAS5AE6rKGG1Z4LL2SRzQ9X-OE6-HACY41iFrj1qxjRuhU_hxQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAS5AE6rKGG1Z4LL2SRzQ9X-OE6-HACY41iFrj1qxjRuhU_hxQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAZ_XjXHd%2BJ-Gdd1rNOS4HaTQwZLAVar%3DjfT0kZWB4pSyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF verification failed when I use smart phone

2019-06-25 Thread Aldian Fazrihady
Please make sure csrftoken cookie is returned to the Android app

Regards,

Aldian Fazrihady

On Wed, 26 Jun 2019, 09:46 Robert F.,  wrote:

> Make sure you aren't blocking cookies on whatever device is giving you
> problems.  You'll get this error if you are blocking them.
>
> On Tuesday, January 6, 2015 at 1:09:46 AM UTC-8, Sugita Shinsuke wrote:
>>
>> Hello.
>>
>> When I use Django via my smart phone Android and iOS.
>> The error sometimes occurred.
>>
>> Forbidden (403)
>> CSRF verification failed. Request aborted.
>> Help
>> Reason given for failure:
>> CSRF token missing or incorrect.
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism has not been used correctly. For
>> POST forms, you need to ensure:
>> Your browser is accepting cookies.
>> The view function uses RequestContext for the template, instead of
>> Context.
>> In the template, there is a {% csrf_token %} template tag inside each
>> POST form that targets an internal URL.
>> If you are not using CsrfViewMiddleware, then you must use csrf_protect
>> on any views that use the csrf_token template tag, as well as those that
>> accept the POST data.
>> You're seeing the help section of this page because you have DEBUG = True
>> in your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>> I append django.middleware.csrf.CsrfViewMiddleware', of
>> MIDDLEWARE_CLASSES in settings.py
>>
>> I use
>> Python 2.7.5
>> Django 1.6.4
>>
>> Anyone who know this matter, please help.
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cb4f6aba-85e6-4105-9fe4-b3cbcddca727%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cb4f6aba-85e6-4105-9fe4-b3cbcddca727%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Why I cannot save records into database?

2019-06-24 Thread Aldian Fazrihady
How do you render your form? Can I see the content of the template file?

Regards,

Aldian Fazrihady

On Mon, 24 Jun 2019, 20:14 Alexandru Caplat,  wrote:

> I have a form that in past works good but after I change some data in the 
> models and add image field it doesn't work.
>
> From admin I can add new records but I think is a problem with form id. When 
> I inspect in google chrome the admin page,
>
> form id is porumbei_form and when I inspect my template, the form id is not 
> showing.
>
> #My view @login_required(login_url='/login/')def porumbelnou(request):
> if request.method == "POST":
> form = AdaugaPorumbel(request.POST, request.FILES)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect('/porumbei/')
> else:
> form = AdaugaPorumbel()
> context = {
> 'form': form,
> }
> template = loader.get_template("adaugare_porumbel.html")
> return HttpResponse(template.render(context, request))
> #My formclass AdaugaPorumbel(forms.ModelForm):
> class Meta:
> model = Porumbei
> fields = ['data_adaugare', 'serie_inel', 'anul', 'culoare', 'crescator', 
> 'culoare_ochi', 'sex', 'ecloziune',
>   'rasa', 'linie', 'nume', 'tata',
>   'mama', 'compartiment', 'status', 'data', 'vaccinat', 'info', 
> 'imagine', 'imagine_ochi']
> widgets = {
> 'ecloziune': forms.DateInput(format='%d/%m/%Y',
>  attrs={'class': 'form-control', 'type': 
> 'date'}),
> 'data': forms.DateInput(format='%d/%m/%Y',
> attrs={'class': 'form-control', 'type': 
> 'date'}),
> 'vaccinat': forms.DateInput(format='%d/%m/%Y',
> attrs={'class': 'form-control', 'type': 
> 'date'}),
>
> 'info': forms.Textarea(attrs={'class': 'form-control mt-15', 'rows': 
> '3',
>   'placeholder': 'Vor apărea în 
> pedigree'}),
> }
> #My model
> class Porumbei(models.Model):
> id_porumbel = models.AutoField(primary_key=True)
> data_adaugare = models.DateTimeField(default=datetime.now())
> crescator = models.ForeignKey(settings.AUTH_USER_MODEL, 
> on_delete=models.CASCADE)
> serie_inel = models.CharField(max_length=25, null=False, blank=False, 
> unique=True)
> anul = models.CharField(max_length=4, null=False, blank=False)
> culoare = models.ForeignKey(CuloriPorumbei, on_delete=models.CASCADE, 
> null=False, blank=False, )
> culoare_ochi = models.ForeignKey(CuloriOchi, on_delete=models.CASCADE, 
> nullhttps://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAZBaxyz8P-0oZ-52ajpy0R4d%3D_DvG7JdzARsDJTpWfuMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone is able to delete or update other's post through url

2019-06-24 Thread Aldian Fazrihady
I would implement get_queryset method that filter blog post by
author=self.request.user

Regards,

Aldian Fazrihady

On Sun, 23 Jun 2019, 20:55 Gaurav Sahu,  wrote:

> Hy, I am developing a  Django Blog application. In this application, I
> have a PostEdit view to edit the post, Delete post view to delete the post.
> These operations can only be performed by the user who has created that
> post. I used Delete view as a functional view and edit view as CBV. Now
> what is happening is that any user is able to delete or edit the others
> post through URL. In my delete post view since it is a functional based
> view, I have used if condition to prevent another user to prevent deleting
> someone else post. But since for post edit, I am using CBV, I am not able
> to find a way to prevent a user from editing someone else's post.
> So how can I prevent doing another user to edit someone else post?
>
>
> class PostUpdateView(LoginRequiredMixin ,UpdateView):
> model = Post
> template_name = 'blog/post_form.html'
> form_class = PostForm
>
> def get_context_data(self, **kwargs):
> context = super().get_context_data(**kwargs)
> context['title'] = 'Update'
> return context
>
> def form_valid(self, form):
> form.instance.author = self.request.user
> form.save()
> return super().form_valid(form)
>
>
> @login_required
> def post_delete(request, slug):
> post = get_object_or_404(Post, slug=slug)
> if (request.user == post.author):
> post.delete()
> return redirect('blog:post_list')
> else:
> return redirect('blog:post_detail', slug=slug)
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9b38d4e0-a30a-43ed-9af6-6c9ac545024f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9b38d4e0-a30a-43ed-9af6-6c9ac545024f%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: invalid literal for int() with base 10: ''

2019-06-21 Thread Aldian Fazrihady
Does the stack trace mention a template variable name?  It looks like a
template variable that is expected to have integer value is not properly
initialized.

Regards,

Aldian Fazrihady

On Fri, 21 Jun 2019, 22:42 Lutalo Bbosa joseph,  wrote:

> i as well have a models.py file for carts, and products which is attached,
> when i try to search for a solution on stack overflow,all solutions insist
> on problem with integers and strings in my code. though these were passed
> solutions and not too similar to this one
>
> On Fri, Jun 21, 2019 at 6:35 PM Lutalo Bbosa joseph 
> wrote:
>
>> on pressing remove the product is supposed to be removed from the cart,
>> but it instead displays an error
>>
>> On Fri, Jun 21, 2019 at 6:34 PM Lutalo Bbosa joseph 
>> wrote:
>>
>>> well here is apic of what am doing,
>>>
>>> On Fri, Jun 21, 2019 at 6:20 PM Ahmed Ishtiaque 
>>> wrote:
>>>
>>>> Hi Lutalo,
>>>>
>>>> Could you also share the stacktrace of the error and when it happens?
>>>> It would help us decipher what's really going on in relation to what you're
>>>> trying to do.
>>>>
>>>> Best,
>>>> Ahmed
>>>>
>>>> On Fri, Jun 21, 2019 at 8:33 AM Lutalo Bbosa joseph 
>>>> wrote:
>>>>
>>>>> hi guys, am working on an ecommerce system, which has cart as an app,
>>>>> but i keep on getting this error and cant move on any help, here is my
>>>>> views.py ,
>>>>> from the commandline the error is on line 42
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DTQikVLrVTnwQse3r5P-rxCvaHFRP-qnYWrYSWGHPSGgw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DTQikVLrVTnwQse3r5P-rxCvaHFRP-qnYWrYSWGHPSGgw%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAKizqR54L-dC46wx--DD4BL%2Biko_itWk-fPs%2B9haibZJ_LnTvA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAKizqR54L-dC46wx--DD4BL%2Biko_itWk-fPs%2B9haibZJ_LnTvA%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DR7b_mpnBw_xLKW%2BX5jyVk4CKXm7jwVG37R8BsSPQQegg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DR7b_mpnBw_xLKW%2BX5jyVk4CKXm7jwVG37R8BsSPQQegg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAbag_or9TPOb-KiYCmaD%2B4DDyG%2ByUfU%3DPzVRfacU09GNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: REST API social authentication

2019-06-21 Thread Aldian Fazrihady
If I want to use Facebook, Twitter, or Google login,  I will use
social-auth-app-django

Regards,

Aldian Fazrihady

On Fri, 21 Jun 2019, 15:51 pastrufazio,  wrote:

>
> Hi all,
>
> I need to implement social authentication in my set of REST API.
>
> I did some googling and found sever modules, e.g.
>
> django-rest-framework-social-oauth2
> social-auth-app-django
> django-rest-social-auth
> rest-social-auth
>
>
> Can you please recommend me a proper way to deal this?
>
> I'm quite a newbie in Django, so any advice and suggestions will be
> greatly appreciated!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e4f933b6-04e2-4f5a-bf7b-5fb1eaaa719b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e4f933b6-04e2-4f5a-bf7b-5fb1eaaa719b%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [Model, ORM] Disabling a field before actually removing it

2019-06-20 Thread Aldian Fazrihady
My solution to this problem was by adding more migrations steps:
1. Step to make the field nullable.
2. Backward step to fill value to the removed field.
3. Step to remove the field.

Regards,

Aldian Fazrihady


On Thu, 20 Jun 2019, 19:37 Matthieu Rudelle,  wrote:

> Hi there!
>
> I am about to file a feature request but I figured this might have been
> discussed (although I can't find where).
>
> The use case is when removing fields in a production environment. We run
> our django migrations without downtimes, such that basically, from time to
> time we have an old release working on an DB migrated by the new release.
>
> And when we remove a field it breaks. So we're thinking there should be a
> way to flag a field as "disabled", its value will not be requested on the
> DB and default to a hardcoded value. No migration should remove the column
> yet. Once the field is actually removed the column can be safely removed
> without breaking the old version.
>
> What do you guys think? Is there a better way to solve this?
>
> *Note: a slightly different usecase that it could solve, the third item on
> this wishlist: *
> https://pankrat.github.io/2015/django-migrations-without-downtimes/#django-wishlist
>
> Best,
> Matthieu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANP1NSx%3DRu63c2vR4R%3DfbtBEHV3WRqf1XxWtN%3Dd23j3VoA-ZZw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANP1NSx%3DRu63c2vR4R%3DfbtBEHV3WRqf1XxWtN%3Dd23j3VoA-ZZw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Wrong Redirect

2019-06-20 Thread Aldian Fazrihady
Hi Ramadhan,

I think redirection is only needed on valid and successful POST.

On invalid POST,  I will re-render the current form + error message without
redirection.


Regards,

Aldian Fazrihady

On Thu, 20 Jun 2019, 16:11 ramadhan ngallen,  wrote:

> Hello Team
> I created an app(called users) for user registration
> If user enter two mismatched password an app should redirect to the same
> page. otherwise it should redirect to the homepage
> Unfortunately when user enter two mismatched password it redirect to the
> wrong url http://127.0.0.1:8000/users/register/register
> and also if user enter matched password it also redirect to the wrong url
> http://127.0.0.1:8000/users/register/register
>
>  its view.py
> from django.shortcuts import render, redirect
> from django.contrib.auth.models import User, auth
>
>
> # Create your views here.
>
>
> def register(request):
>
> if request.method == 'POST':
> first_name = request.POST['first_name']
> first_name = first_name.title
> last_name = request.POST['last_name']
> last_name = last_name.title
> username = request.POST['username']
> password1 = request.POST['password1']
> password2 = request.POST['password2']
> email = request.POST['email']
> if password1 == password2:
> user = User.objects.create_user(
> username=username, first_name=first_name, last_name=last_name, email=email,
> password=password1)
>
> user.save()
> print('user created')
> return redirect('/travello/')
>
> else:
> return render(request, 'users/register.html')
>
> else:
> return render(request, 'users/register.html')
> I have also created its urls.py as follows
> from . import views
> from django.urls import path
>
>
> app_name = 'users'
>
> *urlpatterns = [*
> * path('register/', views.register, name='register'),*
> ]
>
> Settings.py
> INSTALLED_APPS = [
> * 'users.apps.UsersConfig',*
> 'travello.apps.TravelloConfig',
> 'calc.apps.CalcConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> user app directory
>
> [image: image.png]
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAhXuBF07Q72_mi1AfPJ5LHHmaEdd5PhvQ79ToqSvpEt0gCivg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAhXuBF07Q72_mi1AfPJ5LHHmaEdd5PhvQ79ToqSvpEt0gCivg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: unable to import django packages

2019-06-18 Thread Aldian Fazrihady
Has the IDE used the same python environment with the one having Django
module installed?

Aldian Fazrihady


On Wed, 19 Jun 2019, 05:42 KUMBHAGIRI SIVAKRISHNA, <
kumbhagirish...@gmail.com> wrote:

> hi,
> I just django started ,when I run my application ,it gives errors as shown
> in figure
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3b8538ef-0167-4e3b-a42b-8e4047da322e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3b8538ef-0167-4e3b-a42b-8e4047da322e%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Mixing ListView and CreateView

2019-06-09 Thread Aldian Fazrihady
Here is a way to combine them:
https://docs.djangoproject.com/en/2.2/topics/class-based-views/mixins/

If you are using Django Rest Framework, they already have it:
"rest_framework.generics.ListCreateApiView"

regards,

Aldian Fazrihady
http://www.aldianfazrihady.com/en-us/



On Mon, 10 Jun 2019, 04:52 Emad G.Kamel,  wrote:

> Hi there
>
> I'm working on a clone to pastebin <https://pastebin.com/> and I want my
> home page contain a form for creating the snippet and side view to list
> latest snippets.
> How can I mix the ListView and CreateView to achieve that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d8d5715-6058-4907-b9e8-6542116fb339%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8d8d5715-6058-4907-b9e8-6542116fb339%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Channel 2 no longer has Group object. If so, how can we know if a particular group is already created?

2019-06-09 Thread Aldian Fazrihady
Group is more like tagging to a channel. If you need the capability to
check if a group name has been used or not,  you need to add the capability
by yourself.


Regards,

Aldian Fazrihady

On Mon, 10 Jun 2019, 02:38 Arean Bbay,  wrote:

> I want certain users to have the ability to join a  group, if it is
> already created but not create one. In order to do that I need a way to
> check it. How to do that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e0b9e861-6a9d-4213-b407-50a79c8c3173%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e0b9e861-6a9d-4213-b407-50a79c8c3173%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Redirect on POST

2019-06-07 Thread Aldian Fazrihady
How does your client call your POST API? Via AJAX (assuming, CORS header
properly set), or via action attribute of the form?
If it is called via action attribute, then there should be no problem with
HTTPResponseRedirect. You probably need a bug fixing.
If it is called via Ajax, then, IMO, there is no way other than setting JS
window.location.

Regards,

Aldian Fazrihady.

On Fri, Jun 7, 2019 at 6:30 PM Mark Davies Tan  wrote:

> Hi all,
>
> I have this scenario. I have a client who wants to call a POST API of mine
> which then redirects to my site. So client has his own site which has a
> button that does a POST to my registration API to register a user onto my
> site and should automatically redirect to my site without the client
> needing to do anything other than call my API. The client isn't willing to
> place a code like window.location upon getting a response from the POST
> call. So the redirecting has to be done by my django API. I've tried
> returning a HTTPResponseRedirect when the POST is called but nothing
> happens. Since I don't have access to my client's code, I've been testing
> it out on w3schools and jsfiddle. Any clues on this?
>
> Thanks,
> Mark
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/77af30ce-2adc-49c9-b7b5-1f7e65318694%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/77af30ce-2adc-49c9-b7b5-1f7e65318694%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django channels on IIS

2019-05-23 Thread Aldian Fazrihady
IIS still exists?

On Fri, 24 May 2019, 09:04 Daniel Butler,  wrote:

> First off I love this project. Django Channels is amazing!
>
> I just wanted to see if anyone has had any success with using iis with
> Django-Channels since this post over 2 years ago.
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/55a342a9-e2b8-4fa2-aa9a-7105c946e129%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: 1 project, X app = X subdomains (Django, Apache)

2019-05-23 Thread Aldian Fazrihady
Official way:
1. Run separate wsgi process for each subdomain. Each wsgi process uses
unique Unix or TCP socket.
2. Each wsgi process uses its own Django settings that points to the
specific app's urls.py
3. The web server configuration for each subdomain points to the socket of
the Django app representing that subdomain.

Unofficial way:
Create path rewriting rule in wsgi configuration.

I have used those both ways in the past. If your machine has very limited
RAM,  such as 1 GB or below that,  I suggest you to try the second way.


Regards,

Aldian Fazrihady
https://www.aldianfazrihady.com/en-us/

On Thu, 23 May 2019, 21:53 Jakub Jiřička,  wrote:

> Hi,
>
> I want to ask you if someone has solved how to prove that is possible the
> applications in one project run in different subdomains?
>
> I have 1 project (projekt.cz) and provide of 3 applications (app1, app2,
> app3) and I would like to get on my vps (CentOS, Apache, PostgreSQL,
> Django) app1.projekt.cz app2.projekt.cz and app3.projekt.cz
>
> I searched everywhere and I found only django-subdomains and
> django-domains ... unfortunately, I have not managed to get started,
> because out-of-date ...
>
> So, there is someone who can help me with settings Django for this
> task/problem?
>
> Many thanks and regards
> Jakub
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0d2ddb92-5aec-4155-9071-d8c3a69ebee6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0d2ddb92-5aec-4155-9071-d8c3a69ebee6%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAbNGEhsemXw6VV%2BPu3uvSTsRpX%2Bo2Y4AOJBicCcv%3DpAsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: set python 3.6.8 default in my ubuntu

2019-05-22 Thread Aldian Fazrihady
Omar, if you upgraded your system to Ubuntu 18.04,  it will install Python
3.6 for you.


Aldian Fazrihady
https://www.aldianfazrihady.com/en-us/

On Wed, May 22, 2019 at 9:22 PM omar ahmed  wrote:

> ok .. i did it but it make my env with python3.5
>
>
> On Wednesday, May 22, 2019 at 3:09:37 PM UTC+2, Nick Sarbicki wrote:
>>
>> Hi Omar,
>>
>> It is generally recommended to _not_ set python3 as your system default.
>> This is stated in PEP 394
>> <https://www.python.org/dev/peps/pep-0394/#future-changes-to-this-recommendation>.
>> The reasoning being there may be internal and third party processes which
>> still expect the default python to be 2.x. Updating the default to python3
>> will likely break these and could cause unexpected problems.
>>
>> You can however create a virtualenv with python3 by simply running 
>> *virtualenv
>> env -p python3*.
>>
>> It is also worth noting that as far as I know Heroku does support
>> python3. There is some documentation on this here
>> <https://devcenter.heroku.com/articles/python-runtimes>.
>>
>> - Nick
>>
>>
>> On Wed, May 22, 2019 at 1:48 PM omar ahmed  wrote:
>>
>>> hello ..
>>> just finished my first project with django but i can not publish it
>>> because my default python is python 2.7.12 and Heroku now does not support
>>> it ..
>>> now i installed python 3.6.8  how can i set it as default python
>>> version to make my projects with virtualenv ?
>>> thanks in advance
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/2dafe695-66c0-42a3-b92e-a71881401ab7%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/2dafe695-66c0-42a3-b92e-a71881401ab7%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/89c67f74-2ee9-4fdc-b300-9bd701a45a46%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/89c67f74-2ee9-4fdc-b300-9bd701a45a46%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Occasional CSRF cookie not set django 1.11 -> 2.1

2019-05-22 Thread Aldian Fazrihady
Yusuf, did you use
CSRF_COOKIE_SECURE = True
and access the website using http instead of https?

https://stackoverflow.com/questions/17716624/django-csrf-cookie-not-set

On Wed, May 22, 2019 at 6:18 PM Yusuf Musleh  wrote:

> Hello Aldian,
>
> Thank you for your reply.
>
> That was one of the very first things we investigated, but it does not
> seem to be the case, as the error happens sometimes when the page/form is
> still fresh, in addition to that, the error message would have been
> different if the token in the form expired, you'd get "CSRF token missing
> or incorrect.".
>
> I want to mention that it's also not the case where a user is using
> multiple tabs and logs out one of them and then submits a form in another
> tab, those are legitimate errors that should happen, but we are witnessing
> cases where a user opens the website (sometimes for their first time),
> tries to submit a form, and they are not able to because it errors out with
> "CSRF cookie not set."
>
> On Wednesday, May 22, 2019 at 2:31:43 AM UTC+3, Aldian Fazrihady wrote:
>>
>> The form page itself can expire if you let it readily opened in a browser
>> tab for hours. If I did that and I didn't reload my form before using it,
>> I will get a CSRF error.
>>
>> There several ideas to fix it.  The point is to have CSRF cookie to
>> always fresh,  and your form will use that cookie instead of CSRF in hidden
>> form field.
>>
>> Regards,
>>
>> Aldian Fazrihady
>> https://www.aldianfazrihady.com/en-us/
>>
>> On Wed, 22 May 2019, 04:52 Yusuf Musleh,  wrote:
>>
>>> Hello,
>>>
>>> We recently migrated from django 1.11.5 to 2.1.4. We performed all the
>>> necessary changes needed for the migration and the application to work,
>>> things went smoothly except for some CSRF validation issues. After the
>>> migration on our production server we noticed an increase in the number of
>>> 403 errors mainly the `CSRF cookie not set.` error. We added more logging
>>> and investigated to see if they were legitimate errors, some are, however
>>> we discovered that most aren’t. They were normal users making normal
>>> requests on our website. We get around 30 of these failed requests that
>>> should not have failed a day, it happens randomly across random devices,
>>> browsers and urls, and has been quite difficult to reproduce.
>>>
>>> We Copy/Pasted the source code of `middleware.csrf` and added it to our
>>> code base as a custom middleware to add more logging and get a better
>>> traceback in sentry when the error occurs:
>>>
>>> - For some reason the token is not set. `csrf_token =
>>> request.META.get('CSRF_COOKIE’)` returns `None`
>>>
>>> - We know that if a user got the error, if they simply refresh the page
>>> things would work perfectly fine, this means that setting the token works,
>>> but sometimes it does not
>>>
>>> - We know that it is not a problem with our frontend since we also got
>>> this error in the django admin including non-login requests
>>>
>>> We also tried clearing all the expired sessions, and set
>>> `CSRF_USE_SESSIONS = True`, however nothing changed.
>>>
>>> Also something that might be related, after the migration to 2.1 we
>>> started noticing users getting logged out more frequently, with no errors
>>> at all, although we set the session to expire in 30 days. We’ve had users
>>> complain about occasionally being logged out multiple times in day, again
>>> on random devices and browsers.
>>>
>>> Our project is deployed on AWS Elasticbeanstalk running Apache with RDS
>>> PostgreSQL 9.6 and CloudFlare DNS/CDN/Cacheing setup.
>>>
>>> We’d appreciate any help or pointers regarding this issue or anywhere we
>>> can look at that could be helpful.
>>>
>>> Thanks,
>>>
>>> Yusuf
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/06231250-3688-4323-8b79-7ebf2b66b449%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/06231

Re: Occasional CSRF cookie not set django 1.11 -> 2.1

2019-05-21 Thread Aldian Fazrihady
The form page itself can expire if you let it readily opened in a browser
tab for hours. If I did that and I didn't reload my form before using it,
I will get a CSRF error.

There several ideas to fix it.  The point is to have CSRF cookie to always
fresh,  and your form will use that cookie instead of CSRF in hidden form
field.

Regards,

Aldian Fazrihady
https://www.aldianfazrihady.com/en-us/

On Wed, 22 May 2019, 04:52 Yusuf Musleh,  wrote:

> Hello,
>
> We recently migrated from django 1.11.5 to 2.1.4. We performed all the
> necessary changes needed for the migration and the application to work,
> things went smoothly except for some CSRF validation issues. After the
> migration on our production server we noticed an increase in the number of
> 403 errors mainly the `CSRF cookie not set.` error. We added more logging
> and investigated to see if they were legitimate errors, some are, however
> we discovered that most aren’t. They were normal users making normal
> requests on our website. We get around 30 of these failed requests that
> should not have failed a day, it happens randomly across random devices,
> browsers and urls, and has been quite difficult to reproduce.
>
> We Copy/Pasted the source code of `middleware.csrf` and added it to our
> code base as a custom middleware to add more logging and get a better
> traceback in sentry when the error occurs:
>
> - For some reason the token is not set. `csrf_token =
> request.META.get('CSRF_COOKIE’)` returns `None`
>
> - We know that if a user got the error, if they simply refresh the page
> things would work perfectly fine, this means that setting the token works,
> but sometimes it does not
>
> - We know that it is not a problem with our frontend since we also got
> this error in the django admin including non-login requests
>
> We also tried clearing all the expired sessions, and set
> `CSRF_USE_SESSIONS = True`, however nothing changed.
>
> Also something that might be related, after the migration to 2.1 we
> started noticing users getting logged out more frequently, with no errors
> at all, although we set the session to expire in 30 days. We’ve had users
> complain about occasionally being logged out multiple times in day, again
> on random devices and browsers.
>
> Our project is deployed on AWS Elasticbeanstalk running Apache with RDS
> PostgreSQL 9.6 and CloudFlare DNS/CDN/Cacheing setup.
>
> We’d appreciate any help or pointers regarding this issue or anywhere we
> can look at that could be helpful.
>
> Thanks,
>
> Yusuf
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/06231250-3688-4323-8b79-7ebf2b66b449%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/06231250-3688-4323-8b79-7ebf2b66b449%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django permissions framework vs DRF permissions

2019-05-18 Thread Aldian Fazrihady
Hi, based on my experience,  I can create DRF permission based on HTTP
methods.

Django permissions by default are tightly related to ORM models.
DRF permission can be totally unrelated to ORM models.

Regards,

Aldian Fazrihady


On Sat, 18 May 2019, 16:13 Rounak Jain,  wrote:

> Newbie here. I want to create hierarchical permissions in Django, very
> similar to one described here:
> https://stackoverflow.com/questions/49300215/django-hierarchy-permissions
>
> I have read about Django permissions framework and
> https://github.com/vintasoftware/django-role-permissions
>
> I don't understand where DRF permissions fit it? Should DRF permissions be
> used in addition to or instead of Django permissions?
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1e37c07-e223-4244-bb4a-09e3cd0f7737%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b1e37c07-e223-4244-bb4a-09e3cd0f7737%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAYt-SA2KEU_yo1ghG7caZF0iWhQMxEvOvVvDjd%2BC%3D5tGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Run Daphne as non-root on low ports

2019-05-02 Thread Aldian Fazrihady
Hi,

I usually have SSL termination on nginx,  or CDN,  or Load Balancer.
I never need to set SSL on Django or Daphne server.  Probably you could try
this architecture.

Regards,

Aldian Fazrihady


On Thu, 2 May 2019, 20:32 BR,  wrote:

> I'm running a simple Django/Channels website using Daphne. Traffic will be
> relatively low and will likely only see 1-2 clients at a time. I figured
> this would be a good use case for Daphne to serve both HTTPS and WebSockets.
>
> Does Daphne have a mechanism for starting as root and dropping down to a
> non-root user after it is running? Root is required at startup because I
> want it to bind to port 80 or 443, and it needs to access the SSL
> certificate.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1015c96c-1a20-4372-9de3-3ca6d2347d98%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1015c96c-1a20-4372-9de3-3ca6d2347d98%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Which Cloud Service Provider should be chosen to host Django Application

2019-05-02 Thread Aldian Fazrihady
Use AWS or GCP.  You can automate the scaling.

Regards,

Aldian Fazrihady


On Thu, 2 May 2019, 16:51 Balaji Shetty,  wrote:

> Hi
>
> I do not have any experience for cloud hosting. Can you please suggest
> Cloud Service Provider to host Django Application.
>
> My Application need Security and Salability.
>
> Many options are there like
>
>
>- PythonAnywhere. ..
>- *Heroku*. ...
>- A2 Hosting. ...
>- *AWS*. ...
>- *HostUpon*. ...
>- TMD Hosting. ...
>- DigitalOcean
>
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOsUwWWGcNqrFPswKt6a4Byk4Zopy-9SFWjZrLZQc332Ww%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOsUwWWGcNqrFPswKt6a4Byk4Zopy-9SFWjZrLZQc332Ww%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAYFCJ%2BM1evndOQyGC1KK%2BTNzkFVEND3PDt%2B2G%3DGmj0e_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to design a notification system using Django Channels 2? (architecture)

2019-04-13 Thread Aldian Fazrihady
Will the notifications still reach users when your app browser tab/window
is closed?  If yes,  you need to use PWA push notifications instead of
websocket.

On Sat, 13 Apr 2019, 22:35 , <9co...@gmail.com> wrote:

> I have a social network app and users can add posts and other users can
> comment posts. I need to send a notification to the author of a post and to
> the other users who commented on this post. Something similar to FB
> notifications:
>
>-
>
> commented your post
>-
>
> commented post that you also commented
>
>
> How can I compare this with available examples of chat-apps? Could someone
> draw a diagram of how to spin everything together / how the whole flow
> should looks like? Consumers, JS, views etc.
>
> I need something a'la real-time, I could create Django Rest Framework
> endpoint that returns notifications to display and then in the JavaScript I
> could make a request every 1-5 seconds to check if there is something new
> to display but it seems that it is not optimal. That's why I'm considering
> web sockets.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aeb63e3c-cfa2-415d-8a3d-1f0aed40c94f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Aldian Fazrihady
What's the result of

print(Foo.objects.exclude(bar__attribute=1).filter(
bar__attribute_2=2).query)

On Fri, 12 Apr 2019, 20:10 Michael Thomas, 
wrote:

> Hello everyone,
>
> I've run into what I believe is a limitation of the ORM that other people
> must be dealing with somehow, but I can't seem to figure out a sensible
> solution.
>
> I think it's easiest to describe the problem with code.
>
> For the following models:
>
> class Foo(models.Model):
> name = models.CharField(max_length=64)
>
>
> class Bar(models.Model):
> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
> attribute_1 = models.IntegerField()
> attribute_2 = models.IntegerField()
>
> I want to select all Foo() that have 1 or more bar with attribute_1 not
> equal to 1, and attribute_2 equal to 2.
>
> Eg. SQL something like this:
>
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> "app_bar"."attribute_1" <> 1
> AND "app_bar"."attribute_2" = 2
> )
>
> However, here's what I end up with...
>
>
> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> NOT (
> "app_foo"."id" IN (
> SELECT
> U1."foo_id"
> FROM "app_bar" U1
> WHERE U1."attribute_1" = 1
> )
> )
> AND "app_bar"."attribute_2" = 2
> )
>
> print(Foo.objects.filter(~Q(bar__attribute_1=1), bar__attribute_2=2).query)
> Exact same SQL output as above
>
> Interestingly enough, a simple query for attribute_1=1 and attribute_2=2
> works as expected, so it would be trivial to do this with a __ne operator
> (if it existed), without any other changes to the ORM:
>
> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> "app_bar"."attribute_1" = 1
> AND "app_bar"."attribute_2" = 2
> )
>
> Am I missing something here? How are other people tackling this?
>
> Kind Regards,
> Michael Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d852fc10-5f5a-43e8-8dab-c796404867a8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Installation Question

2019-03-29 Thread Aldian Fazrihady
Starting from Python 3.6, we don't need 3rd party virtualenv library.

 We can just do this:

python3.7 -m venv /path/to/env/

https://docs.python.org/3/library/venv.html

 Regards,

 Aldian Fazrihady


On Thu, 28 Mar 2019, 23:32 Michael Achterberg, 
wrote:

> I've installed Python 3.7 which comes with pip installed. When I try to
> create a virtualenv I get a SyntaxError: invalid syntax
>
> What am I doing wrong?
>
>
> Regards,
>
> Michael Achterberg
> E-mail: mich...@achterberg.org.za
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/gbimmpfv2sa1f3o8032dbxih.1553790005386%40email.android.com
> <https://groups.google.com/d/msgid/django-users/gbimmpfv2sa1f3o8032dbxih.1553790005386%40email.android.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Unit-Testing Django Views

2019-03-28 Thread Aldian Fazrihady
There are several things you can try:
1. Mocking csrf token functions
2. Passing the csrf token context from first HTML generation to the second
HTML generation
3. Wiping out the csrf token parts from both HTML before comparing them.

On Thu, 28 Mar 2019, 23:54 Simon Charette,  wrote:

> This is effectively failing because of a mechanism added in 1.10 to protect
> against BREACH attacks[0] by salting the CSRF token.
>
> I'm not aware of any way to disable this mechanism but testing against the
> exact HTML returned from a view seems fragile.
>
> I suggest you use assertContains[1] (with or without html=True) and
> assertTemplateUsed[2] instead.
>
> Cheers,
> Simon
>
> [0] https://docs.djangoproject.com/en/2.1/ref/csrf/#how-it-works
> [1]
> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertContains
> [2]
> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
>
> Le jeudi 28 mars 2019 12:16:43 UTC-4, OnlineJudge95 a écrit :
>>
>> Hi people,
>>
>> I am following the book Test-Driven Development with Python
>> 
>>  by
>> *Harry J.W. Perceval.* The book is using Django version 1.7 which is
>> outdated as of now so I started with version 2.1.
>>
>> I am trying to unit test my index view. One unit-test that I have written
>> is testing whether the index view returns correct HTML or not by comparing
>> the input received through
>> django.template.loader.render_to_string
>> the unit-test fail with the following traceback
>> python manage.py test
>> Creating test database for alias 'default'...
>> .System check identified no issues (0 silenced).
>> F.
>> ==
>> FAIL: test_index_view_returns_correct_html (lists.tests.IndexViewTest)
>> --
>> Traceback (most recent call last):
>>   File "tests.py", line 24, in test_index_view_returns_correct_html
>> self.assertEqual(expected_html, actual_html)
>> AssertionError: '> chars]lue="BJMT1b9fxuXOGugp00SDypeTYZxvlmc6KtBSYMDon[198 chars]l>\n' !=
>> '> chars]l>\n'
>>
>> --
>> Ran 3 tests in 0.006s
>>
>> FAILED (failures=1)
>> Destroying test database for alias 'default'...
>>
>> Process finished with exit code 1
>>
>>
>> It was clear that the csrf token is causing the test to fail. Is there
>> any way to test it, or should it be tested? I ask this as when I changed my
>> Django version to 1.7, the tests were passing, even after giving the csrf
>> token field in the form. I tried going through the changelogs but 1.7 is
>> far behind (beginner here). Please find the code snippets, directory
>> structure provided below.
>>
>>
>> *lists/views.py*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *from django.http import HttpResponsefrom django.shortcuts import render# 
>> Create your views here.def index(request):if request.method == 'POST':   
>>  return HttpResponse(request.POST['item_text'])return 
>> render(request, 'index.html')*
>>
>>
>> *lists/test.py*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *from django.http import HttpRequestfrom django.template.loader import
>> render_to_stringfrom django.test import TestCasefrom django.urls import
>> resolvefrom lists.views import index# Create your tests here.class
>> IndexViewTest(TestCase):def
>> test_root_url_resolves_to_home_page_view(self):   [...]def
>> test_index_view_returns_correct_html(self):request = HttpRequest()
>>   response = index(request)actual_html =
>> response.content.decode()expected_html =
>> render_to_string('index.html', request=request)
>> self.assertEqual(expected_html, actual_html)def
>> test_index_view_can_save_a_post_request(self):   [...]requirements.txt*
>>
>>
>>
>>
>>
>> *Django==2.1.7pytz==2018.9selenium==3.141.0urllib3==1.24.*
>> *settings.py*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *[...]# Application definitionINSTALLED_APPS = [ 'django.contrib.admin',
>> 'django.contrib.auth', 'django.contrib.contenttypes',
>> 'django.contrib.sessions', 'django.contrib.messages',
>> 'django.contrib.staticfiles', 'lists',][...]*
>> *Directory Structure*
>>
>> [image: Screen Shot 2019-03-28 at 9.36.56 PM.png]
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7f0f12be-fc3e-43c3-ba07-e48158def051%40googlegroups.com
> 

Re: Lead Architect / CTO ( Hands on ) - Start Up - Cambridge - 3 Days remote working

2019-03-28 Thread Aldian Fazrihady
Visa sponsorship?

On Thu, 28 Mar 2019, 18:34 ,  wrote:

> Hi Everyone,
>
> I am looking for a candidate who has architectural experience in building
> a Platform in Python Django.
>
> *Software Architect – Part Remote - (Python Django) – Start **Up *
>
>
>
> £65,000 - £75,000 depending on experience
>
> Cambridge
>
> Permanent
>
>
>
>
>
> We have established a firm partnership with a really exciting start up
> that’s going to revolutionise their market.  The company are looking for a
> candidate to come in and help build a ground-breaking platform that is
> going to modernise the agricultural sector. This technology is going to
> bring a once slow-moving market into the 21st century. It’s a very
> exciting opportunity for anyone who is a team lead or has thought about
> being a team lead. The perfect candidate will be from an architectural
> background with lead experience or ambitions to lead a team.
>
>
>
> They are looking for some with a strong development background in Python
> Django. The ideal candidate is someone with previous experience in
> developing backend creating web applications but also has an interest in
> Machine Learning. The role will entail a very hand son approach to start
> and as the team grows it will move more into a line management role. If you
> have some front-end experience it would also be a bonus.
>
>
>
> A successful candidate must be skilled in:
>
> ·Strong experience of creating web applications in Python Django
>
> ·Understanding of REST API and GraphQL development
>
> ·Experience with Amazon Web Services Or Google Cloud
>
> ·Experience in Machine Learning or want to gain the experience
>
> ·Understanding of container technology such as Docker
>
> ·Architectural Background
>
>
> Desirables:
>
> ·Experience with full stack development – React or React Native
>
> ·Understanding of blockchain technologies
>
> ·Had Open source experience
>
> ·Team Lead Experience
>
>
>
> The Company has really got hold of something really exciting with this
> platform. This role is perfect for anyone who is looking for a new
> challenge or is thinking about developing themselves further. They have a
> beautiful new office in Cambridge with the potential to grow further. After
> meeting with them you get a real feeling that they are a fantastic company
> to work for and their benefits package is also very attractive.
>
>
>
> If you are interested in applying for this role, please email
> sc...@socode.co.uk.
>
>
> If you email I am more than happy to get the full spec over to you and
> more information about the company.
>
>
> Best wishes
>
> Scott
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f4c094df-1781-45e4-8087-14566ba12f61%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Aldian Fazrihady
On Sun, Mar 24, 2019 at 11:41 AM Adam Zedan  wrote:

> Thanks Aldian , what about runworker ?
>

I don't use Daphne worker. However, I am using celery

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAb-VPM8btZgVBn5_7hPQhxdwB%2B-HG%3DOb1qAX9nsm%3DooLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Script for running Daphne and runworker in the background . runworker ends after session expires.

2019-03-23 Thread Aldian Fazrihady
Hi,
Mine is like this. It is still running after exiting ssh:

nohup daphne -v 2 -b $AFCOM_DAPHNE_HOST -p $AFCOM_DAPHNE_PORT
afcom.asgi:application > $AFCOM_PROJECT_PATH/daphne/afcom.log 2>&1 &


On Sun, Mar 24, 2019 at 10:52 AM Adam Zedan  wrote:

> I am trying to create a bash script that would run Daphne and runworker in
> the background.
> This is what I came up with so far
>
>
> echo "Killing Redis."
> killall redis-server
>
>
> #echo "Starting redis Server."
> redis-server --daemonize yes
>
>
> echo "Stopping NGINX.."
> sudo /etc/init.d/nginx stop
>
>
> echo "Starting NGINX.."
> sudo /etc/init.d/nginx start
>
>
> echo "Killing Daphne.."
> sudo kill -9 $(ps aux | grep 'daphne' | awk '{print $2}')
>
>
> echo "Starting Daphne."
> /home/ec2-user/MyDomainVenv/bin/daphne -b 0.0.0.0 -p 8001 
> main.asgi:channel_layer
> 2>> ./daphne.log &
>
>
> echo "Starting Django worker thread"
> #nohup python ./manage.py runworker 2>>./daphneWorker.log >&2 &
> python ./manage.py runworker
>
>
> However it seems like run worker simply terminates when my ssh session
> expires. I tried nohup statement as well.
> How did you fix this 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b2a43f85-9b9a-48bf-918d-c70a70b1b80b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Aldian Fazrihady
Hi,

Generating fields is possible,

but for your recipe app, that's absolutely not a good thing to do.

Regards,

Aldian Fazrihady

On Sun, Mar 24, 2019 at 1:54 AM Barkalez XX  wrote:

> Thank for you answer.
>
>
> I did not know that fields could be generated in the database from
> FrontEnd.
>
> It occurs to me to put a "Add ingredient" button and produce a new field
> in the recipe table, but I do not know how to do that.
>
> El sábado, 23 de marzo de 2019, 17:54:24 (UTC+1), Aldian Fazrihady
> escribió:
>>
>> Hi,
>>
>> I don't think that's a good idea to frequently add new field to a
>> database table.
>>
>> A field in form doesn't mean that it will also be a field of a table
>> database.
>> You can make a new ingredient field in a form to become a new row of a
>> database table.
>> You just need to properly design your database schema.
>>
>> Regards,
>>
>> Aldian Fazrihady
>>
>> On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  wrote:
>>
>>>
>>> I would like to know if it is possible to create a new field in a table
>>> from the FrontEnd. For example, in a form to create recipes, not all
>>> recipes contain the same number of ingredients. At first I thought about
>>> putting a high number of ingredients to enter in the form to create a
>>> recipe, but that's not pretty. I think it would be better for the user to
>>> add fields in the form as needed. Although thinking well, if that were
>>> done, who would execute the command makemigrations and migrate ?, it
>>> occurred to me to create a high number of fields for the ingredients but
>>> that did not appear in the FrontEnd form and that they were appearing as
>>> needed by the user.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/c416f450-0172-45e2-9242-4704c4aca421%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/c416f450-0172-45e2-9242-4704c4aca421%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0c94870c-b8df-40eb-89ff-b54565fe4070%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0c94870c-b8df-40eb-89ff-b54565fe4070%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Doubt in the creation of fields in the FrontEnd

2019-03-23 Thread Aldian Fazrihady
Hi,

I don't think that's a good idea to frequently add new field to a database
table.

A field in form doesn't mean that it will also be a field of a table
database.
You can make a new ingredient field in a form to become a new row of a
database table.
You just need to properly design your database schema.

Regards,

Aldian Fazrihady

On Sun, Mar 24, 2019 at 12:46 AM Barkalez XX  wrote:

>
> I would like to know if it is possible to create a new field in a table
> from the FrontEnd. For example, in a form to create recipes, not all
> recipes contain the same number of ingredients. At first I thought about
> putting a high number of ingredients to enter in the form to create a
> recipe, but that's not pretty. I think it would be better for the user to
> add fields in the form as needed. Although thinking well, if that were
> done, who would execute the command makemigrations and migrate ?, it
> occurred to me to create a high number of fields for the ingredients but
> that did not appear in the FrontEnd form and that they were appearing as
> needed by the user.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c416f450-0172-45e2-9242-4704c4aca421%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c416f450-0172-45e2-9242-4704c4aca421%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Dispatching requests from one uwsgi to another uwsgi instance running Django Channels

2019-03-22 Thread Aldian Fazrihady
Does it really use Django channels?  I am using Django channels and
following its suggested package:  ASGI provided by Daphne

Regards,

Aldian Fazrihady

On Sat, 23 Mar 2019, 07:58 Adam Zedan,  wrote:

> I am currently using Django channels for websocket communication. I read
> this
> <https://django-websocket-redis.readthedocs.io/en/latest/running.html#django-with-websockets-for-redis-behind-nginx-using-uwsgi>
>  article
> and it states that I should split the project into two uwsgi instances. It
> states that
>
> "The web server undertakes the task of dispatching normal requests to one
>> uWSGI instance and WebSocket requests to another one"
>
>
> Now I have two uwsgi instances running. This is how I am running both.
>
> This uwsgi handles the normal django site requests
> uwsgi --virtualenv /home/ec2-user/MyProjVenv --socket /home/ec2-user/
> MyProjVenv/MyProjWeb/site1.socket --chmod-socket=777 --buffer-size=32768
> --workers=5 --master --module main.wsgi
>
>
> This uwsgi handles the websocket requests
> uwsgi --virtualenv /home/ec2-user/MyProjVenv --http-socket /home/ec2-user/
> MyProjVenv/MyProjWeb/web.socket --gevent 1000 --http-websockets --workers=
> 2 --master --chmod-socket=777  --module main.wsgi_websocket
>
> Now the websocket uwsgi launches  main.wsgi_websocket
>
> The code for main.wsgi_websocket one is this
> import os
> import gevent.socket
> import redis.connection
> redis.connection.socket = gevent.socket
> os.environ.update(DJANGO_SETTINGS_MODULE='main.settings')
> from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
> application = uWSGIWebsocketServer()
>
> Now after spinning up the two uwsgi instances I am able to access the
> website.The websocket uwsgi instance is also receiving data however I am
> not sure if its passing that data to the website uwsgi instance. I am using
> Django Channels here and this is the configuration I have specified in my
> settings for Django Channels
>
> CHANNEL_LAYERS = {
> "default": {
> "BACKEND": "asgi_redis.RedisChannelLayer",
> "CONFIG": {
> "hosts": [(redis_host, 6379)],
> },
>"ROUTING": "main.routing.channel_routing",
> },
> }
>
> The channel routing is this
> channel_routing = [
> include("chat.routing.websocket_routing", path=r"^/chat/stream"),
> include("chat.routing.custom_routing"),
> ]
>
> and this is the websocket_routing which i have mentioned above
>
>
>
> websocket_routing = [
> route("websocket.connect", ws_connect),
>
>
> # Called when WebSockets get sent a data frame
> route("websocket.receive", ws_receive),
>
>
> # Called when WebSockets disconnect
> route("websocket.disconnect", ws_disconnect),
> ]
>
> Now the problem is that my ws_receive is never called. If I test on my
> local dev machine using  "*ipaddress:8000/chat/stream*" this works
> perfectly fine however I have no clue why my receive is not being called
> when I use *ipadress:80/ws/ *. I am certain that my other uwsgi instance
> is getting that data but I dont know how to find out if its passing it to
> the other uwsgi instance of the djnago side and if it is then why is my
> receive not being called ?. Any suggestions on this would definitely help
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4c4e57fa-c603-4be0-ba1a-cf1e9919fc09%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4c4e57fa-c603-4be0-ba1a-cf1e9919fc09%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


  1   2   >