Re: How to fix deadlocks with tests?

2023-10-27 Thread Chetan Ganji
Hey,
This problem seems to be unique. There might not be a standard solution.

https://github.com/jazzband/django-silk

You can replicate the prod environment to local and profile it using django
silk.
If you can somehow manage to reproduce the bug and find the timestamp when
it happened;
you can find out the sql queries that were running around that timestamp.
You might be able to find out the root cause of the problem and fix it.

I am not 100% sure if it will help. But it is worth a try.
I hope it helps you.

Thanks!


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


On Fri, Oct 27, 2023 at 9:50 PM Joshua Gardner  wrote:

> I'm experiencing deadlocks in my production application occasionally. I'm
> using MySQL. Some of these deadlocks are due to insufficient indexing,
> and I'd like to fix this with some test-driven development.
>
> How can I write tests that exercise the application concurrently, and
> could be used to replicate the deadlocks and then fix them? I use
> pytest-django and I use MySQL in my tests; there's a lot of raw SQL and
> even some views and stored procedures (😱) in this application and some
> of those may be culprits too of course.
>
> I suppose my main question is "how to test bugs that occur due to
> concurrency?"
>
> -Josh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/874jicca6t.fsf%40jgardner.tech
> .
>

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


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: 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.


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: 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: 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: 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: 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: 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: 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.


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: 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.


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.


Free Webinar

2021-06-26 Thread Chetan Ganji
Dear members,

FYI

https://www.scaler.com/event/learn-how-youtube-serves-billions-of-users-in-a-free-masterclass

Thanks!

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


Re: Best way to optimize API requests calls from over 10,000 users simultaneously

2021-06-26 Thread Chetan Ganji
This will help you brother. It is FREE 😉

https://www.scaler.com/event/learn-how-youtube-serves-billions-of-users-in-a-free-masterclass


On Mon, Jun 21, 2021, 8:49 PM Alejandro Garrido Gongora <
nolodelato...@gmail.com> wrote:

> For big problems the answer is in 99% of cases split the problem, maybe
> your problem is your architecture, also you will need cache, also Async,
> maybe you need to en queue  some routines maybe you need more hardware,
> maybe you need to optimize your data structures, maybe the join of all
> those solutions is what you need.
>
> Regards.
>
> Obtener Outlook para iOS 
> --
> *De:* django-users@googlegroups.com  en
> nombre de carlos 
> *Enviado:* Monday, June 21, 2021 4:57:02 PM
> *Para:* django-users@googlegroups.com 
> *Asunto:* Re: Best way to optimize API requests calls from over 10,000
> users simultaneously
>
> maybe try used cache when call many users
> https://www.django-rest-framework.org/api-guide/caching/
>
> Cheers
>
> On Mon, Jun 21, 2021 at 8:18 AM Kasper Laudrup 
> wrote:
>
> On 21/06/2021 15.55, Sunday Iyanu Ajayi wrote:
> > I want to be able to manage API calls from over 1 users without
> > getting network timeout errors
>
> Are you having issues doing so now?
>
> What have you done to try and profile your code for bottlenecks?
>
> What kind of help are you looking? Paid consultancy?
>
> Etc.
>
> You cannot really expect anyone to be able to help you if you don't take
> some time trying to formulate a real question.
>
> 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/7a436427-1069-d173-3e32-0339be9328dc%40stacktrace.dk
> .
>
>
>
> --
> att.
> Carlos Rocha
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAM-7rO33XnZDcXrjQJS%2Bbawy7%3D_HTAMfxfa2MT8ruyDXkE8h%2Bw%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/VI1PR0402MB3342DC9605EF444EA2B6CF35F60A9%40VI1PR0402MB3342.eurprd04.prod.outlook.com
> 
> .
>

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


Re: How can i start to learn django?

2021-06-26 Thread Chetan Ganji
https://youtube.com/c/CodingEntrepreneurs


On Wed, Jun 16, 2021, 2:23 AM Sebastian Jung 
wrote:

> At beginnig Django Girls Tutorial ist a good start in my opinon
> https://tutorial.djangogirls.org/en/
>
> anil9...@gmail.com  schrieb am Di., 15. Juni 2021,
> 14:27:
>
>> You can try freecodecamp.org's youtube channel if you like to learn from
>> videos else Django docs are also great.
>>
>> On Sunday, 13 June, 2021 at 7:52:22 pm UTC+5:30 desai...@gmail.com wrote:
>>
>>> I am begginer in python. how can i start to learn django from begginners
>>> to adance. please help me.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/853d870f-5e57-419d-b3b1-e49738d2746cn%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/CAKGT9mxtPhHc%3Dqq3e7ggH1ZymnKxqOfmJkykxfO%2BN%3D97aJw66w%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/CAMKMUjs%3DOS_jazLYGF%2B5PN%2BTMqu3Xo-m2vv5AB5cDHJxg2Oy6Q%40mail.gmail.com.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread Chetan Ganji
You should have a field on Votes Model diff_vote as integerfield, which
will be updated when a user upvote or downvote.

WHY??
Calculating this value on list view will result in higher latency.
So we can dump that calculation on creating on updating.

What do you mean by calculate the up votes and down votes at the same time?


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


On Fri, Jun 25, 2021 at 12:39 PM DJANGO DEVELOPER 
wrote:

> Oba Thank you so much. and let me try it.
> and one more thing that I want to ask that how can I calculate the up
> votes and down votes at the same time? as Facebook likes and dislikes do.
> can you guide me in this regard?
>
> On Fri, Jun 25, 2021 at 11:15 AM oba stephen 
> wrote:
>
>> Hi,
>>
>> One way would be to create an extra field to track the difference in both
>> fields and then in your meta information on that model set the ordering to
>> that field.
>>
>> Another approach which is better is to do something like this.
>>
>> Votes.objects.extra(select={'diff': 'upvote - downvote'}).order_by('diff')
>>
>>
>> Best regards
>>
>> Stephen Oba
>>
>> On Fri, Jun 25, 2021, 6:03 AM DJANGO DEVELOPER 
>> wrote:
>>
>>> Is there anyone who can help me here?
>>>
>>> On Thu, Jun 24, 2021 at 7:15 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
>>>> Hi Django experts.
>>>> I am building a Django, DRF based mobile app and I want to have
>>>> functionality of up votes and down votes for posts that user will post.
>>>> So what I want to say here that, if an user upvotes a post then it
>>>> should be get higher ranks as quora questions do. and if there are more
>>>> down votes than up votes then a post should be moved down ward rather than
>>>> going up.
>>>> I have applied a logic already here and shared the screenshots as well.
>>>> but I am sure that there is a better logic or solution for this problem.
>>>> Thanks in advance.
>>>> Mr Mike and Mr Lalit can you guide me here 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/c72fefe7-58d2-4c43-84b8-0faa3d9747b0n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/c72fefe7-58d2-4c43-84b8-0faa3d9747b0n%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/CAKPY9pkAYcmio_U%2BAUPMcxzxbdT8QM1QPfPDftMgrj2NQvsJRQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAKPY9pkAYcmio_U%2BAUPMcxzxbdT8QM1QPfPDftMgrj2NQvsJRQ%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/CAAJsLnras7ETsnRc5yj2F-S%3DMo5xfEMWDbVXPOvm08oQDxoFAg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAJsLnras7ETsnRc5yj2F-S%3DMo5xfEMWDbVXPOvm08oQDxoFAg%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/CAKPY9pkYmP2xvW8FYRxBH8a55kURefFwrJGE59O-g%2Be8ktF%2B0g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKPY9pkYmP2xvW8FYRxBH8a55kURefFwrJGE59O-g%2Be8ktF%2B0g%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/CAMKMUjs%2BCj4ygtXt4wwU4AhieyHMfWU9231tO0E28s0UUkNnog%40mail.gmail.com.


Re: Best way to optimize API requests calls from over 10,000 users simultaneously

2021-06-21 Thread Chetan Ganji
What is the problem you are trying to solve?
What do you want to optimize exactly? 🤔

I hope this helps you -
https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd


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


On Mon, Jun 21, 2021 at 6:19 PM Sunday Iyanu Ajayi 
wrote:

> Dear Team,
>
> Please I need help on how to optimize API requests calls for over 10,000
> users simultaneously without any issues and my system spec is 8vCPUs, 16GB
> RAM.
>
> Regards
>
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@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/CAKYSAw2UTC6zvJoTWO%2BFQFqs9JQYaFbybC8ymp8kdt4cfwn3Nw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKYSAw2UTC6zvJoTWO%2BFQFqs9JQYaFbybC8ymp8kdt4cfwn3Nw%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/CAMKMUjuxKtKcF1Y%3Dw3o2XgcpKi2zdAhuGq6UmWzSe6ggDbPbFA%40mail.gmail.com.


Re: django cron Job Functionality

2021-06-11 Thread Chetan Ganji
This will help you

https://pypi.org/project/django-celery-beat/


On Fri, Jun 11, 2021, 5:34 PM Eugene TUYIZERE 
wrote:

> Dear Team,
>
> In my application, I want a user to set for example a leave plan in the
> system and the system notify the user by email for example one day before
> the start leave date. At the same time the system disables the user in the
> system. Here I have a field *is_active *and I want the system to set it
> to False from the leave date to the end date. And also to set Ongoing
> status on the leave plan user list. I heard somewhere that Django Cron Job
> can do this but I never use it and I do not know how to use it in the
> application.
> If someone has used  it for some time please I need help.
>
> Thank you
>
> --
> *Eugene*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABxpZHt2hqPgNU%2BvyDb8Eua%2B6_OMM8H6xsMzTgJ-73-0erfmKw%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/CAMKMUjvErhZDkdA1ZYPOxHq4yuEWk%3DKUsbrgSyX3LOm7FBhFyw%40mail.gmail.com.


Re: Absurdly long queries with Postgres 11 during unit tests

2021-06-09 Thread Chetan Ganji
This might help shed more light on the problem.

   1. https://pypi.org/project/pytest-django-queries/
   2. Try cProfile
   https://www.geeksforgeeks.org/profiling-in-python/



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


