Re: Models: Referencing A Model In Another App and Different Project

2012-07-29 Thread Derek
As a general remark related to the issues that JJ has described... are 
there perhaps - or rather, should there be - pointers from the Django site 
that discuss some good practices to the overall approach of designing and 
building sites/projects/apps/databases - as opposed to the technical 
nitty-gritty of mode/view/form construction?

It seems there are an increasing number of "newbies" flocking to Django, 
with perhaps little or no background in CS fundamentals, and guidelines 
like these would be a good place to point them at!


On Thursday, 26 July 2012 03:12:09 UTC+2, JJ Zolper wrote:
>
> Hello fellow Django developers, 
>
> So here is my model that interfaces with my Artists database: 
>
>
>
> from django.db import models 
>
> class Artist(models.Model): 
>   name = models.CharField(max_length=30) 
>   genre = models.CharField(max_length=30)  
>   city = models.CharField(max_length=30)  
>   state = models.CharField(max_length=30)  
>   country = models.CharField(max_length=30) 
>   website = models.UrlField() 
>
>   def __unicode__(self): 
> return self.name 
>
>
>
> Okay now that you see my database backend interface here's where I'm going 
> next. 
>
> I've been working with GeoDjango for some time now. I've created an app 
> within my GeoDjango project called "discover". What's my goal? Well, I want 
> this app to be able to return information to my users. This app will take 
> the given parameters such as "locationfrom" (the user of the website 
> inserts their city, state) and then that value is used to bring in the 
> artists in their area in relation to the variable "requesteddistance" 
> (which for example could be 25 mi) along with another variable "genre" (a 
> query on the artists). So the picture is the user might say I want to see 
> all the "Rock" artists "25 mi" from me in "Vienna, VA". 
>
> Now that you can see my project here, here is my question. 
>
> In my discover app in the models.py file I could use some help. Through 
> this discover app I want to be able to reference the Artists database. As 
> you can see from above the 
> models.py file has the fields to establish an Artist and their 
> information. Thus, when a request comes in to the discover app I want to be 
> able to calculate the requested information and return that. Here's where 
> I'm stuck...  
>
> In my mind I feel that the appropriate way to do this is to basically 
> create some sort of ForeignKey in the models.py of discover to the 
> models.py of Artist? That way I don't have to have two databases of the 
> same data but can simply reference the Artist database from the discover 
> app. 
>
> Another idea I had was instead of creating a "field" link between the two 
> to try to import the Artist class from the models.py to the models.py file 
> of the discover app? Then from my views.py file in discover I can process 
> the given information referenced and return the result. 
>
> Any input is welcome. I am striving to use Django's DRY (Don't Repeat 
> Yourself) methodolgy and try to reference the Artist database and do the 
> actual processing in the discover application. 
>
> Thanks a lot for your advice, 
>
> JJ Zolper 
>
>

-- 
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/-/Yj1aeD50hX0J.
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: Is this possible using the Django ORM without raw SQL?

2012-07-29 Thread sbrandt
Yes, it sure isn't a one-to-one relationship technically, but maybe "weak" 
one-to-one relationships using a special type-field are an interesting 
approach. On the other hand, I don't know how much use cases there are for 
such a relation.

In all cases, this would need a change to the database backend using outer 
joins, doesn't it? So my problem isn't likely to be solved more elegant in 
the near future. Thanks for all! :)

