unable to render initial data in ModelForm called through CreateView

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

unable to render initial data in ModelForm called through CreateView

Gabriel Wicki
hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the
irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a
form. the form is showed correctly, and the right values are printed in
console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies,
default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = self.jobs[0].worth.currency
        for j in self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %}
{% block 'title' %}{{ title }}{% endblock %}
{% block form %}
{% for field in form %}
<div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: unable to render initial data in ModelForm called through CreateView

Matthew Pava
Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: [hidden email]
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = self.jobs[0].worth.currency
        for j in self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/71d4aa115c7141bba420e62cd6f9de56%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: unable to render initial data in ModelForm called through CreateView

furzihurzischleim
:)

Invoice Form is "just" a normal Modelform - nothing fancy added.

class InvoiceForm(forms.ModelForm):
        class Meta:
                model = Invoice
                fields = '__all__'
        def __init__(self,*args,**kwargs):
                print("InvoiceForm.__init__();;;")
                #print( self)
                print( args)
                print( kwargs)
                return super(InvoiceForm, self).__init__( *args, **kwargs )

Am Dienstag, 6. März 2018 18:08:33 UTC+1 schrieb Matthew Pava:
Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="G650-94LAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="G650-94LAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@googlegroups.com] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="G650-94LAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@...
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs[0].worth.currency
        for j in <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="G650-94LAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="G650-94LAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@....
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;">https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;">https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: unable to render initial data in ModelForm called through CreateView

Matthew Pava

Well, I see that you only set self.jobs in the post method in CreateInvoice.  How are you seeing proper console output for get_initial when self.jobs is not even set in the get method?  Are you sure you are seeing exactly what you want to see?  Please double-check.  When presenting the form for the first time, it will use the get method on CreateInvoice.  Since you did not override it, it will use the default implementation.  You didn’t set self.jobs anywhere else but in the post method.

 

I also find this website helpful when dealing with class-based views:

https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 7:11 AM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

:)

Invoice Form is "just" a normal Modelform - nothing fancy added.

class InvoiceForm(forms.ModelForm):
        class Meta:
                model = Invoice
                fields = '__all__'
        def __init__(self,*args,**kwargs):
                print("InvoiceForm.__init__();;;")
                #print( self)
                print( args)
                print( kwargs)
                return super(InvoiceForm, self).__init__( *args, **kwargs )

Am Dienstag, 6. März 2018 18:08:33 UTC+1 schrieb Matthew Pava:

Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: <a href="javascript:" target="_blank">django...@... [mailto:<a href="javascript:" target="_blank">django...@...] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: <a href="javascript:" target="_blank">django...@...
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = self.jobs[0].worth.currency
        for j in self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">django-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">django...@....
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4989be8c26a94053881644e4fe2b0970%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: unable to render initial data in ModelForm called through CreateView

