Re: Populate a select dropdown based on queryset

2018-03-30 Thread Derek
You can use "smart selects":

https://github.com/digi604/django-smart-selects

Works for both normal forms and in the admin.


On Wednesday, 28 March 2018 23:02:36 UTC+2, James Farris wrote:
>
> Hi,
>
> I'm trying to populate a 'vaccine' dropdown based on a 'species' of a 
> pet.  For example, if a pet is a 'dog' I want to display vaccines for a dog 
> only.  If a pet is a cat, I want to display a list of vaccines for cats 
> only.
>
> How do I do this?  I googled, but didn't come up with anything solid.
>
> *Here is my models.py*
>
> class Pet(models.Model):
> user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
> name = models.CharField(max_length=100, null=True, db_index=True)
> species = models.CharField(choices=SPECIES_CHOICES, null=True, 
> max_length=20)
>
> def __str__(self):
> return self.name
>
>
> class Vaccine(models.Model):
> vacc_name = models.CharField(max_length=100)
> species = models.CharField(choices=SPECIES_CHOICES, null=True, 
> max_length=20)
> pet = models.ManyToManyField(Pet, through='PetHasVaccine')
>
> def __str__(self):
> return self.vacc_name
>
>
> class PetHasVaccine(models.Model):
> pet = models.ForeignKey(Pet, on_delete=models.DO_NOTHING)
> vaccine = models.ForeignKey(Vaccine, on_delete=models.DO_NOTHING)
>
> def __str__(self):
> return str(self.pet.name) + ' - ' + str(self.vaccine.vacc_name)
>
>
>
> *Here is my views.py*
>
>
> def add_vaccine(request, pet_pk):
> pet = Pet.objects.get(pk=pet_pk)
> if pet.user == request.user:
> form = VaccineForm(request.POST or None)
> if request.POST:
> if form.is_valid():
> return HttpResponse(form)
> else:
> return render(request, 'pet/vaccine_add.html', {'vacc_form': 
> VaccineForm(request.POST), 'pet': pet})
> else:
> return render(request, 'pet/vaccine_add.html', {'vacc_form': 
> form, 'pet': pet})
>
>
>
> *Here is my forms.py*
>
>
> class VaccineForm(ModelForm):
>
> class Meta:
> model = PetHasVaccine
> fields = '__all__'
> exclude = ('pet',)
> widgets = {
> 'date_given': DateInput(),
> 'date_due': DateInput(),
> }
>
>

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


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread Andréas Kühne
Hi,

I am sorry, but this doesn't really make sense. What do you mean by
decoupling the data?

Deploying to the cloud, will mean that you will need to setup a new
database for your project - there you will get a completly new database,
that won't be connected to your development data in any way.

You can then add system variables for the username and password for the
database - and thats about all you need?

Regards,

Andréas

2018-03-29 22:24 GMT+02:00 prince gosavi :

> Hi,
> I have made a django project and want to deploy it on cloud.
> Before that i want to decouple all the private information.
> I want to decouple the database info too, like the username password etc.
> Any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/4b09223d-d58f-4fda-b3f7-64b230960d94%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/CAK4qSCeZFiw9D7Sa213H_MkPgcH-aTQ3fk-j5HLjZdHK%2B5ps%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[django-channels] Which process sends message to all channels in a group during group_send?

2018-03-30 Thread krdeepak
Hi,

I was doing a deep dive in django channels and related projects, and plan 
to use it in my project along with contributing to it in the future.
I understood most of the details, but still not clear about one things.

During a group_send in channel_layer, which process is responsible for 
listening to this message and then broadcasting that message to all the 
channels in that group?
Which process is consuming messages in channel layer?

Seems I am missing some details on how redis implements pub-sub.

Thanks,
Kr Deepak

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


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
Hi,


Environment variables are the best option for not embedding sensitive 
information in files which have chances to be stored in places such as external 
source repositories (GitHub et al.).


If you are working with orchestrators such as Kubernetes, you can use the 
"secrets", which are specialized shared configuration data, stored in encrypted 
form. As shared configuration data, they bring the extra benefit over env vars 
of being manageable from a single central place, and then distributed to all 
the replicas and services which need them.


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Friday, March 30, 2018 11:08:52 AM
To: django-users@googlegroups.com
Subject: Re: Decoupling Postgres database credentials in django for deployment.

Hi,

I am sorry, but this doesn't really make sense. What do you mean by decoupling 
the data?

Deploying to the cloud, will mean that you will need to setup a new database 
for your project - there you will get a completly new database, that won't be 
connected to your development data in any way.

You can then add system variables for the username and password for the 
database - and thats about all you need?

Regards,

Andréas