Am Samstag, 28. Juli 2012 23:15:37 UTC+2 schrieb akaariai:
>
> On 28 heinä, 15:39, sbrandt  wrote: 
> > > On 28 heinä, 12:20, sbrandt  wrote: 
> > > > Hello, 
> > 
> > > > for the first time ever how to compile a query with the Django ORM 
> :/ 
> > 
> > > > There are two Models: The second model has a foreign key to the 
> first 
> > > model 
> > > > and a type, where the combination of "first model and second model's 
> > > type" 
> > > > is unique. Let's say type 1 are dogs, type 2 are cats and every 
> model1 
> > > can 
> > > > only have 0 or 1 dogs and cats. I know that it could have been 
> > > implemented 
> > > > as two seperate tables without types and one-to-ones, but I need to 
> > > query 
> > > > the whole model2 often and it's implemented in this way since years. 
> > 
> > > > This is not a problem for single model1 objects, since it's just a 
> > > second 
> > > > objects.get(...)-call as a lazy property in the model1. 
> > 
> > > > But now I need a query for *all* model1-objects with two additional 
> > > > columns: Has this model1 a cat, has this model1 a dog? 
> > 
> > > > Here's some code (Just pseudocode - doesn't work! My actual models 
> would 
> > > be 
> > > > too complicated): 
> > 
> > > > class Model1(Model): 
> > > > name = CharField(...) 
> > 
> > > > m2types = (cats, dogs) 
> > 
> > > > class Model2(Model) 
> > > > m1 = ForeignKey(Model1) 
> > > > type = SmallIntegerField(..., choices=m2types) 
> > > > class Meta: 
> > > > unique_together = ('m1', 'type') 
> > 
> > > > In SQL I would do it with left outer joins: 
> > 
> > > > SELECT m1.id, m1.name, c.id, d.id 
> > > > FROM model1 AS m1 
> > > > LEFT OUTER JOIN model2 AS c ON c.m1_id = m1.id AND c.type = 1 
> > > > LEFT OUTER JOIN model2 AS d ON d.m1_id = m1.id AND d.type = 2; 
> > 
> > > > So, back to my questsion: Is this possible with the Django ORM 
> without 
> > > > using raw SQL? 
> > 
> > > > Note: Speed is not important. Since it is a cronjob being done half 
> a 
> > > year 
> > > > and my models are just hundrets, iterating over every model1 and 
> using 
> > > the 
> > > > lazy property cat and dog would be okay, and also using raw SQL 
> would be 
> > > > okay since I'm tied to PostgreSQL. I'm explicitly searching for an 
> > > elegant 
> > > > solution with the Django ORM. 
> > 
> > > Hmmh, so you want to fetch every object, and "annotate" the 
> > > information about having a dog or a cat in the original model. I don't 
> > > think that can be done, although there might be some trick for this. 
> > 
> > > What you could do is use the prefetch_related() method, and then do 
> > > the annotation in Python code. 
> > 
> > > Something like this: 
> > > objs = Model1.objects.prefetch_related('model2_set') 
> > 
> > > And in model1 you could have two properties, has_cat and has_dog 
> > 
> > > class Model1: 
> > > ... 
> > > def _has_dog(self): 
> > > return any(obj for obj in self.model2_set if obj.type == DOG) 
> > > has_dog = property(_has_dog) 
> > > ... 
> > 
> > > While this isn't elegant it gets the work done... If you need to 
> > > filter or do something else in the ORM with the has_dog information, 
> > > you will not be able to do this using the above idea. 
> > 
> > > Django's ORM can be somewhat hard to use when working with reverse 
> > > foreign key data. There is room to improve the annotation mechanism of 
> > > Django. I hope the situation will improve... The prefetch_related 
> > > machinery has helped with many situations already. 
> > 
> > >  - Anssi 
> > 
> > Okay, so I'll take a closer look at prefetch_related. I didn't know one 
> can 
> > prefetch the model_set. 
> > 
> > If I would have splitted up into one Dog and one Cat table using 
> one-to-one 
> > to Model1, I could have just used select_related on the backwards 
> relation. 
> > But I don't see any way to tell Django this is in fact a one-to-one 
> > relationship. 
>
> Well, it is not a one-to-one relationship, without the added filter on 
> type. 
>
> I really wish we had something like this in Django: 
> qs = Model1.objects.annotate(dog=ModelAnnotation('model2_set', 
> Q(model2_set__type='dog')) 
>
> This would do something similar to select_related - every object is 
> annotated with Model2 instances. You could do further operations to 
> the annotated model: 
> qs.order_by('dog__type') 
>
> The query generated would be something like this: 
>
> select ... 
>   from model1 
>left join model2 on model2.model1_id = model1.id and model2.type = 
> 'do

Help for finance sector

2012-07-29 Thread Seyfullah Tıkıç
Hello,

Do I have any way to get paid help from django developers?
I work for some of the biggest finance corporations in Turkey, and I may
need help in development or bug-fixing for my customers.
And I may not have weeks to get help, how can I get corporate help from
django community?

Thank you.
SEYFULLAH

-- 
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: form.save() fails silently - how to debug?

2012-07-29 Thread Derek
Just to follow up...

I have tried using pdb - but stepping into the Django code goes through 
hundreds of lines of records and, to be honest, its not clear at all what I 
should be looking for or where I would expect to see errors...  If there is 
any guidance in this respect, I would be happy to hear it.

As per Dan's suggestion, I have also tried stripping out all the non-model 
fields from the form, along with all the "funny" clean code (I now just 
have a straightforward return of the cleaned data). Again, no success: the 
cleaned data looks OK (in the print statement) but it is simply not saved.

On Friday, 27 July 2012 15:46:01 UTC+2, Derek wrote:
>
> Thanks Karen
>
> I am not quite sure what you mean by "Model save() would indicate an 
> error" - I am making a call to the form.save(), which in turn, I assume, 
> should result in the data being saved to the model (although nothing gets 
> saved in my case)?  No error is being raised that I can see.  
>
> I have not used pdb before; I will need to look into how that works and 
> how might help me.
>
> On Friday, 27 July 2012 14:00:37 UTC+2, Karen Tracey wrote:
>>
>> On Fri, Jul 27, 2012 at 3:25 AM, Derek  wrote:
>>
>>> The clean() method basically stores the non-model field data in the 
>>> model's dictionary field.  If this method was faulty, then it would also 
>>> cause problems in the test code.  As I said, when I print the data to 
>>> console it looks OK.  I am still trying to find how and where the save() 
>>> method indicates errors...?
>>
>>
>> Model save() would indicate an error by raising an exception, see:
>>
>> https://github.com/django/django/blob/master/django/db/models/base.py#L444
>>
>> I would attack the problem you are seeing by tracing through what's 
>> actually happening using pdb.
>>
>> Karen
>> -- 
>> http://tracey.org/kmt/
>>
>>

-- 
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/-/SGKss8CoaXQJ.
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.



django FastCGI configuration for Share Host.

2012-07-29 Thread Александър Ботев
Hi,
So I followed all the instructions from the django web source about how to 
configure it, but all it seems
it gives me a problem - I always get an error 500. 
My main concern and I think problem is that when I run my fcgi script it 
gives me this: 

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 301 MOVED PERMANENTLY
Content-Type: text/html; charset=utf-8
Location: http://localhost/home/ 

Which I have no idea what exactly it means and why it is there as I 
literally copy/pasted the stuff from the guide.
If you need more details of the project set up this is a 
link
 to 
my explanation.
King regards

-- 
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/-/9uCmqUWaS9YJ.
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: Models: Referencing A Model In Another App and Different Project

2012-07-29 Thread JJ Zolper
"As a general remark related to the issues that JJ has described... are 
there perhaps - or rather, should there be - pointers from the Django site 
that discuss some good practices to the overall approach of designing and 
building sites/projects/apps/databases - as opposed to the technical 
nitty-gritty of mode/view/form construction?"

I second this motion!

"It seems there are an increasing number of "newbies" flocking to Django, 
with perhaps little or no background in CS fundamentals, and guidelines 
like these would be a good place to point them at!"

As far as web programming goes I would say that yes I am a newbie even 
though I am a Computer Engineer at Virginia Tech. More documentation on 
this topic would be grand! Thank you Derek for the comment!



On Sunday, July 29, 2012 3:24:29 AM UTC-4, Derek wrote:
>
> As a general remark related to the issues that JJ has described... are 
> there perhaps - or rather, should there be - pointers from the Django site 
> that discuss some good practices to the overall approach of designing and 
> building sites/projects/apps/databases - as opposed to the technical 
> nitty-gritty of mode/view/form construction?
>
> It seems there are an increasing number of "newbies" flocking to Django, 
> with perhaps little or no background in CS fundamentals, and guidelines 
> like these would be a good place to point them at!
>
>
> On Thursday, 26 July 2012 03:12:09 UTC+2, JJ Zolper wrote:
>>
>> Hello fellow Django developers, 
>>
>> So here is my model that interfaces with my Artists database: 
>>
>>
>>
>> from django.db import models 
>>
>> class Artist(models.Model): 
>>   name = models.CharField(max_length=30) 
>>   genre = models.CharField(max_length=30)  
>>   city = models.CharField(max_length=30)  
>>   state = models.CharField(max_length=30)  
>>   country = models.CharField(max_length=30) 
>>   website = models.UrlField() 
>>
>>   def __unicode__(self): 
>> return self.name 
>>
>>
>>
>> Okay now that you see my database backend interface here's where I'm 
>> going next. 
>>
>> I've been working with GeoDjango for some time now. I've created an app 
>> within my GeoDjango project called "discover". What's my goal? Well, I want 
>> this app to be able to return information to my users. This app will take 
>> the given parameters such as "locationfrom" (the user of the website 
>> inserts their city, state) and then that value is used to bring in the 
>> artists in their area in relation to the variable "requesteddistance" 
>> (which for example could be 25 mi) along with another variable "genre" (a 
>> query on the artists). So the picture is the user might say I want to see 
>> all the "Rock" artists "25 mi" from me in "Vienna, VA". 
>>
>> Now that you can see my project here, here is my question. 
>>
>> In my discover app in the models.py file I could use some help. Through 
>> this discover app I want to be able to reference the Artists database. As 
>> you can see from above the 
>> models.py file has the fields to establish an Artist and their 
>> information. Thus, when a request comes in to the discover app I want to be 
>> able to calculate the requested information and return that. Here's where 
>> I'm stuck...  
>>
>> In my mind I feel that the appropriate way to do this is to basically 
>> create some sort of ForeignKey in the models.py of discover to the 
>> models.py of Artist? That way I don't have to have two databases of the 
>> same data but can simply reference the Artist database from the discover 
>> app. 
>>
>> Another idea I had was instead of creating a "field" link between the two 
>> to try to import the Artist class from the models.py to the models.py file 
>> of the discover app? Then from my views.py file in discover I can process 
>> the given information referenced and return the result. 
>>
>> Any input is welcome. I am striving to use Django's DRY (Don't Repeat 
>> Yourself) methodolgy and try to reference the Artist database and do the 
>> actual processing in the discover application. 
>>
>> Thanks a lot for your advice, 
>>
>> JJ Zolper 
>>
>>