On Tue, Jun 8, 2021 at 1:33 AM Rich Rauenzahn  wrote:

> This is heads up in case anyone sees something similar:
>
> I have managed to trigger this degenerate query case in two completely
> different Django 2.2 projects.   In production with a normal sized dataset,
> the query time is fine.  But during unit testing with a small subset of the
> data, the queries took a long time.  A LONG time.
>
> In the most recent case each query took 100x longer.  200+ seconds instead
> of 2 seconds.  The unit test dataset isn't very large because it's a unit
> test.
>
> I think I may have first seen this when I upgraded the project to postgres
> 11.
>
> Manually vacuuming between tests resolves the issue.  (Yes, autovacuum is
> on by default -- and isn't the db created from scratch for each 'manage
> test' invocation?)
>
> This is how I did it:
>
> def _vacuum():
> # Some unit test queries seem to take a much longer time.
> # Let's try vacuuming.
> # https://stackoverflow.com/a/13955271/2077386
> with connection.cursor() as cursor:
> logger.info("Vacuum: begin")
> cursor.execute("VACUUM ANALYZE")
> logger.info("Vacuum: complete")
>
> class VacuumMixin:
> @classmethod
> def setUpClass(cls):
> _vacuum()
> return super().setUpClass()
>
> @classmethod
> def tearDownClass(cls):
> ret = super().tearDownClass()
> _vacuum()
> return ret
>
> If anyone else sees this, please let me know.  Maybe we can further RCA 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/e76b105e-ed53-4031-869c-830f94677ef4n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e76b105e-ed53-4031-869c-830f94677ef4n%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/CAMKMUjuJPTLxOUF0x5knQOtpCUy0V3tuV2QkwFMH5yVGoym1sw%40mail.gmail.com.


Re: Customizable model field (such as SRID for geometries) and migrations

2021-06-05 Thread Chetan Ganji
I dont understand your requirements :P

But this will certainly help.
https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#geodjango-tutorial
https://docs.djangoproject.com/en/3.2/ref/contrib/gis/model-api/

IN the below link, it says about setting the SRID field :P
https://docs.djangoproject.com/en/3.2/ref/contrib/gis/tutorial/#geographic-data

Note that the models module is imported from django.contrib.gis.db.
The default spatial reference system for geometry fields is WGS84 (meaning
the SRID <https://en.wikipedia.org/wiki/SRID> is 4326) – in other words,
the field coordinates are in longitude, latitude pairs in units of degrees.
To use a different coordinate system, set the SRID of the geometry field
with the srid argument. Use an integer representing the coordinate system’s
EPSG code.


I hope this helps you !!!



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


On Wed, Jun 2, 2021 at 12:26 PM Olivier Dalang 
wrote:

> Dear List,
>
> I'm working on a Django app whose models have geometry fields and that
> will be deployed in several geographic locations.
>
> Using a globally available reference system (WGS84) and reprojecting on
> the fly will not work due to performance and accuracy implications for
> geometric queries. Thus I'd like to make the SRID customizable.
>
> The issue comes with migrations which hard-code the SRID in the
> CreateModel statements. I could import an SRID from a variable in
> settings.py, but don't like that idea, as changing it after creating would
> mess things up (srid mismatch, creating new migrations...). It's actually
> not really a django setting, but more related to the data.
>
> One idea would be to store the default SRID in the DB itself (in a
> dedicated settings model) and retrieve the SRID dynamically from that
> before running the migrations and loading the models. There could even be
> some logic to reproject/adapt all geometries fields if the value changes.
> Sounds nice, but also complicated (models are not available .
>
> I'm probably not the first one with this type of requirement (could also
> happen for other use cases such as language, currencies, etc.). Is there a
> package I could use or some design pattern I could follow ?
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAExk7p1s%2B4XozdQOxjZKMbXmG7xq6hhMSiVTsrSyj26VBG%3DFJw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAExk7p1s%2B4XozdQOxjZKMbXmG7xq6hhMSiVTsrSyj26VBG%3DFJw%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/CAMKMUjsrmPnCTC81Wc7bs6dQ%3D-bWsDDXAGQ8%3Dzi45n%3D_eD1hhQ%40mail.gmail.com.


Re: Newbee help on deploying Django App to Apache2

2021-05-30 Thread Chetan Ganji
I think, you are using the default python version installed on the machine,
not the one of the virtualenv.
You will have to configure the mod_wsgi to use the python of the virtuelanv.

This might help you.
https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html#


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


On Sun, May 30, 2021 at 4:46 PM Moose Smith <47kanga...@gmail.com> wrote:

> App written in ubuntu virtual environment python 3.8.5. Works well on
> Visual Studio Code development server. Am trying to make it run on Apache2
> development server.  I have been able to install WSGI module on Apache
> Server and ran a test Hello World in Python and it worked. However, the
> django app when ported over does not work.
> The error log confirms that the mod_wsgi has been created using by Python
> 3.8
> [mpm_event:notice] [pid 607786:tid 140700034231360] AH00489: Apache/2.4.41
> (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
> The error I am getting indicates that the Apache / WSGI is reading the
> files in the virtual environment I copied over.
>
> mod_wsgi (pid=609049): Exception occurred processing WSGI script '/ File
> "/usr/public/apache/MCE/learn/djpro/wsgi.py", line 12, in 
> from django.core.wsgi import get_wsgi_application
> ModuleNotFoundError: No module named 'django'
>
> My research indicates that this error occurs when the mod--wsgi in being
> interpreted by a different version than what was used to create my virtual
> environment. It also might be permissions/ownership issues with the file
> and directories copied over to the server, or improperly configured module.
>
> My question is this: Does the mod_WSGI module have to be the same as the
> one that created my virtual environment?  My understanding is that WSGI has
> two components, the server side, and the application side. It would not
> make sense that the Server side MUST match the application side because it
> would not be possible to service various apps with different versions of
> Python/Django. I assumed the server side was python version independent and
> that the requirement for Python similarity was only on the application side
> in that the Python used to create the virtual environment and my app must
> match the version used to create the WSGI interface on the application side
> (this side not the server). That said, I have discovered there is a Python
> 2.7 version of the mod_WSGI for the server side which differs from the 3.7
> version.
>
> Can someone clear up the Python version requirement and if it does require
> a match between the server and the app side, how will I be able to run
> future versions of Python/Django apps without having to go back and
> "recomplie"?
>
> Also if someone has any clues on solving my error that would be very much
> appreciated.
>
> Thanks
> Moose
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d3041741-1604-473f-8810-263bb3b16c59n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d3041741-1604-473f-8810-263bb3b16c59n%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/CAMKMUjuOXoG5O0-aGFpMD3wfkNHkOMqBf8PNsKhFeeJvwrpYAQ%40mail.gmail.com.


Re: Custom User

2021-05-06 Thread Chetan Ganji
https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#django.contrib.auth.hashers.make_password

On Thu, May 6, 2021, 6:46 PM Owen Murithi 
wrote:

> How do I make password for AbstractUser Hashed?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/741b9434-d473-4d15-b343-50b3e37d50d7n%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/CAMKMUjtGYwQRxj6QpDcGdoBH9t3btdNgK%2BHfiODVTK1QGxJTaA%40mail.gmail.com.


Re: Admin layout getting too bulky - what to do?

2021-05-03 Thread Chetan Ganji
I am not sure how useful this will be. You can check it out.
https://django-mptt.readthedocs.io/en/latest/index.html


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


On Mon, May 3, 2021 at 8:13 PM Mike Dewhirst  wrote:

> Derek
>
> My phone doesn't do interspersed responses well, so my apologies for top
> posting.
>
> The record to which I refer is any one of those in any list page.
>
> After clicking one, if that record has any 1:1, 1:n or n:m related
> records, their *verbose_name_plural* names will be displayed as dumb
> headings with related records appearing below with show/hide links as well
> as an 'Add another ...' link.
>
> I'd like to see the sidebar display links to those (currently) dumb
> headings and fetch them to the top.
>
> Hope that clarifies what I meant despite what I said :-)
>
> I'll  have a look at Django suit in the morning. Thanks for the heads up.
>
> Cheers
>
> Mike
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: Derek 
> Date: 3/5/21 19:42 (GMT+10:00)
> To: Django users 
> Subject: Re: Admin layout getting too bulky - what to do?
>
> Re "So my need is for a fixed vertical sidebar with the same links which
> take you to the same list pages."
>
> This is what I use Django Suit for -  it can be located at the top or side
> and remains in place across all admin pages.  You can add your own items to
> the menu (and these can point to non-admin pages - for example, I point to
> a page of report URLs which is a non-standard admin page) ; I have never
> added menu items "on the fly" so am not sure this is possible.
>
> I cannot understand your requirement statement "When that page opens for
> the record, the sidebar of links should change to the named headings on
> that page. When a heading is clicked the page should relocate itself so
> that heading is at the top"  at all, sorry. Maybe a follow-up post with a
> picture (== 1000 words)?
>
> Derek
>
>
> On Monday, 3 May 2021 at 08:57:25 UTC+2 Mike Dewhirst wrote:
>
>> OK - I've now looked at some Django Admin templating systems and they
>> all seem to solve a different problem than the one I need to ... which
>> is ...
>>
>> Consider the Admin main menu seen at the /admin url after login. If you
>> click any of the links they take you to a single page with a list of
>> records. So my need is for a fixed vertical sidebar with the same links
>> which take you to the same list pages. The vertical sidebar should
>> remain unchanged and unmoved on the list page in case the user clicked
>> the wrong link.
>>
>> The next step is to select a record from the list. When that page opens
>> for the record, the sidebar of links should change to the named headings
>> on that page. When a heading is clicked the page should relocate itself
>> so that heading is at the top. The sidebar of links should remain
>> unchanged and unmoved in case the user wishes to relocate to a different
>> heading. Much like the Django documentation except the sidebar should
>> stay where it was when clicked!
>>
>> At the moment, those headings don't have urls within the page. And the
>> (Show/Hide) urls are all just a lone hash '#'.
>>
>> Therefore my problem is to understand how to include heading name
>> anchors and construct a list of urls (including 'top' and bottom') for
>> such a sidebar. And of course to understand how to make such a sidebar
>> in the first place.
>>
>> Where might I begin my research?
>>
>> Thanks
>>
>> Mike
>>
>>
>> On 2/05/2021 5:26 pm, Mike Dewhirst wrote:
>> > My project has a central table with many 1:n and n:m sub-tables. I
>> > mean lots of them. It takes forever to keep scrolling up and down the
>> > page to find the section of interest and then maybe scroll through
>> > some records in that section before clicking (SHOW) to reveal data.
>> >
>> > Is there a way I can do a sidebar of links which take the user to
>> > specific sections?
>> >
>> > I have had a look at the contrib layout and it doesn't appear obvious
>> > what to do. Especially since they don't pay me enough to play with js
>> ;-)
>> >
>> > Has this been solved before?
>> >
>> > Thanks for any hints
>> >
>> > Cheers
>> >
>> > Mike
>> >
>>
>>
>> --
>> Signed email is an absolute defence against phishing. This email has
&

Re: deployment UI

2021-03-15 Thread Chetan Ganji
Checkout PythonAnywhere if it helps you or not

On Mon, Mar 15, 2021, 8:15 PM waverider  wrote:

> Hi,
>
> Is there some web interface (SaaS or on premises) for initial server setup
> and Django apps deployment?
>
> Are you happily using it?
>
> There are a few SaaS tools for PHP apps, but I haven't seen one for Django.
>
>
> Thanks
>
> PS: I'm not asking about CLI tools like configuration management software,
> just about turn key web interface solutions.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0a9474ab-b5cf-4408-94e0-355355e2e976n%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/CAMKMUju_eUeR678QMLzUZR6o01bo6F8ti8yF2yaRido1y9VM0w%40mail.gmail.com.


Re: I cant figure out this error

2021-03-13 Thread Chetan Ganji
Good Read!
Thanks Kasper 😊

On Sat, Mar 13, 2021, 5:58 AM Kasper Laudrup  wrote:

>
> https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2bd
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/51f7f7a8-dfa3-0024-3c45-0f4c64f2ee08%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/CAMKMUjtZBOP_06LX1wPLZj5%2BXvZ0j4X1otOX_qSyjv0T%2Bhomiw%40mail.gmail.com.


Re: Why does my django form with recaptcha send data even empty the recaptcha?

2021-03-12 Thread Chetan Ganji
Remove below line and try again

self.fields['captcha'].widget.attrs['required'] = 'True'


If the problem persists, try some js or jquery validation in frontend





On Thu, Mar 11, 2021, 9:19 PM Gabriel Araya Garcia <
gabrielaraya2...@gmail.com> wrote:

> Camarada Sokov:
> Your code is very difficult to understand at first sight. I did not know
> about ReCaptchaField().
> But, is interesting to learn something new.
>
> Recards,
>
> Gabriel Araya Garcia
> GMI - Desarrollo de Sistemas Informáticos
> from Santiago de Chile
>
>
>
> El jue, 11 mar 2021 a las 12:40, Sergei Sokov ()
> escribió:
>
>> I put the google recaptcha V2 to my django project form. It looks like
>> working, but if I leave empty the recaptcha checkbox my form is sent still.
>>
>> forms.py
>> from django import
>> forms from captcha.fields
>> import ReCaptchaField
>> from django.forms import Textarea
>> from .models import *
>> class CustomerForm(forms.ModelForm):
>> captcha = ReCaptchaField( public_key='key', private_key='key', )
>> class Meta:
>> model = Customer fields = '__all__'
>> def __init__(self, *args, **kwargs):
>> # get 'user' param from kwargs
>> user = kwargs.pop('user', None)
>> super().__init__(*args, **kwargs)
>> self.fields['message'].widget = Textarea(attrs={'rows': 4})
>> self.fields['i_have_read_rules'].widget.attrs['required'] = 'True'
>> self.fields['i_agree'].widget.attrs['required'] = 'True'
>> self.fields['captcha'].widget.attrs['required'] = 'True'
>> for field in self.fields:
>> self.fields[field].widget.attrs['class'] = 'form-control'
>> self.fields['i_have_read_rules'].widget.attrs['class'] =
>> 'form-check'
>> self.fields['i_agree'].widget.attrs['class'] = 'form-check'
>>
>> html
>> 
>> {% csrf_token %}
>> Выберите услугу
>> {{form.choice_services}}
>> {{form.name}}
>> > class="form-group">{{form.telephone_number}}
>> {{form.email}}
>> {{form.message}}
>> {{form.contact_text}}
>>  {{
>> form.captcha }}
>> 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/e18dcba2-07e2-44d9-ace6-744a2bb69234n%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/CAKVvSDD_HZmL%2BUVgsFVZgQCuyuhCs3Ofe2DkOtne-ydp%2B3joyw%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/CAMKMUjuA8GZ6XTq8FvBJh0HEfvzezrtJnvXj%3DH1k2vBDkoZLUg%40mail.gmail.com.


Re: Immediately Need Help

2021-02-20 Thread Chetan Ganji
 Shubham is right. However, as no row will be deleted.
Also, the code created once will never be assigned to any other space.
It wont matter!

Formula : LM-categorycode-citycode-current_index
e.g. "LM-CW-DELHI-1"
# Remove dashses from the string, they are added only to make it easier to
understand

String after the citycode is called as current_index and it has to be of a
standard length
e.g. 9. We will call this length as Z_FILL_INDEX. You can modify this
Z_FILL_INDEX as required.
Hence, Z_FILL_INDEX = 9. In above example, current_index = "1"

As no row will be deleted, also, the code created once will never be
assigned to any other space
Hence, current_index will be 1 or plus 1 of the latest one
Below code is for django ORM, IDK sqlalchemy version of it :P
I dont see how Space is related to a City, you can figure that part
yourself.
if current_index > 9, code will break. 10 Cr is a big no.
However, if current_index could be bigger than that, pick a bigger no for
Z_FILL_INDEX.

In case you run out of index in the future, you can write a script to add
few extra zeros
to current index part of the code or add pick a bigger no for Z_FILL_INDEX
initially e.g. 12.

MUST DO : ADD UNIQUE CONSTRAINT ON THE name FIELD OF THE Spaces Model.
Z_FILL_INDEX = 9

last_code = Spaces.objects.filter(space_category="blah").order_by(
"-created_at").first()
if last_code is None:
current_index = "1".zfill(Z_FILL_INDEX)
else:
current_index = str(int(last_code[-Z_FILL_INDEX:]) + 1)

unique_code ="LM" + categorycode + citycode + current_index




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


On Fri, Feb 19, 2021 at 6:16 PM shubham vashisht 
wrote:

> If there are 4 rows which have categorycode="blah" and
> citycode="blah-blah", then the space code will be something like this,
> LMblahblah-blah1, LMblahblah-blah2, LMblahblah-blah3, LMblahblah-blah4.
> But if you delete row with spacecode different from LMblahblah-blah4, then
> your code will generate space code LMblahblah-blah4
>
> On Fri, 19 Feb 2021, 16:07 Chetan Ganji,  wrote:
>
>> Yes kritika show all the models.
>>
>> How shubham?
>> If an entry is deleted, unique code will also be deleted. Next time it
>> gets generated, it might be assigned to different entry, but it still be
>> unique.
>>
>> As kritika clarified already, so it wont be a problem.
>>
>> On Fri, Feb 19, 2021, 3:58 PM shubham vashisht 
>> wrote:
>>
>>> Chetan
>>> If any row is deleted from the table, then your logic will fail to
>>> return the unique code
>>>
>>> On Fri, 19 Feb 2021, 15:52 Chetan Ganji,  wrote:
>>>
>>>> Hi Kritika
>>>>
>>>> Ye chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂
>>>>
>>>> Teko field pe unique constraint lagana padenga
>>>>
>>>> Teko no wapas 1 se start karneke liye query maarana padenga
>>>>
>>>> last_no = Model.objects.filter(categorycode="blah",
>>>> citycode="blah-blah").count()
>>>>
>>>> unique_code ="LM" + categorycode
>>>> + citycode + str(last_no + 1)
>>>>
>>>>
>>>> Aisa code likkha toh result milenga 😋
>>>>
>>>>
>>>> On Fri, Feb 19, 2021, 3:31 PM Kritika Paul 
>>>> wrote:
>>>>
>>>>>  I have to create a unique code for each space saved in dbAb db me
>>>>> save krne k lie, wo multiple part me save ho rha hai, multiple models bhi
>>>>> hai uske.1st model se mujhe space category ka name uthana hai
>>>>> 2nd se city code
>>>>> Category alag alg ho skti hai
>>>>> To code genrate hoga LM-categorycode-citycode-1Next time jb
>>>>> category, B hogi to number 1 se hi start hoga, ni to category same hai to
>>>>> fr se 2 allot ho jaega
>>>>> Eg Category - CW, COM
>>>>> City - Noida, DelhiSpace 1 - Cw category
>>>>> Code space 1- LMCWNoida1Space2 - CW Category
>>>>> CODE SPACE2 - LMCWDelhi2Space 3 - COM category
>>>>> CODE SPACE 3- LM-COM-NOIDA0001
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://gr

Re: Immediately Need Help

2021-02-19 Thread Chetan Ganji
Show the model where you save Space_code

On Fri, Feb 19, 2021, 4:19 PM Kritika Paul  wrote:

> class SpaceCategory(BaseModel):
> __tablename__ = "space_categories"
>
> name = db.Column(db.String(255))
> description = db.Column(db.Text)
> image_url = db.Column(db.Text)
> code = db.Column(db.String(100))
> space_sub_category = db.relationship('SpaceSubCategory', backref
> =db.backref("space_category", uselist=False))
>
> class Cities(BaseModel):
> __tablename__ = "cities"
> name = db.Column(db.String(255))
> code = db.Column(db.String(100))
> is_deleted = db.Column(db.Boolean,default=False)
> These are the models,
> There is one other model where I have to save Space_code
>
> Now, Space Category is CW,COM,MS
> City Code is NOIDA, DELHI,KOlkata
>
> Space code to be generated such that Numbers should increase Space
> Category Wise
>
>
> On Fri, 19 Feb 2021 at 16:07, Chetan Ganji  wrote:
>
>> Yes kritika show all the models.
>>
>> How shubham?
>> If an entry is deleted, unique code will also be deleted. Next time it
>> gets generated, it might be assigned to different entry, but it still be
>> unique.
>>
>> As kritika clarified already, so it wont be a problem.
>>
>> On Fri, Feb 19, 2021, 3:58 PM shubham vashisht 
>> wrote:
>>
>>> Chetan
>>> If any row is deleted from the table, then your logic will fail to
>>> return the unique code
>>>
>>> On Fri, 19 Feb 2021, 15:52 Chetan Ganji,  wrote:
>>>
>>>> Hi Kritika
>>>>
>>>> Ye chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂
>>>>
>>>> Teko field pe unique constraint lagana padenga
>>>>
>>>> Teko no wapas 1 se start karneke liye query maarana padenga
>>>>
>>>> last_no = Model.objects.filter(categorycode="blah",
>>>> citycode="blah-blah").count()
>>>>
>>>> unique_code ="LM" + categorycode
>>>> + citycode + str(last_no + 1)
>>>>
>>>>
>>>> Aisa code likkha toh result milenga 😋
>>>>
>>>>
>>>> On Fri, Feb 19, 2021, 3:31 PM Kritika Paul 
>>>> wrote:
>>>>
>>>>>  I have to create a unique code for each space saved in dbAb db me
>>>>> save krne k lie, wo multiple part me save ho rha hai, multiple models bhi
>>>>> hai uske.1st model se mujhe space category ka name uthana hai
>>>>> 2nd se city code
>>>>> Category alag alg ho skti hai
>>>>> To code genrate hoga LM-categorycode-citycode-1Next time jb
>>>>> category, B hogi to number 1 se hi start hoga, ni to category same hai to
>>>>> fr se 2 allot ho jaega
>>>>> Eg Category - CW, COM
>>>>> City - Noida, DelhiSpace 1 - Cw category
>>>>> Code space 1- LMCWNoida1Space2 - CW Category
>>>>> CODE SPACE2 - LMCWDelhi2Space 3 - COM category
>>>>> CODE SPACE 3- LM-COM-NOIDA0001
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%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/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
&

Re: Immediately Need Help

2021-02-19 Thread Chetan Ganji
Yes kritika show all the models.

How shubham?
If an entry is deleted, unique code will also be deleted. Next time it gets
generated, it might be assigned to different entry, but it still be unique.

As kritika clarified already, so it wont be a problem.

On Fri, Feb 19, 2021, 3:58 PM shubham vashisht  wrote:

> Chetan
> If any row is deleted from the table, then your logic will fail to return
> the unique code
>
> On Fri, 19 Feb 2021, 15:52 Chetan Ganji,  wrote:
>
>> Hi Kritika
>>
>> Ye chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂
>>
>> Teko field pe unique constraint lagana padenga
>>
>> Teko no wapas 1 se start karneke liye query maarana padenga
>>
>> last_no = Model.objects.filter(categorycode="blah",
>> citycode="blah-blah").count()
>>
>> unique_code ="LM" + categorycode
>> + citycode + str(last_no + 1)
>>
>>
>> Aisa code likkha toh result milenga 😋
>>
>>
>> On Fri, Feb 19, 2021, 3:31 PM Kritika Paul 
>> wrote:
>>
>>>  I have to create a unique code for each space saved in dbAb db me save
>>> krne k lie, wo multiple part me save ho rha hai, multiple models bhi hai
>>> uske.1st model se mujhe space category ka name uthana hai
>>> 2nd se city code
>>> Category alag alg ho skti hai
>>> To code genrate hoga LM-categorycode-citycode-1Next time jb
>>> category, B hogi to number 1 se hi start hoga, ni to category same hai to
>>> fr se 2 allot ho jaega
>>> Eg Category - CW, COM
>>> City - Noida, DelhiSpace 1 - Cw category
>>> Code space 1- LMCWNoida1Space2 - CW Category
>>> CODE SPACE2 - LMCWDelhi2Space 3 - COM category
>>> CODE SPACE 3- LM-COM-NOIDA0001
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%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/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%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/CAJW_r64v1-f85ViX%2BnCFdBrupiXi5Ba%3Dzec6xoSvuZnR1jaMEg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJW_r64v1-f85ViX%2BnCFdBrupiXi5Ba%3Dzec6xoSvuZnR1jaMEg%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/CAMKMUjsJR2B7LDHujo_bXxyh1s7WZMqMwgENMQmwiX%3Dpe5QHTg%40mail.gmail.com.


Re: Immediately Need Help

2021-02-19 Thread Chetan Ganji
Hi Kritika

Ye chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂

Teko field pe unique constraint lagana padenga

Teko no wapas 1 se start karneke liye query maarana padenga

last_no = Model.objects.filter(categorycode="blah",
citycode="blah-blah").count()

unique_code ="LM" + categorycode
+ citycode + str(last_no + 1)


Aisa code likkha toh result milenga 😋


On Fri, Feb 19, 2021, 3:31 PM Kritika Paul  wrote:

>  I have to create a unique code for each space saved in dbAb db me save
> krne k lie, wo multiple part me save ho rha hai, multiple models bhi hai
> uske.1st model se mujhe space category ka name uthana hai
> 2nd se city code
> Category alag alg ho skti hai
> To code genrate hoga LM-categorycode-citycode-1Next time jb category,
> B hogi to number 1 se hi start hoga, ni to category same hai to fr se 2
> allot ho jaega
> Eg Category - CW, COM
> City - Noida, DelhiSpace 1 - Cw category
> Code space 1- LMCWNoida1Space2 - CW Category
> CODE SPACE2 - LMCWDelhi2Space 3 - COM category
> CODE SPACE 3- LM-COM-NOIDA0001
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%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/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com.


Re: How to set daily update limit for django model(db)?

2021-02-13 Thread Chetan Ganji
Hi Shailesh,

I am assuming you have created_at and updated_at fields (these or similar)
on the model.
You can write a query like below to get the count of no of rows updated
that day using below code.
Remember to update the filters of the queryset as required e.g. user.


from django.utils import timezone

current_date = timezone.now().date()

edited_count = Model.objects.filter(updated_at__date=current_date).count()


Reference :
https://docs.djangoproject.com/en/3.1/ref/models/querysets/#date

I hope it helps you.

Cheers!


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


On Fri, Feb 5, 2021 at 7:12 AM Shailesh Yadav 
wrote:

> Hi Jaimikp,
>
> I have checked it but no luck. Can we make changes in the resource.py file?
> check the count and store that count into a variable and the next day the
> count value should get reset.
> I have checked *before_import *but not able to implement and also don't
> know if implementing this at resource.py level is good or at views.py logic
> code
>
> Please find the below answer.
>
> https://stackoverflow.com/questions/66042509/how-to-check-perform-field-validation-in-resource-py
>
>
> On Monday, January 25, 2021 at 9:23:50 PM UTC+5:30 jaimikp...@gmail.com
> wrote:
>
>> Hi Shailesh,
>>
>> you can define the function with the use of DateTime module, which
>> changes the value of the variable daily for the count.
>>
>> https://stackoverflow.com/questions/52305294/changing-a-variable-based-on-current-time-of-day
>>
>> and for excel, you can get the number of lines in the file, and you can
>> implement a validator as well.
>>
>> https://stackoverflow.com/questions/13377793/is-it-possible-to-get-an-excel-documents-row-count-without-loading-the-entire-d
>>
>>
>> On Saturday, 23 January 2021 at 02:03:51 UTC+5:30 gabriela...@gmail.com
>> wrote:
>>
>>> Hi Sahilesh:
>>> Try with this:
>>>
>>> https://www.kite.com/python/answers/how-to-count-the-number-of-rows-in-a-pandas-dataframe-in-python
>>>
>>> El viernes, 22 de enero de 2021 a las 14:39:35 UTC-3,
>>> shailesh...@gmail.com escribió:
>>>
>>>> Thanks! but Can you elaborate more?
>>>> *howmany = mytable.count()* = Here How it'll work and how to reset the
>>>> value in 1 day. how I can use it in my code.
>>>>
>>>>
>>>> import xlrd   =
>>>>
>>>> I was trying something like this
>>>> def CTA_upload(request):
>>>> i = 1
>>>> count = (1,)
>>>> print('Counter value at starting :', len(count))
>>>> allcta = CTA.objecta.all()
>>>> allcta7 = len(tuple(allcta)) // 2
>>>> print('Tuple Check:', allcta7)
>>>>
>>>> try:
>>>> if request.method == 'POST':
>>>> movie_resource = CTAResource()
>>>> ##we will get data in movie_resources
>>>> dataset = Dataset()
>>>> new_movie = request.FILES['file']
>>>> if not new_movie.name.endswith('xls'):
>>>> messages.info(request, 'Sorry Wrong File Format.Please Upload valid
>>>> format')
>>>> return render(request, 'apple/uploadcts.html')
>>>> messages.info(request, 'Processing...')
>>>>
>>>> imported_data = dataset.load(new_movie.read(), format='xls')
>>>> for data in imported_data:
>>>> value = CTA(
>>>> data[0],
>>>> data[1],
>>>> data[2],
>>>> data[3],
>>>> data[4],
>>>> data[5],
>>>> data[6],
>>>> data[7],
>>>> data[8],
>>>> )
>>>> if len(count) <= allcta7:
>>>> value.save()
>>>> i+= 1
>>>> count = append(i)
>>>> else:
>>>> messages.info(request, 'Sorry You have uploaded more data than
>>>> specified limit...')
>>>> count.clear()
>>>>
>>>> except:
>>>> messages.info(request,'Same Email ID has been observed more than
>>>> once.Except that other records has been added../nPlease Make sure Email
>>>> field should be unique.')
>>>> print("Problem hai kuch to")
>>>>
>>>> return render(request,'app/uploadcts.html')
>>>>
>>>> On Friday, January 22, 2021 at 10:45:54 PM UTC+5:30
>>>> gabriela...@gmail.com wrote:
>>>>
>>>>> Previous, you can use:
>>>>> howmany = mytabl

Re: Django Rest Framework APIView request

2021-02-01 Thread Chetan Ganji
If it needs to be done on specific endpoints, write a custom decorator
method for that endpoint.

If it needs to be done on every request, write custom middleware.

On Mon, Feb 1, 2021, 1:51 PM Ammar Mohammed  wrote:

>
> Hi everyone i have an API View inherited from another class
> i want to create a new app that reciver the current Client requests and
> process it then pass it to the original View
> (all i want to do is to recive the view from the user (the user will use
> the original urls without any edit in the clients) then i want to add some
> value to one of the request variables and redirect it to the original
> APIView)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c8b3c72e-6664-4aff-b427-69d2933b3ec5n%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/CAMKMUjsmJ-nvvumj%3DMdpRgTGfGs8%2BsrS8%2B3cRsCMhY7waxDw8A%40mail.gmail.com.


Re:

2021-01-26 Thread Chetan Ganji
Hi Salima,

Couple of things you can change in the code to make it run faster!
Do these changes and performance will definitely improve.

1.Queryset

Problem:
classifieds =
vk_classifieds.objects.filter(class_status='1').order_by('-added_date')
This will fetch all the entries in the table; if there are million records
in the table,
all of them will be fetched, which is not required at all!

Processing them will consume resources on the server which is unnecessary
calculation!
Avoid it!

Solution:
classifieds =
vk_classifieds.objects.filter(class_status='1').order_by('-added_date')[:page_size]

Only fetch what you need! As your page size is 40 actual query will look
like below.
classifieds =
vk_classifieds.objects.filter(class_status='1').order_by('-added_date')[:40]

2. Calculation on every request

2.1 classifieds_dist
Distance between two zipcodes is not going to be changed! You dont have to
calculate on every request.
Calculate it only once when the new classified is created and store it in a
separate table.
This calculation must be done using a celery task.

Every time zipcode of classified is updated or user updates his zipcode,
this distance has to be updated.
You have to put restrictions on how many times a user can change his
zipcode.
Otherwise you could end up paying hugh money to the api providers!
This updation must be done using a celery task.


2.2 diff_time
I dont know the code and complexity of it.
However as it is going to be required on every request find a way to
calculate it once and store in a separate table.

Let me know if they are helpful or not!
Cheers!


On Thu, Jan 21, 2021, 9:35 AM Salima Begum 
wrote:

> Hi all,
>
> We are building website, Here I have written functionality for classifieds
> page.
> It is loading to slow because of We are prompting distance calculation in
> classifieds page. By using distance API matrix based on logged in user zip
> code and individual Ad zip codes from query set(database).
>
> ```
> def classifieds(request):
> global dict_time
> try:
> dict_time = {}
> email = request.session.get('email')
>
> # Here we are displaying the classified ads "order by date".
> The ads will be sorted by latest date.
> classifieds =
> vk_classifieds.objects.filter(class_status='1').order_by('-added_date')
>
> count =
> vk_classifieds.objects.filter(class_status='1').order_by('-added_date').count()
> for i in classifieds:
> # diff_time is a child method. By passing 'i' as object in
> diff_time.
> difrnc_date = diff_time(i)
> dict_time[i.id] = difrnc_date
>
> # Pagination for classifieds page.
> # classified = random.sample(list(classifieds), k=count)
> # print("classified = ", str(classified))
> # By default first page
> page = request.GET.get('page', 1)
> # print("page = ", str(page))
> # Per page setting 40 objects.
> paginator = Paginator(list(classifieds), 40)
> # print("paginator = ", str(paginator))
> classified_p = paginator.page(page)
> # print(classified_p)
> except PageNotAnInteger:
> classified_p = paginator.page(1)
> except EmptyPage:
> classified_p = paginator.page(paginator.num_pages)
> except Exception as e:
> logging.error(e)
> return render(request, "classifieds.html",
>   {"Classifieds": classified_p,
>  # distance calculation
>"distance": classifieds_dist(email),
>'some_date': dict_time,
>})
> return render(request, "classifieds.html", {"Classifieds":
> classified_p,
> "distance":
> classifieds_dist(email),
> 'some_date': dict_time,
> })
> ```
>
> ```
>
> def classifieds_dist(email):
> global frm, km
> dict_distance = {}
>
> qury = vk_customer.objects.filter(email=email).first()
>
> # From above qury variable we are getting zip of customer.
> frm = qury.Zip
> # importing json package to calculate the distance
> url = "
> https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial";
> headers = {
> 'Authorization': "Bearer somevalue",
> 'User-Agent': "some value",
> 'Accept': "*/*",
> 'Cache-Control': "no-cache",
> 'Postman-Token': "some value",
> 'Host': "maps.googleapis.com",
> 'Accept-Encoding': "gzip, deflate",
> 'Connection': "keep-alive",
> 'cache-control': "no-cache"
> }
> classifieds =
> vk_classifieds.objects.filter(class_status='1').order_by('-added_date')
> for i in classifieds:
> # while a user login th

Angular Material Help Required

2021-01-22 Thread Chetan Ganji
Hi,

I was hoping someone could help me with this. I know this is not
angular group :P

*Requirement:* errors should be displayed just after the mat-label.

*Problem:* mat-error is always displayed below the matInput in angular
material theme. It doesnt matter in which order I write the markup, errors
are always displayed below the input.

*Solution:*
1. mat-errors need to be made inline in the css, I found the css code that
will make this change.
2. mat-error are always subscripted to matInput - I need help with this.
I want to understand how this happens in the framework and how to stop this
default behaviour.
I have looked into the source code, but could not find the code responsible
for this.

This change needs to be done project wide. Please suggest a solution that's
ideal.
One solution would be to extend the default angular/material directives and
make the changes in those and import extended directives instead of the
default directives.
Is there a better way to do this?

Thanks in advance!


My code in theme pages

First name 
 is
required 




I think below code is the markup of errors
https://github.com/angular/components/blob/acb3f33413b92cc326f51a1db8b43e4a8094d745/src/material/form-field/form-field.html#L74




...




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/CAMKMUjuTntpDGPHNsTSUvMNN2b%2BdbYS-4WW12E9ZTrnaOiMYPw%40mail.gmail.com.


Re: How to get username in django_requestlogging

2021-01-03 Thread Chetan Ganji
However,

use sentry for logging on prod servers, it will make your life easier.

Its free to get started 😉

On Sun, Jan 3, 2021, 11:08 PM Chetan Ganji  wrote:

> Hey,
>
> On that link it is mentioned as below.
>
> If any of this information cannot be extracted from the current request
> (or there is no current request), a hyphen '-' is substituted as a
> placeholder.
>
> Maybe you are trying with anonymous user? 😅
>
>
>
>
> On Sat, Jan 2, 2021, 8:42 PM Shailesh Yadav 
> wrote:
>
>> I am using ‘django_requestlogging’ for the log file and I have followed
>> django_requestlogging <https://pypi.org/project/django-requestlogging/> this
>> link and configured it as per the steps given.
>>
>> I am not getting the username in the log file instead of that I am
>> getting “-”.
>>
>> Please find the code details.
>>
>>
>> *step1*.Installed application
>>
>> INSTALLED_APPS =
>>
>>  [ --- --
>>
>>   'django_requestlogging',
>>
>>  ]
>>
>>
>> *step2:* Created Middleware
>>
>>
>> from django.utils.deprecation import MiddlewareMixin from
>> django_requestlogging.middleware import LogSetupMiddleware as Original
>> class LogSetupMiddleware(MiddlewareMixin, Original): pass
>>
>>
>> *step3:* used in settings.py
>>
>>
>> MIDDLEWARE = [ ‘django.middleware.security.SecurityMiddleware’,
>> ‘django.contrib.sessions.middleware.SessionMiddleware’,
>> ‘django.middleware.common.CommonMiddleware’,
>> ‘django.middleware.csrf.CsrfViewMiddleware’,
>> ‘django.contrib.auth.middleware.AuthenticationMiddleware’,
>> ‘django.contrib.messages.middleware.MessageMiddleware’,
>> ‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
>> ‘user_visit.middleware.UserVisitMiddleware’, #
>> ‘django_requestlogging.middleware.LogSetupMiddleware’,
>> ‘apple.middleware1.LogSetupMiddleware’ ]
>>
>>
>>
>> *step4:* Configuration
>>
>>
>>
>>
>> LOGGING = {
>> 'version': 1,
>> # Version of logging
>> 'disable_existing_loggers': False,
>> 'filters': {
>> # Add an unbound RequestFilter.
>> 'request': {
>> '()': 'django_requestlogging.logging_filters.RequestFilter',
>> },
>> },
>> 'formatters': {
>> 'request_format': {
>> 'format': '%(remote_addr)s "%(request_method)s '
>> '%(path_info)s %(server_protocol)s" %(http_user_agent)s '
>> '%(message)s %(asctime)s',
>> },
>>
>> 'simple': {
>> 'format': '[%(asctime)s] - %(levelname)5s -:%(message)3s -" %(username)5s'
>> },
>>
>> },
>> 'handlers': {
>> 'console': {
>> 'level': 'INFO',
>> 'class': 'logging.StreamHandler',
>> 'filters': ['request'],
>> 'formatter': 'simple',
>> },
>>
>> 'file': {
>> 'level': 'INFO',
>> 'class': 'logging.FileHandler',
>> 'filename': 'icici.log',
>> 'formatter':'simple'
>> },
>> },
>> 'loggers': {
>> 'django': {
>> # Add your handlers that have the unbound request filter
>> 'handlers': ['console','file'],
>> 'level': 'DEBUG',
>> 'propagate': True,
>> # Optionally, add the unbound request filter to your
>> # application.
>> 'filters': ['request'],
>> },
>> },
>> }
>>
>> In the O/p Log file, I am getting.
>>
>> [2021-01-01 21:53:39,243] - INFO -:"GET /genesysall/ HTTP/1.1" 200 82259
>> -" -
>>
>> Any help or hint on this how to get the username.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/f1f1adea-a087-42f6-b5ef-d3847b9bc43bn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f1f1adea-a087-42f6-b5ef-d3847b9bc43bn%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/CAMKMUjtrvcrqSM4p9N_KsZiu2Nc7CMOaSkKf1n_Ane8tT-%3D7vA%40mail.gmail.com.


Re: How to get username in django_requestlogging

2021-01-03 Thread Chetan Ganji
Hey,

On that link it is mentioned as below.

If any of this information cannot be extracted from the current request (or
there is no current request), a hyphen '-' is substituted as a placeholder.

Maybe you are trying with anonymous user? 😅




On Sat, Jan 2, 2021, 8:42 PM Shailesh Yadav 
wrote:

> I am using ‘django_requestlogging’ for the log file and I have followed
> django_requestlogging  this
> link and configured it as per the steps given.
>
> I am not getting the username in the log file instead of that I am getting
> “-”.
>
> Please find the code details.
>
>
> *step1*.Installed application
>
> INSTALLED_APPS =
>
>  [ --- --
>
>   'django_requestlogging',
>
>  ]
>
>
> *step2:* Created Middleware
>
>
> from django.utils.deprecation import MiddlewareMixin from
> django_requestlogging.middleware import LogSetupMiddleware as Original
> class LogSetupMiddleware(MiddlewareMixin, Original): pass
>
>
> *step3:* used in settings.py
>
>
> MIDDLEWARE = [ ‘django.middleware.security.SecurityMiddleware’,
> ‘django.contrib.sessions.middleware.SessionMiddleware’,
> ‘django.middleware.common.CommonMiddleware’,
> ‘django.middleware.csrf.CsrfViewMiddleware’,
> ‘django.contrib.auth.middleware.AuthenticationMiddleware’,
> ‘django.contrib.messages.middleware.MessageMiddleware’,
> ‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
> ‘user_visit.middleware.UserVisitMiddleware’, #
> ‘django_requestlogging.middleware.LogSetupMiddleware’,
> ‘apple.middleware1.LogSetupMiddleware’ ]
>
>
>
> *step4:* Configuration
>
>
>
>
> LOGGING = {
> 'version': 1,
> # Version of logging
> 'disable_existing_loggers': False,
> 'filters': {
> # Add an unbound RequestFilter.
> 'request': {
> '()': 'django_requestlogging.logging_filters.RequestFilter',
> },
> },
> 'formatters': {
> 'request_format': {
> 'format': '%(remote_addr)s "%(request_method)s '
> '%(path_info)s %(server_protocol)s" %(http_user_agent)s '
> '%(message)s %(asctime)s',
> },
>
> 'simple': {
> 'format': '[%(asctime)s] - %(levelname)5s -:%(message)3s -" %(username)5s'
> },
>
> },
> 'handlers': {
> 'console': {
> 'level': 'INFO',
> 'class': 'logging.StreamHandler',
> 'filters': ['request'],
> 'formatter': 'simple',
> },
>
> 'file': {
> 'level': 'INFO',
> 'class': 'logging.FileHandler',
> 'filename': 'icici.log',
> 'formatter':'simple'
> },
> },
> 'loggers': {
> 'django': {
> # Add your handlers that have the unbound request filter
> 'handlers': ['console','file'],
> 'level': 'DEBUG',
> 'propagate': True,
> # Optionally, add the unbound request filter to your
> # application.
> 'filters': ['request'],
> },
> },
> }
>
> In the O/p Log file, I am getting.
>
> [2021-01-01 21:53:39,243] - INFO -:"GET /genesysall/ HTTP/1.1" 200 82259
> -" -
>
> Any help or hint on this how to get the username.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f1f1adea-a087-42f6-b5ef-d3847b9bc43bn%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/CAMKMUjsbBoAZXMzoJKdqMpVis9WOScOEDm_qWig%3DraDgVfdyBQ%40mail.gmail.com.


Re: deployment error : django + pgsql

2020-12-29 Thread Chetan Ganji
Give the details of not able to migrate and someone might be able to help
you

Meanwhile refer to below doc and try again.
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04


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


On Tue, Dec 29, 2020 at 10:05 PM Kasper Laudrup 
wrote:

> Hi Govind,
>
> On 29/12/2020 15.43, Govind Kumar Yadav wrote:
> > hi I have been trying to deploy my Django project with pgsql on Linux
> > with over nginx server but i am not able to migrate for my already
> > existing project which works fine in my windows machine.
> > Help me to get over the issues.
>
> No one is able to help you get over your issues, since no one knows
> which issues you are having apart from lack of communication skills.
>
> Try to take the time to write a proper question and then I'm sure
> someone will be happy to take the time and write a proper answer.
>
> 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/1c48e865-75c2-7c0a-5273-86c41f81f850%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/CAMKMUjuSBHRMQuPy1YiHthn4hHfXszey%3D-%3Dsc7cWaJFLXYQ0mg%40mail.gmail.com.


Re: Trying to trigger a bulkcreation of records using a reverse relationship

2020-11-13 Thread Chetan Ganji
Welcome :)

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


On Fri, Nov 13, 2020 at 9:22 PM Dumba Classics 
wrote:

> thank you @Chetan the solution does work and I am very grateful!!
>
> On Fri, Nov 13, 2020 at 5:35 PM Chetan Ganji 
> wrote:
>
>> Im not 100% sure about this :P
>>
>> Instead of this -
>> def save(self, *args, **kwargs):
>> if self.records.count() <= 0:
>> for student in self.klass.students.all():
>> self.records.create(student=student, status='present')
>> super(Attendance, self).save(*args, **kwargs)
>>
>>
>> Try with below code -
>>
>> def save(self, *args, **kwargs):
>> super(Attendance, self).save(*args, **kwargs)
>> if self.records.count() <= 0:
>> for student in self.klass.students.all():
>> self.records.create(student=student, status='present') # separate sql
>> query i guess for each entry created.
>>
>>
>> There is a diff logic.
>>
>> 1. create attendance object.
>> 2. bulk create AttendanceRecord objects
>> https://docs.djangoproject.com/en/3.1/ref/models/querysets/#bulk-create
>>
>> P.S. both of this operations should happen inside a transaction.
>> https://docs.djangoproject.com/en/3.1/topics/db/transactions/
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Fri, Nov 13, 2020 at 4:41 PM DumbaClassics 
>> wrote:
>>
>>> Hello Family may you help.
>>>
>>> I am trying to create a School Attendance Module and I have a
>>> StudentClass table, the Student table, Attendance table and the
>>> AttendanceRecord table. Here is the code
>>>
>>> class StudentClass(models.Model):
>>> name  =   models.CharField(max_length=100)
>>> # stream   =   models.ForeignKey('Stream', on_delete=models.PROTECT)
>>> creation_date =   models.DateTimeField(auto_now=False,
>>> auto_now_add=True)
>>>
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> class Student(models.Model):
>>> name = models.CharField(max_length=100)
>>> klass = models.ForeignKey('StudentClass', models.PROTECT,
>>> related_name='students')
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> class Attendance(models.Model):
>>> date = models.DateTimeField(auto_now_add=True)
>>> klass = models.ForeignKey('StudentClass', models.PROTECT,
>>> related_name='attendances')
>>>
>>> def save(self, *args, **kwargs):
>>> if self.records.count() <= 0:
>>> for student in self.klass.students.all():
>>> self.records.create(student=student, status='present')
>>> super(Attendance, self).save(*args, **kwargs)
>>>
>>> def __str__(self):
>>> return f"{self.id}, {self.date}"
>>>
>>> class AttendanceRecord(models.Model):
>>> ATTENDANCE_STATUS = [
>>> ('present', 'PRESENT'),
>>> ('absent', 'ABSENT')
>>> ]
>>> attendance = models.ForeignKey(
>>> 'Attendance',
>>> on_delete=models.SET_NULL,
>>> null=True,
>>> blank=True,
>>> related_name='records'
>>> )
>>> student = models.ForeignKey('Student', on_delete=models.PROTECT)
>>> status = models.CharField(max_length=100, choices=ATTENDANCE_STATUS)
>>>
>>>
>>> def __str__(self):
>>> return f"(STUDENT: {self.student}, STATUS: {self.status})"
>>>
>>>
>>> What am I trying to achieve??
>>>
>>> I want to have a situation whereby when I trigger the creation of a
>>> Attendance instance an Attendance Record linked to that instance is
>>> generated with the record generating default attendance records for all
>>> students enrolled in that klass with a default attendance status of present
>>> which I can get on to edit only for those students who are absent. The
>>> method I tried for ovveriding the save method didnt work as it generated
>>> this error '"unsaved related object '%s'." % field.name
>>> ValueError: save() prohibited to prevent data loss due to unsaved
>>> related object 'attendance'.'
>>>
>>> I wasnt really confident of that solution anyway.
>>>
>>> May y

Re: Trying to trigger a bulkcreation of records using a reverse relationship

2020-11-13 Thread Chetan Ganji
Im not 100% sure about this :P

Instead of this -
def save(self, *args, **kwargs):
if self.records.count() <= 0:
for student in self.klass.students.all():
self.records.create(student=student, status='present')
super(Attendance, self).save(*args, **kwargs)


Try with below code -

def save(self, *args, **kwargs):
super(Attendance, self).save(*args, **kwargs)
if self.records.count() <= 0:
for student in self.klass.students.all():
self.records.create(student=student, status='present') # separate sql query
i guess for each entry created.


There is a diff logic.

1. create attendance object.
2. bulk create AttendanceRecord objects
https://docs.djangoproject.com/en/3.1/ref/models/querysets/#bulk-create

P.S. both of this operations should happen inside a transaction.
https://docs.djangoproject.com/en/3.1/topics/db/transactions/


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


On Fri, Nov 13, 2020 at 4:41 PM DumbaClassics 
wrote:

> Hello Family may you help.
>
> I am trying to create a School Attendance Module and I have a StudentClass
> table, the Student table, Attendance table and the AttendanceRecord table.
> Here is the code
>
> class StudentClass(models.Model):
> name  =   models.CharField(max_length=100)
> # stream   =   models.ForeignKey('Stream', on_delete=models.PROTECT)
> creation_date =   models.DateTimeField(auto_now=False,
> auto_now_add=True)
>
>
> def __str__(self):
> return self.name
>
> class Student(models.Model):
> name = models.CharField(max_length=100)
> klass = models.ForeignKey('StudentClass', models.PROTECT,
> related_name='students')
>
> def __str__(self):
> return self.name
>
> class Attendance(models.Model):
> date = models.DateTimeField(auto_now_add=True)
> klass = models.ForeignKey('StudentClass', models.PROTECT,
> related_name='attendances')
>
> def save(self, *args, **kwargs):
> if self.records.count() <= 0:
> for student in self.klass.students.all():
> self.records.create(student=student, status='present')
> super(Attendance, self).save(*args, **kwargs)
>
> def __str__(self):
> return f"{self.id}, {self.date}"
>
> class AttendanceRecord(models.Model):
> ATTENDANCE_STATUS = [
> ('present', 'PRESENT'),
> ('absent', 'ABSENT')
> ]
> attendance = models.ForeignKey(
> 'Attendance',
> on_delete=models.SET_NULL,
> null=True,
> blank=True,
> related_name='records'
> )
> student = models.ForeignKey('Student', on_delete=models.PROTECT)
> status = models.CharField(max_length=100, choices=ATTENDANCE_STATUS)
>
>
> def __str__(self):
> return f"(STUDENT: {self.student}, STATUS: {self.status})"
>
>
> What am I trying to achieve??
>
> I want to have a situation whereby when I trigger the creation of a
> Attendance instance an Attendance Record linked to that instance is
> generated with the record generating default attendance records for all
> students enrolled in that klass with a default attendance status of present
> which I can get on to edit only for those students who are absent. The
> method I tried for ovveriding the save method didnt work as it generated
> this error '"unsaved related object '%s'." % field.name
> ValueError: save() prohibited to prevent data loss due to unsaved related
> object 'attendance'.'
>
> I wasnt really confident of that solution anyway.
>
> May you assist me on how best one wld solve such a problem
>
> Thank you in Advance
>
> Dumba
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2742a034-586d-44a2-872a-5d0c24dc8d70n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2742a034-586d-44a2-872a-5d0c24dc8d70n%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/CAMKMUjvhmpEbB4LeEBnYX5-e8LPVb3m7wpzSChh-F2fyJDTKpg%40mail.gmail.com.


Re: API to stop/resume/terminate a long running task

2020-10-13 Thread Chetan Ganji
Hi Aparna,

I dont know the details of your implementation. As its a bulk upload,
assuming there would be an upload form where user can put multiple files
simultaneously.
One by one, each file would be uploaded to the server.

AFAIK, bulk operations are not supposed to be stopped and resumed in order
to avoid inconsistency issues.
However, after each file upload you could pause and resume later if each
upload is mutually exclusive.
I have an idea, check if it works for you. It can simply be implemented in
the front end by using a boolean variable.
You could stop uploading if the value of boolean is false and resume if
it's true.
Pause button will set it to false and Resume button will set it to true.

Answers to below questions would help anyone who wants to give better
solutions.

What kind of data - csv, xls, audio, videos, etc.
How long would a typical upload operation would take?
What is the stack? frontend and backend
What is the workflow of uploading the files?

Cheers!


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


On Mon, Oct 12, 2020 at 9:01 PM Arpana Mehta 
wrote:

> Hello everybody,
> I am here looking for a solution to a problem commonly faced maybe.
>
> I have like a huge amount of data that is being uploaded in a go. While I
> can keep these upload tasks under atomic decorators to avoid systemic
> failure but I don't have way to let the user stop the task and resume or
> terminate it later.
>
> I would need suggestions on how to go about this workflow.
>
> Would love details in the flow. I understand the basic mechanism myself
> but I want to write APIs to stop or resume any running bulk write/read task
> in my system.
>
> Thanks and regards,
> Arpana
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGyqUuWfaa0_ME%2BHjQx8b6nKyB0g54F0OtA8DrEvzwpqxJ013g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGyqUuWfaa0_ME%2BHjQx8b6nKyB0g54F0OtA8DrEvzwpqxJ013g%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/CAMKMUju6Bm6U_sFGtDKDvesMT37-agfUocz%2BnMrEJEtNkOgZxw%40mail.gmail.com.


Re: multiple database

2020-10-09 Thread Chetan Ganji
https://docs.djangoproject.com/en/3.1/topics/db/multi-db/


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


On Fri, Oct 9, 2020 at 6:41 PM Khaleel Ahmed H. M. Shariff <
khaleelahme...@gmail.com> wrote:

> Hi Suhaib,
> May Peace, Blessings & Mercy of Almighty God be on you!
>
> Kindly throw some light on what database you are using. Are you using
> SQLite (default available with Python) or any other RDBMS like
> MySQL/Oracle???
> Awaiting your reply.
> Thanks in advance.
>
>
> God Bless You!
> God Bless India!!
> --
>
> Love & Regards
> Dr. (h.c.) Khaleel Ahmed H. M.
>
> Managing Director, Tanzanite Realty India Private Limited
>
> ---
>
> Human Life is Precious
> Koran Surah Ma'idah Chapter 5 Verse 32:
> If anyone killed a person, not in retaliation of murder, or (and) to
> spread mischief in the land - it would be as if he killed all mankind, & if
> anyone saved a life, it would be as if he saved the life of all mankind.
>
>
> On Fri, Oct 9, 2020 at 6:05 PM Suhaib Ali  wrote:
>
>> Hello everyone,
>>
>> i have some doubt regarding django database. i want to create multiple
>> database according to the user wish. for example i want to create a company
>> so each and every company needs their own database while creating the
>> company
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/cff6452c-e9fd-4126-9ef7-51ea4083c6f6n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/cff6452c-e9fd-4126-9ef7-51ea4083c6f6n%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/CAMjBbiBL91PMWVAmLWZoPSJSiD5v%2B8WzMB9A83UvWOqy5RwAhw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMjBbiBL91PMWVAmLWZoPSJSiD5v%2B8WzMB9A83UvWOqy5RwAhw%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/CAMKMUjuZRmcyxsrA%3D%3DUZAh5qWOrP8VMvpZNQdwhKtVY3wBHt5w%40mail.gmail.com.


Re: creating a website with django

2020-08-28 Thread Chetan Ganji
https://www.youtube.com/watch?v=KsLHt3D_jsE&list=PLEsfXFp6DpzRcd-q4vR5qAgOZUuz8041S

On Fri, Aug 28, 2020, 9:04 PM sakshi jain  wrote:

> plz help me also
>
> On Fri, Aug 28, 2020, 19:23 Kamini Shukla 
> wrote:
>
>> i want to create a website with the help of django. pls some one help of
>> that.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/2fd61f31-8604-422a-b091-e46cd9bc25d0n%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/CAJhs3iP_YK4gCu48FkbDwSHx6bciQ%2BzZCS_N4RvWFQ71X%2BFEYA%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/CAMKMUjunwDgz1Jbzqv82UstTmCeyjVRmF5sP3x7ziv6cdTd6bw%40mail.gmail.com.


Re: Question about django.utils.autoreload

2020-07-20 Thread Chetan Ganji
RE: os.path.join(BASE_DIR, 'reactapp', 'src')

It seems that the source code of react app is inside the django folder, so
if src code of django is changed, react app would be rebuild!

Try keeping the src code of django and react app if different folders, that
might solve it.


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


On Mon, Jul 20, 2020 at 12:47 PM Dave R  wrote:

> Hello, I'm trying to figure out how to rebuild my React.js project (with
> Django backend) and relaunch the Django dev server if a React.js file
> changes.  The code below works, but it rebuilds React even if the only code
> changes are in Django.  Can anyone suggest how to solve this problem?
>
> import subprocess
> from django.utils.autoreload import autoreload_started
> from django.dispatch import receiver
> @receiver(autoreload_started)
> def rebuild_react_app(sender, **kwargs):
> sender.watch_dir(os.path.join(BASE_DIR, 'reactapp', 'src'), '*')
> subprocess.run(r'yarn --cwd ./reactapp build', shell=True)
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/13c40a08-6084-4609-8141-ddcf029c33a7n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/13c40a08-6084-4609-8141-ddcf029c33a7n%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/CAMKMUjsKeicUWpuxmWcR_s7CEhGD9Tr%3DrCJL%3D_FOvoD8yv2oDA%40mail.gmail.com.


Re: Form theory - locking a field

2020-06-24 Thread Chetan Ganji
Try this one
https://docs.djangoproject.com/en/3.0/ref/forms/fields/#disabled

On Wed, Jun 24, 2020, 8:06 PM Clive Bruton  wrote:

> I have a form in which, after filing, I would like one field to be
> locked for editing, the forms.py looks like this:
>
> **
>
> class ProfileForm(forms.ModelForm):
>  status = forms.ChoiceField(choices=Profile.status_choices,
> widget=forms.RadioSelect)
>
>  class Meta:
>  model = Profile
>  fields = (
>  'status', 'phone', 'display_phone', 'display_address',
> 'display_email', 'display_loginoverride'
>  )
>  widgets = {
>  'phone': PhoneWidget
>  }
>
> **
>
>
> While the user will be able to come back and change the other
> information on the form, I want to be able to lock the "status"
> field, so that it just shows the input they selected, not the radio
> buttons and is no longer editable by the user.
>
> Is there a way to do this in forms.py, or would I have to construct
> the logic in a template (or perhaps some other way)?
>
> Thanks
>
>
> -- Clive
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7A4BCC9C-172C-4511-A422-6E832A72E11D%40indx.co.uk
> .
>

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


Re: Need your help!!

2020-06-15 Thread Chetan Ganji
https://docs.djangoproject.com/en/3.0/topics/security/

On Mon, Jun 15, 2020, 10:59 PM Vishesh Mangla 
wrote:

> What kind of security?
>
>
>
> Sent from Mail  for
> Windows 10
>
>
>
> *From: *meera gangani 
> *Sent: *15 June 2020 22:28
> *To: *django-users@googlegroups.com
> *Subject: *Need your help!!
>
>
>
> Hello ,
>
>
>
>  How to apply security in django application and  how to
> secure django applications
>
>
>
> Thanks in advance
>
> -Meera Gangani
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANaPPPLr9DJstjDvYOOrddtY4fcfNLs7xgudWfJ1aFhkROL0GA%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/6B653CD7-68CB-4C56-9FB3-034FF4902547%40hxcore.ol
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMKMUjvO5VJ-YnA-YY00fB%3D6qpmZAoOdiQNFLyhBq_%2Bwy1DsFw%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.


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: 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: 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: 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: 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: 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: 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: 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: 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,

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: Django tutor/coach wanted

2020-02-14 Thread Chetan Ganji
Not sure about one on one. Will certainly help.
https://www.youtube.com/user/CodingEntrepreneurs

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


On Sat, Feb 15, 2020 at 12:32 AM davidrpando2 
wrote:

> Hello,
>
> My name is David Pando. I am new to Django/Python and also looking for a
> tutor/teacher (BTW - Have you seen Corey Shaffer? Execllent Youtube
> tutorial series, but not available for 1-1- teaching).
>
> Have you found anyone available to do this type of instruction?
>
> Thank you,
> David
> dpan...@bellsouth.net
>
>
> On Friday, February 5, 2016 at 9:37:45 PM UTC-5, Django Learner wrote:
>
>> I'm a very experienced developer, but not experienced with Python/Django.
>> I have a site that I'd like to build using these tools, and am hoping to
>> find someone to help make climbing the learning curve an efficient process.
>> I'm in Boston, but remote is OK. Willing to pay well for comensurate
>> expertise. Contact me at melear...@gmail.com. Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/900c1cb9-6706-469c-a4a3-4df57541b6c1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/900c1cb9-6706-469c-a4a3-4df57541b6c1%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/CAMKMUjvUXhabiFp%3DsXYjKuhFYgN1rNw7DAP%3DOMvRft6DX%3D4acA%40mail.gmail.com.


Re: bugs for beginners

2020-01-12 Thread Chetan Ganji
https://www.freecodecamp.org/news/the-10-most-popular-coding-challenge-websites-of-2016-fb8a5672d22f/

On Sun, Jan 12, 2020, 9:33 PM aakansha jain 
wrote:

> Can someone suggest me the bugs that can be worked upon by beginners?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f98bc063-72a0-400a-ba27-01de9ddd639d%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/CAMKMUjvS6iEY-D9EE%2BYau4P8O7AWDTqsCJrSf299oRU%2BuWdPog%40mail.gmail.com.


Re: 'str' object has no attribute 'objects'

2019-12-28 Thread Chetan Rokade
Thanks Suraj Thapa. 


Sent from Yahoo Mail for iPhone


On Saturday, December 28, 2019, 5:03 PM, Chetan Rokade 
 wrote:

This is resolved now. I had used variable name same as class name. 
Regards,Chetan

On Saturday, December 28, 2019 at 4:30:53 PM UTC+5:30, Chetan Rokade wrote:
Hi Friends,Getting below error while doing search operation :'str' object has 
no attribute 'objects'

Code:1) html having search button :  
  {% csrf_token %} Search 




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5a50d84e-5169-47cc-9d6d-70a702c812c8%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/490184538.4360526.1577533400622%40mail.yahoo.com.


Re: 'str' object has no attribute 'objects'

2019-12-28 Thread Chetan Rokade
This is resolved now. I had used variable name same as class name. 

Regards,
Chetan

On Saturday, December 28, 2019 at 4:30:53 PM UTC+5:30, Chetan Rokade wrote:
>
> Hi Friends,
> Getting below error while doing search operation :
> 'str' object has no attribute 'objects'
>
> Code:
> 1) html having search button :
> 
> {% csrf_token %}
> 
> 
>  placeholder="Enter Application">
> 
> 
>  Search  button>
> 
> 
> 
>
>
>

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


Re: 'str' object has no attribute 'objects'

2019-12-28 Thread Chetan Rokade
2) views.py :
def SearchCR(request):
if request.method == "POST":
CR = request.POST['CR_NAME']

if CR:
match = CR.objects.filter(Q(App_Name__icontains=CR) |
  Q(CR_Status__icontains=CR)
  )
if match:
return render(request, 'changes/changes.html', {'CR'
: match})
else:
messages.error(request, 'No result found')

else:
return redirect('changes')

return render(request, 'changes/changes.html')

On Saturday, December 28, 2019 at 4:30:53 PM UTC+5:30, Chetan Rokade wrote:
>
> Hi Friends,
> Getting below error while doing search operation :
> 'str' object has no attribute 'objects'
>
> Code:
> 1) html having search button :
> 
> {% csrf_token %}
> 
> 
>  placeholder="Enter Application">
> 
> 
>  Search  button>
> 
> 
> 
>
>
>

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


'str' object has no attribute 'objects'

2019-12-28 Thread Chetan Rokade
Hi Friends,
Getting below error while doing search operation :
'str' object has no attribute 'objects'

Code:
1) html having search button :

{% csrf_token %}





 Search 





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


django.urls.exceptions.NoReverseMatch

2019-12-18 Thread Chetan Rokade
Hi Friends,
getting below error :
"django.urls.exceptions.NoReverseMatch: Reverse for 'EditChange' not found. 
'EditChange' is not a valid view function or pattern name."

I have removed EditChange tag/string from all files in my project. 1) app 
level urls.py ,  2) views.py   3) base.html  4) app level changes.html 

still getting the same error. please help me.

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


Re: Python problem

2019-12-15 Thread Chetan Ganji
# input: h123456ello
# output: o123456lleh

# input: th34isisast56ring3
# output: gn34irtsasi56siht3


order = {}
characters = ""
input_string = "h123456ello"
# input_string = "th34isisast56ring3"
counter = 0
output_string = ""


for index, character in enumerate(input_string):
order[index] = character

for item in range(0, len(input_string)):
if input_string[item].isalpha():
characters += input_string[item]

# reversing the string
characters = characters[::-1]

for index, item in enumerate(range(0, len(input_string))) :
if input_string[item].isalpha():
order[index] = characters[counter]
counter += 1

for index in range(0, len(input_string)):
output_string += order[index]

print()
print(input_string)
print(output_string)
print()




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


On Sun, Dec 15, 2019 at 8:14 PM Soumen Khatua 
wrote:

> Hi Folks,
> I'm stucking in this problem from 5 hours but still I'm not bale to logic
> to solve this problem, Please help me guys to solve this problem:
>
> Example:-
> input: h123456ello
> output: o123456lleh
>
> input: th34isisast56ring3
> output: gn34irtsasi56siht3
>
> Thank you in advance.
>
> 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/CAPUw6Wa8LqGGnqbsiKvYrBw6WQkBaqjm9b8Re65PM3zJr1rdkA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6Wa8LqGGnqbsiKvYrBw6WQkBaqjm9b8Re65PM3zJr1rdkA%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/CAMKMUjsLe0zo9_B70dNNq%2Bk_xwOTGt-cs%2BGeqagM-wZk8yYzLA%40mail.gmail.com.


no such table: main.auth_user__old

2019-11-30 Thread Chetan Rokade
Hi Friends
Getting below error while adding new user  from admin page. I am using 
python 3.8 with django 2.1 version
Exception Value: 

no such table: main.auth_user__old   



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


Re: BigAutoField not working

2019-07-29 Thread Chetan Ganji
If you cant see it in your table in dbms, you probably have not run
makemigrations and migrate commands.

If you have done that, you should grab the migration file when that field
was first created and paste that code here. Also paste your old n new code
from the models.py file. So that someone can help you.

On Mon, Jul 29, 2019, 10:03 PM Akshaya Krishnan 
wrote:

> Hi all,
>
> I am trying to create a field in Django 2.2 with BigAutoField as the
> datatype. The backend is MySql. And I am using the mysql.connector.
>
> When I try to add datatype as BigAutoField for the column, I cannot see
> that column in my table.
>
> If I alter it from 'AutoField' to 'BigAutoField', it throws an error:
>
> ValueError: Cannot alter field TableName.columName into
> TableName.columName  - they do not properly define db_type (are you using a
> badly-written custom field?)
>
>
> Thanks in advance
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2ab746fb-70c9-4979-a557-db83f39d00c7%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/CAMKMUjvVKZRs0WjP2QuRnffLfbUHC2%2B0xcM4bsSa_MkPnPDnEw%40mail.gmail.com.


Re: Syntax Error django, python issue

2019-07-28 Thread Chetan Ganji
AUTHENTICATION_BACKENDS
<https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-AUTHENTICATION_BACKENDS>
= ['django.contrib.auth.backends.ModelBackend',

# your backends goes here,

]

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


On Sun, Jul 28, 2019 at 11:12 PM Karreerchange  wrote:

> Hi,
>
> Installing the authentication backend code in settings.py (copy paste..)
> server crashed after save reporting the following,
>
>   File "/Users/ProductionEnv/Desktop/devbnt/project/bnt/bnt/settings.py",
> line 130
>
> 'django.contrib.auth.backends.ModelBackend',
>
>   ^
>
> SyntaxError: invalid syntax
>
> Please can anyone help?
>
> Thanks,
>
> K
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8fce3582-f491-435e-93c1-73af137fff35%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8fce3582-f491-435e-93c1-73af137fff35%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/CAMKMUjtVSrHBZ47bdpMECAhq%2B3EyKC5COtcz0xRwkjRr50TeRQ%40mail.gmail.com.


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: 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: 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: 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.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: 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: 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: 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-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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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.


  1   2   >