Re: Django project

2022-05-12 Thread Chetan Ganji
Hi Tanni,

Simple emails can be sent using django. Not sms!
Since sending sms requires users to pay for it.

You will have to integrate a third party service for sending sms e.g. Twilio
https://www.twilio.com/

I hope this helps!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 12, 2022 at 10:43 PM Tanni Seriki 
wrote:

> Please groups am working on a school project
> The project is to send a SMS to a lecturer when his/her period wants to
> starts.
> The SMS will contain the venue, time and date...
> Is there a way this can be accomplished by 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/CALWCJq0Qe4NRBaU_HZ-%3DsUki2-bVCcBEuBhxtSt%2BxA%2BU4APdiA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALWCJq0Qe4NRBaU_HZ-%3DsUki2-bVCcBEuBhxtSt%2BxA%2BU4APdiA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Django project

2022-05-12 Thread Chetan Ganji
check their website or try searching like sms service providers in nigeria.
https://nigerianinfopedia.com.ng/best-bulk-sms-service-providers-in-nigeria/

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, May 13, 2022 at 1:03 AM Tanni Seriki  wrote:

> Yeah thanks for the assistance
> But the twillo does it work across the globe, because am in Nigeria and
> twillo is an American company.
> So will it work, or is there any other way?
>
> On Thu, May 12, 2022, 6:31 PM Chetan Ganji  wrote:
>
>> Hi Tanni,
>>
>> Simple emails can be sent using django. Not sms!
>> Since sending sms requires users to pay for it.
>>
>> You will have to integrate a third party service for sending sms e.g.
>> Twilio
>> https://www.twilio.com/
>>
>> I hope this helps!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, May 12, 2022 at 10:43 PM Tanni Seriki 
>> wrote:
>>
>>> Please groups am working on a school project
>>> The project is to send a SMS to a lecturer when his/her period wants to
>>> starts.
>>> The SMS will contain the venue, time and date...
>>> Is there a way this can be accomplished by 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/CALWCJq0Qe4NRBaU_HZ-%3DsUki2-bVCcBEuBhxtSt%2BxA%2BU4APdiA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALWCJq0Qe4NRBaU_HZ-%3DsUki2-bVCcBEuBhxtSt%2BxA%2BU4APdiA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMKMUjsZx14EPCzBUJ5djEHgUwpXf3i126x2Tqv78Q4DpmYL1g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjsZx14EPCzBUJ5djEHgUwpXf3i126x2Tqv78Q4DpmYL1g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALWCJq0uDc2dqjcH8f9JZLUNSQ3GCZqBifvymgnMfejf1mj1ug%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALWCJq0uDc2dqjcH8f9JZLUNSQ3GCZqBifvymgnMfejf1mj1ug%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Application for Part Time Python/Django Developer

2022-08-05 Thread Chetan Ganji
Hello Django Users,

I am Chetan Ganji, I have been working as a Part Time Consultant for a New
York based company since last year.
I am looking for another Part Time Remote Python/Django Developer job.

I can build softwares in Python 3 and Django and Django REST Framework. I
can provide production grade code quality in these technologies.
I have developed a few rest api projects using django/drf so far. I have
basic knowledge of front end techs like js, bootstrap, angular 9.
I also have basic knowledge of Postgres, Kubuntu Linux, Git and AWS ( EC2,
S3 and RDS).
I have integrated various third party apis also e.g. twilio, sendgrid,
sentry, algolia, authorize.net, braintree, etc.
I also have worked on 3 GraphQL projects, 2 in NodeJs and 1 in Python.

My resume is attached for your perusal.
Feel free to reach out to me if you have any relevant work opportunities
for me.

Thanks !


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in

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


Resume - Chetan Ganji.pdf
Description: Adobe PDF document


Re: Application for Part Time Python/Django Developer

2022-08-05 Thread Chetan Ganji
Hi herve,

Thanks!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Aug 5, 2022 at 5:04 PM herve bineli  wrote:

> Hello Mr. Chetan,
>
> As I can see, you have a huge experience in web development with a Python
> speciality.
> I suggest you to create an account on turing.com and there you will
> certainly fond a company that will appreciate your experience and give you
> a chance to enter their team.
>
> Best Regards,
> BINELI Arsène - IT Engineer & Python Developer
>
>
> On Fri, Aug 5, 2022 at 10:43 AM Chetan Ganji 
> wrote:
>
>> Hello Django Users,
>>
>> I am Chetan Ganji, I have been working as a Part Time Consultant for a
>> New York based company since last year.
>> I am looking for another Part Time Remote Python/Django Developer job.
>>
>> I can build softwares in Python 3 and Django and Django REST Framework. I
>> can provide production grade code quality in these technologies.
>> I have developed a few rest api projects using django/drf so far. I have
>> basic knowledge of front end techs like js, bootstrap, angular 9.
>> I also have basic knowledge of Postgres, Kubuntu Linux, Git and AWS (
>> EC2, S3 and RDS).
>> I have integrated various third party apis also e.g. twilio, sendgrid,
>> sentry, algolia, authorize.net, braintree, etc.
>> I also have worked on 3 GraphQL projects, 2 in NodeJs and 1 in Python.
>>
>> My resume is attached for your perusal.
>> Feel free to reach out to me if you have any relevant work opportunities
>> for me.
>>
>> Thanks !
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMKMUjsq%2BquWaF_JXV8T9CwJr-CCr6JPaHnx8aKbDbYH1Ek1jA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjsq%2BquWaF_JXV8T9CwJr-CCr6JPaHnx8aKbDbYH1Ek1jA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> *BINELI MANGA Hervé Arsène*
> Ingénieur Informaticien - ENSPY
> binelima...@gmail.com
> (+237) 691388922 / 699946323
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJm63OkkF8dZROjrbVrA%2BzQUOg9m-EJM0QTC5e6NL-kUHX4HjQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJm63OkkF8dZROjrbVrA%2BzQUOg9m-EJM0QTC5e6NL-kUHX4HjQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: TabularInlineAdmin queries waaaaaayyyyyy too much.

2023-02-13 Thread Chetan Ganji
Try them and see if it helps!

https://betterprogramming.pub/django-select-related-and-prefetch-related-f23043fd635d

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Feb 2, 2023 at 8:53 PM Mark Jones  wrote:

> I have an admin with 1 row in the tabular inline.  I have a custom
> queryset in
>
> class ExtensionTabularInlineFormSet(BaseInlineFormSet):
> def get_queryset(self) -> QuerySet[Extension]:
> qs = super().get_queryset()
>
> This gets called 20 times to display that one row.  When you have more
> rows, it gets called 20 times/row.
>
> The culprit is calls to this method:
> def initial_form_count(self):
> """Return the number of forms that are required in this FormSet."""
> if not self.is_bound:
> return len(self.get_queryset())
> return super().initial_form_count()
>
> The solution would be to cache this value, but admin views seem like
> singletons way too often for this to work.  Anyone else seen 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/f4bacbd9-b519-45af-8e5b-826c4b5d9c88n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f4bacbd9-b519-45af-8e5b-826c4b5d9c88n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Stuck with Django Tutorial Part 4

2023-03-15 Thread Chetan Ganji
It seems to me like you are not entering the url name
In place of 'polls:vote' try to enter the name of the url given to that url
For Your Reference
https://docs.djangoproject.com/en/4.1/ref/templates/builtins/#url
I hope it helps you!
Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 15, 2023 at 1:14 AM Sandip Bhattacharya <
sand...@showmethesource.org> wrote:

> Can you share your urls.py?
>
>
> On Mar 14, 2023, at 1:33 AM, Nithin Kumar  wrote:
>
> Hi,
>
> Stuck with this problem
>
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
>
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not
> found. 1 pattern(s) tried: ['polls/
> My detail.html is like this and it is failing at Line 1.
> I checked all solutions online but no luck.
>
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{%
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{
> choice.choice_text }}
> {% endfor %}
> 
> 
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org
> <https://groups.google.com/d/msgid/django-users/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org?utm_medium=email&utm_source=footer>
> .
>

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


Re: Deleted django_content_type table

2023-03-21 Thread Chetan Ganji
try one thing
create new db n migrate again with all the models. it will create the
contentype table again. then just restore this table to the old db.

i hope it solves your problem.

On Fri, Mar 17, 2023, 02:09 shailesh sachan 
wrote:

> Now i am not able to do anything and i cannot lose the data please help
> restore contenttypes
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/879a1674-05c1-4a53-a89e-aec35309f062n%40googlegroups.com
> 
> .
>

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


Re: Debug error when c

2023-03-30 Thread Chetan Ganji
You are trying to hit a url that doesnt exist in your django app
Documentation says you have to add it url, but you dont have to visit that
url.
https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#add-the-urls

When you visit any other url in the app, one toolbar will be shown in the
right hand side of the display.

Try this out
https://www.youtube.com/watch?v=qWLk9S6mvAY

I hope it helps you!

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Mar 30, 2023 at 11:18 PM Ricky Abura  wrote:

> Hi,
> I am learning django, in the process of developing youtube clone, I meet
> the attached error when installing django debug toolbar. I don't know where
> I am not getting right but I strictly follow some tutorial. Any assistance
> please?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fd470375-10c2-4c97-93d3-feaed4130dc1n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fd470375-10c2-4c97-93d3-feaed4130dc1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Web portal by Django

2023-04-11 Thread Chetan Ganji
Hi Ananya,
Your question is very open ended.
You will need to give specific requirements to get any help.
e.g.
Whose license?
How many licenses per user?
Can multiple user have the same license key?
What is the format of the license key?


I hope it helps!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Apr 11, 2023 at 6:14 PM Ananya Agrawal 
wrote:

> How to build a web portal for license information management by using
> 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/0d9ea21f-c6be-4cb9-8ad6-f4f019974545n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0d9ea21f-c6be-4cb9-8ad6-f4f019974545n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Beginner: How to find fields that can be over-ridden in a Generic Class Based Views

2023-04-11 Thread Chetan Ganji
Hello Pulkit,
Information you are asking is not readily available. It will become clear
to you as you start writing code.

However, you can use below options to make your life easier.

   1. https://ccbv.co.uk
   2. dir and callable methods can help you get more clarity.


I hope it helps you.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Apr 11, 2023 at 6:14 PM PULKIT AGRAWAL 
wrote:

> Hello Everyone,
>
> I am very new to Django and am still learning the ropes. If anyone can
> point me in the right direction, I will be thankful to you.
>
> My problems is as follows:
> 1. I have learned about class based views and have started using them
> 2. But every now and then I come across a new field that could have been
> overwritten in the class based view to shorted the code
> 3. Is there a way to identify all the fields that can be over written in a
> class based view.
>
> Let me illustrate with an example:
> class UnitCreateView(CreateView):
> form_class = UnitCreationForm
> template_name = 'units_of_measurement/unit_create.html'
> success_url = reverse_lazy('units_of_measurement:unit_list')
>
> In the above class, can I know how many and what other fields such as
> "form_class" are available to over-riding? I have checked the documentation
> but have not found anything. Maybe its just me.
>
> Thanks in advance!
>
> Regards,
>
> Plkt
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1666860d-5b3a-4cc8-a4b4-0187f5dc5b48n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1666860d-5b3a-4cc8-a4b4-0187f5dc5b48n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Migration don't work

2023-05-17 Thread Chetan Ganji
it seems to be that you have an app in the project named order and it
should have a migration file named 0008_auto_20190301_1035.
0008_auto_20190301_1035 seems to be absent for some reasons.

You should check and confirm that.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 17, 2023 at 6:21 PM sebasti...@gmail.com <
sebastian.ju...@gmail.com> wrote:

> I get on migration following error:
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line
> 419, in execute_from_command_line
> utility.execute()
>   File
> "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line
> 413, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python3.8/site-packages/django/core/management/base.py",
> line 354, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "/usr/lib/python3.8/site-packages/django/core/management/base.py",
> line 398, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/python3.8/site-packages/django/core/management/base.py",
> line 89, in wrapped
> res = handle_func(*args, **kwargs)
>   File
> "/usr/lib/python3.8/site-packages/django/core/management/commands/migrate.py",
> line 92, in handle
> executor = MigrationExecutor(connection,
> self.migration_progress_callback)
>   File
> "/usr/lib/python3.8/site-packages/django/db/migrations/executor.py", line
> 18, in __init__
> self.loader = MigrationLoader(self.connection)
>   File "/usr/lib/python3.8/site-packages/django/db/migrations/loader.py",
> line 53, in __init__
> self.build_graph()
>   File "/usr/lib/python3.8/site-packages/django/db/migrations/loader.py",
> line 259, in build_graph
> self.graph.validate_consistency()
>   File "/usr/lib/python3.8/site-packages/django/db/migrations/graph.py",
> line 195, in validate_consistency
> [n.raise_error() for n in self.node_map.values() if isinstance(n,
> DummyNode)]
>   File "/usr/lib/python3.8/site-packages/django/db/migrations/graph.py",
> line 195, in 
> [n.raise_error() for n in self.node_map.values() if isinstance(n,
> DummyNode)]
>   File "/usr/lib/python3.8/site-packages/django/db/migrations/graph.py",
> line 58, in raise_error
> raise NodeNotFoundError(self.error_message, self.key,
> origin=self.origin)
> django.db.migrations.exceptions.NodeNotFoundError: Migration
> communication.0002_reset_table_names dependencies reference nonexistent
> parent node ('order', '0008_auto_20190301_1035')
>
>
> Now i grep after grep -r "0002_reset_table_names" . and nothing are find
> in my project dir or in venv. I look in django_migrations table and there
> aren't such a entity. I have feeling that is cached entry because in
> history i have such a venv with this file but i delete complete venv and
> load right venv where this file don't exists
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/38278863-2272-49ab-9b5f-38ea15a18d0fn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/38278863-2272-49ab-9b5f-38ea15a18d0fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


FYI: Django Supports Sessions By Default

2023-05-18 Thread Chetan Ganji
http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in

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


Re: Unable to view my categories under category view

2023-05-26 Thread Chetan Ganji
Variable name in the context of CategoryListView is cat_menu_list.
I did not see that variable name in the template. In the template you are
iterating over a variable that doesnt exist in the context.

Iterate over cat_menu_list in the template and it should work fine!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, May 26, 2023 at 2:13 AM Ifeanyi Okoli  wrote:

> Hello,
>
> Please I am building a simple blog, and the video I am referencing used a
> function view for the category view but is not working for me. I am unable
> to see the list of posts based on categories.
>
> Every other thing works except the category view. It shows me   "Sorry,
> this category does not exist yet..."  which indicates that it is not
> reading or seeing the list of posts.
>
> I have tried using class view but is also not working.
>
> Please see screenshots of my code in the attached file.
>
> Kindly assist.
>
> Thanks.
>
> Ifeanyi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/47b10a5c-6252-4ee7-9b18-3b9ecd2bfa75n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/47b10a5c-6252-4ee7-9b18-3b9ecd2bfa75n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: I want help from senior python/django developer to create one django assignment project.

2023-06-05 Thread Chetan Ganji
It looks like a test for getting hired in a company.
You should try to solve this yourself before asking for help.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Jun 6, 2023 at 1:40 AM André Hangalo  wrote:

> Convert this doc in pdf
>
> On Mon, 5/06/2023 at 18:19 AKHIL KORE  wrote:
>
>> ok i can make it pdf format
>>
>> On Mon, 5 Jun 2023 at 22:45, Vishesh Mangla 
>> wrote:
>>
>>> Ya, who ll open up Linux for him 😑
>>>
>>> On Mon, 5 Jun, 2023, 22:43 Lakshyaraj Dash, <
>>> dashlakshyaraj2...@gmail.com> wrote:
>>>
>>>> Bro please send in pdf format so that it will be possible to open in
>>>> mobile
>>>>
>>>> On Mon, 5 Jun, 2023, 22:35 AKHIL KORE,  wrote:
>>>>
>>>>> Hi django developer group.
>>>>>
>>>>>  I'm from india. I got one django assignment from xyz comapny. But i
>>>>> can't how to create  that logical way. Please help me. Below file is that
>>>>> assignment. Please open and see it.
>>>>> can any one send that type of related previous projects 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/7988a2b0-95af-4c75-92db-670e541b9af6n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/7988a2b0-95af-4c75-92db-670e541b9af6n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAF7qQgCBQ9jkBb%3DX0TvaSZMcqBRoKYEWM3XFMTddmhBvGDxO8A%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAF7qQgCBQ9jkBb%3DX0TvaSZMcqBRoKYEWM3XFMTddmhBvGDxO8A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CACaE8x5JW1bfPvmbWLp-7qmP3Ya-5%3DP30vLkCgj8sc-e9fVvDg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CACaE8x5JW1bfPvmbWLp-7qmP3Ya-5%3DP30vLkCgj8sc-e9fVvDg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB11hN95uN1HCSp66s_%3DLLf6Zux7AbtZap4RQ4nYBU2CcWMc%2Bw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAB11hN95uN1HCSp66s_%3DLLf6Zux7AbtZap4RQ4nYBU2CcWMc%2Bw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> RICK DEU
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACQ9QcGydhVvF9XGGZpg-2BL%2B-A0pAv8C3Afn9QFw7ELkMYApA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACQ9QcGydhVvF9XGGZpg-2BL%2B-A0pAv8C3Afn9QFw7ELkMYApA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Problem with my website

2023-07-12 Thread Chetan Ganji
Have you set the default url for the website?

Sharing your urls.py file will help someone guide you better.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jul 12, 2023 at 11:47 PM Ben Sidney Matiko 
wrote:

> Is the website in development stage?
>
> On Wed, 12 Jul 2023, 18:47 Théodore KOSSI, 
> wrote:
>
>> Hello everyone,
>> I have a problem with my website. When I put DEBUG = False, my website
>> appears in white page but when it is in True, my website works normally.
>> Please, anyone can help me ??
>>
>> --
>> theodoros17@python-developer
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKiMjQGQRQ_eanYNBrqAFBU3ayakQUxuQuNmMhn8km%2BCuysfBA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAKiMjQGQRQ_eanYNBrqAFBU3ayakQUxuQuNmMhn8km%2BCuysfBA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BB4jBWvVR3T4RzBdO%3D1qbwXQ-accqDjF%3DUCokN2VkAiKFii%2BQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2BB4jBWvVR3T4RzBdO%3D1qbwXQ-accqDjF%3DUCokN2VkAiKFii%2BQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Own documentation in django

2023-07-14 Thread Chetan Ganji
I am little confused right now.
You have said markdown and jinja templates (reusing them also)

markdown is used for documentation procedures. Jinja is used for actual
html templates.
I am not sure what you want to achieve!

For code reuse you can use template inheritance.
When you pass diff context to diff templates that are extending from the
same base template;
(e.g. template1.html and template2.html are using table.html)
you can reuse html templates with different content.
https://docs.djangoproject.com/en/4.2/ref/templates/language/#template-inheritance




Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jul 14, 2023 at 6:53 PM sebasti...@gmail.com <
sebastian.ju...@gmail.com> wrote:

> Hello,
>
> i use regular markdown and asciidoc. Problem is that both have to less
> feature. For example i want to reuse html templates with different content.
>
> In asciidoc i can do this following:
>
> i declare variables
>
> :varibale1: Teststring
> :variable2: Second String
>
> include::buttontemplate.adoc[]
>
> This is not good in reading such source code. Second thing include i can't
> use inline only in new line and i have problems to make include in tables.
>
> Asciidoc have no multilanguage suppport. And further more problems
>
> So i think for very small documumentation asciidoc is wunderfull but for
> greater docus with several levels in TOC and multilanguage this tool is to
> unflexible. Does anyone knows a package in django where i have a syntax
> like asciidoc/markdown but the felxibility like in django where a can use
> jinja2 and can use templating and multilanguage works?
>
> 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/a2c07298-a2e7-4a8f-ab2e-79367a2b5dcdn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a2c07298-a2e7-4a8f-ab2e-79367a2b5dcdn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Chetan Ganji
Hi Mr Cain,

This would make more sense to me!
https://django-celery-beat.readthedocs.io/en/latest/

You could create background tasks to create background tasks that run at
any specific time ;-)
AFAIK, this solution is as good as it can get!

Thanks!

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Jul 25, 2023 at 11:43 PM M Cain  wrote:

> User application permits registration for upcoming events.  User wants the
> registration page to be open on 4th Saturday of every month at 9am ET as
> the events are very popular with limited capacity and made available on
> first come first serve basis.
>
> Django application is deployed on Heroku. Heroku scheduler works except it
> doesn't 'guarantee' running at specific time (but near the requested time).
>
> Would celery-redis be better for this?
>
> Any other suggestions?
>
> Thank you in advance for replying.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Case-insensitive non-deterministic collation

2023-08-06 Thread Chetan Ganji
Check this out.
https://gist.github.com/hleroy/2f3c6b00f284180da10ed9d20bf9240a

# According to Django documentation, it’s preferable to use
non-deterministic collations
# instead of the citext extension for Postgres > 12.
# Example migation to create the case insensitive collation

class Migration(migrations.Migration):

operations = [
CreateCollation(
'case_insensitive',
provider='icu',
locale='und-u-ks-level2',
deterministic=False
)
]


# Example model using the new db_collation parameter introduced with Django
3.2

class Tag(models.Model):
name = models.CharField(max_length=50, db_collation='case_insensitive')

class Meta:
ordering = ['name']

def __str__(self):
return self.name

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sun, Aug 6, 2023 at 12:32 PM Mike Dewhirst  wrote:

