Friday, September 30, 2016

Re: Django not saving form in DB from frontend

Ludovic I did what you told and that was reason it was not validating.
Thanks

On Fri, Sep 30, 2016 at 9:53 PM, Ali khan <alipathan123123@gmail.com> wrote:
Thanks Mudassar,

Its working now.



On Fri, Sep 30, 2016 at 8:42 PM, M Hashmi <mhashmi1979@gmail.com> wrote:
Please change

def contact_form(request):
        template = 'contact.html'
        if request.method == 'POST':
               form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     new_form = form
                     new_form.save(commit=True)
                     

                return redirect('/')
           else:
                  form = ContactForm
            return render(request, template, context={"form":form})

To
def contact_form(request):
        template = 'contact.html'
        form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     form.save()
               else:
                      do something here
               return render(request, template, context={"form":form})

You are saving a form but calling back variable that holds unsaved version of the form.

Regards,
Mudassar



On Thu, Sep 29, 2016 at 2:18 PM, ludovic coues <couesl@gmail.com> wrote:
I would try to replace

    if form.is_valid():
        new_form = form
        new_form.save(commit=True)

with :

    if form.is_valid():
        print("Form is valid")
        form.save(commit=True)
    else:
        print("Invalid form")


Pretty sure you will get an invalid form, due to a missing field
send_quote field. For the form to send the file, you need to add an
enctype=multipart or something related.

2016-09-29 21:06 GMT+02:00 Ali khan <alipathan123123@gmail.com>:
> Appologies. In my view after else clause its ContactForm.
>
> On Thu, Sep 29, 2016 at 11:52 AM, Ali khan <alipathan123123@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I am newbie so I must be doing some stupid mistake here.
>>
>> I am trying to save a contact form with ModelForm. But its not saving in
>> DB from the frontend form.
>>
>> model.py
>>
>> class Contact(models.Model):
>>      name = models.CharField(max_length=100, null=True, blank=True)
>>      email = models.EmailField()
>>      send_quote = models.FileField(upload_to='/contacts')
>>
>>       def __unicode__(self)
>>            return self.name
>>
>> forms.py
>>
>> from .models import Contact
>> from djagno import forms
>> from django.forms import ModelForm
>>
>> class ContactForm(forms.ModelForm):
>>         class Meta:
>>                     model = Contact
>>                     fields = ['name', 'email', 'send_quote']
>>
>> views.py:
>>
>> from Django.shortcuts import render, redirect
>> from .forms import ContactForm
>>
>> def contact_form(request):
>>         template = 'contact.html'
>>         if request.method == 'POST':
>>                form = ContactForm(request.POST or None, request.Files or
>> None)
>>                if form.is_valid():
>>                      new_form = form
>>                      new_form.save(commit=True)
>>
>>
>>                 return redirect('/')
>>            else:
>>                   form = RFPForm
>>             return render(request, template, context={"form":form})
>>
>>
>> contact.html:
>>
>> <form action=" " method="POST">
>> {% csrf_token %}
>> {{ form }}
>> <input type='submit' class='btn btn-danger' value='Send' />
>> </form>
>>
>> Please advise.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAXvsYkTe_LU03ErF%3Dz%3DbNfM3LapOsyQywzKxUP3tm5pxHh28Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaKjumkUsT_6Y4WVKkZqtG%3DyPE6G6bazDJu39WewtaZrA%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANoUts5%3D%3DkVbJxgCf2MqjjQXkEhNqimzQfn2bJ7Vn%3D_k%3Divqyg%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAXvsY%3DQSNxQf9J2%3DykJsk%3DqhbudnURX%3D_Judy5QxtjTKpev2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django not saving form in DB from frontend

Thanks Mudassar,

Its working now.



On Fri, Sep 30, 2016 at 8:42 PM, M Hashmi <mhashmi1979@gmail.com> wrote:
Please change