-- 
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/-/CX4UbSGdzHIJ.
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 FastCGI configuration for Share Host.

2012-07-29 Thread Michael P. Soulier
On 29/07/12 07:48 AM, Александър Ботев wrote:
> Hi,
> So I followed all the instructions from the django web source about how to 
> configure it, but all it seems
> it gives me a problem - I always get an error 500. 
> My main concern and I think problem is that when I run my fcgi script it 
> gives me this: 

Why are you using fastcgi instead of wsgi?

Mike

-- 
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 FastCGI configuration for Share Host.

2012-07-29 Thread Александър Ботев
On Jul 29, 3:42 pm, "Michael P. Soulier" 
wrote:
> On 29/07/12 07:48 AM, Александър Ботев wrote:
>
> > Hi,
> > So I followed all the instructions from the django web source about how to
> > configure it, but all it seems
> > it gives me a problem - I always get an error 500.
> > My main concern and I think problem is that when I run my fcgi script it
> > gives me this:
>
> Why are you using fastcgi instead of wsgi?
>
> Mike
Well when I was looking at ways to deploy django on shared host... the
only thing I found was the article
which speaks about fastcgi. Now I must admit I know almost nothing
about apache different modes etc...
this is my first encounter with them and even though I might learn
them at the moment I need to deploy this
django app first asap. If you can point we out to any article,guide or
explain me how to set it up with
wsgi I would be very the glad. The main restriction of shared host is
just no root access.

