Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-17 Thread Tom Evans
On Thu, Jun 16, 2011 at 7:03 PM, Rodrigo Gomes  wrote:
> Yes, but the point is not about generate code. Is to follow a DRY
> principle...If I have a "multiple select list" with a specific
> behavior,look-and-feel, with some javascript surrounding the code, etc, I
> don't want to write this everywhere...I just want to create once and use it
> anywhere...with just a line of code...
> And I can do this easily with java through tagfiles, and sometimes taglibs.
> And now with django I'm using inclusion tag as suggested by Tom.
> The only reason that I'm not enjoying inclusion tags so much, is because I
> can not pass named parameters to them...only positional. But is works
> []'s
> Rodrigo Gomes
>

I don't normally pass any parameters; you can instead specify that it
should have the template context available to it instead, and then
pull named parameters out of there.

If the parameters that the inclusion template is expecting have
different names to the ones in the context, then I just alias them
using the {% with %} tag.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: When to use a model property vs. method?

2011-06-17 Thread Tom Evans
On Thu, Jun 16, 2011 at 10:35 PM, Micky Hulse  wrote:
> Just to clarify things for me, does attribute equal a property or method? :D
>
> I am guessing that attribute = property, so you're saying that I
> could/should do this:
>
> @property
> def separator(self):
>    return ' :: '
>

No, he's saying that is ridiculous overkill for a constant attribute.

class MyModel(models.Model):
  SEPARATOR = '::'

Access it with MyModel.SEPARATOR or my_model_instance.SEPARATOR

I use property() when either the setting or modification of an
attribute requires me to run actual code in order to manipulate the
supplied value into a different format. Eg, if I am storing a comma
separated list of IP addresses as strings in a database field, I don't
want to have to deal with splitting, parsing and turning it into a
list of proper objects in every different place. Instead, I supply a
property that serializes/deserializes the data as needed.

Another reason to use property() is when you remove an attribute that
is part of your public API, you can provide a property with the same
name as the attribute. Eg:

class MyModel(models.Model):
  @property
  def SEPARATOR(self):
if self.foo:
  return '::'
return '||'

The behaviour is now dynamic, but any old code using
instance.SEPARATOR will get still work, and use the new dynamic
definition.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: When to use a model property vs. method?

2011-06-17 Thread bruno desthuilliers
On Jun 16, 11:51 pm, Micky Hulse  wrote:
> How's this for a rule-of-thumb(?):
>
> 1. Use a property (class/instance attribute) when an argument(s) is not 
> needed.

Well, a setter does need an argument ;)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[formsets] Initial Values to an inline_formset() instance

2011-06-17 Thread Nikhil Somaru
Hi,

PURPOSE: Mimic the admin "inline" functionality (with
ForeignKeyrelationships) in one of my own forms without using
Javascript (because I
don't know it)

My Solution: Inline Formset via inline_formset()

However,

   - inline_formset() does not accept initial as an argument
   - This is after the form has been submitted once and I want to create new
   forms in the formsets while still keeping the data already entered, waiting
   to be edited

I am using the following workaround in the mean time: (the entire view may
be found here: http://dpaste.com/hold/555463/)

elif 'more_items' in request.POST:
order = form.save(commit=False) # models.Order
instances = formset.save(commit=False) # models.OrderItem(s)
for instance in instances:
initial_data.append({'item': instance.item,
 'quantity_requested':
instance.quantity_requested,
 }
)
formset = OrderFormset() #created via inline_formset()
for subform, data in zip(formset.forms, initial_data):
subform.initial = data
# render_to_response

The problem is, this limits me to a total number of forms as defined in the
extra field passed to inline_formset().

Any improvements or totally new solutions are welcome! My Python/Django
knowledge is beginner-intermediate (leaning towards beginner)

-- 
Yours,
Nikhil Somaru

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: When to use a model property vs. method?

2011-06-17 Thread bruno desthuilliers
On Jun 16, 11:35 pm, Micky Hulse  wrote:
>
> >> def get_separator(self):
> >>     return ' :: '
> > In this case (returning a constant), it would be much simpler to make
> > it a class (or instance) attribute.
>
> Ah, I think I get it.
>
> Just to clarify things for me, does attribute equal a property or method? :D

Python's object model is a bit peculiar (wrt/ most OOPLs at least),
and I won't start to explain it here (this would require a full book
FWIW). To make a long story short, you have class and instance
attributes, and since a small code snippet can say more than a
thousand words:

class Foo(object):
   bar = 42 # this a class attribute

   def __init__(self, yoot):
   self.yoot = yoot # this is an instance attribute

   # this is an instance method
   def baaz(self):
   print "%s.baaz" % self

   # this is a class method
   @classmethod
   def yuu(cls):
   print "%s.yuu" % cls

> I am guessing that attribute = property

Nope. "property" is a builtin Python class that implements the
descriptor protocol and give support for simple computed attributes.



> @property
> def separator(self):
>     return ' :: '

This is even more overkill. In Python, if all you need is a plain
attribute, just use a plain attribute - you can transparently turn it
into a computed one later if needed so no need to waste time with
getters/setters.




> > Properties are for computed attributes - that is, things that are the
> > semantically (conceptually, whatever) attributes, but requires any
> > computation, either on get, set or del.
>
> Ah, interesting... I think I need to let this all sink in a little. :)
>
> > But well, if you prefer java-
> > like getters/setters, then choice is yours... Depends on the
> > programmer's background,
>
> I have a little experience with Actionscipt 3 and PHP5 OOP... I guess
> I am used to the concept/practice of getters/setters,
> (public/private/other) class methods and properties.

Warning: in Python, a "class method" is a method that can be called
either on the class or instance, AND takes the class as first
argument. "ordinary" methods - the ones that takes the instance as
first argument - are also called "instance methods".

wrt/ "public/private", there's no such thing in Python anyway. The
(*very* strong) convention is to prefix implementation stuff with a
single leading underscore which means "don't touch or your on your own
if something breaks", but nothing prevents client code to mess with
some object's internals.


> Are you saying that a non-property model class method is equivalent to
> getter/setter?

No.

> Or, maybe you are saying that the "lat =
> property(_get_lat)" python property syntax is like
> getters/setters/accessors in other programming langs?

Mostly, yes - with the exception that since Python can let you turn a
plain attribute into a computed one without breaking client code, you
don't have to use getters / setters "just in case" - you only use them
if and when needed, and encapsulate them into a property (or a custom
descriptor) so the client code don't have to care.

> Again, sorry if stupid questions... sorry if this is getting OT for
> the Django list.

Well, I usually redirect this kind of questions to c.l.py, since it's
about Python and not Django...

> > and of course of whether the code was written
> > before new-style classes and the descriptor protocol
>
> I have not heard of this before. Googling "new-style classes and the
> descriptor protocol" now. ;)

Warning: this (and metaclasses) can be a bit mind-bending at first,
and tend to become highly addictive once you get it ;)

If I may suggest another related reading:
http://wiki.python.org/moin/FromFunctionToMethod


FWIW, Django relies quite a lot on metaclasses and descriptors for the
ORM part.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [formsets] Initial Values to an inline_formset() instance

2011-06-17 Thread Nikhil Somaru
Hi,

This is the hack-a-round that I figured out:

formset = OrderFormset(request.POST) #created earlier with inline_formset()
# now we recreate it to have the submitted number of forms+3
OrderFormset = inlineformset_factory(Order, OrderItem,
extra=len(formset.forms)+3)
formset = OrderFormset()
# populate the forms
# initial_data is a list of dictionaries created from POST data
# dict keys are field names
for subform, data in zip(formset.forms, initial_data):
subform.initial = data