def contact_form(request):
        template = 'contact.html'
        if request.method == 'POST':
               form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     new_form = form
                     new_form.save(commit=True)
                     

                return redirect('/')
           else:
                  form = ContactForm
            return render(request, template, context={"form":form})

To
def contact_form(request):
        template = 'contact.html'
        form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     form.save()
               else:
                      do something here
               return render(request, template, context={"form":form})

You are saving a form but calling back variable that holds unsaved version of the form.

Regards,
Mudassar



On Thu, Sep 29, 2016 at 2:18 PM, ludovic coues <couesl@gmail.com> wrote:
I would try to replace

    if form.is_valid():
        new_form = form
        new_form.save(commit=True)

with :

    if form.is_valid():
        print("Form is valid")
        form.save(commit=True)
    else:
        print("Invalid form")


Pretty sure you will get an invalid form, due to a missing field
send_quote field. For the form to send the file, you need to add an
enctype=multipart or something related.

2016-09-29 21:06 GMT+02:00 Ali khan <alipathan123123@gmail.com>:
> Appologies. In my view after else clause its ContactForm.
>
> On Thu, Sep 29, 2016 at 11:52 AM, Ali khan <alipathan123123@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I am newbie so I must be doing some stupid mistake here.
>>
>> I am trying to save a contact form with ModelForm. But its not saving in
>> DB from the frontend form.
>>
>> model.py
>>
>> class Contact(models.Model):
>>      name = models.CharField(max_length=100, null=True, blank=True)
>>      email = models.EmailField()
>>      send_quote = models.FileField(upload_to='/contacts')
>>
>>       def __unicode__(self)
>>            return self.name
>>
>> forms.py
>>
>> from .models import Contact
>> from djagno import forms
>> from django.forms import ModelForm
>>
>> class ContactForm(forms.ModelForm):
>>         class Meta:
>>                     model = Contact
>>                     fields = ['name', 'email', 'send_quote']
>>
>> views.py:
>>
>> from Django.shortcuts import render, redirect
>> from .forms import ContactForm
>>
>> def contact_form(request):
>>         template = 'contact.html'
>>         if request.method == 'POST':
>>                form = ContactForm(request.POST or None, request.Files or
>> None)
>>                if form.is_valid():
>>                      new_form = form
>>                      new_form.save(commit=True)
>>
>>
>>                 return redirect('/')
>>            else:
>>                   form = RFPForm
>>             return render(request, template, context={"form":form})
>>
>>
>> contact.html:
>>
>> <form action=" " method="POST">
>> {% csrf_token %}
>> {{ form }}
>> <input type='submit' class='btn btn-danger' value='Send' />
>> </form>
>>
>> Please advise.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAXvsYkTe_LU03ErF%3Dz%3DbNfM3LapOsyQywzKxUP3tm5pxHh28Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaKjumkUsT_6Y4WVKkZqtG%3DyPE6G6bazDJu39WewtaZrA%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANoUts5%3D%3DkVbJxgCf2MqjjQXkEhNqimzQfn2bJ7Vn%3D_k%3Divqyg%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAXvsY%3DLZO1dX%2BDhTGaZ9hkW5SpwpEC5Y43YDeSQTS20bS56Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django not saving form in DB from frontend

Please change

def contact_form(request):
        template = 'contact.html'
        if request.method == 'POST':
               form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     new_form = form
                     new_form.save(commit=True)
                     

                return redirect('/')
           else:
                  form = ContactForm
            return render(request, template, context={"form":form})

To
def contact_form(request):
        template = 'contact.html'
        form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     form.save()
               else:
                      do something here
               return render(request, template, context={"form":form})

You are saving a form but calling back variable that holds unsaved version of the form.

Regards,
Mudassar



On Thu, Sep 29, 2016 at 2:18 PM, ludovic coues <couesl@gmail.com> wrote:
I would try to replace

    if form.is_valid():
        new_form = form
        new_form.save(commit=True)

with :

    if form.is_valid():
        print("Form is valid")
        form.save(commit=True)
    else:
        print("Invalid form")


