Re: Template code tries to join a string to a WSGIRequest

2021-01-10 Thread Luna Tuna
Fixed it.  I checked my app's views.py and I had the template name arg 
reversed with the request when passed to render() shortcut.

On Sunday, January 10, 2021 at 12:46:19 AM UTC-8 Luna Tuna wrote:

> Not sure what to do here.  Have you run into this sort of error before?
> [image: TemplateEngineJoiningStringToWSGIRequest.png]

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


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Luciano Martins
Look I gave up trying on windows and use virtualenv same.

Em sábado, 9 de janeiro de 2021 às 21:55:06 UTC-3, sohailta...@gmail.com 
escreveu:

> im facing difficulty to install pyenv-virtual env on my windows 10
> i googled it several times but it directs me to a git repo where there is 
> an installation process but is of no use because, the command that is 
> displayed is not working in my cmd 
> please help me out
>

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


Re: CRUD Generator

2021-01-10 Thread Carles Pina i Estany


Hi,

On Jan/08/2021, Noel Simela wrote:
> Good day,
> 
> I have explored several crud generator packages.
> 
> I am looking for an opinion on the best package to adopt that has been
> maintained for the past few months,
> 
> If you have experience in django crud generators.Please let me know
> the one you have used, the pros and cons.

I can't remember the details (and I haven't used it at all) but I saw
this talk:
https://djangoday.dk/talks/introducing-iommi/

And I was very impressed by this package. It might help you.

I write the forms using Models, Views, Forms (using
django-crispy-forms), update the urls.py. But depends on the project it
might make sense to use something that helps on this.

Cheers,

-- 
Carles Pina i Estany
https://carles.pina.cat

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


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Atuma Samuel
I don't know if this answers your question, but you can try

$ python -m venv env

env is the name of the virtual environment and can be replaced with any
name of your choice.

On Jan 10, 2021 12:22, "Luciano Martins"  wrote:

> Look I gave up trying on windows and use virtualenv same.
>
> Em sábado, 9 de janeiro de 2021 às 21:55:06 UTC-3, sohailta...@gmail.com
> escreveu:
>
>> im facing difficulty to install pyenv-virtual env on my windows 10
>> i googled it several times but it directs me to a git repo where there is
>> an installation process but is of no use because, the command that is
>> displayed is not working in my cmd
>> please help me out
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1a73a4b5-b12e-473b-9018-be14e584381en%
> 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/CAGL8puUCpfnbWBK3K_zmM_OW2PYF8wpDFAMdfcW2XPUmWKwxow%40mail.gmail.com.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Kasper Laudrup

On 09/01/2021 19.27, Sohail Tanveer wrote:

im facing difficulty to install pyenv-virtual env on my windows 10
i googled it several times but it directs me to a git repo where there 
is an installation process but is of no use because, the command that is 
displayed is not working in my cmd


It would greatly improve your chances of getting some useful help if you 
clarify which git repo you are talking about, which command you are 
trying to using and what exactly you mean by "not working".


Unless you want to leave that as an exercise for the reader.

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/a9d0924c-2906-c97a-3a76-12f06190a188%40stacktrace.dk.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Kunal Solanke
I recently started using pipenv, but still I can say its best thing so far
I have used for storing env variables,creating venv and etc,with one simple
command your virtualenv will be activated,without having to worry about
where your venv files are ,path and etc .
Have a look at it. What do you think about pipenv Kasper?

On Sun, Jan 10, 2021, 20:19 Kasper Laudrup  wrote:

> On 09/01/2021 19.27, Sohail Tanveer wrote:
> > im facing difficulty to install pyenv-virtual env on my windows 10
> > i googled it several times but it directs me to a git repo where there
> > is an installation process but is of no use because, the command that is
> > displayed is not working in my cmd
>
> It would greatly improve your chances of getting some useful help if you
> clarify which git repo you are talking about, which command you are
> trying to using and what exactly you mean by "not working".
>
> Unless you want to leave that as an exercise for the reader.
>
> 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/a9d0924c-2906-c97a-3a76-12f06190a188%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/CAOecAnwtx4up_mOAJMJH%2BD6o0LZQ3tsUZ5EMxu5YCDuXoHOuHw%40mail.gmail.com.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread ramadhan ngallen
Alternatively, You can use virtualenvwrapper-win
On 10 Jan 2021, 18:00 +0300, Kunal Solanke , wrote:
> I recently started using pipenv, but still I can say its best thing so far I 
> have used for storing env variables,creating venv and etc,with one simple 
> command your virtualenv will be activated,without having to worry about where 
> your venv files are ,path and etc .
> Have a look at it. What do you think about pipenv Kasper?
>
> On Sun, Jan 10, 2021, 20:19 Kasper Laudrup  wrote:
> > On 09/01/2021 19.27, Sohail Tanveer wrote:
> > > im facing difficulty to install pyenv-virtual env on my windows 10
> > > i googled it several times but it directs me to a git repo where there
> > > is an installation process but is of no use because, the command that is
> > > displayed is not working in my cmd
> >
> > It would greatly improve your chances of getting some useful help if you
> > clarify which git repo you are talking about, which command you are
> > trying to using and what exactly you mean by "not working".
> >
> > Unless you want to leave that as an exercise for the reader.
> >
> > 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/a9d0924c-2906-c97a-3a76-12f06190a188%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/CAOecAnwtx4up_mOAJMJH%2BD6o0LZQ3tsUZ5EMxu5YCDuXoHOuHw%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/9859ed28-fdb3-487b-b531-6114149a9a2f%40Spark.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Sohail Tanveer
the git repo to which google directs me 
is https://github.com/pyenv/pyenv-virtualenv
the command it wants me to execute in my cmd is   $ git clone 
https://github.com/pyenv/pyenv-virtualenv.git $(pyenv 
root)/plugins/pyenv-virtualenv 
and whenever i execute this it shows an error like 



fatal: Too many arguments.

usage: git clone [] [--]  []

-v, --verbose be more verbose
-q, --quiet   be more quiet
--progressforce progress reporting
-n, --no-checkout don't create a checkout
--barecreate a bare repository
--mirror  create a mirror repository (implies bare)
-l, --local   to clone from a local repository
--no-hardlinksdon't use local hardlinks, always copy  
-s, --shared  setup as shared repository
--recurse-submodules[=]
  initialize submodules in the clone  
--recursive ...   alias of --recurse-submodules
-j, --jobs number of submodules cloned in parallel 
--template 
  directory from which templates will be used
--reference reference repository
--reference-if-able 
  reference repository
--dissociate  use --reference only while cloning  
-o, --originuse  instead of 'origin' to track 
upstream
-b, --branch 
  checkout  instead of the remote's HEAD
-u, --upload-pack 
  path to git-upload-pack on the remote   
--depthcreate a shallow clone of that depth
--shallow-since 
  create a shallow clone since a specific 
time
--shallow-exclude 
  deepen history of shallow clone, excluding rev
--single-branch   clone only one branch, HEAD or --branch 
--no-tags don't clone any tags, and make later fetches not 
to follow them
--shallow-submodules  any cloned submodules will be shallow   
--separate-git-dir 
  separate git dir from working tree  
-c, --config 
  set config inside the new repository
--server-option 
  option to transmit
-4, --ipv4use IPv4 addresses only
-6, --ipv6use IPv6 addresses only
--filterobject filtering
--remote-submodules   any cloned submodules will use their 
remote-tracking branch
--sparse  initialize sparse-checkout file to include only 
files at root 

On Sunday, 10 January 2021 at 20:20:02 UTC+5:30 Kasper Laudrup wrote:

> On 09/01/2021 19.27, Sohail Tanveer wrote:
> > im facing difficulty to install pyenv-virtual env on my windows 10
> > i googled it several times but it directs me to a git repo where there 
> > is an installation process but is of no use because, the command that is 
> > displayed is not working in my cmd
>
> It would greatly improve your chances of getting some useful help if you 
> clarify which git repo you are talking about, which command you are 
> trying to using and what exactly you mean by "not working".
>
> Unless you want to leave that as an exercise for the reader.
>
> 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/86f2fc8d-a20f-4a94-bda6-81d1e4177fb8n%40googlegroups.com.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Gerardo Palazuelos Guerrero
Hi Sohail,
I read your interest for pipenv in Windows. Seems are wasting precious time and 
not productive because of this pipenv tool, which is not even the point of 
Django.

If that keeps resulting complicated, may I suggest you to use venv which comes 
integrated in recent Python installation. You have to install nothing else 
other than Python.

I code Python in Windows using venv - no issues.

In your desired folder, to create virtual environment:
python -m venv the-name-of-my-virtual environment 

Usually I do this (yes, I put a dot in name of my virtual environment):
python -m venv .venv

Then, using gitbash, to activate virtual environment in Windows (assuming you 
are in same desired folder):
. \.venv\Scripts\activate

If not using gitbash, enter to folder .venv\Scripts and run activate - it’s a 
.bat program 

That should work.
Regards,

---
Gerardo



> El 10 ene 2021, a la(s) 9:28, Sohail Tanveer  
> escribió:
> 
> the git repo to which google directs me is 
> https://github.com/pyenv/pyenv-virtualenv
> the command it wants me to execute in my cmd is   $ git clone 
> https://github.com/pyenv/pyenv-virtualenv.git $(pyenv 
> root)/plugins/pyenv-virtualenv 
> and whenever i execute this it shows an error like 
> 
> 
> 
> fatal: Too many arguments.
> 
> usage: git clone [] [--]  []
> 
> -v, --verbose be more verbose
> -q, --quiet   be more quiet
> --progressforce progress reporting
> -n, --no-checkout don't create a checkout
> --barecreate a bare repository
> --mirror  create a mirror repository (implies bare)
> -l, --local   to clone from a local repository
> --no-hardlinksdon't use local hardlinks, always copy  
> -s, --shared  setup as shared repository
> --recurse-submodules[=]
>   initialize submodules in the clone  
> --recursive ...   alias of --recurse-submodules
> -j, --jobs number of submodules cloned in parallel 
> --template 
>   directory from which templates will be used
> --reference reference repository
> --reference-if-able 
>   reference repository
> --dissociate  use --reference only while cloning  
> -o, --originuse  instead of 'origin' to track 
> upstream
> -b, --branch 
>   checkout  instead of the remote's HEAD
> -u, --upload-pack 
>   path to git-upload-pack on the remote   
> --depthcreate a shallow clone of that depth
> --shallow-since 
>   create a shallow clone since a specific 
> time
> --shallow-exclude 
>   deepen history of shallow clone, excluding rev
> --single-branch   clone only one branch, HEAD or --branch 
> --no-tags don't clone any tags, and make later fetches not to 
> follow them
> --shallow-submodules  any cloned submodules will be shallow   
> --separate-git-dir 
>   separate git dir from working tree  
> -c, --config 
>   set config inside the new repository
> --server-option 
>   option to transmit
> -4, --ipv4use IPv4 addresses only
> -6, --ipv6use IPv6 addresses only
> --filterobject filtering
> --remote-submodules   any cloned submodules will use their 
> remote-tracking branch
> --sparse  initialize sparse-checkout file to include only 
> files at root 
> 
>> On Sunday, 10 January 2021 at 20:20:02 UTC+5:30 Kasper Laudrup wrote:
>> On 09/01/2021 19.27, Sohail Tanveer wrote: 
>> > im facing difficulty to install pyenv-virtual env on my windows 10 
>> > i googled it several times but it directs me to a git repo where there 
>> > is an installation process but is of no use because, the command that is 
>> > displayed is not working in my cmd 
>> 
>> It would greatly improve your chances of getting some useful help if you 
>> clarify which git repo you are talking about, which command you are 
>> trying to using and what exactly you mean by "not working". 
>> 
>> Unless you want to leave that as an exercise for the reader. 
>> 
>> 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/86f2fc8d-a20f-4a94-bda6-81d1e4177fb8n%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 

Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Kasper Laudrup