> On 5/08/2023 7:58 pm, Chetan Ganji wrote:
>
> Hi Mike
>
> RE: The primary use case is to establish case-insensitivity when checking
> names - including usernames, company names and abbreviations/acronyms.
>
> I dont know anything about db_collation.
>
>
> Me neither
>
> Below 4 lookups should solve most common scenarios.
>
>
> Actually that was how I did it originally. I switched to using the
> PostgreSQL CI field because it is all done in the database - much faster -
> and my code is much reduced and therefore fewer possibilities for bugs etc.
>
> Judging from the Django release notes and the PostgreSQL docs there should
> be a straightforward answer to my question. Researching the correct answer
> is complex enough to make me ask here first.
>
> Cheers
>
> Mike
>
> https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups
>
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Sat, Aug 5, 2023 at 1:35 PM Mike Dewhirst 
> wrote:
>
>> The following warning triggered a bit of research which looks like a
>> significant amount of study will be required to find the collation needed
>> ...
>>
>>
>> django.contrib.postgres.fields.CICharField is deprecated. Support for it
>> (except in historical migrations) will be removed in Django 5.1.
>> HINT: Use CharField(db_collation="…") with a case-insensitive
>> non-deterministic collation instead.
>>
>>
>> Does anyone have experience they would like to share? What replaces that
>> ellipsis?
>>
>> The primary use case is to establish case-insensitivity when checking
>> names - including usernames, company names and abbreviations/acronyms.
>> Maybe there is a better way to handle that?
>>
>> This is my typical PostgreSQL database spec ...
>>
>> CREATE DATABASE 
>> WITH
>> OWNER = miked
>> ENCODING = 'UTF8'
>> LC_COLLATE = 'C'
>> LC_CTYPE = 'C'
>> TABLESPACE = pg_default
>> CONNECTION LIMIT = -1
>> IS_TEMPLATE = False;
>>
>> Many thanks for any help
>>
>> Cheers
>>
>> Mike
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au
>> <https://groups.google.com/d/msgid/django-users/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
>
> --
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Your
> email software can handle signing.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from t

Re: Django csv file

2019-03-12 Thread Chetan Ganji
I would suggest you use transactions for inserting those many documents.
https://www.mongodb.com/transactions

Django ORM does not support MongoDB. So, you can't use models/ORM/Class
Based Views of Django with mongo.
Only way I know to use Mongo with Django is function based views. There are
some third party MONGO ORMS for django, but I never used them so far, so
can't comment on how good they are or are not. Do your R&D and find it out
;-)

I hope this helps you. Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 13, 2019 at 12:42 AM Ryan Nowakowski 
wrote:

> If I were you, I'd work through the Django tutorial first. Then ask
> specific questions if you have any.
>
> On March 12, 2019 5:32:08 AM CDT, Cigi Sebastine 
> wrote:
>>
>>
>> Hi all
>>
>> I am trying to insert data from csv file to mongodb4 using python3.7
>> (Bulk data insertion 47lakhs records)
>> i need to implement in django
>> Can please anyone share ur idea
>>
>> import pandas as pd
>> import json
>>
>> mng_client = MongoClient('localhost', 27017)
>> mng_db = mng_client['testcsv']
>> collection_name = mng_db['datastore']
>> db_cm = mng_db['datastore']
>>
>> df = pd.read_csv('filepath',encoding = 'ISO-8859-1') # loading csv file
>> #dfstr = df.to_json('testjson1.json')
>> data_json = json.loads( df.to_json())
>> db_cm.insert_many(data_json)
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "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/89E98305-6AEC-4A82-9839-E86760DC3AB2%40fattuba.com
> <https://groups.google.com/d/msgid/django-users/89E98305-6AEC-4A82-9839-E86760DC3AB2%40fattuba.com?utm_medium=email&utm_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/CAMKMUjv%3DrU%3DNJxhd%2BHwpz40RrFB_Z2qP9Mq7q2SoXFys4HSO2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django csv file

2019-03-13 Thread Chetan Ganji
Welcme CIGI

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 13, 2019 at 5:13 PM Cigi Sebastine 
wrote:

> Thank you Chetan.
>
>
> On Wed, Mar 13, 2019 at 3:41 AM Chetan Ganji 
> wrote:
>
>> I would suggest you use transactions for inserting those many documents.
>> https://www.mongodb.com/transactions
>>
>> Django ORM does not support MongoDB. So, you can't use models/ORM/Class
>> Based Views of Django with mongo.
>> Only way I know to use Mongo with Django is function based views. There
>> are some third party MONGO ORMS for django, but I never used them so far,
>> so can't comment on how good they are or are not. Do your R&D and find it
>> out ;-)
>>
>> I hope this helps you. Cheers!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Wed, Mar 13, 2019 at 12:42 AM Ryan Nowakowski 
>> wrote:
>>
>>> If I were you, I'd work through the Django tutorial first. Then ask
>>> specific questions if you have any.
>>>
>>> On March 12, 2019 5:32:08 AM CDT, Cigi Sebastine <
>>> cigisebast...@gmail.com> wrote:
>>>>
>>>>
>>>> Hi all
>>>>
>>>> I am trying to insert data from csv file to mongodb4 using python3.7
>>>> (Bulk data insertion 47lakhs records)
>>>> i need to implement in django
>>>> Can please anyone share ur idea
>>>>
>>>> import pandas as pd
>>>> import json
>>>>
>>>> mng_client = MongoClient('localhost', 27017)
>>>> mng_db = mng_client['testcsv']
>>>> collection_name = mng_db['datastore']
>>>> db_cm = mng_db['datastore']
>>>>
>>>> df = pd.read_csv('filepath',encoding = 'ISO-8859-1') # loading csv file
>>>> #dfstr = df.to_json('testjson1.json')
>>>> data_json = json.loads( df.to_json())
>>>> db_cm.insert_many(data_json)
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/89E98305-6AEC-4A82-9839-E86760DC3AB2%40fattuba.com
>>> <https://groups.google.com/d/msgid/django-users/89E98305-6AEC-4A82-9839-E86760DC3AB2%40fattuba.com?utm_medium=email&utm_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/CAMKMUjv%3DrU%3DNJxhd%2BHwpz40RrFB_Z2qP9Mq7q2SoXFys4HSO2Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjv%3DrU%3DNJxhd%2BHwpz40RrFB_Z2qP9Mq7q2SoXFys4HSO2Q%40mail.gmail.com?utm_medium=email&utm_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/CAAaRqFM-NALvhVJgcDXvRZoa7M-cgSURTbPMAQRcSUVxtH8THw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAaRqFM-NALvhVJgcDXvRZoa7M-cgSURTbPMAQRcSUVxtH8THw%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjsNd0BVch1zpjDU859DoGWiFTOGZ17e873C_vNwD9SfiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Queryset for Multiple set

2019-03-13 Thread Chetan Ganji
Hi Vaibhav,

I think this would do what you want. Make sure too call the objects on the
model name (  Modelname  ) ;-)


systems = ['windows', 'unix']
variable = Modelname.objects.filter(clientname=cname, clienttype__in=systems,
errorcode='20')



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 13, 2019 at 5:17 PM Krishnasagar Subhedarpage <
pagesa...@gmail.com> wrote:

> You could do using django ORM query expressions. Refer below link:
> https://docs.djangoproject.com/en/2.1/ref/models/expressions/
>
>
> Regards,
> Krishnasagar Subhedarpage
>
>
>
> On Wed, 13 Mar 2019 at 17:14, Vaibhav Mishra  wrote:
>
>> Hi All,
>>
>> I am trying to achieve below ,
>>
>> variable = object.filter(clientname =cname , clienttype='windows' and
>> clienttype='unix', errorcode='20')
>>
>>
>>
>>  Notice that I want to filter by two or more values in second parameter..
>> How can we 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 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/54464687-7fd0-4103-b74f-5de566ae9e89%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/54464687-7fd0-4103-b74f-5de566ae9e89%40googlegroups.com?utm_medium=email&utm_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/CAChYJc8NwTG5LDBmjBbFav3b125dOsNCTwtHN%3DJrMbhrZ9T0rw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAChYJc8NwTG5LDBmjBbFav3b125dOsNCTwtHN%3DJrMbhrZ9T0rw%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjt2mw0mfbHHqD2p7_PPD2%3DGFgJM0QadR%3Di_bb5HpG7ORA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need to Store All Model data in RAM

2019-03-13 Thread Chetan Ganji
Hi Vaibhav,

Andréas is right. You need to evaluate the queryset first as the orm
queries are lazy.
So the solution would be something like below example.


another_list = []
getdata = data.objects.all() # this is a queryset

# apply filters if you need to

getdata = list(getdata) # this would be a list in python

for item in getdata: # won't hit database again
if item in another_list:
# do something
pass



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 13, 2019 at 7:27 PM Andréas Kühne 
wrote:

> Hi,
>
> You can't. The way that you are working - it would always go back to the
> database - because you are using the filter methods.
>
> You would need to create a list from the items, then do the comparison in
> python - which probably will be slower (but not necessarily).
>
> Regards,
>
> Andréas
>
>
> Den ons 13 mars 2019 kl 12:44 skrev Vaibhav Mishra :
>
>> Hi All,
>>
>> I have a table of over 100,000 rows which I need to compare with another
>> list to find if the entry matching a rows is in there or not
>>
>> The following does not work
>>
>> getdata = data.objects.all()
>>
>>
>> mydata= getdata.filter(mycriteria)
>>
>>
>>
>>
>> Process information and comparision from 'mydata'
>>
>>
>>
>> .The code .should fetch all data and should no longer go to Database. ,
>> but it still seem to hit database
>> .
>> Whenever I am running code, I see that for each comparision , the Code is
>> Hitting the database resulting in over thousands of queries and lot of
>> delay in finishing Processing data.
>>
>> How can I force All Data to be stored in RAM so that its no longer needed
>> to access database. ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/a120e643-936e-4f6a-9662-7811808fa8cf%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/a120e643-936e-4f6a-9662-7811808fa8cf%40googlegroups.com?utm_medium=email&utm_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/CAK4qSCevkAVGFf%3DMrS8VVsv2BgPuDkRUqW_tSFwk1dfrzb7pvg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK4qSCevkAVGFf%3DMrS8VVsv2BgPuDkRUqW_tSFwk1dfrzb7pvg%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjs%3DxtJPN-gmnfmg7M%3DSGsP0jg5qru6o%3DcQGJmuqabckkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need to Store All Model data in RAM

2019-03-13 Thread Chetan Ganji
Bhai, read your original question

*"I have a table of over 100,000 rows which I need to compare with another
list to find if the entry matching a rows is in there or not "*

Which another list were you talking about?

so the another_list could be a pre-populated list of python or another list
made of queryset.

e.g.
another_list = [1, 2, 3, 4] OR
another_list = list(Modelname.objects.all())

I hope this clears your confusion.



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 13, 2019 at 9:32 PM Vaibhav Mishra  wrote:

> Thanks Andreas, Will try out the list Method.
>
> On Wednesday, March 13, 2019 at 9:58:16 AM UTC-4, Andréas Kühne wrote:
>>
>> Hi,
>>
>> You can't. The way that you are working - it would always go back to the
>> database - because you are using the filter methods.
>>
>> You would need to create a list from the items, then do the comparison in
>> python - which probably will be slower (but not necessarily).
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den ons 13 mars 2019 kl 12:44 skrev Vaibhav Mishra :
>>
>>> Hi All,
>>>
>>> I have a table of over 100,000 rows which I need to compare with another
>>> list to find if the entry matching a rows is in there or not
>>>
>>> The following does not work
>>>
>>> getdata = data.objects.all()
>>>
>>>
>>> mydata= getdata.filter(mycriteria)
>>>
>>>
>>>
>>>
>>> Process information and comparision from 'mydata'
>>>
>>>
>>>
>>> .The code .should fetch all data and should no longer go to Database. ,
>>> but it still seem to hit database
>>> .
>>> Whenever I am running code, I see that for each comparision , the Code
>>> is Hitting the database resulting in over thousands of queries and lot of
>>> delay in finishing Processing data.
>>>
>>> How can I force All Data to be stored in RAM so that its no longer
>>> needed to access database. ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@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/a120e643-936e-4f6a-9662-7811808fa8cf%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/a120e643-936e-4f6a-9662-7811808fa8cf%40googlegroups.com?utm_medium=email&utm_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/5b0499d9-073f-4d3e-8f38-4160e4b50f65%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5b0499d9-073f-4d3e-8f38-4160e4b50f65%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjv6Z-tSmmqD9CP1wGchSPvtTieqi_Ga8Yf7sSJgO-6dyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: image didn't upload

2019-03-14 Thread Chetan Ganji
Did you setup MEDIA-ROOT location in your settings.py
For reference -
https://docs.djangoproject.com/en/2.1/ref/settings/#media-root

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 5:43 PM omar ahmed  wrote:

> this is my model
> class LeagueNews(models.Model):
> ...
> news_image = models.ImageField(upload_to='core/media/core',max_length=255,
> null=True,blank=True)
>
>
> and this is my template
>
>
> {% block content %}
>
> {{ article.news_title }}
>
> {{ article.publication_date }}
>
> {{ article.news_text }}
>
> 
>
> {% endblock %}
> the view
>
> def newsdetail(request, news_id):
> article = get_object_or_404(LeagueNews,pk=news_id)
> return render(request, 'core/newsdetail.html',{'article':article})
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAMKMUjvxSdyNqJan2MjVcsR%2BigpMsj-%2BxZonEUTLt8HKoXBnKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Very much begineer

2019-03-14 Thread Chetan Ganji
Look no further codingforentrepreneurs
Start with trydjango 1.8 project. See his youtube channel.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 6:29 PM AhenTheBegineer 
wrote:

> Hello,
> I'm very new to the software and pretty much know about python(less than
> basics) so I want to explore django.
> And want to know how it works, what software are needed for it and how do
> I start with the softwae to be handy with it.
> 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/5fda8787-9841-4b9f-885d-f43e4e0e5d41%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5fda8787-9841-4b9f-885d-f43e4e0e5d41%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvfuF88sDq39PL8tk8CY73MGp%3DGzJnfyoRXjeiiO3mL_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
Why do you need to do any calculations in the model code?

I would do any calculations in the views and store them using models. That
will remove the getters and setters from model.
Everything should work fine then.

Hope it helps.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 8:31 PM mccc  wrote:

> Hello,
>
> I have set up this nice model:
> class CustomGroup(models.Model):
>
> name = models.CharField(max_length=255)
> _parent = models.ForeignKey(
> "self", on_delete=models.CASCADE, null=True,
> related_name="descendants", db_column="parent"
> )
> _depth = models.IntegerField(default=1)
>
> @property
> def parent(self):
> return self._parent
>
> @property
> def depth(self):
> return self._depth
>
> @parent.setter
> def parent(self, value):
> if self == value:
> raise ValueError("parent must be different from self")
> p = value
> while value is not None:
> if self == value.parent:
> raise ValueError("parent cannot be a descendant")
> value = value.parent
> self._parent = p
> self.depth = (p.depth + 1) if p is not None else 1
>
> @depth.setter
> def depth(self, value):
> if value > MAX_GROUPS_DEPTH:
> raise ValueError("Too many nested groups")
>
> for descendant in self.descendants.all():
> descendant.depth = value + 1
> descendant.save()
> self._depth = value
>
>
> and the CASCADE function is not getting fired when the parent gets deleted;
> I tried adding another field without the property modifiers, and that
> worked as expected.
>
> Is there any way I can have both my custom getter and setter, and the
> on_delete behaviour?
>
> 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/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAMKMUjuRrwxkKGtNEKDibHMaMm4pUEP_YX2rvxZcCGJzPfDxng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
That approach is not working for the original poster. So I gave him a
solution that solves the problem.

I meant, its my opinion to keep models slim and write utils to make the
controllers slim.
You don't have to follow it ;-)  Follow what makes sense to you. I prefer
it that way.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:01 PM Sithembewena L. Dube 
wrote:

> There is nothing wrong with having logic in models.
>
> This is the principle of object orientation - encapsulating methods and
> properties in a class definition to group related behaviours and attributes
> of a specified type of entity.
>
> See the section titled "Make ‘em Fat" here:
> https://django-best-practices.readthedocs.io/en/latest/applications.html
>
>
> Kind regards,
> Sithembewena
>
>
> *Sent with Shift
> <https://tryshift.com/?utm_source=SentWithShift&utm_campaign=Sent%20with%20Shift%20Signature&utm_medium=Email%20Signature&utm_content=General%20Email%20Group>*
>
> On Thu, Mar 14, 2019 at 5:21 PM Chetan Ganji 
> wrote:
>
>> Why do you need to do any calculations in the model code?
>>
>> I would do any calculations in the views and store them using models.
>> That will remove the getters and setters from model.
>> Everything should work fine then.
>>
>> Hope it helps.
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>> <#m_3800371179043208066_m_7932060366693994324_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Thu, Mar 14, 2019 at 8:31 PM mccc  wrote:
>>
>>> Hello,
>>>
>>> I have set up this nice model:
>>> class CustomGroup(models.Model):
>>>
>>> name = models.CharField(max_length=255)
>>> _parent = models.ForeignKey(
>>> "self", on_delete=models.CASCADE, null=True,
>>> related_name="descendants", db_column="parent"
>>> )
>>> _depth = models.IntegerField(default=1)
>>>
>>> @property
>>> def parent(self):
>>> return self._parent
>>>
>>> @property
>>> def depth(self):
>>> return self._depth
>>>
>>> @parent.setter
>>> def parent(self, value):
>>> if self == value:
>>> raise ValueError("parent must be different from self")
>>> p = value
>>> while value is not None:
>>> if self == value.parent:
>>> raise ValueError("parent cannot be a descendant")
>>> value = value.parent
>>> self._parent = p
>>> self.depth = (p.depth + 1) if p is not None else 1
>>>
>>> @depth.setter
>>> def depth(self, value):
>>> if value > MAX_GROUPS_DEPTH:
>>> raise ValueError("Too many nested groups")
>>>
>>> for descendant in self.descendants.all():
>>> descendant.depth = value + 1
>>> descendant.save()
>>> self._depth = value
>>>
>>>
>>> and the CASCADE function is not getting fired when the parent gets
>>> deleted;
>>> I tried adding another field without the property modifiers, and that
>>> worked as expected.
>>>
>>> Is there any way I can have both my custom getter and setter, and the
>>> on_delete behaviour?
>>>
>>> Thanks
>>&g

Re: image didn't upload

2019-03-14 Thread Chetan Ganji
See this works or not.


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]

MEDIAFILES_DIRS = [
os.path.join(BASE_DIR, 'media'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static-root')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media-root')




Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:16 PM omar ahmed  wrote:

> thanks but it doesn't work
> MEDIA_URL = '/media/'
> MEDIA_ROOT = 'media'
>
> On Thursday, March 14, 2019 at 2:36:35 PM UTC+2, Chetan Ganji wrote:
>>
>> Did you setup MEDIA-ROOT location in your settings.py
>> For reference -
>> https://docs.djangoproject.com/en/2.1/ref/settings/#media-root
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>> <#m_7758653622765414323_CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Thu, Mar 14, 2019 at 5:43 PM omar ahmed  wrote:
>>
>>> this is my model
>>> class LeagueNews(models.Model):
>>> ...
>>> news_image = models.ImageField(upload_to='core/media/core',max_length=
>>> 255, null=True,blank=True)
>>>
>>>
>>> and this is my template
>>>
>>>
>>> {% block content %}
>>>
>>> {{ article.news_title }}
>>>
>>> {{ article.publication_date }}
>>>
>>> {{ article.news_text }}
>>>
>>> 
>>>
>>> {% endblock %}
>>> the view
>>>
>>> def newsdetail(request, news_id):
>>> article = get_object_or_404(LeagueNews,pk=news_id)
>>> return render(request, 'core/newsdetail.html',{'article':article})
>>>
>>> --
>>> You received this message because you are subscribed 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/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>> <#m_7758653622765414323_CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubsc

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
OK.

One work around could be to fire the signal manually just after you
set/delete the value? I have not checked it yet :P

Do one thing, implement pre_delete and post_delete signals and check the
values of  instance, sender and using. It might give you more information
about what is happening.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:15 PM mccc  wrote:

>
>
> On Thursday, March 14, 2019 at 4:22:15 PM UTC+1, Chetan Ganji wrote:
>>
>> Why do you need to do any calculations in the model code?
>>
>> I would do any calculations in the views and store them using models.
>> That will remove the getters and setters from model.
>> Everything should work fine then.
>>
>> Hope it helps.
>>
>
> No, nothing would work fine: in that case I would need to remember
> constantly to either copy the code to handle the behaviour or make a call
> to *a view* each time and in any place that handles those fields.
> Plus the tests would need to check over and over for the same behaviour
> every time the field was involved.
>
> I'm sorry, but it really doesn't 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/ed1853bb-402a-4688-9061-63054c44ce63%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ed1853bb-402a-4688-9061-63054c44ce63%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjuXZaAQXtM0ac%3DX7icsk76-eTcWnKSCgYp9iR_crQP%3D6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
https://www.django-rest-framework.org/topics/ajax-csrf-cors/
https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 12:34 AM B  wrote:

> I'm implementing a DeleteView, and for completion I would like to provide
> the functionality indicated here:
>
>
> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>
> *If this view is fetched via GET, it will display a confirmation page that
> should contain a form that POSTs to the same URL.*
>
> However, by default a GET will not include the required context to the
> template for {% csrf_token %}. How do I include the appropriate context
> information for a plain DeleteView CBV?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjuRMSAqgVxdtNPHEt%2BRpSzM-VAx9rTgJf7CBqZ91UFtrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
Frameworks dont work as we want them too :P
We have to understand how the defaults are implemented then make the
changes as necessary ;-)
If it can be customized, great! otherwise learn and use a different
framework, LOLZ ;-)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 1:02 AM B  wrote:

> Thanks. I have things working fine under Ajax. This particular scenario is
> an "odd one" since performing a GET on a delete view isn't common, but it
> is implemented by Django. It is helpful for testing, but perhaps the right
> approach is to "disable" get for the DeleteView and be done with it. My
> main concern was for Django to behave "out of box" as intended without
> overrides.
>
> On Thursday, March 14, 2019 at 3:24:46 PM UTC-4, Chetan Ganji wrote:
>>
>> https://www.django-rest-framework.org/topics/ajax-csrf-cors/
>> https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>> <#m_8157490019364007879_CAMKMUjuRMSAqgVxdtNPHEt+RpSzM-VAx9rTgJf7CBqZ91UFtrg@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Fri, Mar 15, 2019 at 12:34 AM B  wrote:
>>
>>> I'm implementing a DeleteView, and for completion I would like to
>>> provide the functionality indicated here:
>>>
>>>
>>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>>>
>>> *If this view is fetched via GET, it will display a confirmation page
>>> that should contain a form that POSTs to the same URL.*
>>>
>>> However, by default a GET will not include the required context to the
>>> template for {% csrf_token %}. How do I include the appropriate context
>>> information for a plain DeleteView CBV?
>>>
>>> --
>>> You received this message because you are subscribed 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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com?utm_medium=email&utm_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/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvEymdFUtQ0qeaPHsie0PsjeuvwkdQC_kkHuHdoeMi8zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What I am doing wrong