Pretty sure you will get an invalid form, due to a missing field
send_quote field. For the form to send the file, you need to add an
enctype=multipart or something related.

2016-09-29 21:06 GMT+02:00 Ali khan <alipathan123123@gmail.com>:
> Appologies. In my view after else clause its ContactForm.
>
> On Thu, Sep 29, 2016 at 11:52 AM, Ali khan <alipathan123123@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I am newbie so I must be doing some stupid mistake here.
>>
>> I am trying to save a contact form with ModelForm. But its not saving in
>> DB from the frontend form.
>>
>> model.py
>>
>> class Contact(models.Model):
>>      name = models.CharField(max_length=100, null=True, blank=True)
>>      email = models.EmailField()
>>      send_quote = models.FileField(upload_to='/contacts')
>>
>>       def __unicode__(self)
>>            return self.name
>>
>> forms.py
>>
>> from .models import Contact
>> from djagno import forms
>> from django.forms import ModelForm
>>
>> class ContactForm(forms.ModelForm):
>>         class Meta:
>>                     model = Contact
>>                     fields = ['name', 'email', 'send_quote']
>>
>> views.py:
>>
>> from Django.shortcuts import render, redirect
>> from .forms import ContactForm
>>
>> def contact_form(request):
>>         template = 'contact.html'
>>         if request.method == 'POST':
>>                form = ContactForm(request.POST or None, request.Files or
>> None)
>>                if form.is_valid():
>>                      new_form = form
>>                      new_form.save(commit=True)
>>
>>
>>                 return redirect('/')
>>            else:
>>                   form = RFPForm
>>             return render(request, template, context={"form":form})
>>
>>
>> contact.html:
>>
>> <form action=" " method="POST">
>> {% csrf_token %}
>> {{ form }}
>> <input type='submit' class='btn btn-danger' value='Send' />
>> </form>
>>
>> Please advise.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAXvsYkTe_LU03ErF%3Dz%3DbNfM3LapOsyQywzKxUP3tm5pxHh28Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaKjumkUsT_6Y4WVKkZqtG%3DyPE6G6bazDJu39WewtaZrA%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANoUts5%3D%3DkVbJxgCf2MqjjQXkEhNqimzQfn2bJ7Vn%3D_k%3Divqyg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django software docs

Are you looking for something like
https://d3js.org/ ?

Or something like blender with django ?

El lunes, 26 de septiembre de 2016, Jani Tiainen <redetin@gmail.com> escribió:
> Hi,
>
> What you expect Django to do for you?
>
> Django has been successfully used to write great variety of webapps like e-commerce, blogs, cms etc.
>
> So you have to be a bit more spesific what you're looking for.
>
> On 26.09.2016 18:14, Dave Baas wrote:
>
> All,
> Can anyone point me to some software documentation, (I work with 3D visualization software) that utilizes Django?
> Manuals, tutorials, video links and such?
> thanks / Dave
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1bb770a-3b6e-4be2-806f-0e01302d3c7b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> Jani Tiainen
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/024af0bd-bab9-3bb0-8732-cd158965051e%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
"La utopía sirve para caminar" Fernando Birri



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

Re: [Help] Advanced tutorial: How to install my Python package with Virtualenv

You need to create a setup.py file (see setuptools doc) it's a simple file find examples. Then do

python setup.py sdist

This will create dist file then surft to the .tar.gz file

pip install -u django-poll.tar.gz

Or you also can do

python setup.py install