Alex

-- 
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 FastCGI configuration for Share Host.

2012-07-29 Thread Babatunde Akinyanmi
Hi,
If you are using a shared host, I don't think you can choose if you
use FCGI or WSGI. Your host will let you know and also give
instructions on how to set up and launch your app. Why not check their
documentation or just raise a ticket with your host's support team

On 7/29/12, Александър Ботев  wrote:
> On Jul 29, 3:42 pm, "Michael P. Soulier" 
> wrote:
>> On 29/07/12 07:48 AM, Александър Ботев wrote:
>>
>> > Hi,
>> > So I followed all the instructions from the django web source about how
>> > to
>> > configure it, but all it seems
>> > it gives me a problem - I always get an error 500.
>> > My main concern and I think problem is that when I run my fcgi script
>> > it
>> > gives me this:
>>
>> Why are you using fastcgi instead of wsgi?
>>
>> Mike
> Well when I was looking at ways to deploy django on shared host... the
> only thing I found was the article
> which speaks about fastcgi. Now I must admit I know almost nothing
> about apache different modes etc...
> this is my first encounter with them and even though I might learn
> them at the moment I need to deploy this
> django app first asap. If you can point we out to any article,guide or
> explain me how to set it up with
> wsgi I would be very the glad. The main restriction of shared host is
> just no root access.
>
> Alex
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: need help on set_password()..............

2012-07-29 Thread Chris Lawlor
If you're using the User model from contrib.auth, you can simply use 
User.objects.create_user(username, email=None, password=password). This 
will create a new User object, and then call set_password()

# forms.py
class RegistrationForm(form.Form):
username = forms.CharField()
password = forms.CharField(widget=PasswordInput)