2019-03-15 Thread Chetan Ganji
In the admin.py file that import statement seems to be wrong.  "*from
website.module import website*"
I cant help you more as I dont know the directory structure.

Check for the location of the module named website relative to the admin.py
file.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Mar 15, 2019 at 5:36 PM Harish Chaudhary 
wrote:

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CALxqzK4w7v7pg8XuAX7ZUDhWP-5aejpxMT802AYSfHNi7uRfmA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALxqzK4w7v7pg8XuAX7ZUDhWP-5aejpxMT802AYSfHNi7uRfmA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtTiQJ04gQ-TuOzw0MTFJgGXz5Ag_1jnmvRDNwaEByV4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What I am doing wrong

2019-03-15 Thread Chetan Ganji
Sure. please make sure to mention which class or function from which file
needs to be imported in which file


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Mar 15, 2019 at 6:14 PM Harish Chaudhary 
wrote:

> Hello Chetan can I send you my project can you please look into it
>
> On Fri, 15 Mar, 2019, 5:53 PM Chetan Ganji, 
> wrote:
>
>> In the admin.py file that import statement seems to be wrong.  "*from
>> website.module import website*"
>> I cant help you more as I dont know the directory structure.
>>
>> Check for the location of the module named website relative to the
>> admin.py file.
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Fri, Mar 15, 2019 at 5:36 PM Harish Chaudhary 
>> wrote:
>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To 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/CALxqzK4w7v7pg8XuAX7ZUDhWP-5aejpxMT802AYSfHNi7uRfmA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALxqzK4w7v7pg8XuAX7ZUDhWP-5aejpxMT802AYSfHNi7uRfmA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtTiQJ04gQ-TuOzw0MTFJgGXz5Ag_1jnmvRDNwaEByV4A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjtTiQJ04gQ-TuOzw0MTFJgGXz5Ag_1jnmvRDNwaEByV4A%40mail.gmail.com?utm_medium=email&utm_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/CALxqzK6PkgXvLS%3DMnT4RAYmTqHvuM39cA0LKBSPEj9gT1G38yw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALxqzK6PkgXvLS%3DMnT4RAYmTqHvuM39cA0LKBSPEj9gT1G38yw%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjvH3q4B1UCph5UQJ_oT0Y86%2BiQokYi8cNLm64QDhTO8-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there any inline editing the data and delete data in table in Django?

2019-03-20 Thread Chetan Ganji
Hi Sankar,

Derek is right, we can only give you suggestions as we are far away from
you. How is really upto YOU.
What you are trying to achieve is basically a front end task. You only have
knowledge of django which is a backend technology.

You have many options to make choice from -
1. You have to learn to use jquery to do it the way you want it.
2. Use the default UpdateView from django where EDIT/UPDATE view will be
shown separately. i.e. let go of inline editing feature.
3. Find someone who will code it for you.
4. Any other that you can think of.

Happy Coding :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Mar 20, 2019 at 11:58 AM VeeraNagaRaja Sankar 
wrote:

> hi,
>
> means, i am only aware of Django so i need any code reference to do that
>  thank you,
>
> Best Regards,
> Inti VeeraNagaRaja Sankar,M.Tech(IT)
> M: 9985864383
> intisank...@gmail.com 
> https://about.me/veeranagarajasankar
>
>
> On Wed, Mar 20, 2019 at 11:55 AM Derek  wrote:
>
>> That is not an answerable question.  We have given you suggestions - the
>> "how" is up to you.
>>
>> On Tuesday, 19 March 2019 09:36:27 UTC+2, veera nagaraja sankar Inti
>> wrote:
>>>
>>>
>>> how ?
>>>
>>> On Monday, March 4, 2019 at 12:40:03 PM UTC+5:30, Derek wrote:
>>>>
>>>> Grid / tabular editing outside of the admin is tricky; I have not been
>>>> able to manage it and have not found a good app for it.
>>>>
>>>> Here are some suggested reading:
>>>>
>>>> * https://www.ibm.com/developerworks/library/wa-django/index.html
>>>> * https://bossanova.uk/jexcel
>>>> *
>>>> https://medium.com/ag-grid/building-a-crud-application-with-ag-grid-part-4-3189034df922
>>>>
>>>> You'd also need an app like Django REST Framework to handle GET/POST of
>>>> JSON data to populate your grid.
>>>>
>>>> On Wednesday, 27 February 2019 20:39:04 UTC+2, veera nagaraja sankar
>>>> Inti wrote:
>>>>>
>>>>> need help friends ?..
>>>>>
>>>>> thq..
>>>>>
>>>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/562202e8-53a3-44d2-b0aa-ba710e180787%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/562202e8-53a3-44d2-b0aa-ba710e180787%40googlegroups.com?utm_medium=email&utm_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/CAJFTHQa_6OGseZ8TwrniWrUNDM%2BkN8a%3DChBFrF7j4XRysARaLw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJFTHQa_6OGseZ8TwrniWrUNDM%2BkN8a%3DChBFrF7j4XRysARaLw%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjuhQ56%3DEurstUPVqxOXv3u%2Bj3VSaggTOkOAx_u95CJ3%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: custom registration form

2019-03-25 Thread Chetan Ganji
There is a better way in django.

Django provides admin panel for the admins, you just have to create one
account for the admin as superuser. Email needs to be sent manually which
can be done immediately after the form is validated.
User model has "*is_active*" flag that can be used to limit access before
the user is authorised by the admin. You will have to create an additional
page to accept or discard the registered user.

If you dont want to use default admin panel, you will end up writing CRUD
for the admin panel. Workflow will still be the same as above.



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, Mar 25, 2019 at 6:22 PM Shubham Joshi  wrote:

> How can I create sign up form in such a way that..once a form has been
> filled and submitted by user (teacher / student) . The form should be sent
> to the Admins email id , once s/he verified the sign up form , the user
> should able log in
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/67df728c-e165-4390-8fd8-9c5bc4ae1103%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/67df728c-e165-4390-8fd8-9c5bc4ae1103%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjsnb%3D48VXQGhCOc-HoQ2END9n_zL0TrJ_9uQ7PZmdxtDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unit-Testing Django Views

2019-03-28 Thread Chetan Ganji
I would prefer to just check the status code of the response object.
This is what I have done. You have to check if it works for forms with
csrf_token or not.


class TestReverseUrls(TestCase):

def setUp(self):
self.client = Client()
self.reverseUrls = ['index', 'login', 'register']
self.response = {url:self.client.get(reverse(url)) for url in self
.reverseUrls}

def test_reverse_urls(self):
for url in self.reverseUrls:
self.assertEqual(self.response[url].status_code, 200)



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Mar 29, 2019 at 12:57 AM Aldian Fazrihady  wrote:

> 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
>>> <https://www.amazon.in/Test-Driven-Development-Python-Selenium-JavaScript/dp/1491958707>
>>>  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*
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>

Re: Unit-Testing Django Views

2019-03-28 Thread Chetan Ganji
There is one more way you could do it


class TestIndexPageLoad(TestCase):

def setUp(self):
self.client = Client()
self.response = self.client.get('/')

def test_check_response(self):
self.assertTemplateUsed(self.response, 'index.html')



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Mar 29, 2019 at 1:56 AM Chetan Ganji  wrote:

> I would prefer to just check the status code of the response object.
> This is what I have done. You have to check if it works for forms with
> csrf_token or not.
>
>
> class TestReverseUrls(TestCase):
>
> def setUp(self):
> self.client = Client()
> self.reverseUrls = ['index', 'login', 'register']
> self.response = {url:self.client.get(reverse(url)) for url in self
> .reverseUrls}
>
> def test_reverse_urls(self):
> for url in self.reverseUrls:
> self.assertEqual(self.response[url].status_code, 200)
>
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Fri, Mar 29, 2019 at 12:57 AM Aldian Fazrihady 
> wrote:
>
>> 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
>>>> <https://www.amazon.in/Test-Driven-Development-Python-Selenium-JavaScript/dp/1491958707>
>>>>  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 sn

Re: I am on a e-commerce website on a video from youtube and I am having problems with stripe

2019-03-29 Thread Chetan Ganji
 I am not sure about this.

But the issue seems to be that the user in question has a stripe account
and that stripe account does not have any cards associated with the
account. Maybe try adding a card to the account, if it does not have any.
If it has, delete it and create a new one. See if it helps.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 29, 2019 at 6:16 PM Patrice Chaula  wrote:

> I am using Stripe to process payments from my website. Yesterday it was
> working ok. That was before I changed code my code so It can process
> payments using a customer_id. I am using test keys
>
>  My code below. Help I'm still a beginner in django. I'm sorry my English
> is bad.
>
> from django.shortcuts import render
> from django.contrib.auth.decorators import login_required
> from django.conf import settings
> import stripe
>
>
> stripe.api_key =  settings.STRIPE_SECRET_KEY
> # Create your views here.
> @login_required
> def checkout(request):
>  publishKey = settings.STRIPE_PUBLISHABLE_KEY
>customer_id = request.user.userstripe.stripe_id
> print(customer_id)
>  if request.method == 'POST':
>customer = stripe.Customer.retrieve(customer_id)
>token = request.POST['stripeToken']
> charge = stripe.Charge.create(
>  amount = 1000,
>  currency = 'usd',
>   customer = customer,
>description = 'Example Charge',
> )
>   context = {'publishKey':publishKey}
> template = 'checkout.html'
>  return render(request, template, context)
>
>
> The error I am getting is below
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\django\core\handlers\exception.py" in
> inner
>   34. response = get_response(request)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in
> _get_response
>   126. response = self.process_exception_by_middleware(e,
> request)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\django\core\handlers\base.py" in
> _get_response
>   124. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\django\contrib\auth\decorators.py" in
> _wrapped_view
>   21. return view_func(request, *args, **kwargs)
>
> File "C:\Users\Patrice\Desktop\ecommerce web\ecommerce\checkout\views.py"
> in checkout
>   22. description = 'Example Charge',
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\stripe\api_resources\abstract\createable_api_resource.py"
> in create
>   22. response, api_key = requestor.request("post", url, params,
> headers)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in request
>   121. resp = self.interpret_response(rbody, rcode, rheaders)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in
> interpret_response
>   372. self.handle_error_response(rbody, rcode, resp.data,
> rheaders)
>
> File "C:\Program
> Files\Python37-32\lib\site-packages\stripe\api_requestor.py" in
> handle_error_response
>   151. raise err
>
> Exception Type: CardError at /checkout/
> Exception Value: Request req_En9Ipi3bygWUWY: Cannot charge a customer that
> has no active card
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/04423272-5bf9-4b26-9963-c180b926c909%40googlegroups.com
> <https://groups.google.co

Re: ModelForm for model that includes multiple items of one kind

2019-03-30 Thread Chetan Ganji
I think, you will need to implement something like below.

Profile:
first_name
middle_name
last_name
birthday
address  (primary/default)
email (primary/default)
phone (primary/default)


Address

address_line1
address_line2
City
state
zip

Email

email

Phone

phone


As one profile can have multiple entries of addresses, email and phone
numbers, you could use concept of formset to deal with them.
Also, as there are multiple entries, you could store one of them as default
or primary.

I hope this helps :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, Mar 31, 2019 at 3:56 AM Dean Karres  wrote:

> Hi
>
> I am looking for some advice.  I have a basic Profile model.  It looks
> something like:
>
> Profile:
> first_name
> middle_name
> last_name
> birthday
> address_line1
> address_line2
> city
> state
> zip
> email
> phone
>
> I have a ModelForm that goes with this.
>
> This is sufficient for nearly all the cases I am trying to deal with.
> However, there are a few special cases in which a person needs to list two
> or more addresses; two or more email addrs; two or more phone numbers; or,
> combinations.
>
> I know just enough about database normalization to think that I need the
> Profile model plus Address, Email and Phone models and have the Profile
> have a ForeignKey relation to each of the others.  A la:
>
> Profile:
> first_name
> middle_name
> last_name
> birthday
> 
> 
> 
>
> Address
> address_line1
> address_line2
> City
> state
> zip
>
> Email
> email
>
> Phone
> phone
>
> My question is more about the associated ModelForm(s).  First, I currently
> have a ModelForm for the first Profile model without the foreign keys.  If
> I break out the address, email and phone portions into separate models do I
> need to create separate model forms for each new model?  If so would the
> new Profile ModelFOrm just inherit the ModelForms of the other components.
> Something like:
>
> class ProfileForm(ModelForm, AddressForm, EmailForm, PhoneForm):
> ...
>
> The current ModelForm has "clean_" "clean" methods.  Do I keep that
> in the new Profile form?  Do I put the various "clean" methods in their own
> model forms and hope that inheritance will pull them in?
>
> Next, how does a ModelForm deal with more than one of the same item --
> like more then one address?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/a8954cd8-e3c6-4d6f-8780-1f88a9874a3b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a8954cd8-e3c6-4d6f-8780-1f88a9874a3b%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjuXoHKh9CwOe%3DG78mJhQUvw19Uva2hUORKxgCtbReuXNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re:

2019-03-30 Thread Chetan Ganji
Best way to learn coding n framework is to build a project. I have taken
courses from various vendors, best ones are the one from Coding For
Entrepreneurs. He also has a youtube channel. Start with try django 1.8

On Sun, Mar 31, 2019, 6:20 AM Makori Breens  wrote:

> http://track.haatm.com/aff_c?offer_id=919&aff_id=29710
>
> On 3/30/19, Victor H. Velasquez Rizo  wrote:
> > Hello Carol.
> >
> > Try this
> > https://tutorial.djangogirls.org/en/
> >
> > On Sat, Mar 30, 2019 at 9:12 AM carol caro 
> wrote:
> >
> >> Hello. I am a new or beginner django developer. Where do I start
> from
> >> I have installed python and integrated with Django framework but I don't
> >> know what to do next
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "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/CAN%2Bowc-S7n3OX0jc_fLjro6unDSNZJU4yGbYsxTLGeh55%3DFQvA%40mail.gmail.com
> >> <
> https://groups.google.com/d/msgid/django-users/CAN%2Bowc-S7n3OX0jc_fLjro6unDSNZJU4yGbYsxTLGeh55%3DFQvA%40mail.gmail.com?utm_medium=email&utm_source=footer
> >
> >> .
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
> >
> > --
> >
> >
> >
> > Atte...,.
> > Vìctor Hugo Velàsquez Rizo
> > Cali - Colombia
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "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/CAFCXTzjxXSzeP8KQEWeV%2BCnVOZEHPinh08iCN1a1jYWpNcf4Xw%40mail.gmail.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/CAOz9w2Ei8LWhTorQ5Lmw-O4vBK683v%3D-nwLnWZDGQgs0uJrejA%40mail.gmail.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/CAMKMUjspjMOPeuUCCnsCsrU-_D3LWjx68F1VxasEGm8beEOX0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static image not getting displayed.

2019-04-02 Thread Chetan Ganji
{% load static %} in the first link of your template.

You have below code


The line should be



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Apr 3, 2019 at 1:13 AM Ing.Daniel Bojorge 
wrote:

> See the development tools and look what path is it?
>
> So, put STATIC_URL = '/static/' in your settings.py and
> {% load static %} in the first link of your template.
>
>
> Dios L@s Bendiga
>
> Saludos,
>
>
>
> [image: --]
>
> daniel.bojorge
> [image: http://]about.me/daniel.bojorge
> <http://about.me/daniel.bojorge?promo=email_sig>
>  *Curso Desarrollo Web con Python usando Django 2.1 Para Principiantes*
> <https://goo.gl/oeT5Sx>
> *WebService RestFul API con Python usando Django RestFrameWork*
> <https://goo.gl/j8i34C>
> *Fácil Replicación de Cualquier Base de Datos y/o Sistema Operativo*
> <https://goo.gl/HjtExs>
> *Programación en Capas (Web y Escritorio)* <https://goo.gl/zGZpSD>
> Mi Blog <http://debsconsultores.blogspot.com>
> Nicaragua
>
> "Si ustedes permanecen unidos a mí, y si permanecen fieles a mis
> enseñanzas, pidan lo que quieran y se les dará.
> (Juan 15:7 DHH)
> Bendito el varón que se fía en el SEÑOR, y cuya confianza es el SEÑOR.
> (Jeremías 17:7 RV2000)
>
>
>
> El mar., 2 abr. 2019 a las 12:36, Agbonxoft Prince ()
> escribió:
>
>> Try loading static , if it's not loaded
>> *{% load static %}* in the HTML page
>>
>>
>> On Tue, Apr 2, 2019, 19:01 Sandip Nath  wrote:
>>
>>> Downloaded an image of Django Reinhardt and saved it in static/images
>>> folder as django.jpeg. In the settings.py file created a variable
>>> STATIC_DIR and assigned it os.path.join(BASE_DIR, 'static') and again
>>> assign this variable to STATICFILES_DIR and kept the STATIC_URL as
>>> "/static/". In the index.html written that:
>>> 
>>>
>>> But after doing all this I am getting only the text of alt and no image.
>>> Where I am wrong? 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/bbaac132-6d24-43a3-8278-fe5878c0b694%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/bbaac132-6d24-43a3-8278-fe5878c0b694%40googlegroups.com?utm_medium=email&utm_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/CAKbA5VTtt0Gbjn-TPtxhpgDbf1T5EwAUhnPr%2BT%3DqmMmNU%3DsO5A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAKbA5VTtt0Gbjn-TPtxhpgDbf1T5EwAUhnPr%2BT%3DqmMmNU%3DsO5A%40mail.gmail.com?utm_medium=email&utm_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/CAMQeQjb-%3D5vCMYUsZG-RgmPTMxft1mxDWW0w9fErqzYmEbNZMg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMQeQjb-%3D5vCMYUsZG-RgmPTMxft1mxDWW0w9fErqzYmEbNZMg%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjsZHGjrkdE77YTNBXNcwbqg-bqMJvhxRsOx5%3D1-FehtWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Changing Admin Interface in Django

2019-04-11 Thread Chetan Ganji
Django CMS has a different admin site i.e. Layout and CSS is different.
There are many admin site available from third party. Maybe you might like
some of them.
https://djangopackages.org/grids/g/admin-styling/

Other way to do is, list all the templates in the admin site app. Find out
their css files and change them manually.
That's a very tedious task.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Apr 11, 2019 at 10:54 PM Aayush Bhattarai 
wrote:

> Yes I want to change everything.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/309a5372-abb7-4525-8b95-f6e4528bd6f2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/309a5372-abb7-4525-8b95-f6e4528bd6f2%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjt8niG-paSaO0y%3DWzDu3KOCCErozg-ZoXeB3iZYn%2BwZZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help, I need to convert my python code into Secure API using Django

2019-04-29 Thread Chetan Ganji
Hi Vamsi,

For No 1 - You can create a REST API using django or (django + django rest
framework).
For No 2,3,4 - For production you have to user Apache + modwsgi or nginx +
gunicorn (or other wsgi compliant server for python).

I dont suggest windows for production. If you plan to use it on linux,
below is the tutorial. I have used it many times for deployments.
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04




Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, Apr 29, 2019 at 9:46 PM Vamsi tangutoori <
vamsidhar.tanguto...@gmail.com> wrote:

> Hi Everyone,
> I am new to django and python programming. I developed a facial
> recognition module in python using boto3 library. Currently I sued flask to
> create an API and test in my development environment but to move it to
> production i need to use django. Can you please help or point me in the
> right direction as to how do i do the below.
>
> 1. Take my facialrecognition.py file and convert it into an API,
> preferably using django.
> 2. Make this API to be pointing to a specific URL(locally on a windows
> machine).
> 3. Deploy this code into a production machine(windows).
> 4. Make sure that the API starts every time the windows machine starts to
> avoid loosing service.
>
> Things i researched so far are:
> 1. How to create a django project with its REST library.
> 2. From the articles and tutorials i found out that this is only
> development version, to deploy in production i need a production server
> like Apache etc. is this necessary?
>
> Thanks in Advance for your help.
> Vamsi.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/17aa8268-0fd8-4095-a5bb-82e68eecf186%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/17aa8268-0fd8-4095-a5bb-82e68eecf186%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvsqqRLp-6btfhV951gqwq5t1AehKsCgsER2UFuFfhMbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help, I need to convert my python code into Secure API using Django

2019-04-29 Thread Chetan Ganji
Linux is very easy to get started, as a web developer, all the code that
you write will end up on a linux server eventually.
It would be very good idea to start learning linux immediately. You will
require that skill in the near future.
None would want to pay the price of windows server when Linux is FREE ;-)

However, for the time being, please dabble with apache + modwsgi for
windows. I dont remember exact resources I used to deploy on window.
Simplest alternative is given below.
https://bitnami.com/stack/django/installer

One thing I remember is modwsgi is dependant on the python version i.e.
different python versions require modwsgi to be built for that specific
version.
Try some the ones listed in below link, if they don't work, you have to
search online for that.
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

Some tuts from youtube. I havent checked them yet so do your R&D. Follow
the steps that they have shown i the video to see if it works.
https://www.youtube.com/watch?v=s0RX_YU9eJM
https://www.youtube.com/watch?v=VnR5O4IjmOs

Hope it helps.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Apr 30, 2019 at 12:05 AM Vamsi 
wrote:

> Hi Chetan,
> Thanks for the quick reply. Linux is not an option for me as I am not well
> versed in it. Is it possible for you to give me some resource for windows.
>
> Thanks and regards,
> Vamsi
>
> Sent from my iPhone
>
> On Apr 29, 2019, at 1:06 PM, Chetan Ganji  wrote:
>
> Hi Vamsi,
>
> For No 1 - You can create a REST API using django or (django + django rest
> framework).
> For No 2,3,4 - For production you have to user Apache + modwsgi or nginx +
> gunicorn (or other wsgi compliant server for python).
>
> I dont suggest windows for production. If you plan to use it on linux,
> below is the tutorial. I have used it many times for deployments.
>
> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>
>
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Mon, Apr 29, 2019 at 9:46 PM Vamsi tangutoori <
> vamsidhar.tanguto...@gmail.com> wrote:
>
>> Hi Everyone,
>> I am new to django and python programming. I developed a facial
>> recognition module in python using boto3 library. Currently I sued flask to
>> create an API and test in my development environment but to move it to
>> production i need to use django. Can you please help or point me in the
>> right direction as to how do i do the below.
>>
>> 1. Take my facialrecognition.py file and convert it into an API,
>> preferably using django.
>> 2. Make this API to be pointing to a specific URL(locally on a windows
>> machine).
>> 3. Deploy this code into a production machine(windows).
>> 4. Make sure that the API starts every time the windows machine starts to
>> avoid loosing service.
>>
>> Things i researched so far are:
>> 1. How to create a django project with its REST library.
>> 2. From the articles and tutorials i found out that this is only
>> development version, to deploy in production i need a production server
>> like Apache etc. is this necessary?
>>
>> Thanks in Advance for your help.
>> Vamsi.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/17aa8268-0fd8-4095-a5bb-82e68eecf186%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/17aa8268-0fd8-4095-a5bb-82e68eecf186%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvsqqRLp-6btfhV951gqwq5t1AehKsCgsER2UFuFfhMbA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMKMUjvsqqRLp-6btfhV951gqwq5

Re: More controls on createsuperuser

2019-04-30 Thread Chetan Ganji
RE :"*someone could still run createsuperuser *"

How do you suppose this is going to happen unless they have access to your
system?

If you are really concerned about that?? django is basically a package.
Just find the source code for the creatsuperuser admin command and delete
that file if its the only command in that file ;-)
if not just delete that function only :) Its that simple.

But How will you create a superuser after deleting the command from the
django package??

One way to solve is write your own custom management command, create
superuser at the time of deployment and delete that custom command also.

I hope this solves your problemo :)
Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, Apr 30, 2019 at 6:09 PM Lipika Chandel 
wrote:

> Hey,
> I am using Django 2.2 and I am stuck with the image upload functionality
> from admin site. I am not able to get the image on my template.
> Please help.
>
> Thanks & Regards
> LIPIKA CHANDEL
>
> On Tue, Apr 30, 2019 at 11:57 AM Jani Tiainen  wrote:
>
>> I've have to agree that any attempt to limit superuser creation through
>> manage.py is wrong solution to wrong problem.
>>
>> Even it's possible to attempt it it is as easy to circumvent.
>>
>> So do not give an access to manage.py to users that are not supposed to.
>> Problem solved for good.
>>
>> ma 29. huhtik. 2019 klo 21.04  kirjoitti:
>>
>>> Anyone capable of running the createsuperuser command on your project
>>> most probably has access to all and any of the project's files, specially
>>> your config file.
>>>
>>> Actually this user is either a valid su or you are in serious trouble
>>> because the security of your server sucks or you gave access to your
>>> project to the wrong person.
>>>
>>> So, no I don't think there is any point in doing so. Not because it
>>> can't be done but because it is both trivially useless.and uselessly
>>> trivial.
>>>
>>>
>>>
>>> On Sunday, April 28, 2019 at 11:24:57 PM UTC-4, JJ Zolper wrote:
>>>>
>>>> All,
>>>>
>>>> Curious what people think about more thought and control going into who
>>>> can run the createsuperuser method?
>>>>
>>>> For example say there's models that I don't want anyone to touch except
>>>> myself as a superuser. Is it not plausible that even if I make a Django
>>>> Group around that model that someone could still run createsuperuser and
>>>> give themselves the ability to have full control?
>>>>
>>>> Wouldn't it make sense if some random developer were to run
>>>> createsuperuser using django settings with any of the databases (as an
>>>> example) that it prevent them if say that email isn't on say an internal
>>>> list in the django admin of approved potential users?
>>>>
>>>> I see something like this being a good idea to prevent just anyone from
>>>> getting full control over the site without it being specifically provided.
>>>>
>>>> Maybe there's something I'm missing something but been reading about
>>>> third party options and more about what's there and I just feel there's a
>>>> hole when it comes to who can create a super user account. Obviously you
>>>> could have a script that you run to initialize who is a super user, what
>>>> the groups are etc, but then you're basically recording personal
>>>> information somewhere when that should only be typed in.
>>>>
>>>> Open to ideas and thoughts, mostly just curious what could be a good
>>>> answer.
>>>>
>>>> Best,
>>>>
>>>> JJ
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/f85e2d9b-ec2d-4814-b4d5-df137bf8a883%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/f85e2d9b-ec2d-4814-b4d5-df137bf8a883%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For 

Re: Website slowed down drasticaly

2019-05-02 Thread Chetan Ganji
Not sure about whats the issue. You could do couple of things to understand
whats the root cause of the problem.
I know they are generic guidelines. Anyone couldnt be more specific than
this.


   1. Benchmark the time required to process each request. You could write
   a middleware to track this time.
   Attach starttime to each request object and read that at the time of
   returning the response.

   2. Try using the django debug toolbar to see how much time it is taking
   to execute the sql queries.
   There might be some room for improvement as most developers dont
   practice sql regularly.
   https://django-debug-toolbar.readthedocs.io/en/latest/

   3. Maybe try using a different database - PostgreSQL, MySQL, etc.

   4. But if you have time for R&D, you could try using the different
   python implementation, it is said to be faster in many cases than cpython.
   It's not 100% compliant i.e. some packages might not work with pypy. So
   please do your research before walking down this road.
   https://pypy.org/

   5. Try using a different web server. If you are using Apache, try using
   nginx. Also use a different wsgi server. If you are using gunicorn, try
   with waitress or others.



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 2, 2019 at 5:09 PM Saurabh Adhikary 
wrote:

> Hello ,
>
> I'm using Django version 1.8.1  and Python version 2.7.12 . Suddenly since
> Feb '19 there has been a drastic decrease in my website's response rate.
> For sure , there has been some minor increase in the no of hits, but the
> performance is too bad.
>
> Initially , the thought came that the hardware of the server was old , so
> a new server with high configuration was bought.
> We have done the new indexing also on it.
> Still the sought for a higher performance is awaited.
>
>
> Is it that the Django support for 1.8.1 or Python support for 2.7.12 has
> reduced and that is casing the website to slow down or I am missing out on
> something ?
> 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 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/238a6da2-8f34-4b8b-939c-e20d4306545b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/238a6da2-8f34-4b8b-939c-e20d4306545b%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjt8bqgOOns%3DuAsVbtR3yz17VypX3766zCMN5zVtbbRX4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: help with URLS.PY

2019-05-02 Thread Chetan Ganji
The line
path('', HomeView.as_view(), name='home'),

Change it to below and try again.
path(''", HomeView.as_view(), name='home'),


On May 3, 2019 2:52 AM,  wrote:

new to django. so i have an app that displays an html page. i also have a
menu on that page that will load up other html pages.
however, when i add the path to urls.py and then the class def in views, it
fails. i know it's something simple, what am i missing.

As I said, the dashboard.html works, i just want another menu option to
load the other html file. i have commented this out as it causes my app to
break.



urls.py

from django.conf.urls import url
from django.contrib import admin
from django.urls import path

from vr_reporting_app.views import HomeView
from vr_reporting_app.views import Map

urlpatterns = [
path('', HomeView.as_view(), name='home'),#points to the view in
views.py
#path('map/', Map.as_view(), name='map'),

path('admin/', admin.site.urls),
]


views.py

from django.shortcuts import render
from django.views.generic.base import TemplateView

class HomeView(TemplateView):
template_name = 'dashboard.html'

class Map(TemplateView):
template_name = 'map.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/8ef3e2d9-799e-4803-bd20-199300b373af%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/CAMKMUjv3M2J8by9hAcikBS4snG88R0mijmSeG-ms28p%2BRbOKnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Website slowed down drasticaly

2019-05-03 Thread Chetan Ganji
Hi Saurabh,

You are welcome :)

No 1 will give you insights about which endpoints are taking the most time
to load. Then, you can drill down the specific endpoints for bottlenecks.

Two more things you could try.

1. Remove unused/unnecessary middlewares from the middlewares list in the
settings.py of the project.
As they are executed before and after every single request, they could add
hugh unnecessary overhead easily.

2. Normally requests are processed in synchronous manner. Gunicorn has
aysnc worker types.
I did not have a need to look into it yet, but they could help speed up
things.
I would not suggest it for payment gateway endpoints. If your project is a
ERP/CRM type project, it could help you a little to look into it.
https://www.spirulasystems.com/blog/2015/01/20/gunicorn-worker-types/

Nginx already handles requests async manner. Try combining Nginx + Async
worker in gunicorn.
You could get some boost.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, May 3, 2019 at 11:00 AM Saurabh Adhikary 
wrote:

> Hi Chetan,
>
> 1)  Yes . We are infact trying this. Thank You.
> 2) *Taken*
> 3) We are on MySql , migration will cost a lot of man hours, which can be
> invested only if the result is concrete.
> 4) Up-gradation, that's our last resort.
> 5) Tried almost all. All in vain.
>
> Thanks for your inputs. :)
>
> On Thursday, 2 May 2019 17:52:11 UTC+5:30, Chetan Ganji wrote:
>>
>> Not sure about whats the issue. You could do couple of things to
>> understand whats the root cause of the problem.
>> I know they are generic guidelines. Anyone couldnt be more specific than
>> this.
>>
>>
>>1. Benchmark the time required to process each request. You could
>>write a middleware to track this time.
>>Attach starttime to each request object and read that at the time of
>>returning the response.
>>
>>2. Try using the django debug toolbar to see how much time it is
>>taking to execute the sql queries.
>>There might be some room for improvement as most developers dont
>>practice sql regularly.
>>https://django-debug-toolbar.readthedocs.io/en/latest/
>>
>>3. Maybe try using a different database - PostgreSQL, MySQL, etc.
>>
>>4. But if you have time for R&D, you could try using the different
>>python implementation, it is said to be faster in many cases than cpython.
>>It's not 100% compliant i.e. some packages might not work with pypy.
>>So please do your research before walking down this road.
>>https://pypy.org/
>>
>>    5. Try using a different web server. If you are using Apache, try
>>using nginx. Also use a different wsgi server. If you are using gunicorn,
>>try with waitress or others.
>>
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, May 2, 2019 at 5:09 PM Saurabh Adhikary 
>> wrote:
>>
>>> Hello ,
>>>
>>> I'm using Django version 1.8.1  and Python version 2.7.12 . Suddenly
>>> since Feb '19 there has been a drastic decrease in my website's response
>>> rate.
>>> For sure , there has been some minor increase in the no of hits, but the
>>> performance is too bad.
>>>
>>> Initially , the thought came that the hardware of the server was old ,
>>> so a new server with high configuration was bought.
>>> We have done the new indexing also on it.
>>> Still the sought for a higher performance is awaited.
>>>
>>>
>>> Is it that the Django support for 1.8.1 or Python support for 2.7.12 has
>>> reduced and that is casing the website to slow down or I am missing out on
>>> something ?
>>> 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...@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/238a6da2-8f34-4b8b-939c-e20d4306545b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/238a6da2-8f34-4b8b-939c-e20d4306545b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/opto

Re: Website slowed down drasticaly

2019-05-03 Thread Chetan Ganji
One more thing -

All the third party resources i.e. js and css files e.g. bootstrap, jquery,
etc;  don't fetch them from your server.
Use CDN for those. This will help the load times a lot.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, May 3, 2019 at 2:47 PM Chetan Ganji  wrote:

> Hi Saurabh,
>
> You are welcome :)
>
> No 1 will give you insights about which endpoints are taking the most time
> to load. Then, you can drill down the specific endpoints for bottlenecks.
>
> Two more things you could try.
>
> 1. Remove unused/unnecessary middlewares from the middlewares list in the
> settings.py of the project.
> As they are executed before and after every single request, they could add
> hugh unnecessary overhead easily.
>
> 2. Normally requests are processed in synchronous manner. Gunicorn has
> aysnc worker types.
> I did not have a need to look into it yet, but they could help speed up
> things.
> I would not suggest it for payment gateway endpoints. If your project is a
> ERP/CRM type project, it could help you a little to look into it.
> https://www.spirulasystems.com/blog/2015/01/20/gunicorn-worker-types/
>
> Nginx already handles requests async manner. Try combining Nginx + Async
> worker in gunicorn.
> You could get some boost.
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Fri, May 3, 2019 at 11:00 AM Saurabh Adhikary <
> adhikarysaur...@gmail.com> wrote:
>
>> Hi Chetan,
>>
>> 1)  Yes . We are infact trying this. Thank You.
>> 2) *Taken*
>> 3) We are on MySql , migration will cost a lot of man hours, which can be
>> invested only if the result is concrete.
>> 4) Up-gradation, that's our last resort.
>> 5) Tried almost all. All in vain.
>>
>> Thanks for your inputs. :)
>>
>> On Thursday, 2 May 2019 17:52:11 UTC+5:30, Chetan Ganji wrote:
>>>
>>> Not sure about whats the issue. You could do couple of things to
>>> understand whats the root cause of the problem.
>>> I know they are generic guidelines. Anyone couldnt be more specific than
>>> this.
>>>
>>>
>>>1. Benchmark the time required to process each request. You could
>>>write a middleware to track this time.
>>>Attach starttime to each request object and read that at the time of
>>>returning the response.
>>>
>>>2. Try using the django debug toolbar to see how much time it is
>>>taking to execute the sql queries.
>>>There might be some room for improvement as most developers dont
>>>practice sql regularly.
>>>https://django-debug-toolbar.readthedocs.io/en/latest/
>>>
>>>3. Maybe try using a different database - PostgreSQL, MySQL, etc.
>>>
>>>4. But if you have time for R&D, you could try using the different
>>>python implementation, it is said to be faster in many cases than 
>>> cpython.
>>>It's not 100% compliant i.e. some packages might not work with pypy.
>>>So please do your research before walking down this road.
>>>https://pypy.org/
>>>
>>>5. Try using a different web server. If you are using Apache, try
>>>using nginx. Also use a different wsgi server. If you are using gunicorn,
>>>try with waitress or others.
>>>
>>>
>>>
>>> Regards,
>>> Chetan Ganji
>>> +91-900-483-4183
>>> ganji...@gmail.com
>>> http://ryucoder.in
>>>
>>>
>>> On Thu, May 2, 2019 at 5:09 PM Saurabh Adhikary 
>>> wrote:
>>>
>>>> Hello ,
>>>>
>>>> I'm using Django version 1.8.1  and Python version 2.7.12 . Suddenly
>>>> since Feb '19 there has been a drastic decrease in my website's response
>>>> rate.
>>>> For sure , there has been some minor increase in the no of hits, but
>>>> the performance is too bad.
>>>>
>>>> Initially , the thought came that the hardware of the server was old ,
>>>> so a new server with high configuration was bought.
>>>> We have done the new indexing also on it.
>>>> Still the sought for a higher performance is awaited.
>>>>
>>>>
>>>> Is it that the Django support for 1.8.1 or Python support for 2.7.12
>>>> has reduced and that is casing the website to slow down or I am missing out
>>>> on something ?
>>>> Kindly help.
>>>>
>>>> --
&

Re: Need Help

2019-05-07 Thread Chetan Ganji
As far as I know, there are only two dependency for the django, that is
pytz and sqlparse. Rest of the code for django is written from scratch.

You can confirm this by creating a new virtualenv and install django inside
it. Command will install django as well as other 2 libraries.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, May 7, 2019 at 5:15 PM Manoj Kumar Singh 
wrote:

> Many of the  interviewer asked me how many libraries and frameworks are
> used in django project.
> Please let me know the correct answer.
>
> --
>
>
> *Regards:-*Manoj Kumar Singh
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAKfuDkW7XDhaYYNBB2gWRXJ35o6AnJvX4b3b5WPrVWW7HrruzA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKfuDkW7XDhaYYNBB2gWRXJ35o6AnJvX4b3b5WPrVWW7HrruzA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtjgSVosmRaaxi%2BLoSF1qYm3YH7TDNw6FTnT%3DJs9ir5Lw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: form submission

2019-05-09 Thread Chetan Ganji
Hi Ganesh,

This guy is total nerd. He teaches in a very easy to understand way ;-)
https://www.youtube.com/watch?v=KsLHt3D_jsE&list=PLEsfXFp6DpzRcd-q4vR5qAgOZUuz8041S

Start with Try Django 1.8.

Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 9, 2019 at 6:44 PM Lutalo Bbosa joseph 
wrote:

> please specify what type of forms. coz in django u can create forms in
> forms.py using the models, and then this can be invoked in html as {{ forrm
> }} so am not understanding what u want specifically
>
> On Thu, May 9, 2019 at 3:39 PM Ganesh Babu  wrote:
>
>> Recently i was started Pyhon with Django.  Installation has been
>> succeeded in ubuntu and projects creation is also succeeded.
>>
>> Please help me,  how to create  form submission using pycharm
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/24114dd0-1699-4459-905e-49904371dc73%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/24114dd0-1699-4459-905e-49904371dc73%40googlegroups.com?utm_medium=email&utm_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%3DTkAdQ-wTZoxAqjt7HbTp2tHvskAs5pf296d_kb4ybkbA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DTkAdQ-wTZoxAqjt7HbTp2tHvskAs5pf296d_kb4ybkbA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtAdF8Dh_HYOjxtHC89Y6MmeaD6VAMVwkJNZdROFO78-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: form submission

2019-05-09 Thread Chetan Ganji
He sure does have it .

https://www.youtube.com/watch?v=-oQvMHpKkms&list=PLEsfXFp6DpzTD1BD1aWNxS2Ep06vIkaeW&index=49

But in try django 1.8 he teaches the very basic stuff that everyone needs
to know about django. I just wish I started with this project instead of
others.
As I only found one project that teaches the basic stuff in simple and
effective manner. I have taken courses from many different people.
Most of them went out of my head as they never fully explained what the
heck was happening. That's not the case with Justin Mitchell ;-)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 9, 2019 at 9:56 PM Robert Wahoo  wrote:

> That’s for 1.8, does he have an updated set of videos for 2.x?
>
>
>
> *From: *"django-users@googlegroups.com" 
> on behalf of Chetan Ganji 
> *Reply-To: *"django-users@googlegroups.com"  >
> *Date: *Thursday, May 9, 2019 at 12:05 PM
> *To: *"django-users@googlegroups.com" 
> *Subject: *Re: form submission
>
>
>
> Hi Ganesh,
>
> This guy is total nerd. He teaches in a very easy to understand way ;-)
>
>
> https://www.youtube.com/watch?v=KsLHt3D_jsE&list=PLEsfXFp6DpzRcd-q4vR5qAgOZUuz8041S
>
>
>
> Start with Try Django 1.8.
>
>
> Cheers!
>
>
>
>
> Regards,
>
> Chetan Ganji
>
> +91-900-483-4183
>
> ganji.che...@gmail.com
>
> http://ryucoder.in
>
>
>
>
>
> On Thu, May 9, 2019 at 6:44 PM Lutalo Bbosa joseph 
> wrote:
>
> please specify what type of forms. coz in django u can create forms in
> forms.py using the models, and then this can be invoked in html as {{ forrm
> }} so am not understanding what u want specifically
>
>
>
> On Thu, May 9, 2019 at 3:39 PM Ganesh Babu  wrote:
>
> Recently i was started Pyhon with Django.  Installation has been succeeded
> in ubuntu and projects creation is also succeeded.
>
>
>
> Please help me,  how to create  form submission using pycharm
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/24114dd0-1699-4459-905e-49904371dc73%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/24114dd0-1699-4459-905e-49904371dc73%40googlegroups.com?utm_medium=email&utm_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%3DTkAdQ-wTZoxAqjt7HbTp2tHvskAs5pf296d_kb4ybkbA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMz%3Dh%3DTkAdQ-wTZoxAqjt7HbTp2tHvskAs5pf296d_kb4ybkbA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtAdF8Dh_HYOjxtHC89Y6MmeaD6VAMVwkJNZdROFO78-A%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMKMUjtAdF8Dh_HYOjxtHC89Y6MmeaD6VAMVwkJNZdROFO78-A%40mail.gmail.com?utm_medium=email&utm_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 vis

Re: Different database types use in a single Django project

2019-05-10 Thread Chetan Ganji
Hi Bbake,

Django Class Based Views and Models are wired for relational databases
only. If you want to use MongoDB with django you have to say bye bye to CBV
and Django ORM. There are some third party libraries to map django models
to mongo, but IDK how good they are for production use.

One way to solve this problem is use Function Based Views for views where
MongoDB will be used.
You will have to access mongo db using a database driver like pymongo.

If you just need to store the json data, another way to solve this problem
is to use django and postgres database.
PostgreSQL has JSON field, django also supports that. Check the official
documents for more info.
https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/

If you find any more solutions, please let me know, as I also want to
explore the options of using mongo with django.
Thanks in advance.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, May 10, 2019 at 5:27 PM Bbake Waikhom  wrote:

> Is there any way that I can use different database type in a single Django
> project like some model A will use SQL and some model B will use MongoDB?
> Because in my project some data are better to store in a relational
> database and some are better to store in a NoSQL database. I've been
> searching for a while to achieve this but I couldn't find any solution.
> Please let me know if there is a way. 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/b3776d83-18c9-47a0-9a8a-e3e7cb2e849a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b3776d83-18c9-47a0-9a8a-e3e7cb2e849a%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvwPcizHF%3DRrdJai9j8C2BakWj7XpMMK_O%2BbntuByHrTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help on architecture of User layout configuration system

2019-05-13 Thread Chetan Ganji
My 2 cents -