El martes, 27 de septiembre de 2016, Aline C. R. Souza <linecrsouza@gmail.com> escribió:
> Hi everybody,
> Pip was working, but I did not know how to use it. Now, I figured out. 
> Inside the project directory: 
>
> pip install ../django-polls/dist/django-polls-0.1.zip
> Worked fine, the app is running.
> Thank you, guys.
>
> Em terça-feira, 27 de setembro de 2016 08:21:54 UTC-3, Aline C. R. Souza escreveu:
>>
>> Hello Guys,
>> I need some help to install my Python package with virtualenv. I follow the 'Advanced tutorial: How to write reusable apps' and moved the polls directory out of the project. Now I want to install my package using virtualenv and pip, but I don't know how.
>> Consider I am inside of my project diretory (where the manage.py is) and I am working on a virtual environment. What would be the right pip command to install my package, considering that the polls directory is out of the project.
>> Please help!
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66dc1093-dced-4d3b-8a34-3e1c250fbee0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
"La utopía sirve para caminar" Fernando Birri



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

Re: Visiting one Django server logs me out of another Django server, both behind the same proxy

Thanks again. I set a different session cookie name for S1 and it seems to have worked.

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

Subscribe / unsubscribe to data streams over websocket channel

Hello!

 Channels + databinding is a great way to push updates to clients of an API. I'm wondering however if there are any good examples of the client being able to subscribe and unsubscribe to streams of data over an existing websocket/channel pair (while making use of databinding)

 For example, github.com will send a message like this from the client to the server when it wants to get a particular data stream over the websocket:

subscribe:tenant:1:repo:51179261:branch:master

 I'd like to provide this kind of protocol to my clients. I think it may have to go into a custom consumer, but any examples / insights into this pattern would be greatly appreciated.

Ian

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

Re: download file when debug=false

Hi Richard,

There are a lot of options of how to change/switch application behaviour.
It depends on what you eventually need to get.

Mentioned solution: settings.DEBUG = true/false can be one of them

Hope it helps.

Regards,
Constantine C.

On Sep 30, 2016, at 12:06, Richard Auscard <richardauscard@gmail.com> wrote:

hello,

i have developp a django application where excel file are generate after some operation. when debug=true thes excel files can be download but when false it is not possible.
my question is how to solve this issus.

all think are ok when debug=true

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

Re: Upgrading a django 1.2 Alpha site to 1.10 final site, passwords don't work

Django 1.10 can still support SHA1, but it's not enabled by default. Please read https://docs.djangoproject.com/en/dev/releases/1.10/#removed-weak-password-hashers-from-the-default-password-hashers-setting and https://docs.djangoproject.com/en/stable/topics/auth/passwords/.

On Friday, September 30, 2016 at 11:18:36 AM UTC-4, Evan Roberts wrote:
Hello All,

I'm new to django and python.  A project that was last maintained in 2009 was bestowed upon me because the underlying OS is approaching end-of-life.

I've read the first few chapters the Django book and the first 10 chapters of Django Unleashed.  I've got the project and supporting libraries brought up to the python 3.5.0 and django 1.10.
My current hurdle is the user's passwords are stored using SHA1 hashing.  I ***think*** django 1.10 no longer supports the sha1 hashing algorithm. 

Is there a way to allow the users to login (using SHA1 to validate the password) and then force them to change their passwords (storing them using new hash)? 

Best Regards,

Evan R.


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

Re: How to setup django 1.9 with mongodb

Django's ORM doesn't support mongodb or any non-relational database
(read SQL only). So you set it up like any django, but you don't use
the models

2016-09-30 11:37 GMT+02:00 danang geek <dananggeek@gmail.com>:
> hai Man How to setup django 1.9 with mongodb
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d42f85c3-2dfc-4d18-9fc3-c72bf9a355b5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

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

Upgrading a django 1.2 Alpha site to 1.10 final site, passwords don't work

Hello All,

I'm new to django and python.  A project that was last maintained in 2009 was bestowed upon me because the underlying OS is approaching end-of-life.

I've read the first few chapters the Django book and the first 10 chapters of Django Unleashed.  I've got the project and supporting libraries brought up to the python 3.5.0 and django 1.10.
My current hurdle is the user's passwords are stored using SHA1 hashing.  I ***think*** django 1.10 no longer supports the sha1 hashing algorithm. 

Is there a way to allow the users to login (using SHA1 to validate the password) and then force them to change their passwords (storing them using new hash)? 