furzihurzischleim
thanks for the link, i was aware of that but was unable to find my error (that's why i turned to irc, and then to the list)..

it is true self.jobs is set from the post() method. that's because the CreateView should be called if there are jobs selected in a POST-form. so post() sets self.jobs which get processed (and summed to initial['amount'] and initial['currency']) in get_initial(), which itself is printed to console correctly. it then instantiated a form, which gets the right arguments (initial dict) with the right values. but they won't show up :(

just for clarification: post() gets called if the request uses POST-method, and get() gets called on GET-requests, right?

i know this is more of a beginner issue, but i'm unable to get further in my work at this point. thanks for your time and your advice!


Am Mittwoch, 7. März 2018 18:44:40 UTC+1 schrieb Matthew Pava:

Well, I see that you only set <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs in the post method in CreateInvoice.  How are you seeing proper console output for get_initial when <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs is not even set in the get method?  Are you sure you are seeing exactly what you want to see?  Please double-check.  When presenting the form for the first time, it will use the get method on CreateInvoice.  Since you did not override it, it will use the default implementation.  You didn’t set <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs anywhere else but in the post method.

 

I also find this website helpful when dealing with class-based views:

<a href="https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fccbv.co.uk%2Fprojects%2FDjango%2F1.11%2Fdjango.views.generic.edit%2FCreateView%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHE2d9laJc16bvxPmVtEuWh2qA_Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fccbv.co.uk%2Fprojects%2FDjango%2F1.11%2Fdjango.views.generic.edit%2FCreateView%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHE2d9laJc16bvxPmVtEuWh2qA_Vw&#39;;return true;">https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/

 

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A2BUEmxcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="A2BUEmxcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@googlegroups.com] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 7:11 AM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

:)

Invoice Form is "just" a normal Modelform - nothing fancy added.

class InvoiceForm(forms.ModelForm):
        class Meta:
                model = Invoice
                fields = '__all__'
        def __init__(self,*args,**kwargs):
                print("InvoiceForm.__init__();;;")
                #print( self)
                print( args)
                print( kwargs)
                return super(InvoiceForm, self).__init__( *args, **kwargs )

Am Dienstag, 6. März 2018 18:08:33 UTC+1 schrieb Matthew Pava:

Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: [hidden email] [mailto:django...@googlegroups.com] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: [hidden email]
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs[0].worth.currency
        for j in <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed 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 [hidden email].
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;"> https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;"> https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A2BUEmxcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A2BUEmxcAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;"> djang...@....
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;">https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Screen Shot 2018-03-07 at 18.54.14.png (142K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: unable to render initial data in ModelForm called through CreateView

Matthew Pava

Correct, post is for POST, get is for GET.

When a form is POSTed successfully, the user is redirected to another URL, typically a success page or something of your choosing.

So after your POST, if you are simply redirecting back to this CreateView, you no longer have access to the invoice that you just created in this view.  You are creating a completely new invoice using the GET method.

Maybe you mean to be creating an UpdateView with this new information about self.jobs?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 12:10 PM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

thanks for the link, i was aware of that but was unable to find my error (that's why i turned to irc, and then to the list)..

it is true self.jobs is set from the post() method. that's because the CreateView should be called if there are jobs selected in a POST-form. so post() sets self.jobs which get processed (and summed to initial['amount'] and initial['currency']) in get_initial(), which itself is printed to console correctly. it then instantiated a form, which gets the right arguments (initial dict) with the right values. but they won't show up :(

just for clarification: post() gets called if the request uses POST-method, and get() gets called on GET-requests, right?

i know this is more of a beginner issue, but i'm unable to get further in my work at this point. thanks for your time and your advice!


Am Mittwoch, 7. März 2018 18:44:40 UTC+1 schrieb Matthew Pava:

Well, I see that you only set self.jobs in the post method in CreateInvoice.  How are you seeing proper console output for get_initial when self.jobs is not even set in the get method?  Are you sure you are seeing exactly what you want to see?  Please double-check.  When presenting the form for the first time, it will use the get method on CreateInvoice.  Since you did not override it, it will use the default implementation.  You didn’t set self.jobs anywhere else but in the post method.

 

I also find this website helpful when dealing with class-based views:

https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/

 

 

From: <a href="javascript:" target="_blank">django...@... [mailto:<a href="javascript:" target="_blank">django...@...] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 7:11 AM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

:)

Invoice Form is "just" a normal Modelform - nothing fancy added.

class InvoiceForm(forms.ModelForm):
        class Meta:
                model = Invoice
                fields = '__all__'
        def __init__(self,*args,**kwargs):
                print("InvoiceForm.__init__();;;")
                #print( self)
                print( args)
                print( kwargs)
                return super(InvoiceForm, self).__init__( *args, **kwargs )

Am Dienstag, 6. März 2018 18:08:33 UTC+1 schrieb Matthew Pava:

Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: [hidden email]
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = self.jobs[0].worth.currency
        for j in self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
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 <a href="javascript:" target="_blank">django-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">djang...@....
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55baaaee04914ec28766d4cc656746ab%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: unable to render initial data in ModelForm called through CreateView

furzihurzischleim
hmm.. i don't think so. the info about the jobs is meant to be gathered before creating the invoice. see, the app should let you register "jobs" with timing, client and wage information. after creating jobs you can select in a form "open" jobs, meaning they have not been part of an invoice. so you select the jobs and create the invoice, if saving the invoice is succesful, i create the ForeignKey relation from each job to point to the invoice.

... so the CreateView _is_ the right thing, right? or would you create the object "by hand" while processing the POST data and redirect it to an UpdateForm (and delete the instance if updating fails)?


Am Mittwoch, 7. März 2018 19:18:03 UTC+1 schrieb Matthew Pava:

Correct, post is for POST, get is for GET.

When a form is POSTed successfully, the user is redirected to another URL, typically a success page or something of your choosing.

So after your POST, if you are simply redirecting back to this CreateView, you no longer have access to the invoice that you just created in this view.  You are creating a completely new invoice using the GET method.

Maybe you mean to be creating an UpdateView with this new information about <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs?

 

From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GzoNZj5eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@... [mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="GzoNZj5eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@googlegroups.com] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 12:10 PM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

thanks for the link, i was aware of that but was unable to find my error (that's why i turned to irc, and then to the list)..

it is true <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs is set from the post() method. that's because the CreateView should be called if there are jobs selected in a POST-form. so post() sets <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs which get processed (and summed to initial['amount'] and initial['currency']) in get_initial(), which itself is printed to console correctly. it then instantiated a form, which gets the right arguments (initial dict) with the right values. but they won't show up :(

just for clarification: post() gets called if the request uses POST-method, and get() gets called on GET-requests, right?

i know this is more of a beginner issue, but i'm unable to get further in my work at this point. thanks for your time and your advice!


Am Mittwoch, 7. März 2018 18:44:40 UTC+1 schrieb Matthew Pava:

Well, I see that you only set <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs in the post method in CreateInvoice.  How are you seeing proper console output for get_initial when <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs is not even set in the get method?  Are you sure you are seeing exactly what you want to see?  Please double-check.  When presenting the form for the first time, it will use the get method on CreateInvoice.  Since you did not override it, it will use the default implementation.  You didn’t set <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs anywhere else but in the post method.

 

I also find this website helpful when dealing with class-based views:

<a href="https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fccbv.co.uk%2Fprojects%2FDjango%2F1.11%2Fdjango.views.generic.edit%2FCreateView%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHE2d9laJc16bvxPmVtEuWh2qA_Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fccbv.co.uk%2Fprojects%2FDjango%2F1.11%2Fdjango.views.generic.edit%2FCreateView%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHE2d9laJc16bvxPmVtEuWh2qA_Vw&#39;;return true;">https://ccbv.co.uk/projects/Django/1.11/django.views.generic.edit/CreateView/

 

 

From: [hidden email] [mailto:django...@googlegroups.com] On Behalf Of furzihurzischleim
Sent: Wednesday, March 7, 2018 7:11 AM
To: Django users
Subject: Re: unable to render initial data in ModelForm called through CreateView

 

:)

Invoice Form is "just" a normal Modelform - nothing fancy added.

class InvoiceForm(forms.ModelForm):
        class Meta:
                model = Invoice
                fields = '__all__'
        def __init__(self,*args,**kwargs):
                print("InvoiceForm.__init__();;;")
                #print( self)
                print( args)
                print( kwargs)
                return super(InvoiceForm, self).__init__( *args, **kwargs )

Am Dienstag, 6. März 2018 18:08:33 UTC+1 schrieb Matthew Pava:

Let's see InvoiceForm.
Also, it doesn't make much of a different, but I wouldn't call copy on the super.get_initial() method.

 
-----Original Message-----
From: [hidden email] [mailto:django...@googlegroups.com] On Behalf Of Gabriel Wicki
Sent: Sunday, March 4, 2018 2:48 PM
To: [hidden email]
Subject: unable to render initial data in ModelForm called through CreateView

hello list

i ran into some weird stuff and neither i nor 2 gentle folks down at the irc-chat could find any obvious problems. task should have been easy:
calculate some special initial data and present it as initials in a form. the form is showed correctly, and the right values are printed in console.. and, of course, there is no error raised..

thank you for any hints! i've been stuck here....


gabriel




# models.py
class AmountModel(models.Model):
    class Meta:
        abstract = True
    currencies = (
        ('CHF', "Swiss Francs"),
        ('EUR', "Euros"),
    )
    amount = models.FloatField();
    currency = models.CharField( max_length=3, choices=currencies, default='CHF' )

    def __str__(self):
        return "{} {}".format(self.amount, [ j[1] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0] )
    def short(self):
        return "{} {}".format([ j[0] for i,j in
enumerate(self.currencies) if j[0] == self.currency][0], self.amount )
    def __add__(self, other):
        return AmountModel(amount=self.amount+other.amount,
currency=self.currency)

class DocumentModel(models.Model):
    class Meta:
        abstract = True
    tex = models.FileField(verbose_name = "TeX")
    pdf = models.FileField(verbose_name = "PDF")
    def generate_pdf( self ):
        return

class Invoice(AmountModel, DocumentModel):
    STATUS = (
        ("o", "open"), # initialized
        ("c", "complete"), # completed (no info missing)
        ("s","sent"), # sent
        ("p","pending"), # sent but money not yet received
        ("pd","paid") # paid and archived
    )
    client = models.ForeignKey( 'Client', on_delete=models.CASCADE )
    title = models.CharField( max_length=200 )
    status = models.CharField( max_length=2, choices = STATUS )
    number = models.IntegerField( blank=True )
    date_created = models.DateField( auto_now=True )
    date_sent = models.DateField( blank=True )
    date_paid = models.DateField( blank=True )

    @property
    def jobs(self):
        return Job.objects.filter( invoice=self )

    @property
    def expenses(self):
        return Expense.objects.filter( invoice=self )

    def __str__(self):
        if self.status.startswith('p'):
            return '%d %s'.format(self.number, self.title )
            return self.title

    def update_status(self):
        if (self.date_sent == None):
            self.status = STATUS[0][0]
        elif (self.date_paid == None):
            self.status = STATUS[1][0]
        else:
            self.status = STATUS[2][0]
            return

    def calculate_amount(self):
        amount = 0
        for o in [ <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs, self.expenses ].flatten:
            amount += o.amount
            self.amount = amount
            self.save()
        return

    def create_tex( self ):
        template_file = 'templates/invoice.tex'
        t = loader.get_template(template_file)
        context = {
            'title': self.title,
        }
        filename = '%d %s'.format(self.number, slugify(self.title) )
        self.tex.file = open(filename+'.tex', 'w')
        self.tex.file.write(smart_str( t.render(context) ))
        return

    def send_to_client( self ):
        return

# views.py
class CreateInvoice(CreateView):
    model = Invoice
    form_class = InvoiceForm
    template_name = 'standard_form.html'

    def get_initial(self):
        initial = super(CreateView, self).get_initial().copy()
        initial['title'] = "blablabla"
        amount = {'CHF': 0, 'EUR': 0}
        currency = <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs[0].worth.currency
        for j in <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs:
            amount[j.worth.currency] += j.worth.amount
        for a in amount.keys():
            if not amount[a] == 0:
                try:
                    initial['value'] is None
                except KeyError:
                    initial['currency'] = a
                    initial['amount'] = amount[a]
        print(initial)
        return initial

    def post(self, request, *args, **kwargs):
        print("post()")
        req = request.POST.copy()
        req.pop('csrfmiddlewaretoken')
        <a href="http://self.jobs" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fself.jobs\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElhPAmaQ-TcLWOL3cbBd1K5pZTTQ&#39;;return true;">self.jobs = Job.objects.filter(id__in=req.keys(),
client_id=kwargs['client_id'])
        return super(CreateView, self).post(request,*args,**kwargs)

# standard_form.html
{% extends 'main_form.html' %}
{% block formaction %}{{ formaction }}{% endblock %} {% block 'title' %}{{ title }}{% endblock %} {% block form %} {% for field in form %} <div class="field{% if field.is_required %} required{% endif %}">
  <div class="form-error">{{ field.errors }}</div>
  {{ field.label_tag }}
  {{ field }}
</div>
{% endfor %}
{% endblock %}

--
You received this message because you are subscribed 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 [hidden email].
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;"> https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch&#39;;return true;"> https://groups.google.com/d/msgid/django-users/f6cc2d8f-b34e-0444-472f-b0105065e2c1%40erlikon.ch.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> 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 [hidden email].
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;"> https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/django-users/3daa6fd9-be1a-4b15-886c-454aa7ed86f4%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;"> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GzoNZj5eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="GzoNZj5eAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;"> djang...@....
Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;">https://groups.google.com/group/django-users.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/django-users/9804ee28-d865-4878-bd3f-1f46d82c5a1e%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c8db9e30-0f76-4792-a736-95f8f5daf46e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.