# views.py
def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
# UserManager.create_user() is a convenience method for 
creating a new user, and calling user.set_password()
user = User.objects.create_user(form.cleaned_data['username''], 
password=form.cleaned_data['password'])
else:
form = RegistrationForm()
return render(request, 'your_template.html', {'form': form})

If you're not using Django's User model, you could use one of the password 
hashers from contrib.auth.hashers to create the hashed version of the 
user's password. Something like:


class MyUser(models.Model):
username = models.CharField(...)
password = models.CharField(max_length=128)

# views.py

from django.contrib.auth.hashers import PBKDF2PasswordHasher as hasher

def register(request):
...
user = MyUser.objects.create(username=form.cleaned_data['username'], 
commit=False)
salt = hasher.salt()
user.password = hasher.encode(form.cleaned_data['password'], salt)
user.save()


Or better yet, move the user creation logic into a manager, similar to the 
design of UserManager:

class MyUserManager(models.Manager):
def create_user(self, username, password):
user = self.model.create(username, commit=False)
salt = hasher.salt()
user.password = hasher.encode(password, salt)
return user

class MyUser(models.Model):
...
objects = MyUserManager()

With that, you can do user = MyUser.objects.create_user(username, password).

Looking at the source code for 
contrib.auth.modelsand
 
contrib.auth.hashersmay
 prove helpful.


If you have existing password data that you need to convert to a hashed 
format, you might consider using a South data migration. Conveniently, the 
tutorial on data migrations uses this use case as an example: 
http://south.readthedocs.org/en/latest/tutorial/part3.html#data-migrations.

(Consider all code to be untested pseudo-code)

On Saturday, 28 July 2012 22:14:52 UTC-4, Sajja1260 wrote:
>
> hi every one,
>   i created one external registration form.. all are 
> working good, but when we open the admin sit it showing the password as 
> plain text. how to convert the password into hash formate and save into 
> database.. can any one suggest for the abovt one
>
>
> --
> Thanks in advance 
> yaswanth
>
>  

-- 
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/-/_q7uosZ0VSUJ.
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: Read from an uploaded file and put data in a form for automatic Django validation

2012-07-29 Thread Derek
Have a look at:
http://stackoverflow.com/questions/6091965/django-upload-a-file-and-read-its-content-to-populate-a-model


On Sunday, 29 July 2012 04:43:15 UTC+2, forthfan wrote:
>
> Hi all,
>
> Being lazy, I want Django to validate the stuff I read from an uploaded 
> file as if it were being posted.  Is there a nice way to do this?
>

-- 
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/-/kGJ40VUVY90J.
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: form.save() fails silently - how to debug?

2012-07-29 Thread Derek
Finally (!) a  solution.  

Turns out the problem is in line 53 of the code I originally posted:
formset = client_dataform_layout(request.POST, instance=client)
when I omit the ", instance=client" part, then all works as expected...

I do need to understand the reason why that was causing a "silent fail", 
but at least I can make progress now.

Thanks to all who made suggestions.

On Sunday, 29 July 2012 14:59:27 UTC+2, Derek wrote:
>
> Just to follow up...
>
> I have tried using pdb - but stepping into the Django code goes through 
> hundreds of lines of records and, to be honest, its not clear at all what I 
> should be looking for or where I would expect to see errors...  If there is 
> any guidance in this respect, I would be happy to hear it.
>
> As per Dan's suggestion, I have also tried stripping out all the non-model 
> fields from the form, along with all the "funny" clean code (I now just 
> have a straightforward return of the cleaned data). Again, no success: the 
> cleaned data looks OK (in the print statement) but it is simply not saved.
>
> On Friday, 27 July 2012 15:46:01 UTC+2, Derek wrote:
>>
>> Thanks Karen
>>
>> I am not quite sure what you mean by "Model save() would indicate an 
>> error" - I am making a call to the form.save(), which in turn, I assume, 
>> should result in the data being saved to the model (although nothing gets 
>> saved in my case)?  No error is being raised that I can see.  
>>
>> I have not used pdb before; I will need to look into how that works and 
>> how might help me.
>>
>> On Friday, 27 July 2012 14:00:37 UTC+2, Karen Tracey wrote:
>>>
>>> On Fri, Jul 27, 2012 at 3:25 AM, Derek  wrote:
>>>
 The clean() method basically stores the non-model field data in the 
 model's dictionary field.  If this method was faulty, then it would also 
 cause problems in the test code.  As I said, when I print the data to 
 console it looks OK.  I am still trying to find how and where the save() 
 method indicates errors...?
>>>
>>>
>>> Model save() would indicate an error by raising an exception, see:
>>>
>>>
>>> https://github.com/django/django/blob/master/django/db/models/base.py#L444
>>>
>>> I would attack the problem you are seeing by tracing through what's 
>>> actually happening using pdb.
>>>
>>> Karen
>>> -- 
>>> http://tracey.org/kmt/
>>>
>>>

-- 
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/-/6CNwvLJY9s8J.
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: creating formset is very slow

2012-07-29 Thread Thorn
Hi Kottiyath,

What is your solution exactly? I am experiencing the same problem. Simple 
formset takes minutes. 

Render_to_response method has mimetype parameter. Did you call this 
function with some argument?

66 Ocak 2009 Salı 14:10:08 UTC-5 tarihinde Kottiyath Nair yazdı:
>
> Hi all,
>My web application sends a medium size data grid (20 elements). I was 
> using formsets for the same.
>The issue I am facing is that the formset instantiation is very very 
> slow. I timed it and it is taking ~4-7 seconds for it to instantiate.
>Is there someway the speed can be increased?
>
> There are no files sent. I am planning to, later.
> The code:
> logging.info('Start - %s' %time.clock())
> DataFormSet = formset_factory(DataForm, extra=25)
> logging.info('Formset Class created- %s' %time.clock())
> formset = DataFormSet(request.POST, request.FILES)
> logging.info('Created new formset- %s'%time.clock())
>
> From my logs:
> 2009-01-06 22:53:30,671 INFO Start - 0
> 2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829
> 2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468
>   or later
> 2009-01-06 22:56:37,500 INFO Start - 186.836136716
> 2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135
> 2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621
>
>
>Please note that I am running the whole thing under the django 
> development server in my laptop itself and not a server.
>

-- 
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/-/cIoIVLn89EMJ.
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.



Is there a way to use 'request.user' in a custom template tag without an inclusion tag?

2012-07-29 Thread Ash Courchene
So I made a custom template tag that allows pieces of content to be edited 
by the site administrator with the click of a link.
For instance, if i put {% editable 'index_block_one' %}, it would return 
whatever content is in the Placeholder model I created with the name 
"index_block_one".
The code below, for the template tag:

from django import template
from django.contrib.auth.models import User
from cms.models import Placeholder

register = template.Library()

@register.tag(name="editable")
def do_editable(parser, token):
try:
tag_name, location_name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError("%r tag requires a single argument." % 
token.contents.split()[0])
if not(location_name[0] == location_name[-1] and location_name[0] in ('"', 
"'")):
raise template.TemplateSyntaxError("%r tag's arguments should be in 
quotes." % tag_name)
return EditableNode(location_name, context)


class EditableNode(template.Node):
 def __init__(self, location_name):
self.location_name = location_name.encode('utf-8').strip("'")
 def render(self, context):
obj = Placeholder.objects.filter(location=self.location_name)
if request.user.is_authenticated():
for x in obj:
return "%sedit" % (x, self.location_name)
else:
for x in obj:
return x


I want this to return a link that says "Edit" if the site administrator is 
logged in, and just the content if the administrator is not logged in. 
However, I get an error saying "*global name 'request' is not defined*". I 
did put django.core.context_processors.request and .auth in my settings 
file. And still nothing.

So I did some research that said that an inclusion tag is the way to go, 
except I don't have an html file as a template, because this template tag 
is returning a Model object(??). There's no html to show. SO. Is there 
a way to use request.user in this template tag without the use of an 
inclusion tag? If someone could point me in the right direction, that'd be 
great And hopefully all this made sense. Thanks again.

-- 
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/-/ALmVHBTUqQUJ.
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 for finance sector

2012-07-29 Thread Antoni Aloy
Hello,

Your best chance is to try to locate your local django or python group.
There you could find companies that could offer you development and
bug-fixing.
django people shows 93 registered users in  Turkey
https://people.djangoproject.com/tr/.

Another chance is to post a job in Django jobs, or even this list, but you
should be more specific about the kind of job you whant and your needs.
Imagine, I could offer myself or my company for the job, but if it involves
reading or talking to you in turkish this would be a requirement you have
to expose in advance. That's why my first suggestions is to try to contact
a local provider.

Best regards,


2012/7/29 Seyfullah Tıkıç 

> Hello,
>
> Do I have any way to get paid help from django developers?
> I work for some of the biggest finance corporations in Turkey, and I may
> need help in development or bug-fixing for my customers.
> And I may not have weeks to get help, how can I get corporate help from
> django community?
>
> Thank you.
> SEYFULLAH
>
> --
> 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.
>



-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

-- 
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: REMOVE ME

2012-07-29 Thread lacrymol...@gmail.com

Remove yourself, you oaf. Every email from the list comes with instructions to 
do it.

-Mensaje original-
De: Andrew Miller
Enviados:  29/07/2012 02:47:32
Asunto:  REMOVE ME

On Sun, Jul 29, 2012 at 10:43 AM, forthfan  wrote:

> Hi all,
>
> Being lazy, I want Django to validate the stuff I read from an uploaded
> file as if it were being posted.  Is there a nice way to do this?
>
> --
> 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/-/Q7mCnfztueIJ.
> 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: REMOVE ME

2012-07-29 Thread dipo . elegbede
lacrymol...@gmail.com, I think your choice of word is way off the mark. We 
should address everyone with some level of respect no matter how mad we are 
with their requests. 

Regards. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: "lacrymol...@gmail.com" 
Sender: django-users@googlegroups.com
Date: Sun, 29 Jul 2012 19:45:37 
To: django-users@googlegroups.com
Reply-To: django-users@googlegroups.com
Subject: RE: REMOVE ME


Remove yourself, you oaf. Every email from the list comes with instructions to 
do it.

-Mensaje original-
De: Andrew Miller
Enviados:  29/07/2012 02:47:32
Asunto:  REMOVE ME

On Sun, Jul 29, 2012 at 10:43 AM, forthfan  wrote:

> Hi all,
>
> Being lazy, I want Django to validate the stuff I read from an uploaded
> file as if it were being posted.  Is there a nice way to do this?
>
> --
> 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/-/Q7mCnfztueIJ.
> 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.

-- 
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.



Form validation using model data?

2012-07-29 Thread Paul
I have a model for Websites that has 3 fields: name, url and authenticated. 
With a form both the name and url can be changed, but when the website is 
authenticated i don't want to allow that the url changes.

I'm thinking about making the url (form) field readonly but in html the 
field becomes still an input field (just with readonly="True"), so i have 
doubts whether hackers will be able to post a changed value anyhow (i'll 
need to test this).

Another approach is to add some custom form validation against the 
(current) model, but i have doubts whether validation is the solution for 
this?

Thanks for any directions
Paul

-- 
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/-/urE06kkuNBIJ.
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: Form validation using model data?

2012-07-29 Thread Kurtis Mullins
Just to get some more information about the problem; Do you allow your
users to initially insert the Name+URL? When does this become
"authenticated"?

Maybe you could have two forms. One that allows users to add new Name+URL
Objects (not sure what your object/Model is called) and another to allow
them to edit (Using Django's 'fields' meta attribute to limit them to only
modify the "Name" of the object)

On Sun, Jul 29, 2012 at 5:47 PM, Paul  wrote:

> I have a model for Websites that has 3 fields: name, url and
> authenticated. With a form both the name and url can be changed, but when
> the website is authenticated i don't want to allow that the url changes.
>
> I'm thinking about making the url (form) field readonly but in html the
> field becomes still an input field (just with readonly="True"), so i have
> doubts whether hackers will be able to post a changed value anyhow (i'll
> need to test this).
>
> Another approach is to add some custom form validation against the
> (current) model, but i have doubts whether validation is the solution for
> this?
>
> Thanks for any directions
> Paul
>
>  --
> 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/-/urE06kkuNBIJ.
> 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: REMOVE ME

2012-07-29 Thread Russell Keith-Magee
I can't believe I actually have to say this, especially after having
called someone on making an inappropriate joke, but calling someone an
oaf is *definitely* not a behaviour we will tolerate on django-users.
If you make a repeat of that kind of comment we'll ask you to leave.

Yours,
Russ Magee %-)


On Mon, Jul 30, 2012 at 3:45 AM, lacrymol...@gmail.com
 wrote:
>
> Remove yourself, you oaf. Every email from the list comes with instructions 
> to do it.
>
> -Mensaje original-
> De: Andrew Miller
> Enviados:  29/07/2012 02:47:32
> Asunto:  REMOVE ME
>
> On Sun, Jul 29, 2012 at 10:43 AM, forthfan  wrote:
>
>> Hi all,
>>
>> Being lazy, I want Django to validate the stuff I read from an uploaded
>> file as if it were being posted.  Is there a nice way to do this?
>>
>> --
>> 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/-/Q7mCnfztueIJ.
>> 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.
>

-- 
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: ANN: pythonpackages.com beta

2012-07-29 Thread Alex Clark

Hi,

On 7/28/12 11:57 PM, Marcin Tustin wrote:

" Powered by Pyramid  & Redis
 on Heroku . "
You've got a nerve! :)



Hah! Hey I like Django too :-)