Best Regards,

Evan R.


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

Re: Visiting one Django server logs me out of another Django server, both behind the same proxy

Hi Mike,

On Fri, Sep 30, 2016 at 06:00:30AM -0700, Stodge wrote:
> Thanks Michal,
>
> The two servers are on the same domain and use different databases. At the
> moment I'm using the default Django session backend.
>
> It's an experiment, nothing more really. I just wanted to see if I could
> make it work. I haven't really worked out the flow, but it's probably
> something like:
>
> - admin creates user account on A1, auto replicates it to S1
> - user U1 visits S1, not logged in
> - U1 redirected to A1 to generate auth token, not logged in
> - U1 logs into A1
> - U1 redirected back to S1 to accept authentication
> - S1 logs U1 in, creates session as normal
>
> So the user is logged into both. It's a fairly naive attempt at reinventing
> the wheel, but that's how we learn, right? :)

Sounds all right, at least from a higher-level point of view. So
basically, those two services are pretty much separate, just sharing a
domain. In this case, your problem should go away if you set a unique
SESSION_COOKIE_NAME for each of those sites.

It might be a different situation if those two sites were using a
shared database; then, the same session ID would be valid for both,
but since that's not the case here, they need to be separate.

Cheers,

Michal

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

Re: Visiting one Django server logs me out of another Django server, both behind the same proxy

I discovered JSON Web Tokens after I posted my original question. So I'll read about how they work.

Thanks
Mike

On Thursday, 29 September 2016 16:50:22 UTC-4, Stodge wrote:
I have two Django servers A1 and S1, which sit behind a simplistic NodeJS proxy. This is a silly attempt at single sign on.

I can log into and out of A1 (authentication server) just fine. If I log into A1, visit S1 (without being logged in to S1) and then revisit A1, I am no longer logged in. The S1 server doesn't set a new session ID in the cookie and I don't think from memory that the CSRF changes. The session ID cookie hasn't changed, the domain is the same etc.

I can't work out why I'm no longer logged into A1. I know this isn't much to go on but I'm assuming something is happening to the cookies set by S1 when I visit it. Any suggestions 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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1bfc206d-6aa2-44c4-8218-e2d2cdfd0369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Visiting one Django server logs me out of another Django server, both behind the same proxy

Thanks Michal,

The two servers are on the same domain and use different databases. At the moment I'm using the default Django session backend.

It's an experiment, nothing more really. I just wanted to see if I could make it work. I haven't really worked out the flow, but it's probably something like:

 - admin creates user account on A1, auto replicates it to S1
 - user U1 visits S1, not logged in
 - U1 redirected to A1 to generate auth token, not logged in
 - U1 logs into A1
 - U1 redirected back to S1 to accept authentication
 - S1 logs U1 in, creates session as normal

So the user is logged into both. It's a fairly naive attempt at reinventing the wheel, but that's how we learn, right? :)

Cheers
Mike



On Friday, 30 September 2016 04:30:04 UTC-4, Michal Petrucha wrote:
On Thu, Sep 29, 2016 at 01:50:22PM -0700, Stodge wrote:
> I have two Django servers A1 and S1, which sit behind a simplistic
> NodeJS proxy. This is a silly attempt at single sign on.
>
> I can log into and out of A1 (authentication server) just fine. If I
> log into A1, visit S1 (without being logged in to S1) and then
> revisit A1, I am no longer logged in. The S1 server doesn't set a
> new session ID in the cookie and I don't think from memory that the
> CSRF changes. The session ID cookie hasn't changed, the domain is
> the same etc.
>
> I can't work out why I'm no longer logged into A1. I know this isn't
> much to go on but I'm assuming something is happening to the cookies
> set by S1 when I visit it. Any suggestions appreciated.

Are those two applications sitting on the same domain? If yes, then
you should probably configure them to use different session cookies.
Logging in or out causes the session to be reset, and if they try to
use the same session cookie, resetting for either application will
reset it for both.

