Re: how to saven models dynamically inputted by user in form

2014-07-03 Thread Sandeep kaur
On Wed, Jul 2, 2014 at 11:03 AM, Aashita Dutta 
wrote:
>
> here is my model-
> from django.db import models
> import useraccounts
> from librehatti.catalog.models import *
> from django.contrib.auth.models import User
>
> class QuotedOrder(models.Model):
> quote_buyer_id = models.ForeignKey(User)

OMG.
What do want to say?
Can you please use some other medium to show your code? Github may be one.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

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


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


here is my model-
from django.db import models
import useraccounts
from librehatti.catalog.models import *
from django.contrib.auth.models import User

class QuotedOrder(models.Model):
quote_buyer_id = models.ForeignKey(User)
quote_is_debit = models.BooleanField()
quote_delivery_address = models.ForeignKey('useraccounts.Address')
quote_organisation = 
models.ForeignKey('useraccounts.AdminOrganisations')
quote_date_time = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return '%s' % (self.quote_buyer_id) +' - ' '%s' % 
(self.quote_date_time.strftime ('%b %d, %Y'))

class QuotedItem(models.Model):
quote_order = models.ForeignKey(PurchaseOrder)
quote_price = models.IntegerField()
quote_qty = models.IntegerField()
quote_discount= models.IntegerField()
quote_item = models.ForeignKey(Product)
status = models.IntegerField(default=0)
def save(self):
if not self.id:
self.quote_price = self.quote_item.price * self.quote_qty
super(QuotedItem,self).save()

def __unicode__(self):
return '%s' % (self.quote_item) + ' - ' '%s' % (self.quote_order)




here is my forms.py-
from django import forms
from librehatti.bills.models import *

#class ConfirmForm(forms.Form):
#quote_item = forms.CharField()
#quote_qty = forms.IntegerField()


class ConfirmForm(ModelForm):
 class Meta:
 model = QuotedItem
 fields = ('quote_item', 'quote_qty')


here is my html-file-


display items



CONFIRM ITEMS
 {% csrf_token %}


Item
Quantity


 {% for i in quoted_item %}
  

 
Item:  
Quantity:
   
   
 
  
   {% endfor %} 
   
 






here is catalog models, where i want to save the values, input by user in 
form-

from django.db import models
from django.forms import ModelForm
import useraccounts
from django.contrib.auth.models import User

class Category(models.Model):
name = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return unicode(self.name)


class Product(models.Model):
name = models.CharField(max_length=100)
category = models.ForeignKey(Category)
price = models.IntegerField()
organisation = models.ForeignKey('useraccounts.AdminOrganisations')
def __unicode__(self):
return self.name


class Attributes(models.Model):
name = models.CharField(max_length=200)
is_number = models.BooleanField()
is_string = models.BooleanField()
def __unicode__(self):
return self.name


class PurchaseOrder(models.Model):
buyer_id = models.ForeignKey(User)
is_debit = models.BooleanField()
delivery_address = models.ForeignKey('useraccounts.Address')
organisation = models.ForeignKey('useraccounts.AdminOrganisations')
date_time = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return '%s' % (self.buyer_id) +' - ' '%s' % (self.date_time.strftime
   ('%b %d, %Y'))


class PurchasedItem(models.Model):
purchase_order = models.ForeignKey(PurchaseOrder)
price = models.IntegerField()
qty = models.IntegerField()
discount= models.IntegerField()
item = models.ForeignKey(Product)

def save(self):
if not self.id:
self.price = self.item.price * self.qty
super(PurchasedItem,self).save()

def __unicode__(self):
return '%s' % (self.item) + ' - ' '%s' % (self.purchase_order)


class Catalog(models.Model):
attribute = models.ForeignKey(Attributes)
value = models.CharField(max_length=200)
product = models.ForeignKey(Product)
def __unicode__(self):
return self.attribute.name;


how to save now? and to generate bills also?

here is bill.html-











bill
  





 
{{quoted_order.quote_organisation.organisation_type}}
{{quoted_order.quote_organisation.tagline}}   
{{quoted_order.quote_organisation.title}}
  
{{quoted_order.quote_organisation.address}} 
Website : {{quoted_order.quoted_organisation.quote_url}}
 Email:{{quoted_order.quoted_organisation.quote_email1}}  Ph 
: 
{{quoted_order.quote_organisation.telephone}} 
 Fax : {{quoted_order.quote_organisation.fax}}
  
 Bill



STC No. {{ STC_NO }}
PAN No. {{ PAN_No. }}



No. : GNDEC/TCC/B/{{ job_no }}