Alex




On Sat, Jul 28, 2012 at 7:28 PM, Alex Clark mailto:acl...@aclark.net>> wrote:

Hi Django folks,


I am reaching out to various Python-related programming communities
in order to offer new help packaging your software.

If you have ever struggled with packaging and releasing Python
software (e.g. to PyPI), please check out this service:


- http://pythonpackages.com


The basic idea is to automate packaging by checking out code,
testing, and uploading (e.g. to PyPI) all through the web, as
explained in this introduction:


- http://docs.pythonpackages.__com/en/latest/introduction.__html



Also, I will be available to answer your Python packaging questions
most days/nights in #pythonpackages on irc.freenode.net
. Hope to meet/talk with all of you soon.



Alex



--
Alex Clark · http://pythonpackages.com/ONE___CLICK


--
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+unsubscribe@__googlegroups.com
.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
.




--
Marcin Tustin
Tel: 07773 787 105

--
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.



--
Alex Clark · http://pythonpackages.com/ONE_CLICK

--
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: REMOVE ME

2012-07-29 Thread Tomas Neme
I'm very sorry. I got completely out of line.

It's just something that irritates me a lot, and I'm not a native
english speaker, and it may be I don't know the actual "value" of the
word, I felt it was more funny than insulting. And I hadn't read your
first reply.