On 10/01/2021 15.59, Kunal Solanke wrote:

Have a look at it. What do you think about pipenv Kasper?



I don't think I've ever had a need for it. Using the standard venv 
python module has been fine for my needs so far, but I'll keep it in 
mind. Thanks.


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/496c28b4-3145-742b-144e-4eec50b6d558%40stacktrace.dk.


Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Sohail Tanveer
i was actually going through a tutorial where i specifically needed 
pyenv-virtualenv. 
but thanks for ur consideration @gerardo.palazuelos

On Sunday, 10 January 2021 at 22:16:43 UTC+5:30 Gerardo Palazuelos wrote:

> Hi Sohail,
> I read your interest for pipenv in Windows. Seems are wasting precious 
> time and not productive because of this pipenv tool, which is not even the 
> point of Django.
>
> If that keeps resulting complicated, may I suggest you to use venv which 
> comes integrated in recent Python installation. You have to install nothing 
> else other than Python.
>
> I code Python in Windows using venv - no issues.
>
> In your desired folder, to create virtual environment:
> python -m venv the-name-of-my-virtual environment 
>
> Usually I do this (yes, I put a dot in name of my virtual environment):
> python -m venv .venv
>
> Then, using gitbash, to activate virtual environment in Windows (assuming 
> you are in same desired folder):
> . \.venv\Scripts\activate
>
> If not using gitbash, enter to folder .venv\Scripts and run activate - 
> it’s a .bat program 
>
> That should work.
> Regards,
>
> ---
> Gerardo
>
>
>
> El 10 ene 2021, a la(s) 9:28, Sohail Tanveer  
> escribió:
>
> the git repo to which google directs me is 
> https://github.com/pyenv/pyenv-virtualenv
>
> the command it wants me to execute in my cmd is   $ git clone 
> https://github.com/pyenv/pyenv-virtualenv.git $(pyenv 
> root)/plugins/pyenv-virtualenv 
> and whenever i execute this it shows an error like 
>
>
>
> fatal: Too many arguments.
>
> usage: git clone [] [--]  []
>
> -v, --verbose be more verbose
> -q, --quiet   be more quiet
> --progressforce progress reporting
> -n, --no-checkout don't create a checkout
> --barecreate a bare repository
> --mirror  create a mirror repository (implies bare)
> -l, --local   to clone from a local repository
> --no-hardlinksdon't use local hardlinks, always copy  
> -s, --shared  setup as shared repository
> --recurse-submodules[=]
>   initialize submodules in the clone  
> --recursive ...   alias of --recurse-submodules
> -j, --jobs number of submodules cloned in parallel 
> --template 
>   directory from which templates will be used
> --reference reference repository
> --reference-if-able 
>   reference repository
> --dissociate  use --reference only while cloning  
> -o, --originuse  instead of 'origin' to track 
> upstream
> -b, --branch 
>   checkout  instead of the remote's HEAD
> -u, --upload-pack 
>   path to git-upload-pack on the remote   
> --depthcreate a shallow clone of that depth
> --shallow-since 
>   create a shallow clone since a specific 
> time
> --shallow-exclude 
>   deepen history of shallow clone, excluding rev
> --single-branch   clone only one branch, HEAD or --branch 
> --no-tags don't clone any tags, and make later fetches not 
> to follow them
> --shallow-submodules  any cloned submodules will be shallow   
> --separate-git-dir 
>   separate git dir from working tree  
> -c, --config 
>   set config inside the new repository
> --server-option 
>   option to transmit
> -4, --ipv4use IPv4 addresses only
> -6, --ipv6use IPv6 addresses only
> --filterobject filtering
> --remote-submodules   any cloned submodules will use their 
> remote-tracking branch
> --sparse  initialize sparse-checkout file to include only 
> files at root 
>
> On Sunday, 10 January 2021 at 20:20:02 UTC+5:30 Kasper Laudrup wrote:
>
>> On 09/01/2021 19.27, Sohail Tanveer wrote: 
>> > im facing difficulty to install pyenv-virtual env on my windows 10 
>> > i googled it several times but it directs me to a git repo where there 
>> > is an installation process but is of no use because, the command that 
>> is 
>> > displayed is not working in my cmd 
>>
>> It would greatly improve your chances of getting some useful help if you 
>> clarify which git repo you are talking about, which command you are 
>> trying to using and what exactly you mean by "not working". 
>>
>> Unless you want to leave that as an exercise for the reader. 
>>
>> 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...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/86f2fc8d-a20f-4a94-bda6-81d1e4177fb8n%40