I know this is inelegant and probably uses more memory than it should, but
it works. Are there any other, more elegant solutions?

On Fri, Jun 17, 2011 at 3:38 PM, Nikhil Somaru  wrote:

> Hi,
>
> PURPOSE: Mimic the admin "inline" functionality (with 
> ForeignKeyrelationships) in one of my own forms without using Javascript 
> (because I
> don't know it)
>
> My Solution: Inline Formset via inline_formset()
>
> However,
>
>- inline_formset() does not accept initial as an argument
>- This is after the form has been submitted once and I want to create
>new forms in the formsets while still keeping the data already entered,
>waiting to be edited
>
> I am using the following workaround in the mean time: (the entire view may
> be found here: http://dpaste.com/hold/555463/)
>
> elif 'more_items' in request.POST:
> order = form.save(commit=False) # models.Order
> instances = formset.save(commit=False) # models.OrderItem(s)
> for instance in instances:
> initial_data.append({'item': instance.item,
>  'quantity_requested':
> instance.quantity_requested,
>  }
> )
> formset = OrderFormset() #created via inline_formset()
> for subform, data in zip(formset.forms, initial_data):
> subform.initial = data
> # render_to_response
>
> The problem is, this limits me to a total number of forms as defined in the
> extra field passed to inline_formset().
>
> Any improvements or totally new solutions are welcome! My Python/Django
> knowledge is beginner-intermediate (leaning towards beginner)
>
> --
> Yours,
> Nikhil Somaru
>
>


-- 
Yours,
Nikhil Somaru

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Intermediary Models in admin

2011-06-17 Thread victor
Hey guys !

I'm trying to implement a any to many relationship with Intermediary
Models.
I've been following 
https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#working-with-many-to-many-intermediary-models
And I have almost the same code except for names.
The problem : that's crazy slow.

My table Group has 100 rows
My table Person has like 100  rows

So, If I go to a Person, there is no problem to see his groups.
But if from a group I want to see all the persons that's not possible.
(page load never end)

I had a look at the queries the admin generates. And I was a bit
surprised.

First it's selecting my group (eg:select * from group where is =1)
Second it's selecting all my Persons and join it to membership giving
my group id (eg:select person.* from person JOIN membership ON
membership.person = person.id WHERE group = id)
Third it's select all my memberships for my group (eg:SELECT * from
membership WHERE group = id)

Until here I guess it's fine.

Finally it is selecting all my persons (eg : select * from person)  :s
And it is not doing only one time. like 100 times

So I'm a bit lost, is it the normal behavior ? if yes, is there a
better way to do what i want to do ?
Thanks
V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to view the data of a shape file without using the databrowse admin ?

2011-06-17 Thread Satyajit Sarangi
I don't want to use django databrowse admin . Want to create my own
template and view that allows user to view a shapefile stored in the
database . And also view open layers data and OSM data stored in
database . how do I do it ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django on IIS7 With Windows Server 2008 R2

2011-06-17 Thread Yaroslav Govorunov
Hello David.

> Before I go any further with Django under IIS, I would like to ask the
> community what their recommendation is for running Django under IIS?
> What "glue" is preferred for connecting Django 1.3, Python 2.7.1 and IIS
> on Windows Server 2008 R2?

Just two days ago I posted a message. Please take a look:
http://www.helicontech.com/zoo/
Please share your experience with us as we really appreciate your
feedback.

Yaroslav Govorunov,
Helicon Tech
http://www.helicontech.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Chat

2011-06-17 Thread illuminated
You'd have to first decide the chat server platform...

In case you go down the Jabber/XMPP road (and choose something like
Ejabberd or OpenFire or something else), you can use the pyxmpp
(http://pyxmpp.jajcus.net/) or xmpppy (http://xmpppy.sourceforge.net/)
library.

On Jun 16, 5:34 pm, Nadae Ivar BADIO  wrote:
> Hi,
>
> I am programing a chat with python django anyone have a example for me
> please.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Chat

2011-06-17 Thread Mick

If you are using XMPP (which I do recommend) you'll want to check out the JS 
library Strophe (http://strophe.im/) which handles XMPP over HTTP. 

You will still need a server side BOSH endpoint, either a connection manager 
that allows you to connect to existing xmpp servers, like gtalk or jabber.org. 
https://github.com/twonds/punjab

Or use the built in support for BOSH in Ejabberd, or Openfire.

An example of django + strophe +ejabberd project is speeqe.com It is a 
multiuser chat site. The source is on github: https://github.com/thepug/Speeqe




_Mick
On Friday, June 17, 2011 at 7:37 AM, illuminated wrote: 
> You'd have to first decide the chat server platform...
> 
> In case you go down the Jabber/XMPP road (and choose something like
> Ejabberd or OpenFire or something else), you can use the pyxmpp
> (http://pyxmpp.jajcus.net/) or xmpppy (http://xmpppy.sourceforge.net/)
> library.
> 
> On Jun 16, 5:34 pm, Nadae Ivar BADIO  wrote:
> > Hi,
> > 
> > I am programing a chat with python django anyone have a example for me
> > please.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django and Rich Client

2011-06-17 Thread Knack
The requirements are:

1) Handling large (>10 lines, ~ 10 columns) amounts of structured
data in treeviews. For certain use cases comparing two of those trees.
2) Creating different structured views on the data. Like using
different categories of attributes as structure criteria. Those views
are not persistent.
3) Performing filter and configuration operations on the data. Those
can be quite expensive, for example variant configuration which comes
down to evaluating boolean expressions for each item.
4) Maybe (if there's time and I find an easy to use lib, maybe
Panda3D) adding a simple 3D viewer.

The decision has been made without really evaluation JavaScript or
Flash. I must admit that I don't know wether the state of the art JS
libraries can handle that large trees. But I know that PyQt can handle
that large data amazingly well. Further, I have some experience with
these kind of systems: Most of them are quite "server-centric" (as
common web apps are). Those systems have all performance issues when
the user needs another view or configuration of the data. My approach
is to eagerly load all the data to the client and do all calculations
for the views there. I must add that it's an in-house app and all
users have proper PCs.

Lastly, Personal experience and know-how: PyQt is fun to work with
(after some learning curve, of course). It has style-sheets for making
the client sexy at the end. On the other hand, I'm totally impressed
what can be done with JS, but I'm not familiar with it.

Cheers,

Jan



