Hi Ajay,

Thanks for contacting us and using Django. This list is to discuss about Django 
development itself. Discuss bugs, new features that can be added to the 
language. To discuss how to use Django or when having issues using you should 
use the list django-users@google groups.com

You will find help there.

Kind Regards,
Raúl

> On 12 Feb 2015, at 07:29, Ajay Kumar <[email protected]> wrote:
> 
> I'm trying to do this following link feature in django,
> http://demo.smarttutorials.net/jquery-autocomplete/
> 
> Here by choosing country the rest of the fields will be auto populated, like 
> this i'm trying to achieve in django, If any idea pls tell me it will be very 
> great for me
> 
> 
> This is Product table,by this i will add many products
> models.py
> 
> class Product(models.Model):
>       store                           =       models.ForeignKey(Store)
>       code                            =       
> models.CharField(verbose_name='Product Code', max_length=128, blank=False)
>       name                            =       
> models.CharField(verbose_name='Product Name', max_length=128, blank=False)
>       unit_price                      =       
> models.FloatField(verbose_name='Unit Price', blank=False)
>       in_stock                        =       
> models.IntegerField(verbose_name='In Stock', default=0, blank=False)
> 
> 
> 
> This is Invoice order table, in this i will get customer details
> 
> class Invoice(models.Model):
>       customer                                =       
> models.ForeignKey(Customer)
>       date                                    =       
> models.DateTimeField(auto_now=True, blank=False)
> 
> This in Invoice Item order table which is in inline formset 
> 
> class InvoiceItem(models.Model):
>       invoice                                 =       
> models.ForeignKey(Invoice)
>       product                                 =       
> models.ForeignKey(Product)
>       particular                              =       
> models.CharField(verbose_name='Particular', max_length=128, blank=False)
>       quantity                                =       
> models.IntegerField(verbose_name='Quantity', default=0)
>       unit_price                              =       
> models.FloatField(verbose_name='Unit Price', blank=False)
>       tax_rate_percentage     =       models.FloatField(verbose_name='Tax 
> Rate Percentage', blank=False)
> 
> 
> 
> views.py
> 
> I'm trying to raise invoice by autopopulate feature.
> def add_invoice(request):
>       store = Store.objects.get(id=pk)
>       product = Product.objects.filter(store=store)
>       context =  RequestContext(request)
>       InvoiceItemInlineFormSet = inlineformset_factory(Invoice, InvoiceItem, 
> extra = 1,exclude=('invoice',))
>       if request.method == 'POST':
>               invoiceform = InvoiceForm(request.POST)
>               invoiceformset =  InvoiceItemInlineFormSet(request.POST)
>               if invoiceform.is_valid() and invoiceformset.is_valid():
>                       invoice = invoiceform.save(commit=False)
>                       invoice.store = store
>                       invoice.save()
>                       invoiceformset.save(commit=False)
>                       invoiceformset.instance = invoice
>                       invoiceformset.save()
>                       return 
> HttpResponseRedirect('/store_invoice/%s/invoice/'% pk)
>       else:
>               invoiceform = InvoiceForm()
>               invoiceformset =  InvoiceItemInlineFormSet()
>       args = {}
>       args.update(csrf(request))
>       args = {'email':email,'store':store,'invoiceform':invoiceform, 
> 'invoiceformset':invoiceformset}
>       return render_to_response('invoice/invoice_add.html',args,context)
> 
> invoice_add.html
> 
> {% extends "base_site.html" %}
> {% load staticfiles %}
> {% block title %}Add New Order | Finvoicez{% endblock %}
> {% block page-heading %}Add New Order{% endblock %}
> {% block content %}
> <script src="{{ STATIC_URL }}js/jquery-1.3.2.min.js"></script>
> <script type="text/javascript">
>         $(function() {
>             $(".inline.{{ invoiceformset.prefix }}").formset({
>                 prefix: "{{ invoiceformset.prefix }}",
>             })
>         })
>     </script>
> <div class="the-box no-border">
>     <form action="/store_invoice/{{store.id}}/invoice/add/"  method="post">{% 
> csrf_token %}
>         <div class="row">
>             <div class="col-sm-4">
>                 <label>Customer</label>
>                 {{invoiceform}}
>             </div>
>         </div>
>         <fieldset>
>             <legend>Order Items</legend>
>             {{ invoiceformset.management_form }}
>             {{ invoiceformset.non_form_errors }}
>             {% for form in invoiceformset %}
>                 {{ form.id }}
>                 <div class="inline {{ invoiceformset.prefix }}">
>                     {{form}}
>                 </div>
>             {% endfor %}
>         </fieldset>
>         <button type="submit" class="btn btn-success">Add Order</button>
>     </form>
> </div>
> {% endblock %}
> 
> Here i'm trying to bring when i'm adding Invoice Item , by selecting the 
> product code the rest of fields want to be auto populate by corresponding 
> Product details(Particular,unit price and tax) and it must be in 
> inlineformset, for every 'add another' it must be auto populate, like above 
> reference link.
> thanks in advance
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/6b9e44eb-0cbe-470d-aab8-0d24b0ba5540%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 developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6FDAA50B-CE60-4549-AD38-CA1B7BF91418%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to