It won't happen again.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Is there a way to use 'request.user' in a custom template tag without an inclusion tag?

2012-07-29 Thread Tomas Neme
>
> class EditableNode(template.Node):
>  def __init__(self, location_name):
>  self.location_name = location_name.encode('utf-8').strip("'")
>  def render(self, context):
> obj = Placeholder.objects.filter(location=self.location_name)
>  if request.user.is_authenticated():
> for x in obj:
> return "%sedit" % (x, self.location_name)
>  else:
> for x in obj:
> return x
>
>
>
>
that `request` variable isn't declared anywhere, that's what that "global
name `` does not exist" error mean.

I *think* you've got to use context['user'], try that. Else, try
context['request'].user

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Is there a way to use 'request.user' in a custom template tag without an inclusion tag?

2012-07-29 Thread Ash Courchene
Well holy crap!! context['user'] worked perfectly! I thought I would have 
to come up with some crazy workaround!
Thank you kindly sir.


On Sunday, 29 July 2012 15:03:13 UTC-4, Ash Courchene wrote:
>
> So I made a custom template tag that allows pieces of content to be edited 
> by the site administrator with the click of a link.
> For instance, if i put {% editable 'index_block_one' %}, it would return 
> whatever content is in the Placeholder model I created with the name 
> "index_block_one".
> The code below, for the template tag:
>
> from django import template
> from django.contrib.auth.models import User
> from cms.models import Placeholder
>
> register = template.Library()
>
> @register.tag(name="editable")
> def do_editable(parser, token):
> try:
> tag_name, location_name = token.split_contents()
> except ValueError:
> raise template.TemplateSyntaxError("%r tag requires a single argument." % 
> token.contents.split()[0])
> if not(location_name[0] == location_name[-1] and location_name[0] in ('"', 
> "'")):
> raise template.TemplateSyntaxError("%r tag's arguments should be in 
> quotes." % tag_name)
> return EditableNode(location_name, context)
>
>
> class EditableNode(template.Node):
>  def __init__(self, location_name):
> self.location_name = location_name.encode('utf-8').strip("'")
>  def render(self, context):
> obj = Placeholder.objects.filter(location=self.location_name)
> if request.user.is_authenticated():
> for x in obj:
> return "%sedit" % (x, self.location_name)
> else:
> for x in obj:
> return x
>
>
> I want this to return a link that says "Edit" if the site administrator is 
> logged in, and just the content if the administrator is not logged in. 
> However, I get an error saying "*global name 'request' is not defined*". 
> I did put django.core.context_processors.request and .auth in my settings 
> file. And still nothing.
>
> So I did some research that said that an inclusion tag is the way to go, 
> except I don't have an html file as a template, because this template tag 
> is returning a Model object(??). There's no html to show. SO. Is there 
> a way to use request.user in this template tag without the use of an 
> inclusion tag? If someone could point me in the right direction, that'd be 
> great And hopefully all this made sense. Thanks again.
>

-- 
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/-/JI7BDqMOMw0J.
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: REMOVE ME

2012-07-29 Thread kenneth gonsalves
On Sun, 2012-07-29 at 14:32 +0800, Russell Keith-Magee wrote:
> On Sun, Jul 29, 2012 at 1:56 PM, David Lam 
> wrote:
> > Try this from manage.py shell
> >
> DjangoMailListSubscription.objects.filter(email="collective...@gmail.com").delete()
> 
> Andrew obviously wants to unsubscribe. 

are you sure - he has asked a question on validation of an uploaded
file. He seems to have made a mistake on the subject line.
-- 
regards
Kenneth Gonsalves

-- 
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.