You will have to store the user preferences in a settings file on the
server. I would suggest to use a JSONField for the same if you are using
the PostgrSQL. Otherwise you will have to create a separate model. Saving
settings in model will take more efforts. Using JSON for this would be
perfect. Store this JSON on the User Model in the django, so you are
basically adding an extra JSONField to the user model in django. If you
store this data on a different model, you will end up writing one extra
sql/orm query to fetch the settings. So, save yourself that trouble and
store the settings on the user model.

Whatever user can configure, create respective key value pairs for the
same.

Then in every template where these settings would be required, access them
using the variable *request.user.settings* (assuming you named it
settings).
In the templates, wherever the user can customize his view, you would write
the if blocks to check if the current user has selected the respective
settings or not.
Accordingly they would be rendered *DYNAMICALLY*.

I hope it helps :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 13, 2019 at 3:58 PM Devender Kumar  wrote:

> Hi,
> I want to make a web app in which user has rights to configure his
> layout.Means each user can configure his layout according to his choice and
> work
> Like how many fields can his form have how many field he want to see in
> table view of individual record view . configure theme color of his own
> choice .
> all these type of settings he can do for his own use.
> Can any one help me with this type of architecture.
> Thank you
> Devender
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/b9332431-bb74-416d-b5e6-a54db73c1b56%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b9332431-bb74-416d-b5e6-a54db73c1b56%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjtvZ6JngGhGxgVkg%2BjNVm2J4-CgdJRcuUdzpW1aj3p2vA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't save to Postgres db locally - Fresher

2019-05-15 Thread Chetan Ganji
*Problem - *
def *contact*(request):
  ..
  c = *contact*(email='email',subject='subject',message='message')
  ..

The two methods that should be doing two separate things have the same
name. So, the python interpreter is confused.

*Solution - *
Rename anyone of the above methods.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 15, 2019 at 3:50 PM Emmanuel klutse  wrote:

> Hello Team,
> I need help please, I’m try to save to my db from a FORM using the command
> below.
> I’ve all I could but the process keeps failing and I’m stack.
>
> File
> "/Users/emmanuelklutse/Documents/djangodev/myPortfolio/emmanuel/views.py", l
> ine 17, in contact
> c = contact(email='email',subject='subject',message='message')
> TypeError: contact() got an unexpected keyword argument ‘email'
>
>
> def contact(request):
> if request.method == 'POST':
> email = request.POST.get('email')
> subject = request.POST.get('subject')
> message = request.POST.get('message')
>
> c = contact(email='email',subject='subject',message='message')
> c.save()
>
> return render (request,'emmanuel/contact.html')
> else:
> return render (request,'emmanuel/contact.html’)
>
>
> Thanks,
> Emmanuel klutse. 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 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/D5902281-068C-448D-8C3B-4661EC37473A%40gmail.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/CAMKMUjv5c7WoQ8aZzZWgm%3DZxoEs0zX3nVeQC_yiTzKKiHGUVkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help on architecture of User layout configuration system

2019-05-15 Thread Chetan Ganji
This one is interesting. I was also looking for the solution of the same
problem.

If I understand correctly, the problem with forms is -
User can choose the name of the field and the type of the fields e.g.
IntegerField(). FloatField(), etc. Kind of a form that is generated using a
form :P
More like a Form Builder App which will help users create DYNAMIC FORMS.
Am I correct?

We could create a form for that with 2 inputs elements.
One input to enter the name of the field.
Second would be a dropdown (select html element) with the type of the model
fields that django models.Model has. We can also add select dropdown for
constraints.
Store the values of these two in a JSONField(). This part is simple and
possible.

The real challenge is -
*How to turn them into models and store the actual data?*

*Solution 1*
That is also simple. We could create a default string that resembles the
source code of a model class of a django model.
and create the code for it by writing the if clauses for diff fields of the
models and create a string for the same. Then write this string to a .py
file.
e.g.

"class BaseModel(models.Model):
created = models.DateTimeField(auto_now=False, auto_now_add=True,)
updated = models.DateTimeField(auto_now=True, auto_now_add=False,)"


The Problem with this approach is app will end up with lots of .py files
that has diff models.
Making migrations and Migrating will also be a pain point.
Making any migrations will require stopping and restarting the server
(nginx+gunicorn), that is not possible in a production environment.
Will have to restart the server for every new form created and migrated.

*Not a good idea to do this.*

*Solution 2*
As each form/model would have a separate schema, using a JSONField() makes
sense here.
As we are storing forms in JSONField(), store the data also in the
JSONField().
This wont require making any models/migrations and migrating the database.
Also server restarts are not required at all.

This is more feasible solution and will be easier approach than the earlier
one.

However, making the forms populate/reder dynamically from the stored json
field and validating them dynamically according to their schema *NEEDS SOME
R&D*.
Give it a try and share the results with me.

I hope it was worth your time :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 13, 2019 at 4:38 PM Devender Kumar  wrote:

> Thank you for your suggestion
> I am using PostgreSQL
> You have successfully saved the layout but I am talking about the dynamics
> forms fields which will be used for form submission how you are looking to
> store the values of 1000's of records entered after that in those fields.
> that's why I was looking for more efficient way (as I know this solution
> already ignore the fact that storing the json of record values too) as it
> might decrease the efficiency of the system.
>
> On Monday, May 13, 2019 at 3:58:47 PM UTC+5:30, Devender Kumar wrote:
>>
>> Hi,
>> I want to make a web app in which user has rights to configure his
>> layout.Means each user can configure his layout according to his choice and
>> work
>> Like how many fields can his form have how many field he want to see in
>> table view of individual record view . configure theme color of his own
>> choice .
>> all these type of settings he can do for his own use.
>> Can any one help me with this type of architecture.
>> Thank you
>> Devender
>>
> --
> You received this message because you are subscribed to the Google Groups
> "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/ec432f98-e6ce-4849-9d8d-46237f451cda%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ec432f98-e6ce-4849-9d8d-46237f451cda%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjspS2BqJpAyDMyOVHrQK334vNyPopo4wAGCyGMEBT%3DDEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Run django in apache2.4+centos7.5+python2.7

2019-05-15 Thread Chetan Ganji
This might help you.

https://bitnami.com/stack/django/installer


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 15, 2019 at 9:13 PM Kurosh Sol  wrote:

> Hi,
> I would like to ask a question about django setup
> Please if you can help me
> I use dedicate server from inmotion hosting .com
> With apache 2.4 (cpanel)
> I have easy_apach4 in my whm
> I install python 3 and i have python 2.7 in my server  and when i commend
> django in python terminal
> I get
> (1, 11, 20, u’final’ ,0)
> I can run my django project in my port 8000 by run serever
> Also i can run python code in my cgi folder of my website
> But i can not run django from apache server
> I try to install mode_wsgi but i got error in no package found
> Than i read article about can not install from cpanel so i tried to
> download and custom install but new version of easy_apache doesn’t accept
> custom install
> Is there anyway i can use apache
> I would be more than happy if get any 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/69649cf3-310d-4eba-b6e9-770dff0bf76c%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/CAMKMUjuUJaOnvpPd4Tc2Azya9ckiht2wNm0NKmcS2hJ%3DR0e_WA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Training

2019-05-17 Thread Chetan Ganji
You need this one.

https://www.youtube.com/watch?v=KsLHt3D_jsE&list=PLEsfXFp6DpzRcd-q4vR5qAgOZUuz8041S


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 16, 2019 at 10:02 PM Scyil sharma 
wrote:

> Can anyone suggest the best Django summer training in 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 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/7093afe7-4a42-4c5b-8c53-fe12c7e7699d%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/CAMKMUjtLR%2BQd8ZKxzD6%2B%2Br_cGP5%3D66ojJC6rSZX5KDnMrNh-ng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Porting Django app

2019-05-17 Thread Chetan Ganji
I understand the pain of a Linux user ;) You don't need to port anything at
all ;-)

RE:  nothing can be web based, it must be in house and
disconnected from the external web.

As there would be multiple users using the same instance of the software, a
web app is that they need.
That way all the data and the actual app is located in a centralised
location.

Use any stack, you will end up creating a webapp for this scenario.

*Solution - *
Create the app in Python 3.7 and Django 2.2. Give them a desktop pc with
Ubuntu 18.04 LTS installed.
Install Nginx + Gunicorn + Python 3.7 + Django 2.2 on this desktop. Get
everything up and running.
This desktop becomes their new server for this app.

The only difference here will be that instead of hosting the server on at a
hosting providers location i.e. in the cloud,
above server would would be located locally on their premises. This server
would be different from their servers/pcs.
So they would have to use the app in a LAN setting i.e. access the app
using local ip instead of a web domain.
Just remember to charge them for the desktop server you will provide ;-)

Use AMD Ryzen or Threadripper for the server as they have more cores and
threading enabled,
they will be better than intel based cpus for a server pc.

If they don't want your server, ask them to buy a separate one for this app.

This way,

   1. They can use whichever OS they want to use.
   2. Keep their security policy "NADA, NOT GONNA INSTALL THAT".
   3. Get more security as their webserver need not be connected to
   internet at all.
   4. They don't have to install any third party softwares on their so
   called secure servers/pcs.
   5. Store everything in a centralised location.
   6. You don't have to learn C or C++.
   7. You get to pay me $1000 for consulting, LOLZ. Just kidding :)


I hope it helps :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 16, 2019 at 3:29 PM RLM  wrote:

> Hello all.
> I eventually will need to put my dedicated Django app on another system
> owned by a Public institution. The app correlates each data set of 26
> million plus samples to a QR code for each.
> Security is major  so nothing can be web based, it must be in house and
> disconnected from the external web.
>
> A problem is I'm developing on Linux and Mac and much of the world uses
> Windows 10 et al.
>
> Installation of python3, Django, mysql and the app would rely on the IT
> people at the institution who do not like installing software on secure
> systems.
> I would also point out that schools here also fall into the "will not
> install that software" category significantly limiting student's ability
> to learn modern systems.
>
> I trialed compiling Python3 app to an .exe file, works ok, but am
> concerned that P3/Django will not do so.
>
> Bio: I'm in my 70's, been developing web apps for 25 years and do not
> want to learn C and C++.
>
> Can anyone advise me how to go about providing the system at minimum
> problems for the IT sector of the institution.
> Thanks in  advance
>
> Roger
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/f68670b3-a75d-61ef-2f5b-61065e5a9f56%40gmail.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/CAMKMUjveUrmMxHA8fgd_1vuUnw6mkSZvjS66NtiQ%3DRTD2ERdiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implementing multiple session support in a chatbot

2019-05-18 Thread Chetan Ganji
What you need is to implement 2 design patterns in your django app. Which
ones?

1. *Singleton* Design Pattern for the Chatbot. All the users and all of
their sessions are using the same chatbot instance.

Why?

Because when a new session is created for a user, he will be referring to
the same chatbot instance and all of previous history would be accessible.
You need to add a timestamp to each message. So that when a new session is
created,
all of previous messages can be to sent to this session by filtering on the
timestamp of the messages.

This instance can be used to store all of the sessions of all of the users.
Something like below.
That way when the observer getters and setters are called, they get a list
of active session of the current user.
So the actual message is sent by iterating over the active sessions. Hence
all the sessions get the same message.


class Chatbot(object):

_sessions = {
"username1": {
"mobile": [],
"desktop": []
},

"username2": {
"mobile": [],
"desktop": []
}

}

@classmethod
def get_sessions(self, username):
return self._sessions[username]


Other way to achieve singleton effect is create a instance of the chatbot
and import it wherever it is required.
This will given the same effect as singleton but without implementing it.


nikola = Chatbot()


Now just import nikola everywhere it is required.


2. *Observer* Design Pattern for the syncing of the messages across
multiple sessions.

Why?

Because, you need the chatbot to sync between multiple sessions. Same
message needs to goto multiple recipients.
When a new session is created, you will have to send the previous messages
to this new session.
This is the sole purpose of this design pattern. It's use is already
explained above.

As you are using django channels for websockets, you will have to combine
that code with this pattern.
I don't have any experience with websockets, you will have to figure it out
:P

I hope it helps :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, May 18, 2019 at 7:17 PM Parth Sharma 
wrote:

> I am currently implementing a Chatbot purely in python.
>
> In my current implementation, each time the user starts a new chat from a
> session, another Chatbot instance is launched and hence the Chatbot starts
> from the initial state.
>
> I wish to change that behaviour and make it similar to let’s say chat on
> Facebook/Messenger, in which you can seamlessly move between sessions while
> having a chat without inconsistencies. Namely, I want these attributes:
>
>1. If the user enters anything from let’s say session A it should be
>immediately visible in all ongoing sessions. Similarly, the Chatbot reply
>should be visible in all the devices immediately.
>2. Have all sessions show the same chat history
>
> To implement the first point, I used this example
> <https://channels.readthedocs.io/en/latest/tutorial/part_2.html> from the
> django-channels docs and modified it by creating a single group/chatroom
> for each user. All the sessions from the same user get connected to the
> same group/chatroom and hence receive all the messages in the
> group/chatroom regardless of where they were sent from.
>
> However, this implementation currently has a bug. Each time that a user is
> connected, it initializes a Chatbot instance which starts from the initial
> state again while the older connections have Chatbot instances that are
> currently at a different state.
>
> This leads to inconsistent replies which are different based on which
> window the user typed something in.
>
> Basically instead of having two sessions talk to the same Chatbot
> instance, we have two sessions talking to two different Chatbot instances
> and messages from all these four sources are getting added to the same
> chatroom.
>
> Moreover, we are wasting resources by keeping multiple Chatbot instances
> per user which increases with the number of currently active sessions.
>
> I want all of the user windows to interact with the same Chatbot instance.
> What would be the best way to implement that?
>
> Currently I can think of three solutions:
>
>1. Creating another Django project the Chatbot and make requests to
>that HTTP server. The Chatbot state is maintained in that server and any
>request from the user will go to the same Chatbot instance.
>   - This is straightforward to implement for me (simply spin up
>   another server)
>   - This naturally solves all the problems regarding state as all the
>   instances will query the same Chatbot object
>2. Creating a *Master* channel thread which will hold the actual
>Chatbot instance(a python object) and any new channels will will defer to
>it for the re

Re: Porting Django app

2019-05-19 Thread Chetan Ganji
Python is said to be interpreted language. But the c python implementation
is exactly like java
i.e. is compiled + interpreted and runs on a virtual machine. Maybe that
how Java got their idea :P

Pypy is another python implementation which has a JIT compiler, please
check if it helps your scenario.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, May 18, 2019 at 9:42 AM Ganesh Babu  wrote:

> i understand what you are saying..  To collect private IP address or
> create as Virtual host in LINUX server, its should available.
>
> On Thu, May 16, 2019 at 3:29 PM RLM  wrote:
>
>> Hello all.
>> I eventually will need to put my dedicated Django app on another system
>> owned by a Public institution. The app correlates each data set of 26
>> million plus samples to a QR code for each.
>> Security is major  so nothing can be web based, it must be in house and
>> disconnected from the external web.
>>
>> A problem is I'm developing on Linux and Mac and much of the world uses
>> Windows 10 et al.
>>
>> Installation of python3, Django, mysql and the app would rely on the IT
>> people at the institution who do not like installing software on secure
>> systems.
>> I would also point out that schools here also fall into the "will not
>> install that software" category significantly limiting student's ability
>> to learn modern systems.
>>
>> I trialed compiling Python3 app to an .exe file, works ok, but am
>> concerned that P3/Django will not do so.
>>
>> Bio: I'm in my 70's, been developing web apps for 25 years and do not
>> want to learn C and C++.
>>
>> Can anyone advise me how to go about providing the system at minimum
>> problems for the IT sector of the institution.
>> Thanks in  advance
>>
>> Roger
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/f68670b3-a75d-61ef-2f5b-61065e5a9f56%40gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Best Regards
> Sri Ganesh Babu.S
> Sr. Software Engineer,
>
> *Doyen Solutions*
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CAJZVxAv1nSpLNett9kTmRKXEVsheePwqXTM2%2BGbE50rqtTW3Mw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJZVxAv1nSpLNett9kTmRKXEVsheePwqXTM2%2BGbE50rqtTW3Mw%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjvm1h0vSpb-GKU8qSNRnouS5jWx9_e%3DDrTZLrYxck%3DG3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implementing multiple session support in a chatbot

2019-05-19 Thread Chetan Ganji
Hi Parth,

There is only one solution. It has two parts in which you will implement 2
design patterns for the chatbot.
*Singleton* and *Observer*.

RE : Where would you use it?
nikola = Chatbot() # it is called instantiating the chatbot

Wherever it is required :P

The idea is to create one and only one instance of the chatbot for the
whole project and make it available when the projects get loaded into the
memory. Two of the best ways to do this is -

   1. Instantiate the chatbot in the *wsgi.py* file of the project. From
   this file, import it and use as required.
   2. Instantiate the chatbot in the *settings.py* file of the project.
   That way you could import it wherever it is required and access it as
   *settings.nikola*.

   from django.conf import settings



RE : in which files would I import it?

Wherever it is required :P

Lets say, there is a view which will return a response. Its a fictional
example, take it with grain and salt :P

from django.conf import settings
from django.http import JsonResponse

def Reply(request, message):

sessions = settings.nikola.get_sessions(request.user.username)
response = settings.nikola.choose_response(message)

# send the message to all the remaining sessions, except the current one
# as the current session would get this reply in the response of this view
settings.nikola.send_session_replies(sessions)

return JsonResponse(data=response)


I hope its clear now :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, May 20, 2019 at 2:49 AM Parth Sharma 
wrote:

> Thanks a lot for your reply !
>
> In the first part of your reply. I didn't really understand where exactly
> would I actually use this
> nikola = Chatbot()
> and in which files would I import it? Can you please elaborate on the
> second solution a bit?
>
> On Sunday, 19 May 2019 02:59:30 UTC+5:30, Chetan Ganji wrote:
>>
>> What you need is to implement 2 design patterns in your django app. Which
>> ones?
>>
>> 1. *Singleton* Design Pattern for the Chatbot. All the users and all of
>> their sessions are using the same chatbot instance.
>>
>> Why?
>>
>> Because when a new session is created for a user, he will be referring to
>> the same chatbot instance and all of previous history would be accessible.
>> You need to add a timestamp to each message. So that when a new session
>> is created,
>> all of previous messages can be to sent to this session by filtering on
>> the timestamp of the messages.
>>
>> This instance can be used to store all of the sessions of all of the
>> users. Something like below.
>> That way when the observer getters and setters are called, they get a
>> list of active session of the current user.
>> So the actual message is sent by iterating over the active sessions.
>> Hence all the sessions get the same message.
>>
>>
>> class Chatbot(object):
>>
>> _sessions = {
>> "username1": {
>> "mobile": [],
>> "desktop": []
>> },
>>
>> "username2": {
>> "mobile": [],
>> "desktop": []
>> }
>>
>> }
>>
>> @classmethod
>> def get_sessions(self, username):
>> return self._sessions[username]
>>
>>
>> Other way to achieve singleton effect is create a instance of the chatbot
>> and import it wherever it is required.
>> This will given the same effect as singleton but without implementing it.
>>
>>
>> nikola = Chatbot()
>>
>>
>> Now just import nikola everywhere it is required.
>>
>>
>> 2. *Observer* Design Pattern for the syncing of the messages across
>> multiple sessions.
>>
>> Why?
>>
>> Because, you need the chatbot to sync between multiple sessions. Same
>> message needs to goto multiple recipients.
>> When a new session is created, you will have to send the previous
>> messages to this new session.
>> This is the sole purpose of this design pattern. It's use is already
>> explained above.
>>
>> As you are using django channels for websockets, you will have to combine
>> that code with this pattern.
>> I don't ha

Re: Django background scheduled app

2019-05-20 Thread Chetan Ganji
celery is what you need for this. It is very simple. Just stick to it, find
some examples on youtube for celery, and you should get it.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 20, 2019 at 5:42 PM Oguz kagan Olmez 
wrote:

> i just started django, python and back-end. i want to ask you a question
> for my first project. i have functions that creating json file. After that
> i am showing that json file on my webpage. But that functions in view take
> a lot of time and my webpage doesn't open for like 20-30 seconds. Actually
> my functions should work hourly and my web page doesn't depends to it.
> something like celery is too hard and i couldn't handle it. I tried cron
> and it gives errors on windows. thanks
> (Django Background Tasks is my last option. but i am really tired of
> this. I am working for days now just solve 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/04a993fd-dbb5-48da-8c22-f35369c3fbd5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/04a993fd-dbb5-48da-8c22-f35369c3fbd5%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjs%2B1pRM-BPMH9XKA9aSqTGRn2ycxXmQxkFz7g5OzwoeNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django migrations no migrations to apply

2019-05-20 Thread Chetan Ganji
Hi Harish,

Did you commit your changes to git/svn repo after changing the models?
Did they fetch the latest changes from the repo?

Is your db file also in repo?
If yes, there would a table inside the database db.sqlite3, which stores
the information about which migrations were executed.
You have to delete the entry for the migration in question.

Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 20, 2019 at 5:42 PM Harish U Warrier  wrote:

>
>
> In django models i added a new field
>
> in my system its working fine.
>
> but in other systems its showing  no migrations to apply
>
> how to solve it without effecting data?
>
> i tried deleting contents of migrations folder except __init__.py
>
> enter code here
>
> but still same error
>
> what is real method to do migrations while working in a team, live test
> servers etc?
>
> my version is 2.2
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/00ec6e6a-73f1-4d95-9ab6-2565ae29ff40%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/00ec6e6a-73f1-4d95-9ab6-2565ae29ff40%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjtKuwR0nLtTbP4P8BMWP-kx%2B36n5%2BxDvF89tuBJj4S_Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help for Cascading Drop Down for Continent, Country in Admin GUI - Not Getting correct Answer from Many Days

2019-05-21 Thread Chetan Ganji
Hello Balaji Sir,

AFAIK, Django does not filter the foreign key fields by default, Cascading
Drop Down is not available by default in django.
If the filtering was to be done on the initial value only, you could have
overwritten the __init__() in the form to filter the fk values.
But that does not seem to be the case, as the filtering needs to be done on
the clientside.

One solution that I know will work for sure is -
Write custom javascript code to add event listeners on the select dropdown.
Whenever an entry is selected,
AJAX request would be sent to server to fetch only the related/required
fields for the current selection and
show these fetched values in the dropdown. Use of jquery would be optimal
for this.
Hence, you would write separate endpoints to fetch the filtered list also.

Another solution would be output the values and their relations to a
javascript variables in the template.
Then show the select dropdown based on these values. This one can be
cumbersome to understand as well as implement.
I am not sure if it will work or not :P

Go for the first solution :)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 22, 2019 at 11:22 AM Balaji Shetty 
wrote:

> Hi
>
> I have registered model in admin.py
> Added Continent  ( Cont1, Cont2, Cont3 )
>
> Added Country under Continent
>
> Cont1 - Count11
> Cont1- Count12
>
> Cont2 - Count21
> Cont2-Count22
>
> Con3-Count31
> Con3-Count31
>
> When I add Location
>
> When i select Cont1, I should get only Count11 , Count12
>
> When i select Cont2, I should get only Count21 , Count22
>
> When i select Cont3, I should get only Count31 , Count32
>
> But I get all Countries under all Continent. Cascading dependency are not
> shown
>
> I tried different option but lot of issues are there .
>
>
>
> Example
>
>
>
> On Wed, May 22, 2019 at 10:56 AM Nitin Kumar 
> wrote:
>
>> Everything seems alright. It seems you haven't created any continents
>> yet. The table is empty.
>>
>> On Wed, 22 May, 2019, 10:52 AM Balaji Shetty > wrote:
>>
>>> Hi
>>>
>>> I am learning Django from last months and want to implement Cascading
>>> Drop Down for Continent and  Country  in Admin GUI.
>>>
>>> I dropped same query two times but i could not get exact correct
>>> solution.
>>>
>>> I tried lot of option like
>>> django-smart-select and many more..
>>>
>>> But i could not get updates in drop down.
>>>
>>>  Can Any Django Expert solve this issue? Your help would be highly
>>> appreciated.
>>>
>>> This is sample Model for  demonstration of the schema
>>> models.py
>>> --
>>>
>>>
>>> class Continent(models.Model):
>>> name = models.CharField(max_length=255)
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>>
>>> class Country(models.Model):
>>> continent = models.ForeignKey(Continent,on_delete=models.CASCADE)
>>> name = models.CharField(max_length=255)
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> class Location(models.Model):
>>> continent = models.ForeignKey(Continent,on_delete=models.CASCADE)
>>> country = models.ForeignKey(Country,on_delete=models.CASCADE)
>>> city = models.CharField(max_length=50)
>>> street = models.CharField(max_length=100)
>>>
>>> def __str__(self):
>>> return self.city
>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> *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/CAECSbOtoje0sdMsoeQvCO-mq-h-AQVOKtnYA3wFnLAE-tPhXGg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAECSbO

Re: set python 3.6.8 default in my ubuntu

2019-05-22 Thread Chetan Ganji
Hi Omar,

I have added these settings to me ~/.bashrc file in Kubuntu 18.04.
Same would work for rest of the linux with minor changes.
First group would be your answer.
Second groups of lines are used for virtualenv settings
Third group of lines are to make my life easier by saving me typing the
same commands over and over. These are the 3 commands that I use most of
the time.


# *** RyuCoder Settings Start


alias python=python3.7
alias python3=python3.7
alias pip='python3.7 -m pip'
alias sudopip='sudo python3.7 -m pip'

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.7
export WORKON_HOME=~/ENV
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh

alias run='python manage.py runserver'
alias migrations='python manage.py makemigrations'
alias migrate='python manage.py migrate'

# *** RyuCoder Settings End
****



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 22, 2019 at 6:57 PM Aldian Fazrihady  wrote:

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

Re: Hosting - Does pythonanywhere supports all features as AWS.

2019-05-27 Thread Chetan Ganji
Hi Balaji Sir,

AFAIK, Python Anywhere is Shared Hosting Provider for Django. Suitable for
Small to Medium sized Websites and Webapps.
Its like a tiny mouse.

AWS is a platform to create online Platforms like Python Anywhere in the
cloud.
i.e. You can create decentralised online platforms, based on microservices
architecture.
You can also create monolithic architecture webapps.
Its like a giant Elephant.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 27, 2019 at 12:19 AM Balaji Shetty 
wrote:

> Does pythonanywhere supports all features as AWS.
>
> Or any service it does not as compared to AWS.
>
>
>
> On Sat, May 25, 2019 at 6:50 PM Subramanian Sridharan <
> clawsonfir...@gmail.com> wrote:
>
>> I prefer PythonAnywhere <https://www.pythonanywhere.com/> for hosting.
>>
>> On Saturday, May 25, 2019 at 5:27:12 PM UTC+5:30, Prakash Borade wrote:
>>>
>>> Friends tell me is hostgator.in server support django or not.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/3514eafe-e9bb-4d94-b99a-cfc9a698aa0f%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/3514eafe-e9bb-4d94-b99a-cfc9a698aa0f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
>
> *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/CAECSbOt9nVgZQ4RvR34qaKVCT1L8CNYS7H%2BVbrm9_9%2BGqZX3kA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOt9nVgZQ4RvR34qaKVCT1L8CNYS7H%2BVbrm9_9%2BGqZX3kA%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjv9YViZNo8_65VvTAhXLPT0tG%3Dn3zB621aEAiZh2cZJJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Single place for validation

2019-05-27 Thread Chetan Ganji
If you have customized the forms for the user facing website,
you have to specify the same forms in the class extended by
admin.ModelAdmin.

Below answer is what you are looking for.
https://stackoverflow.com/questions/6321916/different-fields-for-add-and-change-pages-in-admin


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Mon, May 27, 2019 at 7:50 PM Harsh Gundecha 
wrote:

> hello,
> i am currently learning django and i have query as following
> is it that we have  to put validators in both the model definition and
> form validation to apply validation to both admin and user site ?
> i tired on reusing a form class assuming that the validator there would
> apply on both user and admin site but it didnt happen.
>
>
> in short,
> i would like to define validation at one place and get them applied on
> both user and admin site
>
> Thank you
> Regards, Harsh
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/8a5280cf-d52b-4a7d-8e21-0d18a741f02a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8a5280cf-d52b-4a7d-8e21-0d18a741f02a%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvNgBa-5vNJkC_D%2BFtABEripi1Zq%2BbE%2B3b0JhE38GC8Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Collectstable displays 0 static file copied issue

2019-06-01 Thread Chetan Ganji
I use below settings. For this to work you have to create 2 folders inside
the folder where manage.py is located - "*static*" and "*media*".
Use below settings and run the *collectstatic* command once again and see
if it works for you.


STATIC_URL = '/static/'
MEDIA_URL = '/media/'

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]

STATIC_ROOT = os.path.join(BASE_DIR, "static/")
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, Jun 1, 2019 at 4:54 PM Ankhi Roy  wrote:

> Hey,
>
>
> So I have made the following changes and Django can now read static CSS
> file now there is no more 404 while loading the static css file. However,
> on the web browser, the output does not reflect css properties like header
> color or header alignment.
>
> I have run python3 manage.py collectstatic(since i am using python3) got
> the following output -
>
> "0 static files copied to
> '/home/username/project/file:/home/username/project/app/templates/static',
> 120 unmodified." -- Not sure what this means, does it means Django is still
> unable to fetch the CSS static file? I am guessing this as I still cannot
> see any CSS specific change on my view. I would like to confirm the cause.
>
> I am using ubuntu linux 18.04, Django-admin - 2.2.1 and Pycharm Community
> IDE.
>
> so my settings.py file has -
>
> STATIC_ROOT = 'file:///home/username/project/app/templates/static/'
> STATIC_URL = 'file:///home/username/project/app/templates/static/'
> BASE_DIR1 = '/home/username/project/app/templates/'
> STATICFILES_DIRS = [
>
> os.path.join(BASE_DIR1, 'static'),
>
> ]
>
> My app/View.py file -
>
> 
> 
> {%load static%}
>  "text/css">
>  #Inline css is working the problem is while loading
> external css file by Django.
> 
> 
>  Hello World!!!
> 
> 
>
>
> My External index.css file -
>
> h1 {
> color: blue;
> text-align: center;
> }
>
> Please help and guide.
>
> Thanks
>
> Ankhi
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/b5216c4a-81a6-4d7f-a890-ad8faf7d840d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b5216c4a-81a6-4d7f-a890-ad8faf7d840d%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjs%3D5GtV3DnMN%3DXJm2dB_%2B3NTgubqjPFfva6Hjx2%2B8RU-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: using single view function or class for multiple types of users

2019-06-04 Thread Chetan Ganji
RE: "slight change in output"
First of all define what it really means. What needs to be changed and how.

RE " is it a good idea to use same URL for both and serve by checking user 
type"
Yes and No. 

It depends on your mentality. I personally prefer to have separate 
endpoints for different types of users, 
so if I change something for one user, I dont have to check if its still 
working for the other user or not.
I would create different apps for different types of users. And each app 
would contain the endpoints for that particular user type.
This is the best way I know. 

Other way to do this, is to update the core GET, POST, PUT, Patch, etc 
methods of the django/rest framework and return a diff response by checking 
the user type.
e.g. If you are overwriting the Update View in django rest framework, you 
could overwrite the update method and check the user type after 
perform_update() was called.
And return a different response by checking the user type. It will work.

I hope it helps :) 

Cheers!


On Monday, June 3, 2019 at 4:04:53 PM UTC+5:30, Harsh Gundecha wrote:
>
> what is recommended practice for serving same object to multiple types of 
> users with slight change in output
> for e.g book object or issued book object to lets say staff and students, 
> is it a good idea to use same URL for both and serve by checking user type
> PS: its a JSON based rest API in rest framework
>
> Thank you
> Regards, Harsh
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/2fe1099c-7341-4a4d-be9e-a420463f1595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What's the best way to inherit boolean values from a model?

2019-06-05 Thread Chetan Ganji
No need for inherit permissions.  As it will increase one more if condition
to be checked.
But, whenever a new user is created, you have to read the values from its
companys permissions and set them for the current user.
If companies permissions are updated, all of its employees permissions
needs to be updated as well.

This is a typical example of a Nested CRUD.



class BasePermissions(models.Model):
allow_blog_access = models.BooleanField(default=True)
allow_shop_access = models.BooleanField(default=True)
allow_admin_access = models.BooleanField(default=True)

class Meta:
abstract = True


class Company(BasePermissions):
name = models.CharField(max_length=255)


class CustomUser(BasePermissions, AbstractUser):
company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name=
"customuser")



Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jun 5, 2019 at 4:26 AM Tal  wrote:

> Lets say I have 2 models:
>
>
> class Company(models.Model):
>  name = models.CharField(...)
>  allow_blog_access = models.BooleanField(...)
>  allow_shop_access = models.BooleanField(...)
>  allow_admin_access = models.BooleanField(...)
>
>
> class User(AbstractUser):
>  company = models.ForeignKey(Company, ...)
>  ...
>
>
>
> Here, users can be assigned to a company, and when a user tries to access
> a particular webpage,
> the view can check:
>
>- Does this user's company have access to this area (ex. the blog app)?
>
>
> This is great. That means access to particular areas (or apps) of the site
> can be controlled at the company level.
> When you create a user, you just assign him to a company, and whatever the
> company is allowed to access, he is
> as well. It makes updating access a lot easier too, when you can change it
> in one place (at the company level), instead
> of doing it for every user.
>
> The problem I'm having is that one or two users that are part of a
> particular company need access to most of, but
> not all of, the areas the company has access to.
>
> What's the best way to implement this?
>
> The main thing I can think of is to have the User class also have Boolean
> fields for allow_blog_access, allow_shop_access
> and allow_admin_access, but add another field called inherit_permissions
> (also boolean). It would look like this:
>
>
> class Company(models.Model):
>  name = models.CharField(...)
>  allow_blog_access = models.BooleanField(...)
>  allow_shop_access = models.BooleanField(...)
>  allow_admin_access = models.BooleanField(...)
>
>
> class User(AbstractUser):
>  company = models.ForeignKey(Company, ...)
>  allow_blog_access = models.BooleanField(...)
>  allow_shop_access = models.BooleanField(...)
>  allow_admin_access = models.BooleanField(...)
>  inherit_permission = models.BooleanField(...)
>  ...
>
>
>
> If inherit_permissions for a user is set, the view should look at the
> permissions of the company the user belongs to
> (request.user.company.allow_blog_access).
> If inherit_permissions for a user is not set, the view should look at the
> permissions of the user (request.user.allow_blog_access).
>
> Is there a better way to do this? Or is that the simplest?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/c0051d28-de5d-427f-87da-4bd986734f69%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c0051d28-de5d-427f-87da-4bd986734f69%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjvPk-%2BYqrZyG0NxvBsMCyLWOfds2QnbVF7MaPv_4H0Y_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: While registering the user with django form, it gives "UNIQUE constraint failed: auth_user.username" error

2019-06-05 Thread Chetan Ganji
I wrote a python script to easily reset a django project. I hope it helps
you.
Just put it in the folder where manage.py file is and run it.


import os
import shutil

from pprint import pprint


folders = []
base_dir = os.path.dirname(os.path.realpath(__file__))


def get_directory_list():
global folders
global base_dir

for root, d_names, f_names in os.walk(base_dir):
for name in d_names:
folders.append(os.path.join(root, name))
folders = sorted(folders)
return folders


def delete_pycache():
global folders

for folder in folders:
if folder.endswith("__pycache__"):
shutil.rmtree(folder)

print("All __pycache__ files deleted.")
return None


def delete_migrations():
global folders

for folder in folders:
if folder.endswith("migrations"):
for item in os.listdir(folder):
if not item.endswith("__init__.py"):
os.remove(os.path.join(folder, item))

print("All migration files deleted.")
return None


def delete_sqlite3():
global base_dir
db_file = os.path.join(base_dir, "default.sqlite3")
if os.path.exists(db_file):
os.remove(db_file)


def main():
global folders

try:
get_directory_list()
delete_pycache()
delete_migrations()
delete_sqlite3()
print("All operations performed successfully.")
except Exception as e:
print("There was some error")


if __name__ == "__main__":
main()


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jun 5, 2019 at 6:29 PM Chandrashekhar Singh <
chandrashekhar...@gmail.com> wrote:

> Better will be, delete all migrations, and again migrate
>
> On Fri, May 17, 2019, 12:51 PM RAJENDRA MYTHILI 17BIS0120 <
> rajendra.mythili2...@vitstudent.ac.in> wrote:
>
>> I'm facing the same issue ... Did you figure out what's wrong?
>>
>> On Saturday, October 6, 2018 at 6:28:09 AM UTC-7, Jaydeep Borkar wrote:
>>>
>>> When I try to register a user using Django form, it gives me "UNIQUE
>>> constraint failed: auth_user.username". When I tried registering the first
>>> user, it worked, but I couldn't see that entry in my database. When I tried
>>> registering the second user, it's giving me this error. Please, help me
>>> through this. I have spent a considerable amount of time on this and I'm
>>> stuck.
>>>
>>> This is my code:
>>>
>>> forms.py
>>> from django import forms
>>> from django.contrib.auth.models import User
>>> from volunteer.models import UserProfileInfo
>>>
>>> class UserForm(forms.ModelForm):
>>>
>>> class Meta():
>>> model = User
>>> fields = ('email','first_name','last_name')
>>>
>>>
>>>
>>>
>>> views.py
>>> from django.shortcuts import render
>>> from volunteer.forms import UserForm
>>>
>>>
>>>
>>> def register(request):
>>>
>>> registered = False
>>>
>>> if request.method =="POST" :
>>> user_form = UserForm(data=request.POST)
>>>
>>> if user_form.is_valid():
>>>
>>> user = user_form.save()
>>> user.save()
>>>
>>> registered = True
>>>
>>> else:
>>> print(user_form.errors)
>>>
>>> else:
>>> user_form = UserForm()
>>>
>>> return render(request, 'volunteer/volunteer.html',
>>>  {'user_form':user_form,
>>>   'registered':registered})
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> models.py
>>> from django.db import models
>>> from django.contrib.auth.models import User
>>>
>>> class UserProfileInfo(models.Model):
>>>
>>> user=models.OneToOneField(User)
>>>
>>> def __str__(self):
>>> return self.user.first_name
>>> return self.user.last_name
>>> return self.user.email
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> urls.py
>>> from django.conf.urls import url
>>>
>>> from . import views
>>>
>>> app_name = 'volunteer'
>>>
>>> urlpatterns = [
>>>
>>>  url(r'^', views.register, name='register'),
>>> ]
>>>
>>>
>>>
>>> adm

Re: Django user profile shared among different apps

2019-06-05 Thread Chetan Ganji
just create another model in the accounts app and put a one to one key to
the User Model of django.
Import it from settings instead of harcoding it. Give it a relevant
related_name.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jun 5, 2019 at 6:23 PM Gaurav Sahu  wrote:

> Hy Everyone,
> I have a Django website which has multiple apps one of the apps is
> accounts app. accounts app is responsible for user sign up and
> authentication. Now I want to create a user profile in my website and that
> user will be the same across all of my web apps. how can I implement 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 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/85bdf45d-ed9e-4a85-a9ce-df25e8b9e2c3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/85bdf45d-ed9e-4a85-a9ce-df25e8b9e2c3%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjsYPYPNCsC5OSGbPZC8DUNhsjPNvuvcjGPMj-dZ4TVYJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What's the best way to inherit boolean values from a model?

2019-06-05 Thread Chetan Ganji
RE : If companies permissions are updated, all of its employees permissions
needs to be updated as well.

Just make sure to use transaction for this.
e.g.

from django.db import DatabaseError, transaction
with transaction.atomic():
# code to update company permissions

# code to update its employees permissions

pass




Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jun 5, 2019 at 8:52 PM Tal  wrote:

> Awesome! Simple and DRY. Thanks!
>
> On Wednesday, June 5, 2019 at 5:07:17 AM UTC-6, RyuCoder wrote:
>>
>> No need for inherit permissions.  As it will increase one more if
>> condition to be checked.
>> But, whenever a new user is created, you have to read the values from its
>> companys permissions and set them for the current user.
>> If companies permissions are updated, all of its employees permissions
>> needs to be updated as well.
>>
>> This is a typical example of a Nested CRUD.
>>
>>
>>
>> class BasePermissions(models.Model):
>> allow_blog_access = models.BooleanField(default=True)
>> allow_shop_access = models.BooleanField(default=True)
>> allow_admin_access = models.BooleanField(default=True)
>>
>> class Meta:
>> abstract = True
>>
>>
>> class Company(BasePermissions):
>> name = models.CharField(max_length=255)
>>
>>
>> class CustomUser(BasePermissions, AbstractUser):
>> company = models.ForeignKey(Company, on_delete=models.CASCADE,
>> related_name="customuser")
>>
>>
>>
>> Cheers!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Wed, Jun 5, 2019 at 4:26 AM Tal  wrote:
>>
>>> Lets say I have 2 models:
>>>
>>>
>>> class Company(models.Model):
>>>  name = models.CharField(...)
>>>  allow_blog_access = models.BooleanField(...)
>>>  allow_shop_access = models.BooleanField(...)
>>>  allow_admin_access = models.BooleanField(...)
>>>
>>>
>>> class User(AbstractUser):
>>>  company = models.ForeignKey(Company, ...)
>>>  ...
>>>
>>>
>>>
>>> Here, users can be assigned to a company, and when a user tries to
>>> access a particular webpage,
>>> the view can check:
>>>
>>>- Does this user's company have access to this area (ex. the blog
>>>app)?
>>>
>>>
>>> This is great. That means access to particular areas (or apps) of the
>>> site can be controlled at the company level.
>>> When you create a user, you just assign him to a company, and whatever
>>> the company is allowed to access, he is
>>> as well. It makes updating access a lot easier too, when you can change
>>> it in one place (at the company level), instead
>>> of doing it for every user.
>>>
>>> The problem I'm having is that one or two users that are part of a
>>> particular company need access to most of, but
>>> not all of, the areas the company has access to.
>>>
>>> What's the best way to implement this?
>>>
>>> The main thing I can think of is to have the User class also have
>>> Boolean fields for allow_blog_access, allow_shop_access
>>> and allow_admin_access, but add another field called inherit_permissions
>>> (also boolean). It would look like this:
>>>
>>>
>>> class Company(models.Model):
>>>  name = models.CharField(...)
>>>  allow_blog_access = models.BooleanField(...)
>>>  allow_shop_access = models.BooleanField(...)
>>>  allow_admin_access = models.BooleanField(...)
>>>
>>>
>>> class User(AbstractUser):
>>>  company = models.ForeignKey(Company, ...)
>>>  allow_blog_access = models.BooleanField(...)
>>>  allow_shop_access = models.BooleanField(...)
>>>  allow_admin_access = models.BooleanField(...)
>>>  inherit_permission = models.BooleanField(...)
>>>  ...
>>>
>>>
>>>
>>> If inherit_permissions for a user is set, the view should look at the
>>> permissions of the company the user belongs to
>>> (request.user.company.allow_blog_access).
>>> If inherit_permissions for a user is not set, the view should look at
>>> the permissions of the user (request.user.allow_blog_access).
>>>
>>> Is there a better way to do this? Or is that the simplest?
>>>
>>> --
>>> You received this message because you are 

Re: Handling two forms at different pages.

2019-06-06 Thread Chetan Ganji
This is front end task.

You combine the two different pages into a single page. Page 1 and page 2
would become step 1 and step 2.
You can use concept of tabs to implement this.

Both the tabs would be under the same form.

When you hit the save button, data from both the steps would be saved.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 2:42 AM Ashutosh Kumar  wrote:

> Hi,
>
> Actually I have two forms at two different pages and the second page is
> the extension of first form.
>
> Basically the first page has some fields and continue button to the next
> page, and next page has some fields and save button.
>
> So once user will click to continue I don't want to save the data, instead
> I want to save all together when the user will hit save button to the next
> page.
>
> My question is how to do this in dango.
>
> Your help is much appreciated.
>
> Regards,
>
> Ashutosh
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAAcNNfJG11_t5VLGE%3Dm62D5WM5Y8sSkzTMw_ZiGE1vZMk3Ar%2Bg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAcNNfJG11_t5VLGE%3Dm62D5WM5Y8sSkzTMw_ZiGE1vZMk3Ar%2Bg%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjtz-BXLkv23Cg6ivP8n%3D4QfVfxhvqMN9pJbLhid6vKjBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
I had a similar need in one of my clients project, I ended up using
@property and a python method.