On 17 Jun., 06:26, Marwan Al-Sabbagh 
wrote:
> Out of curiosity is there a specific need for running a rich client instead
> of just accessing the system app through a web browser.
>
>
>
>
>
>
>
> On Fri, Jun 10, 2011 at 4:16 AM, Ovnicraft  wrote:
> > soaplib 
>
> > On Thu, Jun 9, 2011 at 1:10 PM, Knack  wrote:
>
> >> Hi guys,
>
> >> I've got a prototype DB + Rich Client app and need to make a proper
> >> production app out of it. The client is written in PyQt and needs to
> >> fullfill quite some functional and performance requirements (I would
> >> really like to keep it). The client connects directly to the DB.
>
> >> After some thoughts about security I came to the conclusion that using
> >> django is the way to go. Now I seek some coarse advice / feedback
> >> wether I'm heading in the right directions. I've got some miles to go
> >> and looking forward to learning Django, but want to avoid newbie
> >> pitfalls. So if something of the following sounds like bad ideas to
> >> you, please let me know ;-).
>
> >> Current plans are:
>
> >> 1) Using an Oracle DB
> >> 2) LDAP authentification
> >> 3) Role based authorisation. Here I'm a bit unsure about the approach.
> >> I would implement it by myself within the django world (don't know yet
> >> where exactly).
> >> 4) Transfering the data using a web service via https. Here are my
> >> biggest uncertainties. What kind of web service to use? Rest, xml-rpc
>
> > I recommend you REsT, IMHO XML-RPC is not fast, SOAP is a good option but
> > we get just few libraries under development soaplib[1]  is really promise.
>
> > or soap? How to package the acual data? Embedded in the html or xml?
>
> > Just be light.
>
> > Regards,
>
> > As binary payload? I would need only basic stuff like log in, log out,
> >> read and write whole database rows, which are basically the business
> >> objects. Most of the logic is done on the rich client. I would
> >> transfer large amounts (10s of business objects) of data at
> >> startup time (very eager loading to the client). But also lazy loading
> >> of course.
> >> 5) One important concept is that I change only a small amount of the
> >> data objects. Most of the changes lead to new versions. Therefore I
> >> hope to be able to use caching extensivly. The data objects which are
> >> immutable could be permanently cached in memory. How about
> >> authorisation of these cached objects? Are there ways django takes
> >> care of this?
>
> >> A long first post ;-). Any comments are appreciated!
>
> >> Cheers,
>
> >> Jan
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Cristian Salamea
> > @ovnicraft
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django

Re: Creating a simple contact form

2011-06-17 Thread Tiago Almeida
Try opening a django shell and calling send_mail by hand to see what
exception you get (if any).
Best Regards,

On 17 Jun, 07:27, raj  wrote:
> Hey guys,
>
> I have a webfaction account, and I was trying to get a contact form
> working for my website. The problem is that I can't seem to get it to
> work. Can someone walk me through this? I couldn't figure it out from
> the djangobook tutorial. I think something is wrong with my settings
> and stuff. Here are my files:
>
> forms.py:
>
> from django import forms
>
> class ContactForm(forms.Form):
>     email = forms.EmailField()
>     name = forms.CharField()
>     subject = forms.CharField()
>     message = forms.CharField(widget=forms.widgets.Textarea())
>
> views.py:
>
> def contact(request):
>     if request.method == 'POST':
>         form = ContactForm(request.POST)
>         if form.is_valid():
>             cd = form.cleaned_data
>             send_mail(
>                 cd['subject'] + " - " + cd['name'],
>                 cd['message'],
>                 cd.get('email', 'nore...@oneadmissions.com'),
>                 ['i...@oneadmissions.com'],
>             )
>             return HttpResponseRedirect('/contact/thanks/')
>     else:
>         form = ContactForm()
>     return render_to_response('/home/oneadmin/webapps/oneadmin/
> oneadmin/templates/oneadmissions/contact.html', {'form': form},
> context_instance=RequestContext(request))
>
> def thanks(request):
>     return render_to_response('/home/oneadmin/webapps/oneadmin/
> oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
> We will get back to you shortly"},
> context_instance=RequestContext(request))
>
> settings.py:
>
> EMAIL_HOST = 'smtp.webfaction.com'
> EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
> receives the email
> EMAIL_HOST_PASSWORD = 'PASSWORD'
> EMAIL_USE_TLS = True
>
> *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
> SERVER_EMAIL variables, didn't do anything.
>
> urls.py:
> urlpatterns = patterns('',
>                         (r'^contact/$', views.contact),
>                         (r'^contact/thanks/$', views.thanks),
> )

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-17 Thread Rodrigo Gomes
Hi,

This sounds really better! But I tried it and got an error.

What I tried to do, is to pass a string value that is not on the context,
like this:

{% my_tag with param_str="a string here" %}

and

@register.inclusion_tag('my_tag.html',takes_context=True)
def my_tag(context):

param_str = context['param_str']
...

But this give me the error:
TemplateSyntaxError at /my/url/

my_tag takes 0 arguments


Am I using the 'with' tag wrongly?

thanks,
Rodrigo Gomes

On Fri, Jun 17, 2011 at 5:31 AM, Tom Evans  wrote:

> On Thu, Jun 16, 2011 at 7:03 PM, Rodrigo Gomes  wrote:
> > Yes, but the point is not about generate code. Is to follow a DRY
> > principle...If I have a "multiple select list" with a specific
> > behavior,look-and-feel, with some javascript surrounding the code, etc, I
> > don't want to write this everywhere...I just want to create once and use
> it
> > anywhere...with just a line of code...
> > And I can do this easily with java through tagfiles, and sometimes
> taglibs.
> > And now with django I'm using inclusion tag as suggested by Tom.
> > The only reason that I'm not enjoying inclusion tags so much, is because
> I
> > can not pass named parameters to them...only positional. But is works
> > []'s
> > Rodrigo Gomes
> >
>
> I don't normally pass any parameters; you can instead specify that it
> should have the template context available to it instead, and then
> pull named parameters out of there.
>
> If the parameters that the inclusion template is expecting have
> different names to the ones in the context, then I just alias them
> using the {% with %} tag.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating a simple contact form

2011-06-17 Thread Ibrahim Khalil
I am sorry.I can not prepar well web design.

2011/6/17, Tiago Almeida :
> Try opening a django shell and calling send_mail by hand to see what
> exception you get (if any).
> Best Regards,
>
> On 17 Jun, 07:27, raj  wrote:
>> Hey guys,
>>
>> I have a webfaction account, and I was trying to get a contact form
>> working for my website. The problem is that I can't seem to get it to
>> work. Can someone walk me through this? I couldn't figure it out from
>> the djangobook tutorial. I think something is wrong with my settings
>> and stuff. Here are my files:
>>
>> forms.py:
>>
>> from django import forms
>>
>> class ContactForm(forms.Form):
>>     email = forms.EmailField()
>>     name = forms.CharField()
>>     subject = forms.CharField()
>>     message = forms.CharField(widget=forms.widgets.Textarea())
>>
>> views.py:
>>
>> def contact(request):
>>     if request.method == 'POST':
>>         form = ContactForm(request.POST)
>>         if form.is_valid():
>>             cd = form.cleaned_data
>>             send_mail(
>>                 cd['subject'] + " - " + cd['name'],
>>                 cd['message'],
>>                 cd.get('email', 'nore...@oneadmissions.com'),
>>                 ['i...@oneadmissions.com'],
>>             )
>>             return HttpResponseRedirect('/contact/thanks/')
>>     else:
>>         form = ContactForm()
>>     return render_to_response('/home/oneadmin/webapps/oneadmin/
>> oneadmin/templates/oneadmissions/contact.html', {'form': form},
>> context_instance=RequestContext(request))
>>
>> def thanks(request):
>>     return render_to_response('/home/oneadmin/webapps/oneadmin/
>> oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
>> We will get back to you shortly"},
>> context_instance=RequestContext(request))
>>
>> settings.py:
>>
>> EMAIL_HOST = 'smtp.webfaction.com'
>> EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
>> receives the email
>> EMAIL_HOST_PASSWORD = 'PASSWORD'
>> EMAIL_USE_TLS = True
>>
>> *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
>> SERVER_EMAIL variables, didn't do anything.
>>
>> urls.py:
>> urlpatterns = patterns('',
>>                         (r'^contact/$', views.contact),
>>                         (r'^contact/thanks/$', views.thanks),
>> )
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Helper methods like rails or taglibs/tagfiles like java

