Re: Get the current url in django template

2011-11-10 Thread Martin Pajuste
If you need something like 
"http://example.com/music/bands/the_beatles/?print=true"; try 
{{request.build_absolute_uri}}
https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.build_absolute_uri

-- 
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/-/PzqmOq5u8ysJ.
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: USStateField default value

2012-01-02 Thread Martin Pajuste
You get that error because 'blank' is model field option. If you want to be 
able to accept empty values, use required=False instead.

> state = USStateField(initial='CA', required=False)

-- 
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/-/_ApzlaY9CMQJ.
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: Customizing error message in ModelForm

2011-04-15 Thread Martin Pajuste
Error messages in ModelForms work perfectly fine.

class PersonForm(forms.ModelForm):
first_name = forms.CharField(error_messages={'required': 'Please enter 
your first name!'})
class Meta:
model = Person


http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages

-- 
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: Customizing error message in ModelForm

2011-04-15 Thread Martin Pajuste
This should do the trick:

class PrijsvraagForm(ModelForm):
mail = forms.EmailField(error_messages={'required':'Vul aub een geldig 
Email adres in', 'invalid': 'Het email adres is niet geldig'})

class Meta:
model = Prijsvraag

def clean_code(self):
super(PrijsvraagForm, self).clean()
x = self.cleaned_data['code']
try:
y = Code.objects.all()[0]
except:
raise forms.ValidationError("Er is iets fout gegaan")
if x != y.code:
raise forms.ValidationError("De code is niet juist")
pass
return x

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



Vs: how to override a ModelChoiceField in order to add FKs directly in a TextInput?

2011-06-29 Thread Martin Pajuste
Since ModelChoiceField validates that the given id exists in the queryset, 
there can be no valid choices when you use MyRelatedClass.objects.none().

Try MyRelatedClass.objects.all() or filter by some attribute. If the 
queryset depends on some user input or conditions you can use something 
like:

def __init__(self, some_value, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
qset= MyRelatedClass.objects.filter(some_field=some_value)
self.fields['myrelation '].queryset = qset



Martin

-- 
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/-/Cm7-6sNIfeMJ.
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: len(qs.all()) != qs.count()

2011-01-19 Thread Martin Pajuste
I would say the problem is in your model. Notice in the beginning of the SQL 
there is "productdescriptions"."id" yet there is no such field in database. 
Just specify 
primary_key=Trueon
 one of your fields.

-- 
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: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Martin Pajuste
-d flag sends the specified data in a POST request to the HTTP server, since 
you don't supply CSRF token, Django assumes the post is malicious.
See more http://docs.djangoproject.com/en/dev/ref/contrib/csrf/?from=olddocs

-- 
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: "CSRF verification failed" when sending simple GET request using curl

2011-01-19 Thread Martin Pajuste
curl -d "name=Bob" -G http://localhost:8000/demo/test 

-- 
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: How to check if request.FILES is empty

2011-04-08 Thread Martin Pajuste
What you are looking for is probably something like

if 'uploadphoto' in request.FILES:

-- 
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 News Site Resources

2011-04-08 Thread Martin Pajuste
http://djangopackages.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: How to check if request.FILES is empty

2011-04-08 Thread Martin Pajuste
You'll find well written documentation how to treat basic file uploads in 
Django documentation
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#basic-file-uploads

-- 
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: Stackoverflow kind of Answer/commenting app in Django

2011-04-13 Thread Martin Pajuste
Are You aware of Django’s comments framework?
http://docs.djangoproject.com/en/dev/ref/contrib/comments/

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