AFAIK, AnnotationField is absent from django models. If you would like to
write one, below is the material you need to refer.
https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
wrote:

> Dear list,
>
> I was wondering whether there's a package or pattern to define annotations
> as model fields, so that they could really be used as database-side
> computed fields.
>
> Currently, I do something like this (not tested, it's a simplified case):
>
> class SalesManager(models.Manager):
> def get_queryset(self):
> return super().get_queryset().annotate(
> profit=F("selling_price")-F("buying_price")
> )
>
> class Sales(models.Model):
> objects = SalesManager()
>
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> ...
>
> Ideally, I'd see something like :
>
> class Sales(models.Model):
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
> ...
>
> An AnnotationField would behave like a read-only field, excepted that it
> wouldn't have a database column.
>
> This would have the following benefits :
> - much less verbose
> - all instance related stuff in one place
> - it would make it possible to refer to "profit" as a model field
> - you could use the field in Meta.ordering
> - you could easily display in django.admin without additional methods
>
> Of course similar result can be achieved with @property and a python
> method, but I really need this to be on the database side to use
> subqueries, sorting and filtering, etc.
>
> Does anything like this exist ? Is it possible to emulate this behaviour
> somehow ?
>
> Thanks !!
>
> Olivier
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjscehKiqt4Gcu3Cnm%2BHKhH8Y98RnGhR6chVZ7NS5qc-sw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-06 Thread Chetan Ganji
Right now its an open ended question.

If you post code for your models here, someone can help you.

On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:

> Hi,
> I am working on CRM project and stuck with REPORTING part.
>
> I have Accounts , Lead , contact, Calls ,Concern modules
> account/Lead can have multiple contacts
> contacts have multiple calls and concerns
> calls have different status like Incoming outgoing missed call etc
>
> Question
> I need to create a reporting system
> In this I have to give a functionality like so
> list of accounts with counts of :
>  contacts, total calls,incoming, outgoing etc
>
>  how can list all this count for a given date ranges calls on all accounts
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
I think this would solve your problem. Whatever calculations needs to be
done, you can do it manually before saving the Sales instance.
Preferably after checking if form.is_valid() in case of django and in the
function perform_create() in case of django rest framework.


class Sales(models.Model):
buying_price = models.FloatField()
selling_price = models.FloatField()
profit = models.models.FloatField()


Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 4:50 PM Olivier Dalang 
wrote:

> Thanks for the answer. As said, the @property + python method wouldn't
> work for my use case, as I need to be able to use the field in the queryset
> to filter/order (plus my actual computed field use aggregates expressions).
>
> Cheers,
>
> Olivier
>
> On Thu, 6 Jun 2019 at 12:36, Chetan Ganji  wrote:
>
>> I had a similar need in one of my clients project, I ended up using
>> @property and a python method.
>>
>> AFAIK, AnnotationField is absent from django models. If you would like to
>> write one, below is the material you need to refer.
>> https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
>> wrote:
>>
>>> Dear list,
>>>
>>> I was wondering whether there's a package or pattern to define
>>> annotations as model fields, so that they could really be used as
>>> database-side computed fields.
>>>
>>> Currently, I do something like this (not tested, it's a simplified case):
>>>
>>> class SalesManager(models.Manager):
>>> def get_queryset(self):
>>> return super().get_queryset().annotate(
>>> profit=F("selling_price")-F("buying_price")
>>> )
>>>
>>> class Sales(models.Model):
>>> objects = SalesManager()
>>>
>>> buying_price = models.FloatField()
>>> selling_price = models.FloatField()
>>> ...
>>>
>>> Ideally, I'd see something like :
>>>
>>> class Sales(models.Model):
>>> buying_price = models.FloatField()
>>> selling_price = models.FloatField()
>>> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
>>> ...
>>>
>>> An AnnotationField would behave like a read-only field, excepted that it
>>> wouldn't have a database column.
>>>
>>> This would have the following benefits :
>>> - much less verbose
>>> - all instance related stuff in one place
>>> - it would make it possible to refer to "profit" as a model field
>>> - you could use the field in Meta.ordering
>>> - you could easily display in django.admin without additional methods
>>>
>>> Of course similar result can be achieved with @property and a python
>>> method, but I really need this to be on the database side to use
>>> subqueries, sorting and filtering, etc.
>>>
>>> Does anything like this exist ? Is it possible to emulate this behaviour
>>> somehow ?
>>>
>>> Thanks !!
>>>
>>> Olivier
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%40mail.gmail.com?utm_medium=email&utm_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-user

Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
Yes Olivier, You are right :P

If I understand the problem correctly this time, you want the field
available on django model, but does not want the python to do the
calculation.
You want the database to compute the value.

If yes, you could use a row level trigger i.e after create and after update
trigger. PostgreSQL supports it.


class Sales(models.Model):
buying_price = models.FloatField()
selling_price = models.FloatField()
profit = models.models.FloatField(null=True, blank=True)


*For your reference - *
*RE: SQL Triggers*
http://www.postgresqltutorial.com/introduction-postgresql-trigger/

*RE: database-side computed fields*
Instead of concatenation as in the below example, you would do some other
operation and/or aggregation which would be calculated by the database.
https://dba.stackexchange.com/questions/21897/set-a-columns-default-value-to-the-concatenation-of-two-other-columns-values


If it works, as it would be on database level, you have to document it in
the readme file of your project.
Otherwise, next developer on the project might not know about the trigger
and bang his head on the floor like I did earlier, lolz :P

I hope it helps this time :P


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 6:57 PM Olivier Dalang 
wrote:

> Thanks Chetan for trying to help, but please read carefully the issue, as
> you didn't understand what I'm trying to do.
>
> In the meantime, and for the record, I found this, which works for simple
> cases.  https://github.com/schinckel/django-computed-field
>
> On Thu, 6 Jun 2019 at 14:57, Chetan Ganji  wrote:
>
>> I think this would solve your problem. Whatever calculations needs to be
>> done, you can do it manually before saving the Sales instance.
>> Preferably after checking if form.is_valid() in case of django and in the
>> function perform_create() in case of django rest framework.
>>
>>
>> class Sales(models.Model):
>> buying_price = models.FloatField()
>> selling_price = models.FloatField()
>> profit = models.models.FloatField()
>>
>>
>> Cheers!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, Jun 6, 2019 at 4:50 PM Olivier Dalang 
>> wrote:
>>
>>> Thanks for the answer. As said, the @property + python method wouldn't
>>> work for my use case, as I need to be able to use the field in the queryset
>>> to filter/order (plus my actual computed field use aggregates expressions).
>>>
>>> Cheers,
>>>
>>> Olivier
>>>
>>> On Thu, 6 Jun 2019 at 12:36, Chetan Ganji 
>>> wrote:
>>>
>>>> I had a similar need in one of my clients project, I ended up using
>>>> @property and a python method.
>>>>
>>>> AFAIK, AnnotationField is absent from django models. If you would like
>>>> to write one, below is the material you need to refer.
>>>> https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/
>>>>
>>>>
>>>> Regards,
>>>> Chetan Ganji
>>>> +91-900-483-4183
>>>> ganji.che...@gmail.com
>>>> http://ryucoder.in
>>>>
>>>>
>>>> On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
>>>> wrote:
>>>>
>>>>> Dear list,
>>>>>
>>>>> I was wondering whether there's a package or pattern to define
>>>>> annotations as model fields, so that they could really be used as
>>>>> database-side computed fields.
>>>>>
>>>>> Currently, I do something like this (not tested, it's a simplified
>>>>> case):
>>>>>
>>>>> class SalesManager(models.Manager):
>>>>> def get_queryset(self):
>>>>> return super().get_queryset().annotate(
>>>>> profit=F("selling_price")-F("buying_price")
>>>>> )
>>>>>
>>>>> class Sales(models.Model):
>>>>> objects = SalesManager()
>>>>>
>>>>> buying_price = models.FloatField()
>>>>> selling_price = models.FloatField()
>>>>> ...
>>>>>
>>>>> Ideally, I'd see something like :
>>>>>
>>>>> class Sales(models.Model):
>>>>> buying_price = models.FloatField()
>>>>> selling_price = models.FloatField()
>>>>> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
>>>>&g

Re: user Form error

2019-06-06 Thread Chetan Ganji
Hi Anchal

PFA
https://stackoverflow.com/questions/9061846/attributeerror-at-registration-userform-object-has-no-attribute-save


.save() method is available on forms.ModelForm; not on forms.Form

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jun 7, 2019 at 12:02 AM terry frank  wrote:

> Hello,  from which repos ?
>
> On Thu, Jun 6, 2019 at 7:50 PM anchal agarwal 
> wrote:
>
>> Hello,
>> I am making a simple user form but my form data is not saving.It is
>> showing this error
>> 'UserForm' object has no attribute 'save'
>> Here is my code. Please tell me where i am wrong
>> views.py
>> class UserFormView(View):
>> form_class=UserForm
>> template_name='music/registration_form.html'
>>
>> #display blank form
>> def get(self , request):
>> form=self.form_class(None)
>> return render(request,self.template_name,{'form':form})
>>
>> #process from data
>> def post(self, request):
>> form=self.form_class(request.POST)
>>
>> if form.is_valid():
>> user=form.save(commit=False)
>>
>> #cleaned (normalized) data
>> username=form.cleaned_data['username']
>> password=form.cleaned_data['password']
>> user.set_password(password)
>> user.save()
>>
>> #returns User objects if credentials are correct
>>
>> user=authenticate(username=username,password=password)
>>
>> if user is not None:
>>
>> if user.is_active:
>> login(request,user)
>> return redirect('music:index')
>> return render(request,self.template_name,{'form':form})
>>
>> forms.py
>> from django import forms
>> from django.contrib.auth.models import User
>>
>> class UserForm(forms.Form):
>> password=forms.CharField(wiget = forms.PasswordInput)
>> class Meta:
>> model=User
>> fields=['username','email','password']
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%40mail.gmail.com?utm_medium=email&utm_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/CACGjKra8_nF%2BcymQogX9Y0iQbNt0nG9mLWv6kfB_4OVJB-HC1Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACGjKra8_nF%2BcymQogX9Y0iQbNt0nG9mLWv6kfB_4OVJB-HC1Q%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjvyOVUrjO-X-iAQE4UwhEzOvMBtwryj0iy7xZceQmxguw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deployments

2019-06-06 Thread Chetan Ganji
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 10:33 PM Soumen Khatua 
wrote:

> Hi Folks,
>
> I develope one project using django in my localhost. Now how I can deploy
> that project into digital ocean and what are changes I need to do in my
> project for moving to production server. Please help I have no idea
> regarding this matter.
> Thank You.
>
> Regards,
> Soumen
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjsAfH-rB1cJW%2BbKh8Ldf9%3D%3DbntfvjTOibKMzm9DSKdGFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multitentant login

2019-06-06 Thread Chetan Ganji
Oh yes, this one is possible.

Do you want to know if this is possible or how to actually implement it??

I have implemented a solution to solve exactly the same problem.
Let me know if you want to know the one that I implemented.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 5:38 AM Sebastian Jung 
wrote:

> Hello,
>
> i have a Login Form with 3 Fields: Mandatename, Username and Password. Now
> the user login now with a Mandatename. There are a global database where
> there are a relation between mandate name and a further database. All
> Querys now from this User goes then to this database.
>
> Example:
>
> User A login with Mandatename Mandate_A. In global Database there are a
> entry Mandate_A to Database with Name "1". Now i want that all querys from
> request from User A to Database 1 goes. Another User B Login with
> Mandate_B. In global Database there are a Entry to Database "2". All Querys
> from this User goes to Database 2.
>
> Is this possible?
>
> 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 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/b8bc6fb3-f453-4b5c-a39d-31b39dc73b9e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b8bc6fb3-f453-4b5c-a39d-31b39dc73b9e%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjt%2BZMPS%3DmOHhmTaiUTLfMXo9gejp6C1fZfZEORk152zGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deployments

2019-06-07 Thread Chetan Ganji
You should follow each and every step of the tutorial. Once you can get an
empty django project up and running, you can swap that project with yours.

git clone the repo to the above projects folder location and make the
changes (e.g. rename project name in config files, etc.) as required.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jun 7, 2019 at 9:51 AM Soumen Khatua 
wrote:

> In this tutorial I think they are covering about a how we can create new
> project in digital ocean but I have already one project in my local
> machine. How I can upload that project into server??
>
> Thank you for your support.
>
> On Fri, 7 Jun 2019, 01:24 Chetan Ganji,  wrote:
>
>>
>> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>>
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, Jun 6, 2019 at 10:33 PM Soumen Khatua 
>> wrote:
>>
>>> Hi Folks,
>>>
>>> I develope one project using django in my localhost. Now how I can
>>> deploy that project into digital ocean and what are changes I need to do in
>>> my project for moving to production server. Please help I have no idea
>>> regarding this matter.
>>> Thank You.
>>>
>>> Regards,
>>> Soumen
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjsAfH-rB1cJW%2BbKh8Ldf9%3D%3DbntfvjTOibKMzm9DSKdGFg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjsAfH-rB1cJW%2BbKh8Ldf9%3D%3DbntfvjTOibKMzm9DSKdGFg%40mail.gmail.com?utm_medium=email&utm_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/CAPUw6WbidHAsiPDHY%3D3JvpLZ4fD1URiu-7t%3DEpf4PTmpavDuFg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WbidHAsiPDHY%3D3JvpLZ4fD1URiu-7t%3DEpf4PTmpavDuFg%40mail.gmail.com?utm_medium=email&utm_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/CAMKMUjvta%2BC4c%2BmOj1QXK50Yjq_VXOQCry1NEyx2HOgnXUHfrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing - get_object_or_404 returns 200 status code

2019-06-10 Thread Chetan Ganji
Whats your question?
I failed to understand that 😅

On Tue, Jun 11, 2019, 1:45 AM Cristhiam Gabriel Fernández <
cristhiang...@gmail.com> wrote:

> Hi Django super heroes
>
> I'm making of test cases for my simple Django application. When I test a
> view with get_object_or_404 shortcut it returns 200 status code.
>
> def my_view(self, request):
>   obj_id = request.POST.get('id')
>   obj = get_object_or_404(MyModel, pk=id)
>   
>
>
> # Test case
> ...data = {'id': 999}
>  response = self.client.post(reverse('view.name'), data=data)
>  self.assertEqual(response.status_code, 404)
>
>
> I'm getting *AssertionError: 200 != 404*
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/488aa077-1b11-4404-8d4e-0dad1885707b%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/CAMKMUjsTgjvtxO84VRLwz6sAc6YSXVMguQGXRHPjoehMYD8W-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.gis for Windows 10

2019-06-13 Thread Chetan Ganji
Hey,

I had a similar issue with one of the projects I was working on.

GDAL was not working properly in windows 10, it was not getting detected
for some reason.
I never figured out why and how to fix that.

I ended up using Ubuntu to fix the issue. It worked like a charm!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 13, 2019 at 11:54 PM Thanasis  wrote:

> Hello.
> I want to use the GeoDjango application. I begun with the tutorial GIS
> Tutorial <https://docs.djangoproject.com/en/2.2/ref/contrib/gis/tutorial/>.
> I installed properly the PostgreSQL and PostGis for Windows 10. In
> addition, I follow the steps and I installed the OSGeo4W
> <https://docs.djangoproject.com/en/2.2/ref/contrib/gis/install/#osgeo4w>
> in order to get the geospartial libraries. I foolowed the steps in order to
> create the environment variables GDA L_DATA and PROJ_LIB. So, I continued
> with the tutorial
> https://docs.djangoproject.com/en/2.2/ref/contrib/gis/tutorial/#use-ogrinfo-to-examine-spatial-data
>  which
> this command works properly. I make a geographic model and try to make a
> migration in the database. Although, I get a big traceback
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 381, in execute_from_command_line
> utility.execute()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 357, in execute
> django.setup()
>   File "C:\Users\examples\vent\lib\site-packages\django\__init__.py",
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "C:\Users\examples\vent\lib\site-packages\django\apps\registry.py",
> line 122, in populate
> app_config.ready()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\apps.py",
> line 24, in ready
> self.module.autodiscover()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\__init__.py"
> , line 26, in autodiscover
> autodiscover_modules('admin', register_to=site)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\utils\module_loading.py",
> line 47, in autodiscover_modules
> import_module('%s.%s' % (app_config.name, module_to_search))
>   File "C:\Users\examples\vent\lib\importlib\__init__.py", line 127, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\__init__.py"
> , line 5, in 
> from django.contrib.gis.admin.options import GeoModelAdmin,
> OSMGeoAdmin
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\options.py"
> , line 2, in 
> from django.contrib.gis.admin.widgets import OpenLayersWidget
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\widgets.py"
> , line 3, in 
> from django.contrib.gis.gdal import GDALException
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\__init__.py"
> , line 28, in 
> from django.contrib.gis.gdal.datasource import DataSource
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\datasource.py"
> , line 39, in 
> from django.contrib.gis.gdal.driver import Driver
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\driver.py"
> , line 5, in 
> from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as
> rcapi
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py"
> , line 9, in 
> from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
>   File "C:\Users\examples\
> vent\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in
> 
> lgdal = CDLL(lib_path)
>   File "c:\program files (x86)\python37-32\Lib\ctypes\__init__.py", line
> 356, in __init__
> self._handle = _dlopen(self._name, mode)
> OSError: [WinError 193] %1 is not a valid Win32 applicationEnter code here
> ...
>
&g

Re: Can we create a Rest Api in Django which can able to communicate with multiple databases(Relational, Non relational) dynamically. If yes please recommend me a way to do that

2019-06-21 Thread Chetan Ganji
If it is one time selection like storing in a user level settings, you can
store the database to use in user model
i.e. you have to customize default Usermodel in django and add one extra
field to store the db type of the current user.

Then access the right db

Author.objects.using(request.user.database).all()

OR

Author.objects.using('mysql').all()

Author.objects.using('postgresql').all()

You might have to use the database routers also. It depends on your
detailed requirements.


Official docs -
https://docs.djangoproject.com/en/2.2/topics/db/multi-db/

Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jun 21, 2019 at 4:55 PM anilkumar sangu 
wrote:

> Hello,
>
> I am working on Django
>
> I have a scenario like
> I want to connect multiple databases. based on user selection.  if user
> selects MySql from front end my Api could able to connect MySql. if user
> select postgreSql my api could able to connect to postgreSql based on user
> selection dynamically. how to achieve this 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 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/50a8fe84-0966-4b2c-bcf4-725f75a78609%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/50a8fe84-0966-4b2c-bcf4-725f75a78609%40googlegroups.com?utm_medium=email&utm_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/CAMKMUjuH_j_OGDpLQfQQZ8EqChRTXXvutNb%3DK%2BJEv76QJeQmFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django sessions

2019-07-07 Thread Chetan Ganji
Hii,

below answer might ring some bells.

https://stackoverflow.com/questions/2551933/django-accessing-session-variables-from-within-a-template

Cheers!

On Sat, Jul 6, 2019, 5:24 PM Luka Lelashvili 
wrote:

> Hello, how can I access session in my base.html? {% request.session.name
> %} doesn't work on base.html any clues?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/f9247737-44bd-4263-ace0-c1cf4d71fbde%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/CAMKMUjuLy%2BOSBHK_fX%3DRvoYsK0hzT1CY0NKfr8%2Bybk1Y_VMLfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django post request faild on user_id

2019-07-09 Thread Chetan Ganji
Please paste the whole view so that someone can help you.

On Tue, Jul 9, 2019, 5:34 PM Aayush Bhattarai 
wrote:

> Hello, My Question is here.
> It will be better if you give me a full answer.
>
> https://stackoverflow.com/questions/56919062/insert-or-update-on-table-app-job-violates-foreign-key-constraint-app-job-use
>
> Thanks for your 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/1abdfbbf-f1e9-492e-86e8-f03c385410e6%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/CAMKMUju_V%3DCG7a1T-eWLMfeTp5o_%2BO_fm2Dh%2B%3D3GyT337fH6WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: linking different wepages

2019-07-09 Thread Chetan Ganji
Because the href is relative to the current page. Use url tag of django
templates. That will solve your problemo.

On Mon, Jul 8, 2019, 9:20 PM Surya Adhikari  wrote:

> my nav menu have 2 menus :
> Home ,  Search Names
>
> ie. from index page when i click student from Sub menu of Search names  ,
> it will redirects search.html after
> if i click again teacher from search.html it will redirects to
> search.html/ search1.html rather then search1.html only.
>
> it works normal only from index page.
>  i am inheriting the nav menu from index page to all of other pages.
> what am i doing wrong ?
>
> 
>
>   Home
>
>   
> Search Names
>   
> 
> 
>   student
>   teachers
>   non teaching
>  
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/3bf58350-5f27-4b88-b803-1694ada2d6a6%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/CAMKMUjvtuAgT9LjRzb89LpPWnFq5wru4K6SGsVbaVhWjOr3XjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: reg: User model data missing from web page

2020-05-05 Thread Chetan Ganji
Hi Amitesh,

If you post the models, then only someone will be able to give you exact
solution.

Couple of things I noticed.
How is this even working??
You have not defined User variable in the function??
If its the default User model, how would passing it to UserProfile will
help in your scenario??
pr = UserProfile(User)

You dont need this line as it is already available as request.user.  Why do
you want to fetch it again, when it is already available???
*pr.user = User.objects.get(id=request.user.id <http://request.user.id/>)*
data2 = get_object_or_404(User, user=request.user)

In the *profile_page *view, you can use reverse relation on the user model.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, May 5, 2020 at 9:02 PM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> I have a profile page where I am fetching data from two models. One from
> the default User model and another one is custom UserProfile.
>
> However, The data from the custom model is getting populated, but not the
> User model.
> Below are the two functions responsible for the whole procedure.
>
> *def userprofileview(request):  # Authenticated user filling the form to
> complete the registration*
> *if request.method == 'POST':*
> *form = UserProfileForm(request.POST, request.FILES)*
> *if form.is_valid():*
> *pr = UserProfile(User)*
>
> *pr.user = User.objects.get(id=request.user.id
> <http://request.user.id>)*
> *pr.first_name = form.cleaned_data['first_name']*
> *pr.last_name = form.cleaned_data['last_name']*
> *pr.email = form.cleaned_data['email']*
>
> *pr.dob = form.cleaned_data['dob']*
> *pr.country = form.cleaned_data['country']*
> *pr.State = form.cleaned_data['State']*
> *pr.District = form.cleaned_data['District']*
> *pr.phone = form.cleaned_data['phone']*
> *pr.save()*
>
> *messages.success(request, f'Profile has been updated
> successfully')*
> *return redirect('/profile')*
> *else:*
> *messages.error(request, AssertionError)*
> *else:*
> *form = UserProfileForm()*
> *return render(request, 'authenticate\\bolo.html', context={'form':
> form})*
>
>
> *@login_required*
> *def profile_page(request):  # Fetching data from DB to show user's
> complete profile page*
> *data = get_object_or_404(UserProfile, user=request.user)*
> *data2 = get_object_or_404(User, user=request.user)*
> *context = {'data': data, 'data2': data2}*
> *return render(request, 'authenticate\\profile.html', locals())*
>
> To test it further, I realized that the three fields (email, first_name,
> and last_name) is coming from the "user". So, in the *"userprofileview" *I
> added* "user" *for those fields in the below format.
>
> pr.user.first_name = form.cleaned_data['first_name']
> pr.user.last_name = form.cleaned_data['last_name']
> pr.user.email = form.cleaned_data['email']
>
> However, I started to get below error
>
> -
> Internal Server Error: /fetch_data/ * # HTML Template*
> Traceback (most recent call last):
>   File "C:\Python38\lib\site-packages\django\core\handlers\exception.py",
> line 34, in inner
> response = get_response(request)
>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "C:\Python38\lib\site-packages\django\core\handlers\base.py", line
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Users\anshu\djago-project\AUTHENTICATION\views.py", line 65, in
> userprofileview
>
> *pr.user.first_name = form.cleaned_data['first_name']KeyError:
> 'first_name'*
> *--*
>
> It would be very kind of anybody who can help me rectify the issue. I have
> been struggling for 4 days minimum now.
>
> Amitesh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this dis

Re: Dynamic Radio Form

2020-05-05 Thread Chetan Ganji
To answer your question, you could add an extra field on schedule model to
store the winner
e.g. winner = models.CharField(max_length=55)

IMO, league and team in the schedule model should be separate tables. You
would use fk to them in schedule model.
winner should also be an fk to team.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Tue, May 5, 2020 at 3:54 AM J.T.  wrote:

> I'm working on an app that will allow the user to select the winner
> between two teams (radio buttons) and I need the info saved to the
> database. I'm having trouble with the radio forms part. I've read the
> documentation and searched Google all day, but I can't seem to wrap my
> heads around it.
>
> Here are my models:
>
> class Schedule(models.Model):
> LEAGUE_CHOICES = (('HS','HS'), ('NFL', 'NFL'), ('NCAA','NCAA'))
> week = models.IntegerField()
> game_id = models.IntegerField(unique=True)
> away_team = models.CharField(max_length=55)
> home_team = models.CharField(max_length=55)
> away_id = models.IntegerField(unique=True)
> home_id = models.IntegerField(unique=True)
> league = models.CharField(max_length=15, choices=LEAGUE_CHOICES)
> def __str__(self):
> return f'Week {self.week} {self.away_team} vs {self.home_team}'
>
> class Selection(models.Model):
> username = models.ForeignKey(User, on_delete=models.CASCADE)
> week = models.ForeignKey(Schedule, on_delete=models.CASCADE)
> select_one = models.CharField(max_length=50)
> select_two = models.CharField(max_length=50)
> select_three = models.CharField(max_length=50)
> select_four = models.CharField(max_length=50)
> select_five = models.CharField(max_length=50)
> select_six = models.CharField(max_length=50)
> select_seven = models.CharField(max_length=50)
> select_eight = models.CharField(max_length=50)
> select_nine = models.CharField(max_length=50)
> select_ten = models.CharField(max_length=50)
> tie_breaker = models.IntegerField()
> def __str__(self):
> return f'Week {self.week} selections for {self.username}'
>
> Below is a portion of what I want the template to look like when rendered.
> It takes the teams from the "Schedule" model
> and displays them.
> I then want the id of the selection (the value) of each game saved to the
> "Selections" model (select_one, select_two, etc.)
> I can't figure out how to tie in the view so it saves the data to the db.
> I realize I need to create a forms.py, import it into the view, but that
> is the part I'm having trouble understanding. I don't
> know what my forms.py should look like since the team names will change
> weekly and each match-up is it's own radio selection.
> Any help is greatly appreciated. Also, if I'm screwing this up on the
> models level, let me know. I realize that could
> also be an issue.
> JT
>
> 1  Oklahoma  Oklahoma State NCAA
> 1  Texas Christian  Houston NCAA
> 1  Dallas  Philadelphia NFL
> 1  Houston  Indianapolis NFL
> 1  New Orleans  Atlanta NFL
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/398cb0ad-fb81-49ff-bbee-53aa054b6a17%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/398cb0ad-fb81-49ff-bbee-53aa054b6a17%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: reg: User model data missing from web page

2020-05-05 Thread Chetan Ganji
Hi Amitesh,

Assuming you are using model forms in django without any customisation,
as UserProfile model does not have first_name, last_name and email field,
reading the first_name from cleaned_data is failing.

To solve it, you have to add 3 extra fields in the UserProfileForm
i.e. first_name, last_name and email, and pop them before saving the form.
also save these three fields on the user model.

*request.user.first_name = form.cleaned_data.pop('first_name')*
request.user.save()

form.save()

Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



On Tue, May 5, 2020 at 10:32 PM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> Hello Chetan,
>
> I was doing some random test, so I put "User" there. It is not the part of
> the original code.
>
> Below is models.py
>
> *from django.db import models*
> *from django.urls import reverse*
> *from django.contrib.auth.models import User*
>
>
> *class UserProfile(models.Model):*
> *user = models.OneToOneField(User, on_delete=models.CASCADE)*
> *Photo = models.FileField(upload_to='documents/%Y/%m/%d)*
> *uploaded_at = models.DateTimeField(auto_now_add=True)*
> *dob = models.DateField(max_length=20)*
> *country = models.CharField(max_length=100)*
> *State = models.CharField(max_length=100)*
> *District = models.CharField(max_length=100)*
> *phone = models.CharField(max_length=10)*
>
> *def get_absolute_url(self):*
> *return reverse('profile', kwargs={'id': self.id
> <http://self.id>})*
>
> Kindly give me the modified code that you think would work.
>
> Regards,
> Amitesh
>
>
> On Tuesday, 5 May, 2020, 09:24:58 pm IST, Chetan Ganji <
> ganji.che...@gmail.com> wrote:
>
>
> Hi Amitesh,
>
> If you post the models, then only someone will be able to give you exact
> solution.
>
> Couple of things I noticed.
> How is this even working??
> You have not defined User variable in the function??
> If its the default User model, how would passing it to UserProfile will
> help in your scenario??
> pr = UserProfile(User)
>
> You dont need this line as it is already available as request.user.  Why
> do you want to fetch it again, when it is already available???
> *pr.user = User.objects.get(id=request.user.id <http://request.user.id/>)*
> data2 = get_object_or_404(User, user=request.user)
>
> In the *profile_page *view, you can use reverse relation on the user
> model.
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Tue, May 5, 2020 at 9:02 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
> I have a profile page where I am fetching data from two models. One from
> the default User model and another one is custom UserProfile.
>
> However, The data from the custom model is getting populated, but not the
> User model.
> Below are the two functions responsible for the whole procedure.
>
> *def userprofileview(request):  # Authenticated user filling the form to
> complete the registration*
> *if request.method == 'POST':*
> *form = UserProfileForm(request.POST, request.FILES)*
> *if form.is_valid():*
> *pr = UserProfile(User)*
>
> *pr.user = User.objects.get(id=request.user.id
> <http://request.user.id>)*
> *pr.first_name = form.cleaned_data['first_name']*
> *pr.last_name = form.cleaned_data['last_name']*
> *pr.email = form.cleaned_data['email']*
>
> *pr.dob = form.cleaned_data['dob']*
> *pr.country = form.cleaned_data['country']*
> *pr.State = form.cleaned_data['State']*
> *pr.District = form.cleaned_data['District']*
> *pr.phone = form.cleaned_data['phone']*
> *pr.save()*
>
> *messages.success(request, f'Profile has been updated
> successfully')*
> *return redirect('/profile')*
> *else:*
> *messages.error(request, AssertionError)*
> *else:*
> *form = UserProfileForm()*
> *return render(request, 'authenticate\\bolo.html', context={'form':
> form})*
>
>
> *@login_required*
> *def profile_page(request):  # Fetching data from DB to show user's
> complete profile page*
> *data = get_object_or_404(UserProfile, user=request.user)*
> *data2 = get_object_or_404(User, user=request.user)

Re: reg: User model data missing from web page

2020-05-06 Thread Chetan Ganji
Ok.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 6, 2020 at 11:42 AM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> Hello Chetan,
>
> I got the issue resolved. Below are the correct views:
>
> def userprofileview(request):  # Authenticated user filling the form to 
> complete the registration
> if request.method == 'POST':
> form = UserProfileForm(request.POST, request.FILES)
> if form.is_valid():
> pr = UserProfile()
> pr.user = User.objects.get(id=request.user.id)
> pr.dob = form.cleaned_data['dob']
> pr.country = form.cleaned_data['country']
> pr.State = form.cleaned_data['State']
> pr.District = form.cleaned_data['District']
> pr.phone = form.cleaned_data['phone']
> pr.save()
> messages.success(request, f'Profile has been updated 
> successfully')
> return redirect('/profile')
> else:
> messages.error(request, AssertionError)
> else:
> form = UserProfileForm()
> return render(request, 'authenticate\\bolo.html', context={'form': form})
>
> @login_required
> def profile_page(request):  # Fetching data from DB to show user's complete 
> profile page
> data = get_object_or_404(UserProfile, user=request.user)
> #data2 = get_object_or_404(User, user=request.user)
> data2 = User.objects.get(id = request.user.id)
> context = {'data': data, 'data2': data2}
> return render(request, 'authenticate\\profile.html', locals())
>
>
>
> Regards,
> Amitesh
>
>
> On Wednesday, 6 May, 2020, 10:34:05 am IST, 'Amitesh Sahay' via Django
> users  wrote:
>
>
> Hello Chetan,
>
> Below is how I have created the forms.
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from .models import UserProfile
> from django import forms
>
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class UserProfileForm(forms.ModelForm):
> Photo = forms.FileField( max_length=100)  
> #widget=forms.ClearableFileInput(attrs={'multiple': True}),
> dob = forms.DateField(widget=forms.TextInput(attrs={'type': 'date'}))
> country = forms.CharField(max_length=100)
> State = forms.CharField(max_length=100)
> District = forms.CharField(max_length=100)
> phone = forms.CharField(max_length=10)
>
> class Meta:
> model = UserProfile
> fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')
>
>
> I hope that helps. Please let me know. Just to let you know that there was
> a time during the development when I could only see the User model data on
> my page, but none from the UserProfile model. During the debug process I
> have made changes in both the files over the last couple of weeks, so now I
> have reached to the point where I can see only the UserProfile data.
>
> Just wanted to give you some insight.
>
> Regards,
> Amitesh
>
>
> On Wednesday, 6 May, 2020, 12:11:32 am IST, 'Amitesh Sahay' via Django
> users  wrote:
>
>
> Hi Chetan,
>
> The default user model already has those three fields, right? And since I
> have extended the  User as a onetoone field inside the UserProfile model,
> so shouldn't that work? I mean, that's my understanding. May be I am wrong.
> Let me know, just for the sake of clarity.
>
> Right now I don't have access to my system. I will send the code snippet
> of the forms.py, may be then you can give more inputs
>
> Thank you so much for your time though
>
> Amitesh
>
> Sent from Yahoo Mail on Android
> <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature>
>
> On Tue, 5 May 2020 at 23:32, Chetan Ganji
>  wrote:
> Hi Amitesh,
>
> Assuming you are using model forms in django without any customisation,
> as UserProfile model does not have first_name, last_name and email

Re: help on jwt

2020-05-21 Thread Chetan Ganji
If you post the error, someone can help you better.

Did you look into authentication_classes variable of the endpoint ???

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, May 21, 2020 at 6:48 PM ola neat  wrote:

> halo, i'm working on implementing JWT for user registration but i'm having
> issue with that, when i make post request for signup, i get an
> authentication  detail no provided err, below is my code, hope anyone can
> help out
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn73JY3zZFQbAir-t5As%3D5VUm0Sn-AC3CqAeoPqXQ%3Dp4_zA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHLKn73JY3zZFQbAir-t5As%3D5VUm0Sn-AC3CqAeoPqXQ%3Dp4_zA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Optmized Query

2020-05-27 Thread Chetan Ganji
select_related for fk and prefetch_related for m2m in django, you can chain
them together

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, May 27, 2020 at 4:51 PM Soumen Khatua 
wrote:

> Hi Folks,
> I have many to many relationships and Foreign Key in the table, I'm using
> select_realted(foreign key filed name) to optimize the query but I want to
> fetch many to many and foreign key at the same time , How I can do this in
> very optimized way?
>
> Thank You
> Regards,
> Soumen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6Wb6f-BCwUZfvgzGtsrbV1seq1iGbXyuqoH%3DKxZrJ2EyLg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6Wb6f-BCwUZfvgzGtsrbV1seq1iGbXyuqoH%3DKxZrJ2EyLg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Optmized Query

2020-05-27 Thread Chetan Ganji
Profile.objects.filter().select_related("user").prefetch_related("location")

On Thu, May 28, 2020, 2:01 AM Soumen Khatua 
wrote:

> I also know about this concept but I don't how I can achieve it, Could
> you give me an example?
> Suppose I have:
>
>
>
>
>
>
>
> *class Profile(models.Model):user = models.OneToOneField(
> settings.AUTH_USER_MODEL,on_delete = models.CASCADE,
> related_name="profile")location = models.ManyToManyField(Location)*
>
>
> Thank you
>
> Regards,
> Soumen
>
> On Wed, May 27, 2020 at 7:20 PM Chetan Ganji 
> wrote:
>
>> select_related for fk and prefetch_related for m2m in django, you can
>> chain them together
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Wed, May 27, 2020 at 4:51 PM Soumen Khatua 
>> wrote:
>>
>>> Hi Folks,
>>> I have many to many relationships and Foreign Key in the table, I'm
>>> using select_realted(foreign key filed name) to optimize the query but I
>>> want to fetch many to many and foreign key at the same time , How I can do
>>> this in very optimized way?
>>>
>>> Thank You
>>> Regards,
>>> Soumen
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAPUw6Wb6f-BCwUZfvgzGtsrbV1seq1iGbXyuqoH%3DKxZrJ2EyLg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPUw6Wb6f-BCwUZfvgzGtsrbV1seq1iGbXyuqoH%3DKxZrJ2EyLg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMKMUju19j7apa1pXZQcZTY-6ThTJC%3DAL2eQhtO7DL2oTk6Oog%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUju19j7apa1pXZQcZTY-6ThTJC%3DAL2eQhtO7DL2oTk6Oog%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WZXtTJssu6SwO8_BiTDxDnzJtKYy9j1hQsMR74jKYC6aA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WZXtTJssu6SwO8_BiTDxDnzJtKYy9j1hQsMR74jKYC6aA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: Django Pagination

2020-05-30 Thread Chetan Ganji
Hi akshat,
What is the difficulty?
Where have you defined the variable   is_paginated? Is it present in the
context?

On Sat, May 30, 2020, 8:53 PM maninder singh Kumar <
maninder.s.ku...@gmail.com> wrote:

> Views.py looks fine !
>
> regards
> willy
>
>
> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  wrote:
>
>> Hello,
>>
>> I am finding it difficult to paginate through all the posts
>>
>> My views.py :
>>
>> @login_required
>> def home_view(request):
>> """Display all the post of friends and own posts on the dashboard"""
>> posts = Post.objects.all().order_by('-date_posted')
>> media: MEDIA_URL
>> # 'post':Post.objects.filter(Q(author=request.user) |
>> Q(author__from_user=request.user) |
>> Q(author__to_user=request.user)).order_by('-date_posted'),
>> paginator = Paginator(posts, 2)
>> page_number = request.GET.get('page')
>> page_obj = paginator.get_page(page_number)
>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>
>>
>> and in template post/home.html:
>>
>> {% if is_paginated %}
>> {% if page_obj.has_previous %}
>> First
>> arrow_left
>> 
>> {% endif %}
>> {% for num in page_obj.paginator.page_range %}
>> {% if page_obj.number == num %}
>> {{ num }}
>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4'
>> %}
>> {{ num }}
>> {% endif %}
>> {% endfor %}
>> {% if page_obj.has_next %}
>> arrow_right
>> Last
>> {% endif %}
>>
>>
>> Thanks
>>
>> Akshat Zala
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABOHK3QumzEA417%3DMV3dTwRszxmULfHp9y-tADSD56N_sTNQ5g%40mail.gmail.com
> 
> .
>

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


Re: Issue with serving angular with django

2020-06-01 Thread Chetan Ganji
You should use nginx to serve angular n static files and gunicorn for python

Below tuts might help you.

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

Look for a tutorial without docker.
https://medium.com/bb-tutorials-and-thoughts/how-to-serve-angular-application-with-nginx-and-docker-3af45be5b854


On Mon, Jun 1, 2020, 7:25 PM Kasper Laudrup  wrote:

> Hi Sunday,
>
> On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:
> >
> > Please What am I doing wrong? Or are there better ways of serving
> > angular build files on django?
> >
>
> You haven't described how you are currently serving static files with
> Django. I suggest you start by reading this:
>
> https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/
>
> You definitely shouldn't use DEBUG in production and you definitely
> should serve static files with your web server of choice.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%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/CAMKMUju7Sjt7Hn2qvJQrZCUKbCJ-83RBFMpkZ7s6gjsZNnuPDg%40mail.gmail.com.


Re: How to get a full path of web page to my views.py?

2020-06-09 Thread Chetan Ganji
https://docs.djangoproject.com/en/3.0/ref/request-response/


On Tue, Jun 9, 2020, 6:41 PM Sergei Sokov  wrote:

> I would like to use a current url path in my views.py
>
> понедельник, 8 июня 2020 г., 14:25:25 UTC+2 пользователь Rupesh Dahal
> написал:
>>
>> Can you please elaborate your problem.
>>
>> On Monday, June 8, 2020 at 12:26:12 AM UTC+5:45, Sergei Sokov wrote:
>>>
>>> I have the path in the web browser like this
>>>
>>> http://192.168.0.178:8000/customers-orders/37/customers-orders-date/?datefilter=06%2F14%2F2020+-+06%2F26%2F2020
>>>
>>> How to get this path to my views.py for to work with 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/d6fe7979-a895-4797-98b1-ea4fdbdc8c34o%40googlegroups.com
> 
> .
>

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


Re: Changing name of file in FileField field

2020-06-09 Thread Chetan Ganji
Hi,
I had come across a similar issue last year. Filename would change after
the upload.
It been time and I am not sure why it happened then. But, i think it
happened
because a file with the same name was already present the given location.
And the django/drf code would make the name of the file unique by appending
random text like above.
You can check if this is the case.

You can try a couple of things.

1. Print the name of the file being generated as soon as it gets generated.

2. Print the name of the file and Path(d1.file.name).name just before the
assertion.
3. Check if a document with the same name already exists in the db and
media root folder, and make sure that it doesnt.

I hope it helps.

Cheers


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Wed, Jun 10, 2020 at 12:31 AM Matthew Pava 
wrote:

> Good day,
> I have been struggling with this issue for weeks, and I can't figure out
> what I'm doing wrong.
> I have a model with a FileField with a custom upload_to function. It
> seems to work fine when I'm doing runserver.
> Problems arise during my tests.
>
> My assertion error fails:
>
> AssertionError: 'Rev0_2020-06-09_L123_My_Document_63ExUTF.docx' !=
> 'Rev0_2020-06-09_L123_My_Document.docx'
> - Rev0_2020-06-09_L123_My_Document_63ExUTF.docx
> ? 
> + Rev0_2020-06-09_L123_My_Document.docx
>
>
> You see, it keeps adding these extra random characters to the filename,
> which is not at all in my upload_to function.
>
> class DocumentTestCase(TestCase):
> def create_document(self, **kwargs):
> if 'file' not in kwargs:
> kwargs['file'] = self.get_test_file()
> return Document.objects.create(**kwargs)
>
>  def _create_file(self):
> f = tempfile.NamedTemporaryFile(suffix=self.TEST_FILE_EXTENSION, 
> delete=False)
> with open(f.name, mode='wb'):
>
> f.write(b"NA")
>
> return open(f.name, mode='rb')
>
>
> TEST_FILE_EXTENSION = ".docx"
>
> def setUp(self):
> super().setUp()
>
> settings.MEDIA_ROOT = MEDIA_ROOT
>
> def get_test_file(self):
> file = self._create_file()
>
> return File(file, name=file.name)
>
> def test_rename_file_after_upload(self):
> d1 = self.create_document(title="My Document", number="L123")
>
> title = d1.title.replace(" ", "_")
> extension = Path(d1.file.path).suffix
>
> new_name = 
> f"Rev{d1.revision}_{d1.revision_date}_{d1.number}_{title}{extension}"
> self.assertEqual(Path(d1.file.name).name, new_name)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cbc812fc-6d5e-4afb-ab64-6bc0fad303a3o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cbc812fc-6d5e-4afb-ab64-6bc0fad303a3o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


  1   2   >