2011-06-17 Thread Tom Evans
On Fri, Jun 17, 2011 at 4:32 PM, Rodrigo Gomes  wrote:
> Hi,
> This sounds really better! But I tried it and got an error.
> What I tried to do, is to pass a string value that is not on the context,
> like this:
> {% my_tag with param_str="a string here" %}

{% with some_name_my_tag_wants=some_name tag_var2=var2 %}
{% mytag %}
{% endwith %}

NB {% with %} has different syntax in <1.3

Thinking about it, this could be made easier if there was a
standardized wrapper for parsing arguments. Less boilerplate in the
template, less boilerplate in the tag code.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating a simple contact form

2011-06-17 Thread william ratcliff
If you can wait, I use webfaction and can give you a response for what we do
when I get home late tonight--the email part was a bit annoying to
setup--the main thing is to recognize that they are using their mailbox.

Best,
William

On Fri, Jun 17, 2011 at 2:27 AM, raj  wrote:

> Hey guys,
>
> I have a webfaction account, and I was trying to get a contact form
> working for my website. The problem is that I can't seem to get it to
> work. Can someone walk me through this? I couldn't figure it out from
> the djangobook tutorial. I think something is wrong with my settings
> and stuff. Here are my files:
>
> forms.py:
>
> from django import forms
>
> class ContactForm(forms.Form):
>email = forms.EmailField()
>name = forms.CharField()
>subject = forms.CharField()
>message = forms.CharField(widget=forms.widgets.Textarea())
>
> views.py:
>
> def contact(request):
>if request.method == 'POST':
>form = ContactForm(request.POST)
>if form.is_valid():
>cd = form.cleaned_data
>send_mail(
>cd['subject'] + " - " + cd['name'],
>cd['message'],
>cd.get('email', 'nore...@oneadmissions.com'),
>['i...@oneadmissions.com'],
>)
>return HttpResponseRedirect('/contact/thanks/')
>else:
>form = ContactForm()
>return render_to_response('/home/oneadmin/webapps/oneadmin/
> oneadmin/templates/oneadmissions/contact.html', {'form': form},
> context_instance=RequestContext(request))
>
> def thanks(request):
>return render_to_response('/home/oneadmin/webapps/oneadmin/
> oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
> We will get back to you shortly"},
> context_instance=RequestContext(request))
>
> settings.py:
>
> EMAIL_HOST = 'smtp.webfaction.com'
> EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
> receives the email
> EMAIL_HOST_PASSWORD = 'PASSWORD'
> EMAIL_USE_TLS = True
>
> *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
> SERVER_EMAIL variables, didn't do anything.
>
> urls.py:
> urlpatterns = patterns('',
>(r'^contact/$', views.contact),
>(r'^contact/thanks/$', views.thanks),
> )
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating a simple contact form

2011-06-17 Thread Alex s
I´m having the same problem using Dreamhost. Have anyone this emails
settings for Dreamhost?
Regards
Alex


On Fri, Jun 17, 2011 at 1:23 PM, william ratcliff <
william.ratcl...@gmail.com> wrote:

> If you can wait, I use webfaction and can give you a response for what we
> do when I get home late tonight--the email part was a bit annoying to
> setup--the main thing is to recognize that they are using their mailbox.
>
> Best,
> William
>
>
> On Fri, Jun 17, 2011 at 2:27 AM, raj  wrote:
>
>> Hey guys,
>>
>> I have a webfaction account, and I was trying to get a contact form
>> working for my website. The problem is that I can't seem to get it to
>> work. Can someone walk me through this? I couldn't figure it out from
>> the djangobook tutorial. I think something is wrong with my settings
>> and stuff. Here are my files:
>>
>> forms.py:
>>
>> from django import forms
>>
>> class ContactForm(forms.Form):
>>email = forms.EmailField()
>>name = forms.CharField()
>>subject = forms.CharField()
>>message = forms.CharField(widget=forms.widgets.Textarea())
>>
>> views.py:
>>
>> def contact(request):
>>if request.method == 'POST':
>>form = ContactForm(request.POST)
>>if form.is_valid():
>>cd = form.cleaned_data
>>send_mail(
>>cd['subject'] + " - " + cd['name'],
>>cd['message'],
>>cd.get('email', 'nore...@oneadmissions.com'),
>>['i...@oneadmissions.com'],
>>)
>>return HttpResponseRedirect('/contact/thanks/')
>>else:
>>form = ContactForm()
>>return render_to_response('/home/oneadmin/webapps/oneadmin/
>> oneadmin/templates/oneadmissions/contact.html', {'form': form},
>> context_instance=RequestContext(request))
>>
>> def thanks(request):
>>return render_to_response('/home/oneadmin/webapps/oneadmin/
>> oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
>> We will get back to you shortly"},
>> context_instance=RequestContext(request))
>>
>> settings.py:
>>
>> EMAIL_HOST = 'smtp.webfaction.com'
>> EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
>> receives the email
>> EMAIL_HOST_PASSWORD = 'PASSWORD'
>> EMAIL_USE_TLS = True
>>
>> *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
>> SERVER_EMAIL variables, didn't do anything.
>>
>> urls.py:
>> urlpatterns = patterns('',
>>(r'^contact/$', views.contact),
>>(r'^contact/thanks/$', views.thanks),
>> )
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating a simple contact form

2011-06-17 Thread raj
Thanks, I tried the shell thing above. It says that it sends without
error, but I still dont receive any emails. Thank you
-Raj

On Jun 17, 12:23 pm, william ratcliff 
wrote:
> If you can wait, I use webfaction and can give you a response for what we do
> when I get home late tonight--the email part was a bit annoying to
> setup--the main thing is to recognize that they are using their mailbox.
>
> Best,
> William
>
>
>
>
>
>
>
> On Fri, Jun 17, 2011 at 2:27 AM, raj  wrote:
> > Hey guys,
>
> > I have a webfaction account, and I was trying to get a contact form
> > working for my website. The problem is that I can't seem to get it to
> > work. Can someone walk me through this? I couldn't figure it out from
> > the djangobook tutorial. I think something is wrong with my settings
> > and stuff. Here are my files:
>
> > forms.py:
>
> > from django import forms
>
> > class ContactForm(forms.Form):
> >    email = forms.EmailField()
> >    name = forms.CharField()
> >    subject = forms.CharField()
> >    message = forms.CharField(widget=forms.widgets.Textarea())
>
> > views.py:
>
> > def contact(request):
> >    if request.method == 'POST':
> >        form = ContactForm(request.POST)
> >        if form.is_valid():
> >            cd = form.cleaned_data
> >            send_mail(
> >                cd['subject'] + " - " + cd['name'],
> >                cd['message'],
> >                cd.get('email', 'nore...@oneadmissions.com'),
> >                ['i...@oneadmissions.com'],
> >            )
> >            return HttpResponseRedirect('/contact/thanks/')
> >    else:
> >        form = ContactForm()
> >    return render_to_response('/home/oneadmin/webapps/oneadmin/
> > oneadmin/templates/oneadmissions/contact.html', {'form': form},
> > context_instance=RequestContext(request))
>
> > def thanks(request):
> >    return render_to_response('/home/oneadmin/webapps/oneadmin/
> > oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
> > We will get back to you shortly"},
> > context_instance=RequestContext(request))
>
> > settings.py:
>
> > EMAIL_HOST = 'smtp.webfaction.com'
> > EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
> > receives the email
> > EMAIL_HOST_PASSWORD = 'PASSWORD'
> > EMAIL_USE_TLS = True
>
> > *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
> > SERVER_EMAIL variables, didn't do anything.
>
> > urls.py:
> > urlpatterns = patterns('',
> >                        (r'^contact/$', views.contact),
> >                        (r'^contact/thanks/$', views.thanks),
> > )
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Forwarding to different domain after authentication