Re: how to install pyenv-virtualenv on windows

2021-01-10 Thread Kasper Laudrup

On 10/01/2021 17.27, Sohail Tanveer wrote:
the git repo to which google directs me 
is https://github.com/pyenv/pyenv-virtualenv


The first line of the readme says:

"pyenv-virtualenv is a pyenv plugin that provides features to manage 
virtualenvs and conda environments for Python on UNIX-like systems."


Windows is not a "UNIX-like system" so what made you think you could use 
that on Windows?


An ever better question is probably, what made you want to use 
pyenv-virtualenv on Windows in the first place?


There are probably better solutions as someone else has already 
commented, but it's probably easier for someone to help you if you let 
them know what you are trying to accomplish. I don't assume you're 
trying to port pyenv-virtualenv to Windows.



the command it wants me to execute in my cmd is $ git clone 
https://github.com/pyenv/pyenv-virtualenv.git $(pyenv 
root)/plugins/pyenv-virtualenv

and whenever i execute this it shows an error like



That's because that's a UNIX shell command, although I'm not sure if the 
$() syntax is standard. Anyway, that's not going to work in your DOS cmd 
shell and I doubt changing to a more sane command shell is going to help 
you.


So the short answer to your original question "how to install 
pyenv-virtualenv in Windows?" seems to be, "you don't".


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/eadc871e-0e7e-913f-fab4-e8cf9bdebab8%40stacktrace.dk.


django admin site password changed every time user's attributes are changed

2021-01-10 Thread Vishesh Mangla

https://dpaste.org/bN7d

Please see code at dpaste.

I 'm trying to modify my admin site so that the admin can create new 
accounts there. After clicking save , to whatever email address which the 
admin has entered an email would bbe sent with a random password. It works 
perfectly but when I try to change the users permission in the admin site, 
first of all the password's hash code is visible and the password gets 
substituted with that hash. 

Also why is the password string visible, shouldn't it be dots here?
https://ibb.co/zXjx0BW

Please help me out.

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


Re: ForeignKey with different queryset from manager

2021-01-10 Thread Peter of the Norse
This is an interesting question.  Thank you for asking it.

I wasn’t able to find exactly what you are asking for.  The closest I could 
find was 
https://docs.djangoproject.com/en/2.2/topics/db/queries/#using-a-custom-reverse-manager
 

 which needs to be invoked at the call.  So you you have to do. 