2018-03-29 22:24 GMT+02:00 prince gosavi 
mailto:princegosav...@gmail.com>>:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is appreciated.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4b09223d-d58f-4fda-b3f7-64b230960d94%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/CAK4qSCeZFiw9D7Sa213H_MkPgcH-aTQ3fk-j5HLjZdHK%2B5ps%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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


How to make asynchronous ajax requests if the server side work takes plenty of time to finish?

2018-03-30 Thread Chasan KIOUTSOUKMOUSTAFA


I need advice or sample code to achieve a task related asynchronous ajax 
request that server side work takes plenty of time to finish its job.


Here is the sample scenario;

I've a simple CSV file upload form. User submits file

   - Server starts processing CSV file.
   - Server makes queries to external REST apis for each line of CSV file. 
   (additional network request/response delays)
   - Server parses each response (regex calculations, additional delays) 
   and stores data into database.
   - Server produces another output CSV file.

If the CSV file contains < 100 rows, it works even without using ajax. 
However I need to make it asynchronous to be able to feed a lot of rows. 
The critical part is I don't want to have timeouts as long as server side 
code is working. I want to be able to update client side regularly about 
the progress of work (log-like update, for example "x record is saved into 
database")

Can you provide me a working dummy sample code (for example, calculating 
fibonacci numbers) both client side and server side. (if possible django)

Thanks.

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/3d3a12f6-98dd-4084-a9e6-322b3b04332a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Version update for my project

2018-03-30 Thread Haroon Ahmed
Hi,

I want to update my Django version from Django 1.9.8 to Django 2.0.3 
because it is mentioned in the Django 1.9.8 official document that this 
version has security issues. 

https://docs.djangoproject.com/en/1.9/internals/release-process/#backwards-compatibility-policy
'This document is for an insecure version of Django that is no longer 
supported. Please upgrade to a newer release!'

This is my first time to upgrade Django version for my project.
I simply upgraded Django in my virtual environment to Django 2.0.3, now i 
am facing errors about url resolver etc. At the moment i haven't changed my 
code.

I have some questions in my mind:

   - Do we have to upgrade Django whenever the new Django version is 
   released?
   - At the moment if i am able to upgrade my Project with Django 2 and 
   after some time this version also  become insecure then i have to repeat 
   the Django version updates again?
   - Is there any blog written or any helpful materiel for me  that How to 
   upgrade Django Version so that my project comes in working state?

Any kind of help will be appreciated, 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/72b7acd8-f8a5-4c50-87b5-fb9b6e4c9e63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Updating Django for my web based application

2018-03-30 Thread Haroon Ahmed
Hi, 

Currently my application is developed with Django 1.9.8 and I want to 
upgrade it to 2.0.3 because 
Django 1.9.8 is an insecure version of django as mention on it official 
documentation.

https://docs.djangoproject.com/en/1.9/internals/release-process/#backwards-compatibility-policy

This document is for an insecure version of Django that is no longer 
supported. Please upgrade to a newer release!


Its my first time to update Django Version for my application,
I have updated the Dango 1.9.8 to Django 2.0.3 in my virtual environment.
I am using Python 3.4.4

I haven't changes any thing in the code yet and facing some error

\virtualEnv\DjangoUp\lib\site-packages\rest_framework\routers.py", line 23, 
in 
from django.core.urlresolvers import NoReverseMatch
ImportError: No module named 'django.core.urlresolvers'

Some question that are coming into my mind:

   - Do i have to update my application according to new Django release 
   every time when new Django version releases?
   - Is there any article or blog written that can help me to upgrade 
   Django version from Django 1.9.8 to Django 2.0.3?
   - What people follow, dose most of the developers upgrade there web 
   application according to new Django version release?

Any kind of help will be appreciated, 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/1162960f-46e4-4c24-9e36-df1d7edbb2eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting channels 2 to work

2018-03-30 Thread Luke Waltman
Hello Everyone,

I am still having an issue with Channels that was never really solved in an 
earlier Stackoverflow question...

Why does :

from channels.asgi import get_channel_layer

result in :

from channels.asgi import get_channel_layerImportError: No module named asgi

I am using Django (2.03), Channels (2.02) and Python(3.5.1) within a 
virtual environment.  I also installed asgi_redis.

-Luke

On Monday, December 4, 2017 at 11:11:14 AM UTC-6, Andrew Godwin wrote:
>
> Hi John,
>
> The ProtocolTypeRouter currently does this for you automatically as long 
> as you don't specify a `http` handler. Otherwise, the ASGI application that 
> runs Django's view system is channels.http.AsgiHandler
>
> Andrew
>
> On Mon, Dec 4, 2017 at 7:56 AM, John Wayne  > wrote:
>
>> Hi Andrew,
>>
>> first of all thanks for your reply. With your answer and the information 
>> from your blog I was able to get my asgi application running. 
>>
>> Now I want to route all http traffic to django's viewsystem back as i 
>> dont need channel's http handling. On your blog you posted this snippet
>>
>> application = ProtocolTypeRouter({
>> "http": URLRouter([
>> url("^", DjangoViewSystem),
>> ]),
>>
>> But how should the DjangoViewSystem class look like? There is no such 
>> file included.
>>
>>
>> John
>>
>> On Friday, December 1, 2017 at 6:22:06 PM UTC+1, Andrew Godwin wrote:
>>>
>>> Hi John,
>>>
>>> It's not in an end-user-useable state quite yet, so apologies for it 
>>> being hard to install. Crucially, the docs on ASGI_APPLICATION aren't 
>>> written yet as I'm still working on authentication stuff!
>>>
>>> A brief guide is:
>>>
>>>  - Make an asgi.py as specified in 
>>> http://channels.readthedocs.io/en/2.0/deploying.html
>>>  - Make a channels.routing.ProtocolTypeRouter in your project's 
>>> routing.py and configure this as needed (you'll have to read the code for 
>>> now)
>>>  - Point ASGI_APPLICATION to that root router.
>>>
>>> I'll have a lot more docs and stuff coming soon as I start prepping 
>>> Channels 2 for a beta release, which will include routing and setup 
>>> examples.
>>>
>>> Andrew
>>>
>>> On Fri, Dec 1, 2017 at 6:03 AM, John Wayne  wrote:
>>>
 Hi everyone,

 I am stuck getting the new channels 2 to a working state. I installed 
 django==2.0rc1,  and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from 
 the git repo
 channels is enabled inside the settings.py. I also created the asgi.py 
 file in the direcotry of the wsgi.py file acording to the docs. But still 
 i 
 get this error

 raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.")
 django.core.exceptions.ImproperlyConfigured: Cannot find 
 ASGI_APPLICATION setting.

 So it seems that ASGI_APPLICATION has to be specified. So after adding 
 the following line:
 ASGI_APPLICATION='mytestproject.asgi.application'
 and starting ./manage.py runserver it now complains again. So which 
 value is supposed to be there?

   raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION 
 module %s" % (name, path))
 django.core.exceptions.ImproperlyConfigured: Cannot find 'application' 
 in ASGI_APPLICATION module mytestproject.asgi

 I need to stick to version 2 as i want to try out asgigram (
 https://github.com/andrewgodwin/asgigram).

 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...@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/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%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...@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/22ceb8b4-e28e-4301-857a-3fffb211e5a9%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to th

Re: How to make asynchronous ajax requests if the server side work takes plenty of time to finish?

2018-03-30 Thread m1chael
I think a typical approach would be, using Django celery to process your
heavy workload in the background, and then when finished, notify the user
via email, text, or maybe have a periodic async ajax call check to see if
there are completed tasks not yet looked at

On Fri, Mar 30, 2018 at 12:53 AM, Chasan KIOUTSOUKMOUSTAFA <
chas...@gmail.com> wrote:

> I need advice or sample code to achieve a task related asynchronous ajax
> request that server side work takes plenty of time to finish its job.
>
>
> Here is the sample scenario;
>
> I've a simple CSV file upload form. User submits file
>
>- Server starts processing CSV file.
>- Server makes queries to external REST apis for each line of CSV
>file. (additional network request/response delays)
>- Server parses each response (regex calculations, additional delays)
>and stores data into database.
>- Server produces another output CSV file.
>
> If the CSV file contains < 100 rows, it works even without using ajax.
> However I need to make it asynchronous to be able to feed a lot of rows.
> The critical part is I don't want to have timeouts as long as server side
> code is working. I want to be able to update client side regularly about
> the progress of work (log-like update, for example "x record is saved into
> database")
>
> Can you provide me a working dummy sample code (for example, calculating
> fibonacci numbers) both client side and server side. (if possible django)
>
> Thanks.
>
> 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/3d3a12f6-98dd-4084-a9e6-322b3b04332a%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/CAAuoY6POU2dmNg8psGtFWCS2ehXx9xtuhuta32-KCa7v3h%3Du%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread Antonis Christofides
> Environment variables are the best option for not embedding sensitive
> information in files 
However some people (me that is :-) think that environment variables, though
widely used, are an ugly hack for this problem.


I explain the way I do it (TLDR; production settings must be stored in a
different "deployment" repository, preferably with any secrets encrypted) in
https://www.crowdcast.io/e/deploying-django, from 38m10s to 46m30s.


Regards,


Antonis

Antonis Christofides
http://djangodeployment.com


On 2018-03-30 13:06, PASCUAL Eric wrote:
>
> Hi,
>
>
> Environment variables are the best option for not embedding sensitive
> information in files which have chances to be stored in places such as
> external source repositories (GitHub et al.).
>
>
> If you are working with orchestrators such as Kubernetes, you can use the
> "secrets", which are specialized shared configuration data, stored in
> encrypted form. As shared configuration data, they bring the extra benefit
> over env vars of being manageable from a single central place, and then
> distributed to all the replicas and services which need them.
>
>
> Best regards
>
>
> Eric
>
> 
> *From:* django-users@googlegroups.com  on
> behalf of Andréas Kühne 
> *Sent:* Friday, March 30, 2018 11:08:52 AM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Decoupling Postgres database credentials in django for 
> deployment.
>  
> Hi, 
>
> I am sorry, but this doesn't really make sense. What do you mean by decoupling
> the data? 
>
> Deploying to the cloud, will mean that you will need to setup a new database
> for your project - there you will get a completly new database, that won't be
> connected to your development data in any way. 
>
> You can then add system variables for the username and password for the
> database - and thats about all you need?
>
> Regards,
>
> Andréas
>
> 2018-03-29 22:24 GMT+02:00 prince gosavi  >:
>
> Hi,
> I have made a django project and want to deploy it on cloud.
> Before that i want to decouple all the private information.
> I want to decouple the database info too, like the username password etc.
> Any help is appreciated.
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/django-users
> .
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/4b09223d-d58f-4fda-b3f7-64b230960d94%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/CAK4qSCeZFiw9D7Sa213H_MkPgcH-aTQ3fk-j5HLjZdHK%2B5ps%2BQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/DB7P193MB0331039E86ABAEFF1B794D898CA10%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
You rece

Re: Updating Django for my web based application

2018-03-30 Thread Jani Tiainen
Hi,

Standard procedure to update Django is to upgrade gradually all versions
from source version to target.

There is no single document to describe changes needed between versions
that are apart more than one release.

Only changelog you can find is at every release which contains changes from
previous release.

You can try to combine required changes to directly upgrade.

pe 30. maaliskuuta 2018 klo 14.07 Haroon Ahmed 
kirjoitti:

> Hi,
>
> Currently my application is developed with Django 1.9.8 and I want to
> upgrade it to 2.0.3 because
> Django 1.9.8 is an insecure version of django as mention on it official
> documentation.
>
>
> https://docs.djangoproject.com/en/1.9/internals/release-process/#backwards-compatibility-policy
>
> This document is for an insecure version of Django that is no longer
> supported. Please upgrade to a newer release!
>
>
> Its my first time to update Django Version for my application,
> I have updated the Dango 1.9.8 to Django 2.0.3 in my virtual environment.
> I am using Python 3.4.4
>
> I haven't changes any thing in the code yet and facing some error
>
> \virtualEnv\DjangoUp\lib\site-packages\rest_framework\routers.py", line
> 23, in 
> from django.core.urlresolvers import NoReverseMatch
> ImportError: No module named 'django.core.urlresolvers'
>
> Some question that are coming into my mind:
>
>- Do i have to update my application according to new Django release
>every time when new Django version releases?
>- Is there any article or blog written that can help me to upgrade
>Django version from Django 1.9.8 to Django 2.0.3?
>- What people follow, dose most of the developers upgrade there web
>application according to new Django version release?
>
> Any kind of help will be appreciated, 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/1162960f-46e4-4c24-9e36-df1d7edbb2eb%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/CAHn91oeRFX6N7cvUTL9jwLGQJOTV8dLxCUWKdicCiYbbqCUbtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


When deleting field in models admin form not updating.

2018-03-30 Thread Gerald Brown
I am using Django 2.0.3 and Python 3.6.  When I delete a field in the model 
file it is NOT being deleted in the admin form.  Any ideas on how I can 
delete the field on the admin form?

Thanks.

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


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
Env vars are considered bad in contexts where everything runs in the same... 
environment. And I too have considered them as hacks or as options to avoid by 
all means.


But times are changing, and nowadays there is a move towards containerized 
apps, even outside the cloud context. And we are no more now in the traditional 
initial hype phase, which means that the approach has proven its benefits (and 
also its constraints and maybe weaknesses). As an example of a real life work 
project, I've deployed a docker compose stack on RaspberryPi's for running an 
instrumentation system, to avoid having to install each and every component and 
manage the possible conflicts or interferences between them. It works 24/7 for 
months now without any hiccup. Containers really shine for relieving you from 
DLLs/shared libs/packages/... hell.


That being said, in such an architecture, each container is an isolated 
environment, and thus you can use env vars without fearing that someone else 
could tampered with them.


So perhaps the time is coming for considering env vars are no more the evil :) 
It depends on when and how you use them.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Antonis Christofides 
Sent: Friday, March 30, 2018 2:11:02 PM
To: django-users@googlegroups.com
Subject: Re: Decoupling Postgres database credentials in django for deployment.


Environment variables are the best option for not embedding sensitive 
information in files
However some people (me that is :-) think that environment variables, though 
widely used, are an ugly hack for this problem.


I explain the way I do it (TLDR; production settings must be stored in a 
different "deployment" repository, preferably with any secrets encrypted) in 
https://www.crowdcast.io/e/deploying-django, from 38m10s to 46m30s.


Regards,


Antonis

Antonis Christofides
http://djangodeployment.com

On 2018-03-30 13:06, PASCUAL Eric wrote:

Hi,


Environment variables are the best option for not embedding sensitive 
information in files which have chances to be stored in places such as external 
source repositories (GitHub et al.).


If you are working with orchestrators such as Kubernetes, you can use the 
"secrets", which are specialized shared configuration data, stored in encrypted 
form. As shared configuration data, they bring the extra benefit over env vars 
of being manageable from a single central place, and then distributed to all 
the replicas and services which need them.


Best regards


Eric


From: django-users@googlegroups.com 
 on behalf 
of Andréas Kühne 
Sent: Friday, March 30, 2018 11:08:52 AM
To: django-users@googlegroups.com
Subject: Re: Decoupling Postgres database credentials in django for deployment.

Hi,

I am sorry, but this doesn't really make sense. What do you mean by decoupling 
the data?

Deploying to the cloud, will mean that you will need to setup a new database 
for your project - there you will get a completly new database, that won't be 
connected to your development data in any way.

You can then add system variables for the username and password for the 
database - and thats about all you need?

Regards,

Andréas

2018-03-29 22:24 GMT+02:00 prince gosavi 
mailto:princegosav...@gmail.com>>:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is appreciated.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4b09223d-d58f-4fda-b3f7-64b230960d94%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.g

Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread Bill Torcaso

I have a concern about using environment variables to hold secret 
information, and an opinion about it.  

IF

DEBUG is enabled, and there is a 500 server internal error, and the default 
500 template is used to render the response, 


THEN

*all of your secret information is shown in the browser output*


Of course, DEBUG should never be enabled in production.  But a single human 
error might make it happen. 

I would prefer to trust Github security and long passwords than to think I 
am infallible about setting DEBUG. 

Note that this is certainly what happens when I run on a Vagrant VM, and I 
think it would be the same in a Docker-like container.




On Thursday, March 29, 2018 at 4:24:40 PM UTC-4, prince gosavi wrote:
>
> Hi,
> I have made a django project and want to deploy it on cloud.
> Before that i want to decouple all the private information.
> I want to decouple the database info too, like the username password etc.
> Any help is appreciated.
>

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


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
You're perfectly right about the "500 Error + DEBUG" case.


One solution is to set DEBUG to off by default, and turn it on by code in the 
setting module if detecting  that the app is executing in a dev or Q&A 
environment. Depending on your context, this can be done with rules based on 
the host name or some other properties of the target systems.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Bill Torcaso 
Sent: Friday, March 30, 2018 4:50:02 PM
To: Django users
Subject: Re: Decoupling Postgres database credentials in django for deployment.


I have a concern about using environment variables to hold secret information, 
and an opinion about it.

IF

DEBUG is enabled, and there is a 500 server internal error, and the default 500 
template is used to render the response,

THEN

all of your secret information is shown in the browser output

Of course, DEBUG should never be enabled in production.  But a single human 
error might make it happen.

I would prefer to trust Github security and long passwords than to think I am 
infallible about setting DEBUG.

Note that this is certainly what happens when I run on a Vagrant VM, and I 
think it would be the same in a Docker-like container.




On Thursday, March 29, 2018 at 4:24:40 PM UTC-4, prince gosavi wrote:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is appreciated.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f5a1498a-3383-4219-b10e-e3e64f164658%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/DB7P193MB03311541D366207EF76069C28CA10%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread Phang Mulianto
I agree to set debug to false in your production configuration file. Never
debug on production setup.

If need enable debug on, use in staging environment or with different
django configuration files.



On Fri, 30 Mar 2018 23:52 PASCUAL Eric,  wrote:

> You're perfectly right about the "500 Error + DEBUG" case.
>
>
> One solution is to set DEBUG to off by default, and turn it on by code in
> the setting module if detecting  that the app is executing in a dev or Q&A
> environment. Depending on your context, this can be done with rules based
> on the host name or some other properties of the target systems.
>
>
> Best
>
>
> Eric
>
> --
> *From:* django-users@googlegroups.com  on
> behalf of Bill Torcaso 
> *Sent:* Friday, March 30, 2018 4:50:02 PM
> *To:* Django users
> *Subject:* Re: Decoupling Postgres database credentials in django for
> deployment.
>
>
> I have a concern about using environment variables to hold secret
> information, and an opinion about it.
>
> IF
>
> DEBUG is enabled, and there is a 500 server internal error, and the
> default 500 template is used to render the response,
>
>
> THEN
>
> *all of your secret information is shown in the browser output*
>
>
> Of course, DEBUG should never be enabled in production.  But a single
> human error might make it happen.
>
> I would prefer to trust Github security and long passwords than to think I
> am infallible about setting DEBUG.
>
> Note that this is certainly what happens when I run on a Vagrant VM, and I
> think it would be the same in a Docker-like container.
>
>
>
>
> On Thursday, March 29, 2018 at 4:24:40 PM UTC-4, prince gosavi wrote:
>
> Hi,
> I have made a django project and want to deploy it on cloud.
> Before that i want to decouple all the private information.
> I want to decouple the database info too, like the username password etc.
> Any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f5a1498a-3383-4219-b10e-e3e64f164658%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/DB7P193MB03311541D366207EF76069C28CA10%40DB7P193MB0331.EURP193.PROD.OUTLOOK.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/CA%2BSr5mTee6UdLUqXUnr8Pz1HNp5YTL%2BMME3-gjp_Mc-Q2CNJNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting channels 2 to work

2018-03-30 Thread Andrew Godwin
That code would be for Channels 1. Channels 2 is an entirely different
import set - make sure you are using tutorials or answers specifically for
2.

Andrew

On Thu, Mar 29, 2018 at 4:52 PM, Luke Waltman  wrote:

> Hello Everyone,
>
> I am still having an issue with Channels that was never really solved in
> an earlier Stackoverflow question...
>
> Why does :
>
> from channels.asgi import get_channel_layer
>
> result in :
>
> from channels.asgi import get_channel_layerImportError: No module named asgi
>
> I am using Django (2.03), Channels (2.02) and Python(3.5.1) within a
> virtual environment.  I also installed asgi_redis.
>
> -Luke
>
> On Monday, December 4, 2017 at 11:11:14 AM UTC-6, Andrew Godwin wrote:
>>
>> Hi John,
>>
>> The ProtocolTypeRouter currently does this for you automatically as long
>> as you don't specify a `http` handler. Otherwise, the ASGI application that
>> runs Django's view system is channels.http.AsgiHandler
>>
>> Andrew
>>
>> On Mon, Dec 4, 2017 at 7:56 AM, John Wayne  wrote:
>>
>>> Hi Andrew,
>>>
>>> first of all thanks for your reply. With your answer and the information
>>> from your blog I was able to get my asgi application running.
>>>
>>> Now I want to route all http traffic to django's viewsystem back as i
>>> dont need channel's http handling. On your blog you posted this snippet
>>>
>>> application = ProtocolTypeRouter({
>>> "http": URLRouter([
>>> url("^", DjangoViewSystem),
>>> ]),
>>>
>>> But how should the DjangoViewSystem class look like? There is no such
>>> file included.
>>>
>>>
>>> John
>>>
>>> On Friday, December 1, 2017 at 6:22:06 PM UTC+1, Andrew Godwin wrote:

 Hi John,

 It's not in an end-user-useable state quite yet, so apologies for it
 being hard to install. Crucially, the docs on ASGI_APPLICATION aren't
 written yet as I'm still working on authentication stuff!

 A brief guide is:

  - Make an asgi.py as specified in http://channels.readthedocs
 .io/en/2.0/deploying.html
  - Make a channels.routing.ProtocolTypeRouter in your project's
 routing.py and configure this as needed (you'll have to read the code for
 now)
  - Point ASGI_APPLICATION to that root router.

 I'll have a lot more docs and stuff coming soon as I start prepping
 Channels 2 for a beta release, which will include routing and setup
 examples.

 Andrew

 On Fri, Dec 1, 2017 at 6:03 AM, John Wayne  wrote:

> Hi everyone,
>
> I am stuck getting the new channels 2 to a working state. I installed
> django==2.0rc1,  and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from
> the git repo
> channels is enabled inside the settings.py. I also created the asgi.py
> file in the direcotry of the wsgi.py file acording to the docs. But still 
> i
> get this error
>
> raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.")
> django.core.exceptions.ImproperlyConfigured: Cannot find
> ASGI_APPLICATION setting.
>
> So it seems that ASGI_APPLICATION has to be specified. So after adding
> the following line:
> ASGI_APPLICATION='mytestproject.asgi.application'
> and starting ./manage.py runserver it now complains again. So which
> value is supposed to be there?
>
>   raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION
> module %s" % (name, path))
> django.core.exceptions.ImproperlyConfigured: Cannot find
> 'application' in ASGI_APPLICATION module mytestproject.asgi
>
> I need to stick to version 2 as i want to try out asgigram (
> https://github.com/andrewgodwin/asgigram).
>
> 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...@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/3c426628-13da
> -4ad3-8e4c-3e8938ab0c8d%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...@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/ms
>>> gid/django-users/22ceb8b4-e28e-4301-857a-3fffb211

Re: [django-channels] Which process sends message to all channels in a group during group_send?

2018-03-30 Thread Andrew Godwin
When you do a group send, the message doing the sending fans out the send
to all the target channels (currently using individual commands, and soon
with a Lua script inside Redis). We're not using redis pub-sub - we use
lists instead.

Andrew

On Fri, Mar 30, 2018 at 2:26 AM, krdeepak  wrote:

> Hi,
>
> I was doing a deep dive in django channels and related projects, and plan
> to use it in my project along with contributing to it in the future.
> I understood most of the details, but still not clear about one things.
>
> During a group_send in channel_layer, which process is responsible for
> listening to this message and then broadcasting that message to all the
> channels in that group?
> Which process is consuming messages in channel layer?
>
> Seems I am missing some details on how redis implements pub-sub.
>
> Thanks,
> Kr Deepak
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d8018f8e-614e-4456-b534-b8bb17d5bf3f%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/CAFwN1uqDa0e5SfMtW_4EXKbJ9y82ubA_Ym7dZ5HgvSkMXaw12g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: When deleting field in models admin form not updating.

2018-03-30 Thread Andrew Korir
have you tried to run migrations on that particular app in your django
project

python manage.py makemigrations app_name

python manage.py migrate app_name

On Fri, Mar 30, 2018 at 4:27 PM, Gerald Brown  wrote:

> I am using Django 2.0.3 and Python 3.6.  When I delete a field in the
> model file it is NOT being deleted in the admin form.  Any ideas on how I
> can delete the field on the admin form?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/3274bd21-77ec-4778-9af5-89c4c0daa12f%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/CAGG8WjLKRwMtHu%3DD2O5G8gQYtwjZS7AMMxr1kdvqA9dEvkB46w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filtering Queryset by Foreign Key Properties

2018-03-30 Thread Jamaldin Pro

>
> class ProductType(models.Model):
> class Meta:
> verbose_name_plural = 'тип'
> verbose_name = 'типы'
>
> image = models.ImageField(upload_to='products_type_images/')
> name = models.CharField(max_length=20, blank=True, null=True, 
> default=None)
> is_active = models.BooleanField(default=True)
>
> def __str__(self):
> return "%s" % self.name
>
>
> class Product(models.Model):
> class Meta:
> verbose_name_plural = 'запчасть'
> verbose_name = 'запчасти'
>
> name = models.CharField(max_length=20)
> price = models.DecimalField(max_digits=10, decimal_places=2, default=0)
> short_description = models.TextField(blank=True, null=True, default=None, 
> max_length=100)
> description = models.TextField(blank=True, null=True, default=None)
> is_active = models.BooleanField(default=True)
> type = models.ForeignKey(ProductType, blank=True, null=True, default=None)
>
> def __str__(self):
> return "(%s, %s)" % (self.id, self.name)
>
>
> class ProductImage(models.Model):
> class Meta:
> verbose_name_plural = 'фотография_запчасти'
> verbose_name = 'фотографии_запчасти'
>
> product = models.ForeignKey(Product, blank=True, null=True, default=None)
> image = models.ImageField(upload_to='products_images/')
> is_main = models.BooleanField(default=False)
> is_active = models.BooleanField(default=True)
> created = models.DateTimeField(default=timezone.now)
>
> def category(request, category_name):
# products_images_list = get_object_or_404(Product, id=category_name)
query = request.GET.get("q")
if query:

products_images_list = ProductImage.objects.filter(
product__type__name__contains=query) 


But in my template this is not working I want to filter my product's types. 
Can you help my? Django 1.11

Thank you.
 

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


How to make a custom login() using Django login() method?

2018-03-30 Thread Susan Tan
Hi Django Users,

This is my first-time post.

I want to return my own SusanTemplateResponse class in
https://github.com/django/django/blob/stable/1.10.x/django/contrib/auth/views.py#L98
 

instead of the default Django "TemplateResponse" that gets returned. What 
is a good way
to do that? 

SusanTemplateResponse is my version of django.template.repsonseimport 
TemplateResponse.

I'm using Django 1.10.

Susan Tan

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


Re: [django-channels] Which process sends message to all channels in a group during group_send?

2018-03-30 Thread kumar deepak
Thanks Andrew. I looked at the code and was able to figure out how it is
being done (including the comment to use lua scripts in the future).
The deep dive into codebase keeps getting deeper (channels, channels_redis,
aioredis, asgiref, twisted, asyncio ...).

I am building a chat based game using channels and hopefully will submit it
to official examples.
Contributing will take more time and effort I guess, so I will get back
once I am ready.

Thanks for the great work.

Kr Deepak


On Fri, Mar 30, 2018 at 10:21 PM, Andrew Godwin  wrote:

> When you do a group send, the message doing the sending fans out the send
> to all the target channels (currently using individual commands, and soon
> with a Lua script inside Redis). We're not using redis pub-sub - we use
> lists instead.
>
> Andrew
>
> On Fri, Mar 30, 2018 at 2:26 AM, krdeepak  wrote:
>
>> Hi,
>>
>> I was doing a deep dive in django channels and related projects, and plan
>> to use it in my project along with contributing to it in the future.
>> I understood most of the details, but still not clear about one things.
>>
>> During a group_send in channel_layer, which process is responsible for
>> listening to this message and then broadcasting that message to all the
>> channels in that group?
>> Which process is consuming messages in channel layer?
>>
>> Seems I am missing some details on how redis implements pub-sub.
>>
>> Thanks,
>> Kr Deepak
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/d8018f8e-614e-4456-b534-b8bb17d5bf3f%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/MnOAGlEpbGc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAFwN1uqDa0e5SfMtW_4EXKbJ9y82ubA_
> Ym7dZ5HgvSkMXaw12g%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Populate a select dropdown based on queryset

2018-03-30 Thread James Farris
Thank you Derek! I will definitely look into it. 

-James

> On Mar 30, 2018, at 12:08 AM, Derek  wrote:
> 
> You can use "smart selects":
> 
> https://github.com/digi604/django-smart-selects
> 
> Works for both normal forms and in the admin.
> 
> 
>> On Wednesday, 28 March 2018 23:02:36 UTC+2, James Farris wrote:
>> Hi,
>> 
>> I'm trying to populate a 'vaccine' dropdown based on a 'species' of a pet.  
>> For example, if a pet is a 'dog' I want to display vaccines for a dog only.  
>> If a pet is a cat, I want to display a list of vaccines for cats only.
>> 
>> How do I do this?  I googled, but didn't come up with anything solid.
>> 
>> Here is my models.py
>> 
>> class Pet(models.Model):
>> user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
>> name = models.CharField(max_length=100, null=True, db_index=True)
>> species = models.CharField(choices=SPECIES_CHOICES, null=True, 
>> max_length=20)
>> 
>> def __str__(self):
>> return self.name
>> 
>> 
>> class Vaccine(models.Model):
>> vacc_name = models.CharField(max_length=100)
>> species = models.CharField(choices=SPECIES_CHOICES, null=True, 
>> max_length=20)
>> pet = models.ManyToManyField(Pet, through='PetHasVaccine')
>> 
>> def __str__(self):
>> return self.vacc_name
>> 
>> 
>> class PetHasVaccine(models.Model):
>> pet = models.ForeignKey(Pet, on_delete=models.DO_NOTHING)
>> vaccine = models.ForeignKey(Vaccine, on_delete=models.DO_NOTHING)
>> 
>> def __str__(self):
>> return str(self.pet.name) + ' - ' + str(self.vaccine.vacc_name)
>> 
>> 
>> Here is my views.py
>> 
>> def add_vaccine(request, pet_pk):
>> pet = Pet.objects.get(pk=pet_pk)
>> if pet.user == request.user:
>> form = VaccineForm(request.POST or None)
>> if request.POST:
>> if form.is_valid():
>> return HttpResponse(form)
>> else:
>> return render(request, 'pet/vaccine_add.html', {'vacc_form': 
>> VaccineForm(request.POST), 'pet': pet})
>> else:
>> return render(request, 'pet/vaccine_add.html', {'vacc_form': 
>> form, 'pet': pet})
>> 
>> 
>> Here is my forms.py
>> 
>> class VaccineForm(ModelForm):
>> 
>> class Meta:
>> model = PetHasVaccine
>> fields = '__all__'
>> exclude = ('pet',)
>> widgets = {
>> 'date_given': DateInput(),
>> 'date_due': DateInput(),
>> }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/172ae5f3-df10-4bf2-acdc-390dea7edc49%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/BFA9FBCE-77D8-45DE-81B7-7CA527AD09A5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.