2011-06-17 Thread Alexandros Diamantidis
Hello!

I'd like to unify authentication of a MediaWiki instance with a
Django site using django.contrib.auth with the following plugin:

https://bitbucket.org/pythonian4000/django-mediawiki-authentication-by-user-id/

It works fine, but I hit a small snag due to the wiki and the main site
being on different domains (say, www.example.com and wiki.example.com).
The MediaWiki auth plugin gets users to the Django login form like
this...

http://www.example.com/accounts/login/?next=http://wiki.example.com/wiki/Main_Page

... but the auth app doesn't like "next" pointing to a differt domain and
ignores it. I got it to work with the following patch to Django:

--- django/contrib/auth/views.py~   2011-06-13 21:20:18.0 +0300
+++ django/contrib/auth/views.py2011-06-13 21:57:27.0 +0300
@@ -41,7 +41,8 @@
 
 # Security check -- don't allow redirection to a different
 # host.
-elif netloc and netloc != request.get_host():
+elif (netloc and netloc != request.get_host() and
+ netloc not in settings.LOGIN_REDIRECT_WHITELIST):
 redirect_to = settings.LOGIN_REDIRECT_URL
 
 # Okay, security checks complete. Log the user in.

I'm not very confortable doing this, though. Is there a better way?

Thanks for any help!

Alexandros

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Django on IIS7 With Windows Server 2008 R2

2011-06-17 Thread Lurton, David
Yaroslav,

So far our experiences have been great!  Thanks for this making this
tool.  Do you know when it will be out of beta and what the price will
be when it's purchasable?

Also, does this beta version have any kind of expiration?  We know it's
beta and not production ready every options that we've tried so far
experienced so far (configuration of PyISAPI, FastCGI, and isapi_wsgi)
has terrible documentation and no automated installation or is simply
out of date and doesn't work with Django 1.3.  With zoo however we had
our (3rd party) Django application working within  a day.  

We would have deployed this on a Linux box but unfortunately our
operations team's only core competency is with Windows.  We were working
for a week with the other three options, so the timing of your beta
release was quite serendipitous indeed!  

Thanks again,
-David Lurton

-Original Message-
From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Yaroslav Govorunov
Sent: Friday, June 17, 2011 6:19 AM
To: Django users
Subject: Re: Django on IIS7 With Windows Server 2008 R2

Hello David.

> Before I go any further with Django under IIS, I would like to ask the

> community what their recommendation is for running Django under IIS?
> What "glue" is preferred for connecting Django 1.3, Python 2.7.1 and 
> IIS on Windows Server 2008 R2?

Just two days ago I posted a message. Please take a look:
http://www.helicontech.com/zoo/
Please share your experience with us as we really appreciate your
feedback.

Yaroslav Govorunov,
Helicon Tech
http://www.helicontech.com

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Single auth database for multiple (different) django projects

2011-06-17 Thread Cal Leeming [Simplicity Media Ltd]
Okay. If you want to have multiple webapps authenticating off a single user
base, then you will need to either:


   - Expose a server side authentication system (basically your own mini
   network of OpenID)
   - Merge all the sites into a single Django webapp.


If you have a look through the mailing list archives, you will see someone
else who had a similar issue, and I explained to them how to properly handle
"cross domain handoffs".

http://www.mail-archive.com/django-users@googlegroups.com/msg120598.html

Let me know if this helps answer your question.

Cal

On Thu, Jun 16, 2011 at 10:59 PM, DK  wrote:

>
>
> On Thursday, June 16, 2011 2:38:52 PM UTC+2, SleepyCal wrote:
>>
>>
>> Having a central authorization point is the way forward. I'm a bit
>> confused by this comment though:
>>
>> "But this still do not solve problem of NOT having multiple accounts in
>> several django projects"
>>
>> Could you explain what you mean?
>>
>
> As far as I know, using authorization like Google Account, Facebook or
> OpenID just makes that user has an auto generated account in Django
> connected with external account (for example Google Account). So still - you
> bypass only the fact of logging, but storing/editing user profile, some
> other additional data is complicated and involves using this auto-generated
> accounts in django.
>
>
> I hope  you get my point.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8qBkZkMn5E0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: When to use a model property vs. method?

2011-06-17 Thread Micky Hulse
Hi Tom and Bruno! Thank you so much for your pro help and assistance.
I really appreciate it. :)

Replying to both of you in this one e-mail... See inline replies below.

On Fri, Jun 17, 2011 at 1:42 AM, Tom Evans  wrote:
> Access it with MyModel.SEPARATOR or my_model_instance.SEPARATOR

Ahhh, I see now. Thanks for the clarification!

I now plan on re-factoring my simple "category/sub-category" model:

https://gist.github.com/1031882

> ..
> list of proper objects in every different place. Instead, I supply a
> property that serializes/deserializes the data as needed.

Awesome. That's a good description.

I have a few spots in my latest app that needs this type of
functionality, I will be sure to use property().

Not to state the obvious, but I just learned/realized that the
property decorator is Python 2.4's version of foo =
property(get_foo)... For some reason, up until now, I was under the
assumption that the property decorator was a Django thing! :D

> ..
> The behaviour is now dynamic, but any old code using
> instance.SEPARATOR will get still work, and use the new dynamic
> definition.

Ooh, that is interesting too! Thank you for the explanations and code
examples, that really helps clear things up for me. :)

On Fri, Jun 17, 2011 at 3:18 AM, bruno desthuilliers
 wrote:
> Python's object model is a bit peculiar (wrt/ most OOPLs at least),
> and I won't start to explain it here (this would require a full book
> FWIW).

Hehe!

Yah, you know, I am one of those few folks that learned (er, is
learning) Django before getting to know Python...

:: hangs head in shame ::

I am planning on spending a few upcoming weekends reading through the
online version of Dive into Python. :)

> To make a long story short, you have class and instance
> attributes, and since a small code snippet can say more than a
> thousand words:
> ..
>   # this is a class method
>   @classmethod
>   def yuu(cls):
>   print "%s.yuu" % cls

Oh, perfect! That really helps clarify things! Thanks for the code example. :)

I have never used the @classmethod decorator before. I will have to
read up on that one.

Looks like there's also @staticmethod... Interesting stuff! Thanks!

>> I am guessing that attribute = property
> Nope. "property" is a builtin Python class that implements the
> descriptor protocol and give support for simple computed attributes.

Ahh, I see now! Thanks for the clarification.

> ..
> you can transparently turn it
> into a computed one later if needed so no need to waste time with
> getters/setters.

Awesome! I get it now. :)

> ..
> wrt/ "public/private", there's no such thing in Python anyway. The
> (*very* strong) convention is to prefix implementation stuff with a
> single leading underscore which means "don't touch or your on your own
> if something breaks", but nothing prevents client code to mess with
> some object's internals.

I am reminded of a sidebar that I read in the Dive Into Python book:

"There are no constants in Python. Everything can be changed if you
try hard enough. This fits with one of the core principles of Python:
bad behavior should be discouraged but not banned. If you really want
to change the value of None, you can do it, but don't come running to
me when your code is impossible to debug."
-- 

... specifically, that last two sentences! :)

> Mostly, yes - with the exception that since Python can let you turn a
> plain attribute into a computed one without breaking client code, you
> don't have to use getters / setters "just in case" - you only use them
> if and when needed, and encapsulate them into a property (or a custom
> descriptor) so the client code don't have to care.

That's a great explanation. Thanks!

> Well, I usually redirect this kind of questions to c.l.py, since it's
> about Python and not Django...

I have not hear of c.l.py... I assume that it is a Python listserv?
Googling now. :)

I am a member of the Google Python group, but I am not a huge fan of
digest e-mails... I would love to find a python list that allowed for
e-mail for every message.

> Warning: this (and metaclasses) can be a bit mind-bending at first,
> and tend to become highly addictive once you get it ;)
> If I may suggest another related reading:
> http://wiki.python.org/moin/FromFunctionToMethod

Ooooh, interesting! Thanks for the linkage! Much appreciated.

Looks like my weekend is going to be full of pure python coding!

Also, thanks for pointing towards the wiki:

http://wiki.python.org/

That site looks useful.

> FWIW, Django relies quite a lot on metaclasses and descriptors for the
> ORM part.

Good to know. All of this information will give me stuff to research
over then next several weeks.

Thanks again Tom and Bruno! You folks ROCK! :D

I owe you one.

Have a nice day.

Cheers,
Micky

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to t

Re: Django on IIS7 With Windows Server 2008 R2

2011-06-17 Thread Yaroslav Govorunov
David,

I am glad to hear it helped you!
Helicon Zoo is free, we are not planning to sell it (thus any help in
promotion, like blogging, liking, etc. is greatly appreciated).
This beta version has no trial limitations.
As for ETA, well, it works and for us it is quite stable, but we need
to collect more real user experience data to declare release. So as
more users will know about it and will give it a try the faster we can
grow from beta version.

Thank you for your feedback!


Yaroslav Govorunov,
Helicon Tech
http://www.helicontech.com


On Jun 17, 8:24 pm, "Lurton, David" 
wrote:
> Yaroslav,
>
> So far our experiences have been great!  Thanks for this making this
> tool.  Do you know when it will be out of beta and what the price will
> be when it's purchasable?
>
> Also, does this beta version have any kind of expiration?  We know it's
> beta and not production ready every options that we've tried so far
> experienced so far (configuration of PyISAPI, FastCGI, and isapi_wsgi)
> has terrible documentation and no automated installation or is simply
> out of date and doesn't work with Django 1.3.  With zoo however we had
> our (3rd party) Django application working within  a day.  
>
> We would have deployed this on a Linux box but unfortunately our
> operations team's only core competency is with Windows.  We were working
> for a week with the other three options, so the timing of your beta
> release was quite serendipitous indeed!  
>
> Thanks again,
> -David Lurton
>
>
>
> -Original Message-
> From: django-users@googlegroups.com
>
> [mailto:django-users@googlegroups.com] On Behalf Of Yaroslav Govorunov
> Sent: Friday, June 17, 2011 6:19 AM
> To: Django users
> Subject: Re: Django on IIS7 With Windows Server 2008 R2
>
> Hello David.
>
> > Before I go any further with Django under IIS, I would like to ask the
>
> > community what their recommendation is for running Django under IIS?
> > What "glue" is preferred for connecting Django 1.3, Python 2.7.1 and
> > IIS on Windows Server 2008 R2?
>
> Just two days ago I posted a message. Please take a 
> look:http://www.helicontech.com/zoo/
> Please share your experience with us as we really appreciate your
> feedback.
>
> Yaroslav Govorunov,
> Helicon Techhttp://www.helicontech.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django and Rich Client

2011-06-17 Thread Marwan Al-Sabbagh
thats pretty amazing that PyQt can handle such a big dataset at once.
Putting JavaScript aside just trying to load html tables with a large amount
of rows can become very unwieldy. Good luck with the app.

cheers,
Marwan

On Fri, Jun 17, 2011 at 5:55 PM, Knack  wrote:

> The requirements are:
>
> 1) Handling large (>10 lines, ~ 10 columns) amounts of structured
> data in treeviews. For certain use cases comparing two of those trees.
> 2) Creating different structured views on the data. Like using
> different categories of attributes as structure criteria. Those views
> are not persistent.
> 3) Performing filter and configuration operations on the data. Those
> can be quite expensive, for example variant configuration which comes
> down to evaluating boolean expressions for each item.
> 4) Maybe (if there's time and I find an easy to use lib, maybe
> Panda3D) adding a simple 3D viewer.
>
> The decision has been made without really evaluation JavaScript or
> Flash. I must admit that I don't know wether the state of the art JS
> libraries can handle that large trees. But I know that PyQt can handle
> that large data amazingly well. Further, I have some experience with
> these kind of systems: Most of them are quite "server-centric" (as
> common web apps are). Those systems have all performance issues when
> the user needs another view or configuration of the data. My approach
> is to eagerly load all the data to the client and do all calculations
> for the views there. I must add that it's an in-house app and all
> users have proper PCs.
>
> Lastly, Personal experience and know-how: PyQt is fun to work with
> (after some learning curve, of course). It has style-sheets for making
> the client sexy at the end. On the other hand, I'm totally impressed
> what can be done with JS, but I'm not familiar with it.
>
> Cheers,
>
> Jan
>
>
>
> On 17 Jun., 06:26, Marwan Al-Sabbagh 
> wrote:
> > Out of curiosity is there a specific need for running a rich client
> instead
> > of just accessing the system app through a web browser.
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Jun 10, 2011 at 4:16 AM, Ovnicraft  wrote:
> > > soaplib 
> >
> > > On Thu, Jun 9, 2011 at 1:10 PM, Knack  wrote:
> >
> > >> Hi guys,
> >
> > >> I've got a prototype DB + Rich Client app and need to make a proper
> > >> production app out of it. The client is written in PyQt and needs to
> > >> fullfill quite some functional and performance requirements (I would
> > >> really like to keep it). The client connects directly to the DB.
> >
> > >> After some thoughts about security I came to the conclusion that using
> > >> django is the way to go. Now I seek some coarse advice / feedback
> > >> wether I'm heading in the right directions. I've got some miles to go
> > >> and looking forward to learning Django, but want to avoid newbie
> > >> pitfalls. So if something of the following sounds like bad ideas to
> > >> you, please let me know ;-).
> >
> > >> Current plans are:
> >
> > >> 1) Using an Oracle DB
> > >> 2) LDAP authentification
> > >> 3) Role based authorisation. Here I'm a bit unsure about the approach.
> > >> I would implement it by myself within the django world (don't know yet
> > >> where exactly).
> > >> 4) Transfering the data using a web service via https. Here are my
> > >> biggest uncertainties. What kind of web service to use? Rest, xml-rpc
> >
> > > I recommend you REsT, IMHO XML-RPC is not fast, SOAP is a good option
> but
> > > we get just few libraries under development soaplib[1]  is really
> promise.
> >
> > > or soap? How to package the acual data? Embedded in the html or xml?
> >
> > > Just be light.
> >
> > > Regards,
> >
> > > As binary payload? I would need only basic stuff like log in, log out,
> > >> read and write whole database rows, which are basically the business
> > >> objects. Most of the logic is done on the rich client. I would
> > >> transfer large amounts (10s of business objects) of data at
> > >> startup time (very eager loading to the client). But also lazy loading
> > >> of course.
> > >> 5) One important concept is that I change only a small amount of the
> > >> data objects. Most of the changes lead to new versions. Therefore I
> > >> hope to be able to use caching extensivly. The data objects which are
> > >> immutable could be permanently cached in memory. How about
> > >> authorisation of these cached objects? Are there ways django takes
> > >> care of this?
> >
> > >> A long first post ;-). Any comments are appreciated!
> >
> > >> Cheers,
> >
> > >> Jan
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Django users" group.
> > >> To post to this group, send email to django-users@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> django-users+unsubscr...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > 