parent.member_set(manager=‘all_objects').all()

> On Dec 14, 2020, at 3:25 PM, Jimmy Gawain  wrote:
> 
> This is with Django v2.2.
> 
> We use tombstoning via a custom BaseModelManager to mark items as deleted in 
> the database but keep them around for reference.
> 
> class BaseModelManager(models.Manager):
> def __init__(self, *args, **kwargs):
> self.include_tombstoned = kwargs.pop('include_tombstoned',False)
> super(BaseModelManager, self).__init__(*args, **kwargs)
> 
> def get_queryset(self):
> if not self.include_tombstoned:
> return TombstonedQuerySet(self.model).filter(is_tombstoned=False)
> return TombstonedQuerySet(self.model)
> 
> class BaseModel(models.Model):
> def __init__(self, *args, **kwargs):
> super(BaseModel, self).__init__(*args, **kwargs)
> 
> # manager
> objects = BaseModelManager()
> all_objects = BaseModelManager(include_tombstoned=True)
> 
> This way models can reference Model.objects when they want undeleted items 
> and Model.all_objects when they want to included deleted items.
> 
> We now have a situation where we want a ForeignKey, which uses objects, to 
> use all_objects instead.
> 
> That is instead of this:
> 
> ref_member = models.ForeignKey(Member, related_name='+', null=True, 
> blank=True, on_delete=models.CASCADE)
> 
> Do something like this:
> 
> ref_member = models.ForeignKey(Member, queryset=Member.all_objects.all(), 
> related_name='+', null=True, blank=True, on_delete=models.CASCADE)
> 
> Is there any way to do the equivalent of this?
> 
> thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/4ee488b1-3489-430d-b917-70c157b35a92n%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/942B9218-D8BE-47B3-A0E2-789E39633A37%40gmail.com.


Re: How to securely store passwords used in backend code

2021-01-10 Thread Peter of the Norse
I use multiple settings.py files to do this.  Specifically, in my main one, I 
have what I consider the only acceptable instance of import *.

import os
if (os.getenv('PRODUCTION')):
from .prod_settings import *
else:
from .dev_settings import *

While dev_settings.py is in my repo, prod_settings.py is not. 

If there are settings that are used in different systems/programs, 
https://pypi.org/project/python-dotenv/ 
 looks like the best choice.  Like 
Pankaj Jangid using Docker, and wants the same values in two places.

> On Dec 14, 2020, at 9:03 PM, David Nugent  wrote:
> 
> 
> On 10 December 2020 at 01:18:16, Pankaj Jangid (pan...@codeisgreat.org 
> ) wrote:
> 
>> Fenrir Sivar mailto:fenrir.si...@gmail.com>> 
>> writes: 
>> 
>> > I inherited a django app that calls private APIs in a view to fetch some 
>> > data. The credentials or api keys are currently hardcoded in the source, 
>> > making it difficult to share. 
>> > What is the preferred way to store these kind of keys in a secure way only 
>> > accessible to the django server? 
>> 
>> As Kasper suggests, I also use environment variables in development 
>> environment. But a few more things add up to convenience. 
> 
> Not only convenience, but a very good idea. First and foremost, keep secrets 
> out of configuration even gitignore'd ones, with .env files being the 
> exception.
> 
> The environment is not a perfect place to store these but they are better 
> then placing them in code or configuration.
> 
> For more info and a very tried and tested approach, check out 
> https://12factor.net/ 
> 
>> 1. I use ‘direnv’ for managing per directory environment variables. As I 
>> enter a perticular directory (on terminal), it echos the newly set 
>> environment variables. 
> 
> Seconded ... and thirded!
> 
> If you use .env files you can even suck these in automatically, set your 
> virtualenv and any configuration information in your .envrc. It is a really 
> good approach especially so i you work on multiple projects and don't want to 
> clutter your .*profile or Windows global env.
> 
> 
> 
>> 2. It might be overkill but I use Docker on my development machine. And 
>> I use the same environment variables in my docker-compose.yml. This 
>> is also useful in production setup where you are deploying in Docker. 
>> 
> 
> I would argue that this is definitely NOT an overkill unless you're entirely 
> unfamiliar with container technology when it would become another burden in 
> the path to understanding.
> 
> Running your code in a container when it is to be deployed in production in a 
> container is very important to avoid pitfalls such as local dependencies of 
> all sorts. "it works here" but fails in production is definitely something 
> you want to avoid.  You can mount your development environment locally and 
> run the server within the container and all is good, although this does raise 
> some interesting challenges if you want to debug the server...
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAPvfA9A1zjp76qNf%2BN0QgacHuSzT0LQ246hFHoJCb7Bj1m1tYg%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/8367868B-70EC-47EF-A04B-702A48B23F63%40gmail.com.


Re: import *

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


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

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

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


Regards,

/d

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