It's hard to give you any more specific advice, because there are many
ways to go about implementing SSO, some of which would be affected by
this.

You might want to share some more information, such as:

- Are those two applications sharing one database?
- What session backend are you using?
- Are they on the same domain? (this one I've already asked above)
- Could you describe the SSO flow in a bit more detail?

Cheers,

Michal

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

How to setup django 1.9 with mongodb

hai Man How to setup django 1.9 with mongodb

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

download file when debug=false

hello,

i have developp a django application where excel file are generate after some operation. when debug=true thes excel files can be download but when false it is not possible.
my question is how to solve this issus.

all think are ok when debug=true

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

Re: Visiting one Django server logs me out of another Django server, both behind the same proxy

On Thu, Sep 29, 2016 at 01:50:22PM -0700, Stodge wrote:
> I have two Django servers A1 and S1, which sit behind a simplistic
> NodeJS proxy. This is a silly attempt at single sign on.
>
> I can log into and out of A1 (authentication server) just fine. If I
> log into A1, visit S1 (without being logged in to S1) and then
> revisit A1, I am no longer logged in. The S1 server doesn't set a
> new session ID in the cookie and I don't think from memory that the
> CSRF changes. The session ID cookie hasn't changed, the domain is
> the same etc.
>
> I can't work out why I'm no longer logged into A1. I know this isn't
> much to go on but I'm assuming something is happening to the cookies
> set by S1 when I visit it. Any suggestions appreciated.

Are those two applications sitting on the same domain? If yes, then
you should probably configure them to use different session cookies.
Logging in or out causes the session to be reset, and if they try to
use the same session cookie, resetting for either application will
reset it for both.

It's hard to give you any more specific advice, because there are many
ways to go about implementing SSO, some of which would be affected by
this.

You might want to share some more information, such as:

- Are those two applications sharing one database?
- What session backend are you using?
- Are they on the same domain? (this one I've already asked above)
- Could you describe the SSO flow in a bit more detail?

Cheers,

Michal

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

Thursday, September 29, 2016

Re: Model Inheritance across apps

On 30/09/2016 10:33 AM, Malik Rumi wrote:
> Assume two models, class Parent(models.Model): and Child(Parent):
>
> Assume they are both in the same Project
>
> Can Child be in a different app than Parent? In most cases the answer
> seems to be yes.

True. You only need to import Parent. But it might be better to put them
both in their own app with Parent defined before Child.

>
> Each app has many other models to which Parent and Child,
> respectively, are closely tied - which is why they are in those apps.
>
> If so, what is the best practices way of doing so, and
>
> how does one avoid or minimize circular imports?

In the other apps you don't need to import Parent and Child for FK and
such. That completely avoids circular imports. If your Parent and Child
classes are defined in the parentchild app then you specify your FK like
this ...

class ThisThing(models.Model):
parent = models.ForeignKey("parentchild.Parent")
...

class OtherThing(models.Model):
child = models.ForeignKey("parentchild.Child")
...

> For example, if Child.models.py imports Parent in order to facilitate
> the inheritance, what do you do if another model in Parent.models.py
> has a fk to another model in Child.models.py?

You can also use quotes to specify the model class here. Just omit the
app name if they are in the same app.

Mike

> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/01251136-3cfb-4069-862c-78e118475958%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/01251136-3cfb-4069-862c-78e118475958%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

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

Model Inheritance across apps

Assume two models, class Parent(models.Model): and Child(Parent):

Assume they are both in the same Project

Can Child be in a different app than Parent? In most cases the answer seems to be yes.

Each app has many other models to which Parent and Child, respectively, are closely tied - which is why they are in those apps.

If so, what is the best practices way of doing so, and

how does one avoid or minimize circular imports?

For example, if Child.models.py imports Parent in order to facilitate the inheritance, what do you do if another model in Parent.models.py has a fk to another model in Child.models.py?

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

Re: Django not saving form in DB from frontend

I would try to replace

if form.is_valid():
new_form = form
new_form.save(commit=True)

with :

if form.is_valid():
print("Form is valid")
form.save(commit=True)
else:
print("Invalid form")


Pretty sure you will get an invalid form, due to a missing field
send_quote field. For the form to send the file, you need to add an
enctype=multipart or something related.

2016-09-29 21:06 GMT+02:00 Ali khan <alipathan123123@gmail.com>:
> Appologies. In my view after else clause its ContactForm.
>
> On Thu, Sep 29, 2016 at 11:52 AM, Ali khan <alipathan123123@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I am newbie so I must be doing some stupid mistake here.
>>
>> I am trying to save a contact form with ModelForm. But its not saving in
>> DB from the frontend form.
>>
>> model.py
>>
>> class Contact(models.Model):
>> name = models.CharField(max_length=100, null=True, blank=True)
>> email = models.EmailField()
>> send_quote = models.FileField(upload_to='/contacts')
>>
>> def __unicode__(self)
>> return self.name
>>
>> forms.py
>>
>> from .models import Contact
>> from djagno import forms
>> from django.forms import ModelForm
>>
>> class ContactForm(forms.ModelForm):
>> class Meta:
>> model = Contact
>> fields = ['name', 'email', 'send_quote']
>>
>> views.py:
>>
>> from Django.shortcuts import render, redirect
>> from .forms import ContactForm
>>
>> def contact_form(request):
>> template = 'contact.html'
>> if request.method == 'POST':
>> form = ContactForm(request.POST or None, request.Files or
>> None)
>> if form.is_valid():
>> new_form = form
>> new_form.save(commit=True)
>>
>>
>> return redirect('/')
>> else:
>> form = RFPForm
>> return render(request, template, context={"form":form})
>>
>>
>> contact.html:
>>
>> <form action=" " method="POST">
>> {% csrf_token %}
>> {{ form }}
>> <input type='submit' class='btn btn-danger' value='Send' />
>> </form>
>>
>> Please advise.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAXvsYkTe_LU03ErF%3Dz%3DbNfM3LapOsyQywzKxUP3tm5pxHh28Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

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

Visiting one Django server logs me out of another Django server, both behind the same proxy

I have two Django servers A1 and S1, which sit behind a simplistic NodeJS proxy. This is a silly attempt at single sign on.

I can log into and out of A1 (authentication server) just fine. If I log into A1, visit S1 (without being logged in to S1) and then revisit A1, I am no longer logged in. The S1 server doesn't set a new session ID in the cookie and I don't think from memory that the CSRF changes. The session ID cookie hasn't changed, the domain is the same etc.

I can't work out why I'm no longer logged into A1. I know this isn't much to go on but I'm assuming something is happening to the cookies set by S1 when I visit it. Any suggestions 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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6ce063f-b0df-46d9-90cd-29a72f57410c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django not saving form in DB from frontend

Appologies. In my view after else clause its ContactForm.

On Thu, Sep 29, 2016 at 11:52 AM, Ali khan <alipathan123123@gmail.com> wrote:
Hi,

I am newbie so I must be doing some stupid mistake here.

I am trying to save a contact form with ModelForm. But its not saving in DB from the frontend form.

model.py

class Contact(models.Model):
     name = models.CharField(max_length=100, null=True, blank=True)
     email = models.EmailField()
     send_quote = models.FileField(upload_to='/contacts')

      def __unicode__(self)
           return self.name

forms.py

from .models import Contact
from djagno import forms
from django.forms import ModelForm

class ContactForm(forms.ModelForm):
        class Meta:
                    model = Contact
                    fields = ['name', 'email', 'send_quote']

views.py:

from Django.shortcuts import render, redirect
from .forms import ContactForm

def contact_form(request):
        template = 'contact.html'
        if request.method == 'POST':
               form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     new_form = form
                     new_form.save(commit=True)
                     

                return redirect('/')
           else:
                  form = RFPForm
            return render(request, template, context={"form":form})


contact.html:

<form action=" " method="POST">
{% csrf_token %}
{{ form }}
<input type='submit' class='btn btn-danger' value='Send' />
</form>

Please advise.


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

Django not saving form in DB from frontend

Hi,

I am newbie so I must be doing some stupid mistake here.

I am trying to save a contact form with ModelForm. But its not saving in DB from the frontend form.

model.py

class Contact(models.Model):
     name = models.CharField(max_length=100, null=True, blank=True)
     email = models.EmailField()
     send_quote = models.FileField(upload_to='/contacts')

      def __unicode__(self)
           return self.name

forms.py

from .models import Contact
from djagno import forms
from django.forms import ModelForm

class ContactForm(forms.ModelForm):
        class Meta:
                    model = Contact
                    fields = ['name', 'email', 'send_quote']

views.py:

from Django.shortcuts import render, redirect
from .forms import ContactForm

def contact_form(request):
        template = 'contact.html'
        if request.method == 'POST':
               form = ContactForm(request.POST or None, request.Files or None)
               if form.is_valid():
                     new_form = form
                     new_form.save(commit=True)
                     

                return redirect('/')
           else:
                  form = RFPForm
            return render(request, template, context={"form":form})


contact.html:

<form action=" " method="POST">
{% csrf_token %}
{{ form }}
<input type='submit' class='btn btn-danger' value='Send' />
</form>

Please advise.

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

Re: Cache-Control header for Flat Pages

On Thu, Sep 29, 2016 at 05:17:54AM -0700, Web Architect wrote:
> Hi Michal,
>
> Thanks for your response. My mistake that I should have mentioned that we
> are using Django 1.8. The decorator cache_control I think was introduced in
> 1.9. Would there be something similar in 1.8?

It's also in 1.8:
https://docs.djangoproject.com/en/1.8/topics/cache/#controlling-cache-using-other-headers

(And yeah, I just verified that I can import it in a 1.8 project.)

Michal

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

Discussing the documentation on formset.get_form_kwargs()

https://docs.djangoproject.com/en/1.10/topics/forms/formsets/#passing-custom-parameters-to-formset-forms

In the documentation there is a sentence "The formset base class provides a get_form_kwargs method." 

Could you help me understand why this sentence should be illustrated with the exmple of redefinition of this method.

Then I would say this is an example of side effect in programming: it gives unpredictable result. If the form is called get_form_kwargs, then we expect that it returns what kwargs are present in the form. But this method disfigures the picture.
Well, side effect in its classical meaning (https://en.wikipedia.org/wiki/Side_effect_(computer_science))

Wouldn't just formset.get_form_kwargs(0)  be better here?

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

Formset: Is get_form_kwargs() has a bad example in documentation?

https://docs.djangoproject.com/en/1.10/topics/forms/formsets/#passing-custom-parameters-to-formset-forms

In the documentation we can read: 

====Quotation=====

The form_kwargs may also depend on the specific form instance. The formset base class provides aget_form_kwargs method. The method takes a single argument - the index of the form in the formset. The index is None for the empty_form:

>>> from django.forms import BaseFormSet  >>> from django.forms import formset_factory    >>> class BaseArticleFormSet(BaseFormSet):  ...     def get_form_kwargs(self, index):  ...         kwargs = super(BaseArticleFormSet, self).get_form_kwargs(index)  ...         kwargs['custom_kwarg'] = index  ...         return kwargs
====Quotation=====
I can see that 
1) Example doesn't illustrate the text of documentation. It illustrates redefinition of the method.
2) The example seems to be bad itself. Doesn't this brings about some side effect? 
https://en.wikipedia.org/wiki/Side_effect_(computer_science)

Wouldn't just kwargs = formset.get_form_kwargs(0) be better?
If this makes sense, I could create a ticket at Djangoproject. 
But I'm too green for deep understanding this example. So, I decided to discuss it here.



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