registering unzipped files on the local disk

2011-06-17 Thread Faheem Mitha


Hi,

Can anyone help me with

http://stackoverflow.com/questions/6386062/django-registering-unzipped-files-on-the-local-disk

?

If you reply via email, please cc me. Thanks.

 Regards, Faheem.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Forwarding to different domain after authentication

2011-06-17 Thread Alexandros Diamantidis
* To django-users@googlegroups.com [2011-06-17 19:34]:
> ... but the auth app doesn't like "next" pointing to a differt domain and
> ignores it. I got it to work with the following patch to Django:

Ok, I solved the problem without a patch by checking in my view if a
redirect exception is required...

netloc = urlparse.urlparse(next)[1]
if (netloc and netloc != request.get_host() and
netloc in settings.LOGIN_REDIRECT_WHITELIST):
redirect_exception = next

... and if so, modifying the login() response:

response = login(...)
if redirect_exception and isinstance(response, HttpResponseRedirect):
   return HttpResponseRedirect(redirect_exception)
return response

Should have thought a bit more before posting, I guess.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Help with Templates and ljust

2011-06-17 Thread Chris McComas
I have this as my template code:

http://dpaste.com/555651/

This is the HTML it is outputting, which makes sense. What I'm trying
to do is make it so the closing  tag is right after the team name
and the whitespace from the ljust after it.

http://dpaste.com/555649/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help with Templates and ljust

2011-06-17 Thread Chris McComas
Figured it out. Added this to my Model:

@property
def spacer(self):
return (25-len(str(self.team.name)))*' '

then in my template just added {{ team.spacer }}



On Jun 17, 7:17 pm, Chris McComas  wrote:
> I have this as my template code:
>
> http://dpaste.com/555651/
>
> This is the HTML it is outputting, which makes sense. What I'm trying
> to do is make it so the closing  tag is right after the team name
> and the whitespace from the ljust after it.
>
> http://dpaste.com/555649/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Proper way to reuse django's built-in admin javascript in my own templates (outside admin)?

2011-06-17 Thread br
Hi,

I am using inline fromsets in my own custom forms and would like to
reuse the same functionality that is provided django admin's
inlines.js, particularly the add row button functionality, in order to
add rows to my own inline formsets, similarly as is done in django's
admin.  What is the proper way to reference these files?

Should I copy the files into my own static directory, or should i just
include {{STATIC_URL}}/admin/js/inlines.min.js in my template.  Or
something else?

Seems like i've seen it recommended either way.  is either way the
correct way of doing it?

Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[Forms] Avoiding Repetition

2011-06-17 Thread Nikhil Somaru
Hi,

Is there a way to reduce the repetition in the following form classes:

class ItemsStep2(ModelForm): #approval
class Meta:
model = OrderItem
fields = ('item', 'quantity_requested', 'quantity_approved')
widgets = {
'quantity_requested': TextInput(attrs={'readonly':'readonly'})
 }


class ItemsStep3(ModelForm): #ship
class Meta:
model = OrderItem
fields = ('item', 'quantity_requested', 'quantity_approved')
widgets = {
'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
'quantity_approved': TextInput(attrs={'readonly':'readonly'})
 }


class ItemsStep4(ModelForm): #confirm receipt
class Meta:
model = OrderItem
fields = ('item', 'quantity_requested', 'quantity_approved',
'quantity_received')
widgets = {
'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
'quantity_approved': TextInput(attrs={'readonly':'readonly'})
 }


class ItemsStep5(ModelForm): #order summary
class Meta:
model = OrderItem
fields = ('item', 'quantity_requested', 'quantity_approved',
'quantity_received')
widgets = {
'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
'quantity_approved': TextInput(attrs={'readonly':'readonly'}),
'quantity_received': TextInput(attrs={'readonly':'readonly'}),
 }

The model that uses these forms has a ForeignKey (Order hasMany OrderItems)
to an associated model that has a attribute "step" (order_instance.step)
which determines the class above to use (this code is in views)

Thanks in advance.
-- 
Yours,
Nikhil Somaru

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating a simple contact form

2011-06-17 Thread william ratcliff
Hi Raj,

It sounds like your problem is email, rather than the form.   In our
settings.py we use:

EMAIL_USE_TLS= True
EMAIL_HOST='smtp.webfaction.com'
EMAIL_HOST_USER=''
EMAIL_HOST_PASSWORD=r' wrote:

> Thanks, I tried the shell thing above. It says that it sends without
> error, but I still dont receive any emails. Thank you
> -Raj
>
> On Jun 17, 12:23 pm, william ratcliff 
> wrote:
> > If you can wait, I use webfaction and can give you a response for what we
> do
> > when I get home late tonight--the email part was a bit annoying to
> > setup--the main thing is to recognize that they are using their mailbox.
> >
> > Best,
> > William
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Jun 17, 2011 at 2:27 AM, raj  wrote:
> > > Hey guys,
> >
> > > I have a webfaction account, and I was trying to get a contact form
> > > working for my website. The problem is that I can't seem to get it to
> > > work. Can someone walk me through this? I couldn't figure it out from
> > > the djangobook tutorial. I think something is wrong with my settings
> > > and stuff. Here are my files:
> >
> > > forms.py:
> >
> > > from django import forms
> >
> > > class ContactForm(forms.Form):
> > >email = forms.EmailField()
> > >name = forms.CharField()
> > >subject = forms.CharField()
> > >message = forms.CharField(widget=forms.widgets.Textarea())
> >
> > > views.py:
> >
> > > def contact(request):
> > >if request.method == 'POST':
> > >form = ContactForm(request.POST)
> > >if form.is_valid():
> > >cd = form.cleaned_data
> > >send_mail(
> > >cd['subject'] + " - " + cd['name'],
> > >cd['message'],
> > >cd.get('email', 'nore...@oneadmissions.com'),
> > >['i...@oneadmissions.com'],
> > >)
> > >return HttpResponseRedirect('/contact/thanks/')
> > >else:
> > >form = ContactForm()
> > >return render_to_response('/home/oneadmin/webapps/oneadmin/
> > > oneadmin/templates/oneadmissions/contact.html', {'form': form},
> > > context_instance=RequestContext(request))
> >
> > > def thanks(request):
> > >return render_to_response('/home/oneadmin/webapps/oneadmin/
> > > oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
> > > We will get back to you shortly"},
> > > context_instance=RequestContext(request))
> >
> > > settings.py:
> >
> > > EMAIL_HOST = 'smtp.webfaction.com'
> > > EMAIL_HOST_USER = 'i...@oneadmissions.com' #the email account that
> > > receives the email
> > > EMAIL_HOST_PASSWORD = 'PASSWORD'
> > > EMAIL_USE_TLS = True
> >
> > > *I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
> > > SERVER_EMAIL variables, didn't do anything.
> >
> > > urls.py:
> > > urlpatterns = patterns('',
> > >(r'^contact/$', views.contact),
> > >(r'^contact/thanks/$', views.thanks),
> > > )
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem with CheckboxSelectMultiple and ManyToManyField with Modelform