Dated : {{quoted_order.date_time}} 




 To,
 {{quote_delivery_address}}
 Organisation:{{quote_organisation}}
 Buyer Id : {{ purchased_order.buyer_id.username }}
 Ref: Your Letter No.{{L_No.}}, 
dated:{{quoted_order.date_time}} , respectively.
 







  S.no.
  Charges For Following
  Price
  Per
  Total



{% if QuotedItem %}
{% for i in QuotedItem %}

 
  {{ forloop.counter }}
  {{ i.quote_item }}
  {{ i.quote_price }} 
  {{ i.quote_qty  }} 
  {{ i.total }}


{% endfor %}
{% endif %}


Total 

 {{total_cost}}
 


{% if bill.trans_total != None %}

 Transportation Charge

Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Lachlan Musicman
Woah there.

Ok, well it's hard to help without more info, but here are some tips:

 - please don't ask a community project to "reply soon". We will reply
when and if we can. Obviously ideally we would reply, and speedily,
but we get what we got.

 - How to save the ForeignKey on an item? Well assign it. FYI, it's
incredibly difficult to help without some code to look at. HAving said
that, the Django documentation is *excellent* and you should utilise
it - like I said in my original emails, ModelFormsets are your friend,
you should look into them.

 - With errors, sending them raw is not a way to get them solved. They
way I solve errors like that is to Google the error, and then look at
the line of code indicated:
"EOL while scanning string literal (views.py, line 31)" <- views, line
31. Maybe line 30, probably line 31. If Google doesn't help, and you
do need to ask here (which may well be the case), you MUST include
line 31 (pref the lines 25-35) so we have an idea of what is going on.

 - The error "The view librehatti.bills.views.final didn't return an
HttpResponse object. It returned None instea" means your return
statement in the view final isn't sending a proper object back -
either change the return statement, or figure out why it's sending
None. Again, without any context at all, it's very hard to help you.



cheers
L.


On 2 July 2014 06:16, Aashita Dutta  wrote:
>
>
> On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>>
>> Hi Aashita,
>>
>> There's a couple of things happening here. I'm no expert and this is a
>> rushed end of evening email.
>>
>> For getting the obj.save() to work, here:
>>
>> cd = form.cleaned_data
>> newPI = PurchasedItem()
>> newPI.name = cd['quote_item']
>> newPI.qty = cd['quote_qty']
>> newPI.save()
>>
>> You now have a new PurchaseItem with a name and a qty.
>>
>> Having said that, is there a reason you aren't using ModelForms and
>> Generic Views?
>>
>> Then there's the PurchaseOrder.  Will there be other PuchaseItems on
>> the order? Is it ManyToMany?
>>
>> If it is, it might be better to have the PurchaseOrder Form, with
>> PurchaseItem as an attached ModelFormset - in that way you can have as
>> many PIs on you PO as you want.
>>
>>
>
> now new error is coming-
>
> The view librehatti.bills.views.final didn't return an HttpResponse object.
> It returned None instea
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aa9f7896-e19a-46f5-ae5f-830a0484106e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

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


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>
> Hi Aashita, 
>
> There's a couple of things happening here. I'm no expert and this is a 
> rushed end of evening email. 
>
> For getting the obj.save() to work, here: 
>
> cd = form.cleaned_data 
> newPI = PurchasedItem() 
> newPI.name = cd['quote_item'] 
> newPI.qty = cd['quote_qty'] 
> newPI.save() 
>
> You now have a new PurchaseItem with a name and a qty. 
>
> Having said that, is there a reason you aren't using ModelForms and 
> Generic Views? 
>
> Then there's the PurchaseOrder.  Will there be other PuchaseItems on 
> the order? Is it ManyToMany? 
>
> If it is, it might be better to have the PurchaseOrder Form, with 
> PurchaseItem as an attached ModelFormset - in that way you can have as 
> many PIs on you PO as you want. 
>
>
>
now new error is coming-

The view librehatti.bills.views.final didn't return an HttpResponse object. It 
returned None instea

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


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>
> Hi Aashita, 
>
> There's a couple of things happening here. I'm no expert and this is a 
> rushed end of evening email. 
>
> For getting the obj.save() to work, here: 
>
> cd = form.cleaned_data 
> newPI = PurchasedItem() 
> newPI.name = cd['quote_item'] 
> newPI.qty = cd['quote_qty'] 
> newPI.save() 
>
> You now have a new PurchaseItem with a name and a qty. 
>
Now error is coming , 

EOL while scanning string literal (views.py, line 31)

 

>
>
>

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


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


PurchaseOrder has no use here, and yes item is foreign key to Product class 
which consists of item's name i.e item__name. Actually my QuotedItem class 
in models consist of 5 fields, and i want to save only two. Would this 
method be work? And also can we save method item__name which is foreign key?
reply soon

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