2011-06-17 Thread Abhishek Tiwari
Hi Everyone,
I am quite new to Django(4months actually), I am struggling with this
problem for last 2 days, I think I am making some stupid mistake. Any
help or input is highly appreciated. I am using Django 1.3, so old
(1.1 -) solutions are not helpful much actually there are many on
stack-overflow.


In the model I have,

BUSINESS_GROUP = (
('MNC','Multinational'),
('INT','International (Export/Import)'),
('DOM','Domestic/National'),
('LOC','Local'),
('VIR','Virtual'),
)

class BusinessGroup(models.Model):
bgroup_type = models.CharField(max_length=15, choices =
BUSINESS_GROUP, blank = True, null = True)

class Business(models.Model):
business_group_choices = models.ManyToManyField(BusinessGroup,
verbose_name= "Business Group")

In Form I am doing like,

def __init__(self, *args, **kwargs):
self.fields['business_group_choices'].widget =
forms.CheckboxSelectMultiple(choices=BUSINESS_GROUP)

My view looks like,
   if request.method == 'POST':
form = BusinessForm(request.POST, instance = business)
#print request
#print form
if form.is_valid():
new_business = form.save(commit=False)
new_business.created_by = request.user
new_business.is_blocked=False
form_values = form.cleaned_data
new_business.save()
assign('edit_business', request.user, new_business)
return
HttpResponseRedirect(new_business.get_absolute_url())

I am getting error like this,

"DOM" is not a valid value for a primary key.
"INT" is not a valid value for a primary key.

etc.

I found source of error here in Django model source,
http://www.java2s.com/Open-Source/Python/Web-Frameworks/Django/django/forms/models.py.htm

But not clear how to interpret and workout this problem.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Stuck on "ViewDoesNotExist" last step of tutorial part 4

2011-06-17 Thread TuckFrance
I am using Django 1.3 with SQlite. I got through the entire tutorial
except the last step of part 4.

It says "You can now delete the index(), detail() and results() views
from polls/views.py. We don't need them anymore -- they have been
replaced by generic views."

However when I do this I get the following error:

Environment:


Request Method: POST
Request URL: http://localhost:8000/polls/1/vote/

Django Version: 1.3
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'polls',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "c:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "C:\Documents and Settings\ask\Desktop\Stream Coding Project
\Django First Tutorial\mysite\polls\views.py" in vote
  24. return HttpResponseRedirect(reverse('poll_results',
args=(p.id,)))
File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
reverse
  391. *args, **kwargs)))
File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
reverse
  312. possibilities = self.reverse_dict.getlist(lookup_view)
File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_reverse_dict
  229. self._populate()
File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_populate
  220. lookups.appendlist(pattern.callback, (bits,
p_pattern))
File "c:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_callback
  170. raise ViewDoesNotExist("Tried %s in module %s.
Error was: %s" % (func_name, mod_name, str(e)))

Exception Type: ViewDoesNotExist at /polls/1/vote/
Exception Value: Tried results in module polls.views. Error was:
'module' object has no attribute 'results'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



contribute_to_class and the admin site

2011-06-17 Thread raj
Hey guys,

I want to find an easy way to expand fields in the User model. I'm not
quite understanding the tutorial where I need to create a model from a
new app. I heard that there is a function called contribute_to_class.
This is what my model.py file looks like:

from django.db import models
from django.contrib.auth.models import User

skype_field = models.CharField(max_length=32)
skype_field.contribute_to_class(User, 'skype_field')

The problem is that my admin site doesn't show these changes and I
don't know why. Is this file even doing anything? When I run the
sqlall over the app, nothing shows up, so I feel like nothing is
happening.
Also, if I were to now create an object and set its skype field, would
it be something like:

u = User.object.create...
u.skype_field = "blah"

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Alternate user fields

2011-06-17 Thread raj
Hey guys,

I've been trying to figure out how to add more fields in the auth user
part of django. I looked through dozens of tutorials, and tried a lot
of things to no avail.
I simply ask this,
If a user were to sign up on my site, and he/she was required to
insert a skype SN, aim SN, etc.. How would one go about doing so?

I attempted to add fields into the User profile in the admin site, but
i couldn't do so. Would it be better to create an app that handles
this part (a new table), and it shares a relation with the auth user?
Thank you.
-Raj

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with CheckboxSelectMultiple and ManyToManyField with Modelform

2011-06-17 Thread Abhishek Tiwari
I tried making fields null=True and/or blank=True still I get the
validation error, why?

With some changes on the whole set-up I got this new error,

Select a valid choice. [u'MNC', u'INT', u'DOM', u'LOC', u'VIR'] is
not one of the available choices.

New setup:
In the model

class BusinessGroup(models.Model):
bgroup_type = models.CharField(max_length=15)

class Business(models.Model):
business_group_choices = models.ManyToManyField(BusinessGroup,
verbose_name= "Business Group", choices=BUSINESS_GROUP)

In Form I have something like,

def __init__(self, *args, **kwargs):
super(BusinessForm, self).__init__(*args, **kwargs)
self.fields['business_group_choices'].widget =
forms.CheckboxSelectMultiple(choices=BUSINESS_GROUP)

I am not sure which is correct approach, I am sorry to say but this is
first I am stuck with poor documentation of Django.
Please!! Any input is greatly appreciated

cheers
Abhishek


On Jun 18, 12:17 pm, Abhishek Tiwari  wrote:
> Hi Everyone,
> I am quite new to Django(4months actually), I am struggling with this
> problem for last 2 days, I think I am making some stupid mistake. Any
> help or input is highly appreciated. I am using Django 1.3, so old
> (1.1 -) solutions are not helpful much actually there are many on
> stack-overflow.
>
> In the model I have,
>
> BUSINESS_GROUP = (
>     ('MNC','Multinational'),
>     ('INT','International (Export/Import)'),
>     ('DOM','Domestic/National'),
>     ('LOC','Local'),
>     ('VIR','Virtual'),
> )
>
> class BusinessGroup(models.Model):
>     bgroup_type = models.CharField(max_length=15, choices =
> BUSINESS_GROUP, blank = True, null = True)
>
> class Business(models.Model):
>     business_group_choices = models.ManyToManyField(BusinessGroup,
> verbose_name= "Business Group")
>
> In Form I am doing like,
>
> def __init__(self, *args, **kwargs):
>     self.fields['business_group_choices'].widget =
> forms.CheckboxSelectMultiple(choices=BUSINESS_GROUP)
>
> My view looks like,
>    if request.method == 'POST':
>         form = BusinessForm(request.POST, instance = business)
>         #print request
>         #print form
>         if form.is_valid():
>             new_business = form.save(commit=False)
>             new_business.created_by = request.user
>             new_business.is_blocked=False
>             form_values = form.cleaned_data
>             new_business.save()
>             assign('edit_business', request.user, new_business)
>             return
> HttpResponseRedirect(new_business.get_absolute_url())
>
> I am getting error like this,
>
> "DOM" is not a valid value for a primary key.
> "INT" is not a valid value for a primary key.
>
> etc.
>
> I found source of error here in Django model 
> source,http://www.java2s.com/Open-Source/Python/Web-Frameworks/Django/django...
>
> But not clear how to interpret and workout this problem.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.