Re: Looking for a way to broadcast live video streams. Is it possible with Django ?

2015-01-27 Thread Jeremy Hermelin

Thank you Russ and Cal for your answers. 

I'll take a look at WebRTC that seems to be a revolution in that domain, 
and it's a matter of time before it will spread to Safari or IE. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6a062e85-5b8b-41fd-aaab-90c6daef61d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select Field With Other option

2015-01-27 Thread Karim
On Wed, Jan 28, 2015 at 4:28 PM, Sergiy Khohlov  wrote:

> You can not do it directly. This should be do by JavaScript's using at
> HTML side. All field s are added to form and some of them are hidden.
>
​Is not possible to use crispy forms and change the widget with the Field()
object?

http://django-crispy-forms.readthedocs.org/en/latest/layouts.html#layout-objects-attributes
​

​

-- 
Karim N. Gorjux

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


Re: Select Field With Other option

2015-01-27 Thread Sergiy Khohlov
You can not do it directly. This should be do by JavaScript's using at HTML
side. All field s are added to form and some of them are hidden.
27 січ. 2015 00:29, користувач "Paul Royik" 
написав:

> I need to build a form field with a special select field.
> Select field should have option other on which text field is shown. After
> entering value in textfield, it should be validated, saved and then refered
> to initial form.
>
> How this can be done?
>
>
> I'm trying to override MultiValueField and MultiWidget, but no luck.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/268074d9-67af-4b19-a083-314ad1125414%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Best practice to render the view based on the user

2015-01-27 Thread Karim
Hi! I would like to render views based on the user. I have some differents
type of users on my app and I would like to create a class like this one
for the view:

class MyView(MyCustomView)  # MyCustomView subclass View

def __init__(self, *args, **kwargs):
# common code for all persons

def personA(self):
# code for personA

def personB(self):
# code for personA

# 

def personN(self):
# code for personA

def anyPerson(self)
# For any user non listed above


Then if the MyView is run, the function based on the user is automatically
fired.

My doubts (at the moment):

1) Do you think is the a good way to face the problem?

2) I have methods in the models to know what person is logged. How I can
automatically load the right function in the class based on the user?

Thank you

-- 
Karim N. Gorjux

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


Re: sending email

2015-01-27 Thread sum abiut
Can someone please guide me here. i am kinda lost, the other part is ok
just the email part i am really lost, please help

here is my view.py the email part is not working

def coporateservices_authorized_Leave(request, id):
if request.method == 'POST':
a=newleave.objects.get(id=id)
form = coporateservices_authoriseleave(request.POST, instance=a)
if form.is_valid():
   form.save()
   to_emails = [u.email for u in
User.objects.filter(id__in=[a.'id'])]
   send_mail("RBV Leave Application Email Testing", "Your Leave
have been approved",
  "RBV eLeave ", [to_emails])
return render_to_response('thankyou.html')
else:
a=newleave.objects.get(id=id)
form =  coporateservices_authoriseleave(instance=a)
return render_to_response('coporate_services_leave_approvial.html',
{'form': form}, context_instance=RequestContext(request))

cheers,





On Wed, Jan 28, 2015 at 7:18 AM, Collin Anderson 
wrote:

> Hi,
>
> You should be able to figure out which box is checked from
> form.cleaned_data.
>
> Collin
>
> On Sunday, January 25, 2015 at 11:53:12 PM UTC-5, suabiut wrote:
>>
>> Hi Collin,
>> Thank you very much for your help. its works perfectly.
>> The next thing i want to do is to send an email to a specific user that i
>> select on a table. when an authorized user select a user to approve his or
>> her leave i want an email to be send to the user. so basically when i click
>> on the checkbox on the Test User form the table below. i should get a form
>> to approve the leave as below. now when i click on authorized Leave button
>> an email should be send to the test user. please point me to right
>> direction.
>>  [image: Inline image 1]
>>
>> [image: Inline image 2]
>>
>> Cheers,
>>
>> On Fri, Jan 23, 2015 at 1:18 PM, Collin Anderson 
>> wrote:
>>
>>> Hi,
>>>
>>> Just query the users you want.
>>>
>>> to_emails = [u.email for u in User.objects.filter(username__in=['person1',
>>> 'person2', 'person3'])]
>>> send_mail('Subject here', 'Here is the message.', from_email_address,
>>> to_emails)
>>>
>>> Collin
>>>
>>> On Wednesday, January 21, 2015 at 11:29:51 PM UTC-5, suabiut wrote:

 Thanks,
 I am trying to send email to the users that their email address is
 stored in the database on the auth_user table. can someone please point me
 to the right direction.

 Cheers,


 On Thu, Jan 22, 2015 at 3:03 PM, Collin Anderson 
 wrote:

> Hi,
>
> Yes, this is possible. Something like:
>
> from django.core.mail import send_mail
>
> def authorized_leave(request):
> form = MyForm()
> if request.method == 'POST':
> form = MyForm(request.POST)
> if form.is_valid():
> obj = form.save()
> send_mail('Subject here', 'Here is the message.', '
> fr...@example.com', ['t...@example.com'])
> return redirect('/done/')
> return render(request, 'template.html', {form: 'form'})
>
> Collin
>
>
> On Monday, January 19, 2015 at 10:02:45 PM UTC-5, suabiut wrote:
>>
>> Hi,
>> I am trying to send an email to several users once a form is submit.
>> I have done the view.py to update the database once the form is submitted
>> and is working fine. what i want to accomplish when the form is submitted
>> is to update the database and at the same time send out email when a user
>> click on the Authorized leave button.
>>
>> here is the step i want to do:
>>
>>  [image: Inline image 1]
>>
>> 1) user click on the check box and this form below appears
>>
>>
>> [image: Inline image 2]
>>  2) the user then fill up the form and click on authorized leave
>> button. the form will stored the information into the database. which i
>> have already done it. what i wanted to do next is to also send a emails
>> when the authorized leave button is click. is it possible to send emails
>> and also save data to database when the authorized leave button is 
>> click. i
>> want to send email to the *Test User* which have his email address
>> store in the database.
>>
>> template.html
>> {%csrf_token%}
>> 
>> {{form.as_table}}
>> 
>> 
>> 
>>
>>
>> 
>>
>> please point me to the right direction.
>>
>> Cheers,
>>
>>   --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> 

how to have popup window and print it

2015-01-27 Thread 163 email
hi.
i'm new to django. i'm try using django1.7 with jquery ,bootstrap.
 Now i have a webpage , i want:
  when click a  link , there is  a new popup window, and form with data from 
database 
  in  popup window,and then print contend in the popup window.
but i did not find how to do it just using django in doc of django.
is there anybody can tell me how to do it with  example code .
Thanks!   

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


Re: Help in Django-contact-form

2015-01-27 Thread Vijay Khemlani
And I'm not following, contact_form does not provide a ContactForm model,
but you are providing one it seems, but it's on the same contact_form
package as the library itself?

Also, the fact that the model class has the same name as the form class
does not help much.

On Tue, Jan 27, 2015 at 10:45 PM, Karim  wrote:

> Can you show us also the view?
>
> On Wed, Jan 28, 2015 at 8:04 AM, Akash Nimare 
> wrote:
>
>> Hello everyone. I am using a third party app django-contact-form. It is
>> working fine but the problem is it does not show my models in admin. I
>> can't see the data in admin. The docs are very poor.
>> Here is my model.py
>>
>> from django.db import models
>> from contact_form.forms import ContactForm
>> class ContactForm(models.Model):
>> name = models.CharField(max_length=100)
>> email = models.EmailField(max_length=200)
>> body = models.CharField(max_length=200)
>> def __str__(self):
>> return (self.email)
>>
>>  admin.py
>> from django.contrib import admin
>> from . import models
>> from contact_form.models import ContactForm
>> class ContactFormAdmin(admin.ModelAdmin):
>> list_display = ("name", "body", "email")
>> admin.site.register(ContactForm, ContactFormAdmin)
>> I am using django 1.7
>> http://django-contact-form.readthedocs.org/en/latest/quickstart.html
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/035e8b0b-e502-4ba5-b8e2-9923afa43909%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Karim N. Gorjux
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACeuRGUDWMDg1UQb7KMZ5e0jK%3DcmfrVa-%3DfRzyXUAiqV6ATtYQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django UnicodeDecodeError at /admin/login/

2015-01-27 Thread Human Bsd
Hi James. your hint  was actually very inspiring.

After concatenating  'drupal$' to the imported password, I was still unable
to authenticate. Then I realized that the passwords are in unicode but the
hasher considers them to be ascii, so I added :

password = password.encode('ascii','ignore')

at the begining of the both 'encode' and 'verify' methods

This solved the problem and saved my escape rout out of drupal :)

Thank you very much for your hint.

On Tue, Jan 27, 2015 at 9:04 PM, James Schneider 
wrote:

> Did you read the comments on that snippet? It appears there may need to be
> some extra encoding/decoding needed (example additional code is listed
> there), which would make sense given the decoding errors you are seeing.
>
> -James
> On Jan 27, 2015 9:54 AM, "Supermario"  wrote:
>
>> I try to implement this 
>> hasher in order to be able to authenticate user who are imported from
>> drupal 7.
>>
>> So I put the hasher in the settings.py as follows:
>>
>>
>> PASSWORD_HASHERS = (
>>
>> 'myproj.drupal_hasher.DrupalPasswordHasher', #drupal hasher
>>
>> 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
>>
>> 'django.contrib.auth.hashers.BCryptPasswordHasher',
>> 'django.contrib.auth.hashers.SHA1PasswordHasher',
>> 'django.contrib.auth.hashers.MD5PasswordHasher',
>> 'django.contrib.auth.hashers.CryptPasswordHasher',
>>  )
>>
>>
>>
>> However it does not authenticate imported users from drupal and for users
>> who are created in Django I get:
>>
>> 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in
>> range(128)
>>
>>
>>
>>
>> Here is the trackback:
>>
>>
>> Environment:
>>
>>
>> Request Method: POST
>> Request URL: http://127.0.0.1:8000/auth/
>>
>> Django Version: 1.7.3
>> Python Version: 2.7.3
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'article',
>>  'photo',
>>  'debug_toolbar',
>>  'django_markdown',
>>  'haystack')
>> Installed Middleware:
>> (u'debug_toolbar.middleware.DebugToolbarMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>>
>>
>> Traceback:
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/core/handlers/base.py"
>> in get_response
>>   111. response = wrapped_callback(request, *
>> callback_args, **callback_kwargs)
>> File "/home/mario/myproj/myauth/views.py" in auth_view
>>   16. user = auth.authenticate(username=username, password=
>> password)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py"
>> in authenticate
>>   60. user = backend.authenticate(**credentials)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/backends.py"
>> in authenticate
>>   17. if user.check_password(password):
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
>> in check_password
>>   237. return check_password(raw_password, self.password,
>> setter)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
>> in check_password
>>   63. setter(password)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
>> in setter
>>   235. self.set_password(raw_password)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
>> in set_password
>>   227. self.password = make_password(raw_password)
>> File
>> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
>> in make_password
>>   85. return hasher.encode(password, salt)
>> File "/home/mario/myproj/myproj/drupal_hasher.py" in encode
>>   81. encoded_hash = self._apply_hash(password, self._digests
>> [digest], settings)
>> File "/home/mario/myproj/myproj/drupal_hasher.py" in _apply_hash
>>   68. password_hash = digest(password_hash + password).
>> digest()
>>
>> Exception Type: UnicodeDecodeError at /auth/
>> Exception Value: 'ascii' codec can't decode byte 0xcf in position 0:
>> ordinal not in range(128)
>>
>>
>> All source and destination database 

Re: Help in Django-contact-form

2015-01-27 Thread Karim
Can you show us also the view?

On Wed, Jan 28, 2015 at 8:04 AM, Akash Nimare  wrote:

> Hello everyone. I am using a third party app django-contact-form. It is
> working fine but the problem is it does not show my models in admin. I
> can't see the data in admin. The docs are very poor.
> Here is my model.py
>
> from django.db import models
> from contact_form.forms import ContactForm
> class ContactForm(models.Model):
> name = models.CharField(max_length=100)
> email = models.EmailField(max_length=200)
> body = models.CharField(max_length=200)
> def __str__(self):
> return (self.email)
>
>  admin.py
> from django.contrib import admin
> from . import models
> from contact_form.models import ContactForm
> class ContactFormAdmin(admin.ModelAdmin):
> list_display = ("name", "body", "email")
> admin.site.register(ContactForm, ContactFormAdmin)
> I am using django 1.7
> http://django-contact-form.readthedocs.org/en/latest/quickstart.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/035e8b0b-e502-4ba5-b8e2-9923afa43909%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Karim N. Gorjux

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


Re: Looking for a way to broadcast live video streams. Is it possible with Django ?

2015-01-27 Thread Cal Leeming
This really isn't something Django can do out of the box, but if
you're looking to get simple video streams integrated into your site,
then perhaps consider using LiveStream embed instead?

If you're looking to create your own service, then unless you are a
skilled programmer with experience in multiple languages/frameworks
then you're gonna find this extremely difficult, as you have a ton of
other components which would need to be included and a variety of
technical challenges to overcome.

Previously I worked on a similar project which used Flash fallback for
encoding when WebRTC wasn't available, there are all sorts of weird
edge cases due to browser bugs, including 100% CPU bugs when encoding
streams above 720p in Chrome (which has been outstanding for 2 years).
For flash fallback, you also have to implement IPC between Flash and
JS because you would only want to offload rendering and RTMP to flash,
not the entire interface. I might consider open sourcing this part of
the code if there is interest for it.

Then you have to consider the backend, handling video streams is an
absolute pita and most streaming solutions have poor performance or
leak memory. There are some out of the box streaming servers such as
Wowza, or the awful FMS (stay away from this, seriously), then you
also have to consider bandwidth usage, distributing load, handling
spikes, preventing DoS, mitigating DDoS.. You could look at using
Zencoder live transcode but this isn't cheap by any means (and for
good reason).

If you're looking for a fantastic learning experience, then try
building your own. If you're looking to just get something working,
use LiveStream embed :)

Hope this helps

Cal

On Tue, Jan 27, 2015 at 2:05 PM, Jeremy Hermelin
 wrote:
> Hi everybody,
>
> I'm quite new in Django community. I've just learn the basics of the
> framework, and now that I know how to create a "blog-style" website, I'm
> wondering how to integrate video streams in my project. Do you have some
> advices about that ? Any existing app ?
>
> What I am looking for precisely :
> - Capturing video stream from a client's webcam (Maybe the easier will be
> using a script)
> - Sending the stream to the server and then to hundreds of clients connected
> to this session.
>
> In fact, it's really close to Google Hangout.
>
> As I said, I'm new in Django, and also in Python, then I'm sorry if the
> answer is obvious. I've made some research on djangopackages but haven't
> find anything.
>
>
> Have an awesome and fantastic day,
>
> Jeremy
>
> By the way : Wooohhh Django is so easy and powerful at the same time !
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cb8c96bf-854f-4ed5-a803-6cd943c767df%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Looking for a way to broadcast live video streams. Is it possible with Django ?

2015-01-27 Thread Russell Keith-Magee
Hi Jeremy,

What you're trying to tackle here is fairly complex - and for the most
part, won't have anything to do with Django. The capability of capturing
webcam video and sending it will be almost entirely "client side" - which
means that the logic will reside in the browser, and will be implemented in
Javascript.

The only involvement Django will have will be:
1) Sending the initial content to the user
2) Receiving video content, if it's going to be archived.

If you're looking to do Hangout-like stuff, you're going to be using the
WebRTC extensions that are available in *some* browsers - the best
resources I can point you at are:

http://www.webrtc.org
http://simplewebrtc.com

But even then - the specification isn't widespread. Safari, for example,
doesn't support WebRTC, and neither does IE. That doesn't mean you can't do
hangout in Safari or IE - clearly you can - but it means the interface
isn't going to be easy, either.

Yours,
Russ Magee %-)


On Tue, Jan 27, 2015 at 10:05 PM, Jeremy Hermelin <
contact.herme...@gmail.com> wrote:

> Hi everybody,
>
> I'm quite new in Django community. I've just learn the basics of the
> framework, and now that I know how to create a "blog-style" website, I'm
> wondering how to integrate video streams in my project. Do you have some
> advices about that ? Any existing app ?
>
> What I am looking for precisely :
> - Capturing video stream from a client's webcam (Maybe the easier will be
> using a script)
> - Sending the stream to the server and then to hundreds of clients
> connected to this session.
>
> In fact, it's really close to Google Hangout.
>
> As I said, I'm new in Django, and also in Python, then I'm sorry if the
> answer is obvious. I've made some research on djangopackages but haven't
> find anything.
>
>
> Have an awesome and fantastic day,
>
> Jeremy
>
> By the way : Wooohhh Django is so easy and powerful at the same time !
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cb8c96bf-854f-4ed5-a803-6cd943c767df%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: forloop

2015-01-27 Thread sum abiut
Thanks James,
I have figure out how to do that. thanks again for your help.

On Wed, Jan 28, 2015 at 9:33 AM, sum abiut  wrote:

> Hi James,
> Thanks very much for shearing your intellect, i really appreciate your
> help. It works perfectly well. i want the users who receive the email to be
> able to know who have apply for the leave: where it is highlighted blue i
> want to put like test user have apply for a leave. could you please advise
> how to do that.
> here is my view.py
>
> def email_authorizer(request):
> email_obj = newleave.objects.order_by('-pk')[0]
> if email_obj.department == 'GOV':
> to_emails = [u.email for u in
> User.objects.filter(username__in=['sabiut'])]
> send_mail("RBV Leave Application Email Testing", "You have
> received a leave application form. Please login to the leave system to
> Authorize the leave. \nPlease ignore this message, we are testing the new
> eLeave system!",
> "RBV eLeave ", [to_emails])
> return render_to_response('thankyou.html')
>
>
> Cheers,
>
>
>
>
>
> On Tue, Jan 27, 2015 at 6:03 PM, James Schneider 
> wrote:
>
>> Instead of looping through the all() set of objects (which works quickly
>> with small sets of objects, imagine >20K objects, that would be noticeably
>> slower, probably seconds or more),  you should just query the object you
>> want directly using something like:
>>
>> obj = newleave.objects.order_by('-pk')[0]
>>
>> That would give you the newleave object that has the highest PK, and
>> would presumably be the most recently added entry. No need for a loop, let
>> the DB do the work in this case.
>>
>> I'm a bit confused by the logic in the for loop. You
>> re-query newleave.objects.filter(department="GOV"), which would return a
>> bunch of rows no matter what (based on the output you provided), and has no
>> relation based on the object that you asked about initially. I don't think
>> that does what you want, as it will send out an email every time no matter
>> what, not just every time that obj.department == 'GOV' (which is probably
>> the check you want instead).
>>
>> -James
>>
>> On Mon, Jan 26, 2015 at 4:01 PM, sum abiut  wrote:
>>
>>> Here is how it looks like, when a new row is added it display last.
>>> [image: Inline image 1]
>>>
>>>
>>> On Tue, Jan 27, 2015 at 10:51 AM, Stephen J. Butler <
>>> stephen.but...@gmail.com> wrote:
>>>
 Do you have a default ordering on the Model object? That is, an
 ordering option on newleave.Meta? Because otherwise this query
 "newleave.objects.all()" is not at all guaranteed to return rows in
 the order they were added.

 It may, by coincidence, in your current environment behave that way.
 But change databases, or add more rows, or look at it funny, and that
 won't be true.

 On Mon, Jan 26, 2015 at 5:38 PM, sum abiut  wrote:
 > Thank you for your email. I am iterating all the row to find out
 which row
 > was recently added. basically when a row is added to it become last.
 so i am
 > trying to comparing a column on the last row. which is the row that
 was
 > recently add if the condition of the column is exist. that is when i
 send
 > out email.
 >
 > hope my explanation is clear.
 >
 > Cheers
 >
 >
 > On Tue, Jan 27, 2015 at 10:28 AM, Paul Royik 
 > wrote:
 >>
 >> Inside view there is no forloop (unless you explicitly define it).
 forloop
 >> is defined only inside for loops in templates
 >>
 >> Actually your code is somewhat weird.
 >> You iterate all list until last without doing anything.
 >>
 >> It is more efficient to use slicing
 >>
 >> email = newleave.objects.all()[-1] # this is already last item
 >> govoffice=newleave.objects.filter(department="GOV")
 >> if govoffice.exists():
 >> to_emails = [u.email for u   in
 >> User.objects.filter(username__in['testuser','sabiut'])]
 >> send_mail("RBV Leave Application Email Testing",
 "You have
 >> received a leave application form. Please login to the leave system
 to
 >> Authorize the leave.",
 >> "RBV eLeave ", [to_emails])
 >> return render_to_response('thankyou.html')
 >>
 >> Other code is also not very understandable, but I can't help you,
 since
 >> don't understand what should be done.
 >>
 >> --
 >> You received this message because you are subscribed to the Google
 Groups
 >> "Django users" group.
 >> To unsubscribe from this group and stop receiving emails from it,
 send an
 >> email to django-users+unsubscr...@googlegroups.com.
 >> To post to this group, send email to django-users@googlegroups.com.
 >> Visit this group at http://groups.google.com/group/django-users.

Re: forloop

2015-01-27 Thread sum abiut
Hi James,
Thanks very much for shearing your intellect, i really appreciate your
help. It works perfectly well. i want the users who receive the email to be
able to know who have apply for the leave: where it is highlighted blue i
want to put like test user have apply for a leave. could you please advise
how to do that.
here is my view.py

def email_authorizer(request):
email_obj = newleave.objects.order_by('-pk')[0]
if email_obj.department == 'GOV':
to_emails = [u.email for u in
User.objects.filter(username__in=['sabiut'])]
send_mail("RBV Leave Application Email Testing", "You have received
a leave application form. Please login to the leave system to Authorize the
leave. \nPlease ignore this message, we are testing the new eLeave system!",
"RBV eLeave ", [to_emails])
return render_to_response('thankyou.html')


Cheers,





On Tue, Jan 27, 2015 at 6:03 PM, James Schneider 
wrote:

> Instead of looping through the all() set of objects (which works quickly
> with small sets of objects, imagine >20K objects, that would be noticeably
> slower, probably seconds or more),  you should just query the object you
> want directly using something like:
>
> obj = newleave.objects.order_by('-pk')[0]
>
> That would give you the newleave object that has the highest PK, and would
> presumably be the most recently added entry. No need for a loop, let the DB
> do the work in this case.
>
> I'm a bit confused by the logic in the for loop. You
> re-query newleave.objects.filter(department="GOV"), which would return a
> bunch of rows no matter what (based on the output you provided), and has no
> relation based on the object that you asked about initially. I don't think
> that does what you want, as it will send out an email every time no matter
> what, not just every time that obj.department == 'GOV' (which is probably
> the check you want instead).
>
> -James
>
> On Mon, Jan 26, 2015 at 4:01 PM, sum abiut  wrote:
>
>> Here is how it looks like, when a new row is added it display last.
>> [image: Inline image 1]
>>
>>
>> On Tue, Jan 27, 2015 at 10:51 AM, Stephen J. Butler <
>> stephen.but...@gmail.com> wrote:
>>
>>> Do you have a default ordering on the Model object? That is, an
>>> ordering option on newleave.Meta? Because otherwise this query
>>> "newleave.objects.all()" is not at all guaranteed to return rows in
>>> the order they were added.
>>>
>>> It may, by coincidence, in your current environment behave that way.
>>> But change databases, or add more rows, or look at it funny, and that
>>> won't be true.
>>>
>>> On Mon, Jan 26, 2015 at 5:38 PM, sum abiut  wrote:
>>> > Thank you for your email. I am iterating all the row to find out which
>>> row
>>> > was recently added. basically when a row is added to it become last.
>>> so i am
>>> > trying to comparing a column on the last row. which is the row that was
>>> > recently add if the condition of the column is exist. that is when i
>>> send
>>> > out email.
>>> >
>>> > hope my explanation is clear.
>>> >
>>> > Cheers
>>> >
>>> >
>>> > On Tue, Jan 27, 2015 at 10:28 AM, Paul Royik 
>>> > wrote:
>>> >>
>>> >> Inside view there is no forloop (unless you explicitly define it).
>>> forloop
>>> >> is defined only inside for loops in templates
>>> >>
>>> >> Actually your code is somewhat weird.
>>> >> You iterate all list until last without doing anything.
>>> >>
>>> >> It is more efficient to use slicing
>>> >>
>>> >> email = newleave.objects.all()[-1] # this is already last item
>>> >> govoffice=newleave.objects.filter(department="GOV")
>>> >> if govoffice.exists():
>>> >> to_emails = [u.email for u   in
>>> >> User.objects.filter(username__in['testuser','sabiut'])]
>>> >> send_mail("RBV Leave Application Email Testing", "You
>>> have
>>> >> received a leave application form. Please login to the leave system to
>>> >> Authorize the leave.",
>>> >> "RBV eLeave ", [to_emails])
>>> >> return render_to_response('thankyou.html')
>>> >>
>>> >> Other code is also not very understandable, but I can't help you,
>>> since
>>> >> don't understand what should be done.
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Django users" group.
>>> >> To unsubscribe from this group and stop receiving emails from it,
>>> send an
>>> >> email to django-users+unsubscr...@googlegroups.com.
>>> >> To post to this group, send email to django-users@googlegroups.com.
>>> >> Visit this group at http://groups.google.com/group/django-users.
>>> >> To view this discussion on the web visit
>>> >>
>>> https://groups.google.com/d/msgid/django-users/ac2740f3-2e60-44f7-860d-974550476cd4%40googlegroups.com
>>> .
>>> >> For more options, visit https://groups.google.com/d/optout.
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> > --
>>> > You received this 

Help in Django-contact-form

2015-01-27 Thread Akash Nimare
Hello everyone. I am using a third party app django-contact-form. It is 
working fine but the problem is it does not show my models in admin. I 
can't see the data in admin. The docs are very poor.
Here is my model.py 

from django.db import models
from contact_form.forms import ContactForm
class ContactForm(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField(max_length=200)
body = models.CharField(max_length=200)
def __str__(self):
return (self.email)

 admin.py
from django.contrib import admin
from . import models
from contact_form.models import ContactForm
class ContactFormAdmin(admin.ModelAdmin):
list_display = ("name", "body", "email")
admin.site.register(ContactForm, ContactFormAdmin)
I am using django 1.7
http://django-contact-form.readthedocs.org/en/latest/quickstart.html

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


Re: Wanted: Best practices for setting "_" (to ugettext/ugettext_lazy)

2015-01-27 Thread Collin Anderson
Hi,

Why reset it at the end of your module?

Why not use ugettext_lazy everywhere?
from django.utils.translation import ugettext_lazy as _

(Disclaimer: I've never used translations before :)

Collin

On Saturday, January 24, 2015 at 3:46:31 AM UTC-5, Torsten Bronger wrote:
>
> Hallöchen! 
>
> This is not about where to use ugettext/ugettext_lazy.  I know 
> that.  :-) 
>
> But I was fed up with all those "_ = ugettext" scattered in my code 
> and tried to find a more systematic approach.  The following test 
> program runs through: 
>
> ugettext = lambda x: x 
> ugettext_lazy = lambda x: x 
>
> _ = ugettext_lazy 
>
> def function(): 
> assert _ == ugettext 
>
> class A(object): 
> assert _ == ugettext_lazy 
>
> def method(self): 
> assert _ == ugettext 
>
> assert _ == ugettext_lazy 
>
> assert _ == ugettext_lazy 
>
> def function_b(): 
> assert _ == ugettext 
>
> _ = ugettext 
>
>
> function() 
> function_b() 
> a = A() 
> a.method() 
>
> Do you think this is a good idea?  Simply setting _ to 
> ugetttext_lazy at the beginning of a module and to ugettext at the 
> end (and dealing with the very few remaining exceptions)?  How do 
> you do that? 
>
> Tschö, 
> Torsten. 
>
> -- 
> Torsten BrongerJabber ID: torsten...@jabber.rwth-aachen.de 
>  
>   or http://bronger-jmp.appspot.com 
>
>

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


Re: gis: geo_db_type error in run_checks() in 1.7 (not 1.6)

2015-01-27 Thread Collin Anderson
Hi,

You could also try the geodjango mailing list if nothing else.
http://groups.google.com/group/geodjango

Collin

On Sunday, January 25, 2015 at 6:04:57 PM UTC-5, dne...@destinati.com wrote:
>
> Hi,
>
> Wanted to throw this out there, not sure truly if it is my fault or a bug.
>
> Just upgraded from (python 2.6.x, django 1.6) to (python 2.7.x, django 
> 1.7).
> If I invoke manage.py on any subcommand, I get an error as follows:
>
> 
> [app_dev]$ python2.7 manage.py sql
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 385, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 377, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 337, in execute
> self.check()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 371, in check
> all_issues = checks.run_checks(app_configs=app_configs, tags=tags)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py", 
> line 59, in run_checks
> new_errors = check(app_configs=app_configs)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/checks/model_checks.py", 
> line 28, in check_all_models
> errors.extend(model.check(**kwargs))
>   File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", 
> line 1046, in check
> errors.extend(cls._check_fields(**kwargs))
>   File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", 
> line 1122, in _check_fields
> errors.extend(field.check(**kwargs))
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" 
> , line 192, in check
> errors.extend(self._check_backend_specific_checks(**kwargs))
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py" 
> , line 290, in _check_backend_specific_checks
> return connection.validation.check_field(self, **kwargs)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>  
> line 23, in check_field
> field_type = field.db_type(connection)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/contrib/gis/db/models/fields.py",
>  
> line 221, in db_type
> return connection.ops.geo_db_type(self)
> AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
> 
>
> In mysql/validation.py in Django 1.7 it attempts 'field_type = 
> field.db_type(connection)'. This call isn't made in the same function in 
> Django 1.6, so this problem doesn't arise. If I add this call into the 
> Django 1.6 function the same error appears.
>
> Something to do with the fact that connection.ops is  'django.db.DefaultConnectionProxy'>. 'django.db.backends.mysql.base.DatabaseOperations'> so it isn't correctly 
> getting to contrib/gis/db/backends/mysql/operations.py (?).
>
> This error occurs for a PointField field (not sure about any others), e.g. 
> a model of the type:
>
> ---
> from django.contrib.gis.db import models class MyModel(models.Model):
> point_xy = models.PointField()
> objects = models.GeoManager()
> ---
>
> CentOS release 6.6 (Final)
> geos.x86_64 3.3.2-1.el6
> mysql.x86_645.1.73-3.el6_5
> Django (1.7.3)
> Python 2.7.9
> MySQL-python (1.2.5)
>
> I fixed this with a hack (avoid the db_type call based on the few field 
> names I use for PointField's), but perhaps this should be looked into.
>
> Dylan Nelson
>
>

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


Re: Forms test run on development database instead of test database

2015-01-27 Thread Collin Anderson
Hi,

I just tried out your project. Looking at the stacktrace, the test module 
is importing forms (before the test starts). The forms module is running a 
query on startup for choices.

https://github.com/merwan/django-choicefield/blob/master/myapp/forms.py

Don't do queries on startup. :)

Collin

On Monday, January 26, 2015 at 7:07:54 AM UTC-5, Merouane Atig wrote:
>
> Hi,
>
> I have a strange issue with a forms test and I would like to know if I'm 
> doing something wrong or if it is a Django bug.
>
> I created a repo to reproduce the issue I have: 
> https://github.com/merwan/django-choicefield
>
> I have a DomainForm class with a choice field populated from a table in 
> the database. I'm trying to test it using the Django testing tools, but I 
> get the error "django.db.utils.OperationalError: no such table: 
> myapp_topleveldomain" (see the README in the Github repo for the full stack 
> trace).
>
> If I first create my development database and migrate it, then I do not 
> have any error. I expected that the test would run on the test database but 
> it is not the case.
>
> My test environment should work properly as I also created a model test 
> which runs correctly on the test database and do not need the development 
> database.
>
> Can you tell me what would be the proper way to write this test so that it 
> runs on the test database? Is it a bug with the Django testing tools or am 
> I doing something wrong when populating my ChoiceField?
>
> I'm using Django 1.7.3 and Python 3.4.0
>
> Thanks for your help
>

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


Re: sending email

2015-01-27 Thread Collin Anderson
Hi,

You should be able to figure out which box is checked from 
form.cleaned_data.

Collin

On Sunday, January 25, 2015 at 11:53:12 PM UTC-5, suabiut wrote:
>
> Hi Collin,
> Thank you very much for your help. its works perfectly.
> The next thing i want to do is to send an email to a specific user that i 
> select on a table. when an authorized user select a user to approve his or 
> her leave i want an email to be send to the user. so basically when i click 
> on the checkbox on the Test User form the table below. i should get a form 
> to approve the leave as below. now when i click on authorized Leave button 
> an email should be send to the test user. please point me to right 
> direction.
>  [image: Inline image 1]
>
> [image: Inline image 2]
>
> Cheers,
>
> On Fri, Jan 23, 2015 at 1:18 PM, Collin Anderson  > wrote:
>
>> Hi,
>>
>> Just query the users you want.
>>
>> to_emails = [u.email for u in 
>> User.objects.filter(username__in=['person1', 'person2', 'person3'])]
>> send_mail('Subject here', 'Here is the message.', from_email_address, 
>> to_emails)
>>
>> Collin
>>
>> On Wednesday, January 21, 2015 at 11:29:51 PM UTC-5, suabiut wrote:
>>>
>>> Thanks,
>>> I am trying to send email to the users that their email address is 
>>> stored in the database on the auth_user table. can someone please point me 
>>> to the right direction.
>>>
>>> Cheers,
>>>
>>>
>>> On Thu, Jan 22, 2015 at 3:03 PM, Collin Anderson  
>>> wrote:
>>>
 Hi,

 Yes, this is possible. Something like:

 from django.core.mail import send_mail

 def authorized_leave(request):
 form = MyForm()
 if request.method == 'POST':
 form = MyForm(request.POST)
 if form.is_valid():
 obj = form.save()
 send_mail('Subject here', 'Here is the message.', '
 fr...@example.com', ['t...@example.com'])
 return redirect('/done/')
 return render(request, 'template.html', {form: 'form'})

 Collin


 On Monday, January 19, 2015 at 10:02:45 PM UTC-5, suabiut wrote:
>
> Hi,
> I am trying to send an email to several users once a form is submit. I 
> have done the view.py to update the database once the form is submitted 
> and 
> is working fine. what i want to accomplish when the form is submitted is 
> to 
> update the database and at the same time send out email when a user click 
> on the Authorized leave button.
>
> here is the step i want to do:
>
>  [image: Inline image 1]
>
> 1) user click on the check box and this form below appears
>
>
> [image: Inline image 2]
>  2) the user then fill up the form and click on authorized leave 
> button. the form will stored the information into the database. which i 
> have already done it. what i wanted to do next is to also send a emails 
> when the authorized leave button is click. is it possible to send emails 
> and also save data to database when the authorized leave button is click. 
> i 
> want to send email to the *Test User* which have his email address 
> store in the database. 
>
> template.html
> {%csrf_token%}
> 
> {{form.as_table}}
> 
> 
>   
>
>
> 
>
> please point me to the right direction.
>
> Cheers,   
>
>   -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/3df19a0c-2afc-4e17-b527-83d38a639611%
 40googlegroups.com 
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>>   -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/619e2173-3ac1-4e98-9b91-5c49966ab968%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -
>  

-- 
You received this 

Re: programming error in group by clause

2015-01-27 Thread Collin Anderson
Hi,

What database are you using?

If you can reproduce this in a simple project, feel free to open a ticket 
about it.

Thanks,
Collin

On Sunday, January 25, 2015 at 12:51:31 AM UTC-5, satya wrote:
>
> Need some help on fixing the following error. I recently moved to 1.8alpha 
> version from an older version django-e9d1f11 and I started seeing this 
> error. Looks like the way group by is constructed has changed.
>
> Here is the model that I have.
>
> class everydaycost(models.Model):
> cost = models.DecimalField(max_digits=20, decimal_places=2)
> rev = models.DecimalField(max_digits=20, decimal_places=2)
> ts = models.DateField(db_index=True)
>
> I am trying to get roi (rev/cost) for each day of week.
>
> $ python manage.py shell
> Python 2.7.5 (default, Mar  9 2014, 22:15:05)
> [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>>
> >>> from testgroupby.models import *
> >>> from django.db.models import Q, Count, Min, Sum, Func, FloatField
> >>> qs = everydaycost.objects.all()
> >>> qs = qs.extra(select={'dow': "TO_CHAR(ts, 'D')"})
> >>> qs = qs.values('dow')
> >>> qs = qs.annotate(sum_cost=Sum('cost'))
> >>> qs = qs.annotate(sum_rev=Sum('rev'))
> >>> qs = qs.annotate(roi=Func(A='CAST(Sum("rev") as numeric)', 
> B='CAST(Sum("cost") as numeric)',
> ... template='ROUND(COALESCE(%(A)s / NULLIF(%(B)s,0), 0), 
> 2)', output_field=FloatField()))
> >>> print qs
> DEBUG(0.002) SELECT (TO_CHAR(ts, 'D')) AS "dow", 
> SUM("testgroupby_everydaycost"."cost") AS "sum_cost", 
> SUM("testgroupby_everydaycost"."rev") AS "sum_rev", 
> ROUND(COALESCE(CAST(Sum("rev") as numeric) / NULLIF(CAST(Sum("cost") as 
> numeric),0), 0), 2) AS "roi" FROM "testgroupby_everydaycost" GROUP BY 
> (TO_CHAR(ts, 'D')), ROUND(COALESCE(CAST(Sum("rev") as numeric) / 
> NULLIF(CAST(Sum("cost") as numeric),0), 0), 2) LIMIT 21; args=()
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Downloads/Django-1.8a1/django/db/models/query.py", line 139, in 
> __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File "/Downloads/Django-1.8a1/django/db/models/query.py", line 163, in 
> __iter__
> self._fetch_all()
>   File "/Downloads/Django-1.8a1/django/db/models/query.py", line 955, in 
> _fetch_all
> self._result_cache = list(self.iterator())
>   File "/Downloads/Django-1.8a1/django/db/models/query.py", line 1075, in 
> iterator
> for row in self.query.get_compiler(self.db).results_iter():
>   File "/Downloads/Django-1.8a1/django/db/models/sql/compiler.py", line 
> 780, in results_iter
> results = self.execute_sql(MULTI)
>   File "/Downloads/Django-1.8a1/django/db/models/sql/compiler.py", line 
> 826, in execute_sql
> cursor.execute(sql, params)
>   File "/Downloads/Django-1.8a1/django/db/backends/utils.py", line 80, in 
> execute
> return super(CursorDebugWrapper, self).execute(sql, params)
>   File "/Downloads/Django-1.8a1/django/db/backends/utils.py", line 65, in 
> execute
> return self.cursor.execute(sql, params)
>   File "/Downloads/Django-1.8a1/django/db/utils.py", line 95, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>   File "/Downloads/Django-1.8a1/django/db/backends/utils.py", line 65, in 
> execute
> return self.cursor.execute(sql, params)
> ProgrammingError: aggregate functions are not allowed in GROUP BY
> LINE 1: ... GROUP BY (TO_CHAR(ts, 'D')), ROUND(COALESCE(CAST(Sum("rev")...
>  ^
>
> >>> print qs.query
> SELECT (TO_CHAR(ts, 'D')) AS "dow", SUM("testgroupby_everydaycost"."cost") 
> AS "sum_cost", SUM("testgroupby_everydaycost"."rev") AS "sum_rev", 
> ROUND(COALESCE(CAST(Sum("rev") as numeric) / NULLIF(CAST(Sum("cost") as 
> numeric),0), 0), 2) AS "roi" FROM "testgroupby_everydaycost" GROUP BY 
> (TO_CHAR(ts, 'D')), ROUND(COALESCE(CAST(Sum("rev") as numeric) / 
> NULLIF(CAST(Sum("cost") as numeric),0), 0), 2)
> >>>
>
>
> With earlier version, this worked fine for me.
>
>
> $ python manage.py shell
> Python 2.7.5 (default, Mar  9 2014, 22:15:05)
> [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>>
> >>> from testgroupby.models import *
> >>> from django.db.models import Q, Count, Min, Sum, Func, FloatField
> >>> qs = everydaycost.objects.all()
> >>> qs = qs.extra(select={'dow': "TO_CHAR(ts, 'D')"})
> >>> qs = qs.values('dow')
> >>> qs = qs.annotate(sum_cost=Sum('
> cost'))
> >>> qs = qs.annotate(sum_rev=Sum('rev'))
> >>> qs = qs.annotate(roi=Func(A='CAST(Sum("rev") as numeric)', 
> B='CAST(Sum("cost") as numeric)',
> ... template='ROUND(COALESCE(%(A)s / NULLIF(%(B)s,0), 0), 
> 2)', output_field=FloatField()))
> >>> print qs
> DEBUG(0.002) SELECT (TO_CHAR(ts, 'D')) AS "dow", 
> SUM("testgroupby_everydaycost"."cost") AS 

Re: How do you link your Django project to a domain

2015-01-27 Thread François Schiettecatte
I would not recommend godaddy.com, they try really hard to upsell you, I use 
hover.com and I have also heard good things about domain.com

François

> On Jan 27, 2015, at 3:09 PM, Collin Anderson  wrote:
> 
> I use namecheap, but yes, domains.google.com has a nice user interface.
> 
> On Saturday, January 24, 2015 at 8:22:33 AM UTC-5, patrickbeeson wrote:
> You might also check out Google's recently launched domain registrar at 
> domains.google.com.
> 
> On Saturday, January 24, 2015 at 2:01:43 AM UTC-5, djangocharm2020 wrote:
> pretty much have a project built but now want to purchase a domain to link it 
> live . Do you guys have any suggestions on who i should go with like 
> godaddy.com.
> 
> I also need to know is there a special step or code that is needed to add to 
> the project?
> 
> Thanks 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d49b77bc-a760-4867-8611-0f80cac9717c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Django: How to customize the admin form for specific model

2015-01-27 Thread Collin Anderson
Hi,

You could have the images be inline:

class CommentImageInline(models.TabularInline):
model = CommentImage
extra = 0

class CommentAdmin(models.ModelAdmin):
inlines = [CommentImageInline]

Though, you may need to use a custom widget to get the actual images to 
show up.

Collin

On Saturday, January 24, 2015 at 2:31:02 PM UTC-5, Shoaib Ijaz wrote:
>
> First of all I apologize the question title can be unrelated to my query. 
> I am also confused what I want to do because I am less familiar with django.
>
> I want to create simple comment system. The requirement is clear that user 
> can post comment with multiple images.Every comment should have reply. so I 
> created following models.
>
> #comment table class Comments(models.Model):
> parent = models.ForeignKey('self',null=True) // for comment reply
> description = models.TextField(max_length=1000, blank=False, null=False)
>
> class Meta:
> db_table = u'comments'
>
> #images tableclass CommentImages(models.Model):
> comment = models.ForeignKey(Comments)
> image = models.CharField(max_length=250, blank=False, null=False)
>
> class Meta:
> db_table = u'comments_images'
>
> I have query about admin side how can i manage these things?
>
> I want to show images list when admin view the specific comment.
>
> Admin can view replies of specific comment.
>
> Here i draw the example. [image: enter image description here]
>
> So I dont want to ask about coding. I want to know what techniques will be 
> used to change the admin view. I am using admin panel for others models too 
> so I want to change the specific model view.
>
> How can I get these things? Thank you
>

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


Re: unable to open project

2015-01-27 Thread Collin Anderson
Hi,

What happens when you try?

Collin

On Saturday, January 24, 2015 at 3:59:55 AM UTC-5, abhishek kumar wrote:
>
> I am unable to open my project again.  As i am using virtual enviroment in 
> windows.
>

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


Re: How do you link your Django project to a domain

2015-01-27 Thread Collin Anderson
I use namecheap, but yes, domains.google.com has a nice user interface.

On Saturday, January 24, 2015 at 8:22:33 AM UTC-5, patrickbeeson wrote:
>
> You might also check out Google's recently launched domain registrar at 
> domains.google.com.
>
> On Saturday, January 24, 2015 at 2:01:43 AM UTC-5, djangocharm2020 wrote:
>>
>> pretty much have a project built but now want to purchase a domain to 
>> link it live . Do you guys have any suggestions on who i should go with 
>> like godaddy.com.
>>
>> I also need to know is there a special step or code that is needed to add 
>> to the project?
>>
>> Thanks 
>>
>

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


Re: login_required in urlpatterns TypeError 'tuple' object is not callable

2015-01-27 Thread Collin Anderson
Hi,

Something like this might work:

from home.urls import urlpatterns as home_urls


url('^home/', include(list(login_required(x) for x in home_urls)))

Collin

On Friday, January 23, 2015 at 7:09:30 PM UTC-5, Vijay Khemlani wrote:
>
> I may be mistaken, but I don't think you can decorate an entire "include" 
> call
>
> On Fri, Jan 23, 2015 at 8:51 PM, Neto  > wrote:
>
>> Hi, I'm using login_required in url patterns but it does an error:
>>
>> urls.py
>>
>> from django.conf.urls import patterns, include, url
>> from django.contrib.auth.decorators import login_required
>>
>>
>> urlpatterns = patterns('',
>> url(r'^home/', login_required(include('home.urls'))),
>>
>> )
>>
>>
>> error:
>> TypeError at /home/
>>
>> 'tuple' object is not callable
>>
>> how to fix this?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a0a93906-ce10-4b46-bb7a-67aa8d458a6c%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: Dictionary in admin interface

2015-01-27 Thread Collin Anderson
Hi,

The admin doesn't really have a way to do this. You could edit KeyValuePair 
inline on Dictionary.

Why not have a "Params" model that has a ForeignKey to Request?

Collin

On Friday, January 23, 2015 at 1:32:21 PM UTC-5, Sven Mäurer wrote:
>
> I want to manage a dictionary inline over the admin interface. These are 
> my models. What I got working is of course a separated management of 
> request and dictionary. But I want to add key value pairs in the request 
> admin interface with a TabularInline. Do I have to skip the dictionary in 
> some way or what do I have to do?
>
> class Dictionary(models.Model):
> name = models.CharField(max_length=255)
> class KeyValuePair(models.Model):
> container = models.ForeignKey(Dictionary, db_index=True)
> key = models.CharField(max_length=240, db_index=True)
> value = models.CharField(max_length=240, db_index=True)
> class Request(models.Model):
> params = models.ForeignKey(Dictionary, related_name="params_map", 
> blank=True, null=True)
>
>

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


Re: Django UnicodeDecodeError at /admin/login/

2015-01-27 Thread James Schneider
Did you read the comments on that snippet? It appears there may need to be
some extra encoding/decoding needed (example additional code is listed
there), which would make sense given the decoding errors you are seeing.

-James
On Jan 27, 2015 9:54 AM, "Supermario"  wrote:

> I try to implement this 
> hasher in order to be able to authenticate user who are imported from
> drupal 7.
>
> So I put the hasher in the settings.py as follows:
>
>
> PASSWORD_HASHERS = (
>
> 'myproj.drupal_hasher.DrupalPasswordHasher', #drupal hasher
>
> 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
>
> 'django.contrib.auth.hashers.BCryptPasswordHasher',
> 'django.contrib.auth.hashers.SHA1PasswordHasher',
> 'django.contrib.auth.hashers.MD5PasswordHasher',
> 'django.contrib.auth.hashers.CryptPasswordHasher',
>  )
>
>
>
> However it does not authenticate imported users from drupal and for users
> who are created in Django I get:
>
> 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in
> range(128)
>
>
>
>
> Here is the trackback:
>
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/auth/
>
> Django Version: 1.7.3
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'article',
>  'photo',
>  'debug_toolbar',
>  'django_markdown',
>  'haystack')
> Installed Middleware:
> (u'debug_toolbar.middleware.DebugToolbarMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
> Traceback:
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   111. response = wrapped_callback(request, *
> callback_args, **callback_kwargs)
> File "/home/mario/myproj/myauth/views.py" in auth_view
>   16. user = auth.authenticate(username=username, password=
> password)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py"
> in authenticate
>   60. user = backend.authenticate(**credentials)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/backends.py"
> in authenticate
>   17. if user.check_password(password):
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
> in check_password
>   237. return check_password(raw_password, self.password,
> setter)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
> in check_password
>   63. setter(password)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
> in setter
>   235. self.set_password(raw_password)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
> in set_password
>   227. self.password = make_password(raw_password)
> File
> "/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
> in make_password
>   85. return hasher.encode(password, salt)
> File "/home/mario/myproj/myproj/drupal_hasher.py" in encode
>   81. encoded_hash = self._apply_hash(password, self._digests[
> digest], settings)
> File "/home/mario/myproj/myproj/drupal_hasher.py" in _apply_hash
>   68. password_hash = digest(password_hash + password).
> digest()
>
> Exception Type: UnicodeDecodeError at /auth/
> Exception Value: 'ascii' codec can't decode byte 0xcf in position 0:
> ordinal not in range(128)
>
>
> All source and destination database tables are converted to
> utf8_unicode_ci.
>
> I am stock on this problem for days so really appreciate your help.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5dd15420-01d5-4b1f-adf0-af3ee585ba73%40googlegroups.com
> 

Re: How to detect (daily) User Login when using cookies?

2015-01-27 Thread Collin Anderson
Hi,

Would it make sense to simply keep a record of when the last time you've 
seen the user is?

Collin

On Friday, January 23, 2015 at 4:43:41 AM UTC-5, Tobias Dacoir wrote:
>
> I'm using django-allauth and I receive a signal when a user logs in. Now I 
> want to store each day the user logs in. However, when the user does not 
> logout he can still log in the next day thanks to the cookies. I know that 
> I can set SESSION_EXPIRE_AT_BROWSER_CLOSE to True in settings.py. But this 
> may annoy some Users. 
>
> So is there a way to use cookies but still tell if a User has accessed the 
> site for the first time today?
>

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


Re: Unable to save object with images while using FormWizard in Django 1.7 and Python 3.4

2015-01-27 Thread Collin Anderson
Hi,

Use items() instead of iteritems().

Collin

On Thursday, January 22, 2015 at 11:31:23 AM UTC-5, Frankline wrote:
>
> ​Hi all​,
> I am having a problem saving a Django form using the *FormWizard 
> * 
> while using *Django 1.7* and *Python 3.4*. Below is my code:
>
> *models.py*
>
> ...class Advert(models.Model):
> ... # Some irelevant code removed for brevity
> owner = models.ForeignKey(settings.AUTH_USER_MODEL, db_index=True, 
> blank=False, null=False)
> title = models.CharField(_("Title"), max_length=120)
> description = models.TextField(_("Description"), default='')
> category = models.ForeignKey(AdCategory, db_index=True, 
> related_name='ad_category', verbose_name=_('Category'))
> status = models.IntegerField(choices=ADVERT_STATES, default=0)
> adtype = models.IntegerField(choices=ADTYPES, default=1)
> price = models.DecimalField(_('Price'), max_digits=12, decimal_places=2, 
> blank=True, default=0,
> help_text=_('Price'), 
> validators=[MinValueValidator(0)])
> ...class AdvertImage(models.Model):
>
> def generate_new_filename(instance, filename):
> IMAGE_UPLOAD_DIR = "advert_images"
> old_fname, extension = os.path.splitext(filename)
> return '%s/%s%s' % (IMAGE_UPLOAD_DIR, uuid.uuid4().hex, extension)
> 
> advert = models.ForeignKey(Advert, related_name='images')
> image = models.ImageField(upload_to=generate_new_filename, null=True, 
> blank=True)
>
>
> *forms.py*
>
> from django.forms.models import inlineformset_factoryfrom django import 
> formsfrom django.forms import ModelForm, RadioSelect, TextInput
> from .models import Advert, AdvertImage
>
> class AdvertCategoryForm(ModelForm):
>
> class Meta:
> model = Advert
> fields = ('category',)
>
> class AdvertDetailsForm(ModelForm):
>
> class Meta:
> model = Advert
> fields = ('title', 'description', 'location', 'adtype', 'price')
>
> class AdvertImageForm(ModelForm):
>
> class Meta:
> model = AdvertImage
> fields = ('image',)
>
> AdvertImageFormset = inlineformset_factory(Advert, AdvertImage, 
> fields=('image',), can_delete=False, extra=3, max_num=3)
>
>
> FORMS = [("ad_category", AdvertCategoryForm),
>  ("ad_details", AdvertDetailsForm),
>  ("ad_images", AdvertImageFormset)]
>
> TEMPLATES = {"ad_category": "adverts/advert_category_step.html",
>  "ad_details": "adverts/advert_details_step.html",
>  "ad_images": "adverts/advert_images_step.html"}
>
>
> *views.py*
>
> ...class AdvertWizard(LoginRequiredMixin, SessionWizardView):
>
> form_list = FORMS
> file_storage = 
> FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT))
>
> def get_template_names(self):
> return [TEMPLATES[self.steps.current]]
>
> ...
>
> def done(self, form_list, **kwargs):
> advert = Advert()
> """for form in form_list:for field, value in 
> form.cleaned_data.iteritems():setattr(advert, field, value)"""
>
> form_dict = {}
> for form in form_list:
> form_dict.update(form.cleaned_data)
>
> advert.owner = self.request.user
> advert.save()
> redirect(advert)
>
>
> ​The problem occurs in the done method while saving the form:
>
> ValueError at /ads/new
>
> dictionary update sequence element #0 has length 3; 2 is required
>
> Request Method:POSTRequest URL:http://localhost:8000/ads/newDjango 
> Version:1.7.1Exception Type:ValueErrorException Value:
>
> dictionary update sequence element #0 has length 3; 2 is required
>
> Exception 
> Location:/home/frank/Projects/python/django/pet_store/src/petstore/apps/adverts/views.py
>  
> in done, line 147Python Executable:
> /home/frank/.virtualenvs/petstore/bin/pythonPython Version:3.4.0
>
>- 
>
> /home/frank/Projects/python/django/pet_store/src/petstore/apps/adverts/views.py
> in done
>1. 
>   
>   form_dict.update(form.cleaned_data)
>   
>   ...
>▶ Local vars 
>
> However, when I replace the following code:
>
> form_dict = {}
> for form in form_list:
> form_dict.update(form.cleaned_data)
>
> with this one
>
> for form in form_list:
> for field, value in form.cleaned_data.iteritems():
> setattr(advert, field, value)
>
> I now get the following error:
>
> AttributeError at /ads/new
>
> 'dict' object has no attribute 'iteritems'
>
> Request Method:POSTRequest URL:http://localhost:8000/ads/newDjango 
> Version:1.7.1Exception Type:AttributeErrorException Value:
>
> 'dict' object has no attribute 'iteritems'
>
> Exception 
> Location:/home/frank/Projects/python/django/pet_store/src/petstore/apps/adverts/views.py
>  
> in done, line 140Python Executable:
> 

Django UnicodeDecodeError at /admin/login/

2015-01-27 Thread Supermario
I try to implement this  hasher 
in order to be able to authenticate user who are imported from drupal 7. 

So I put the hasher in the settings.py as follows:


PASSWORD_HASHERS = (

'myproj.drupal_hasher.DrupalPasswordHasher', #drupal hasher
 
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',

'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
 ) 



However it does not authenticate imported users from drupal and for users 
who are created in Django I get:

'ascii' codec can't decode byte 0xcf in position 0: ordinal not in 
range(128)




Here is the trackback:


Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/auth/

Django Version: 1.7.3
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'article',
 'photo',
 'debug_toolbar',
 'django_markdown',
 'haystack')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 
in get_response
  111. response = wrapped_callback(request, *
callback_args, **callback_kwargs)
File "/home/mario/myproj/myauth/views.py" in auth_view
  16. user = auth.authenticate(username=username, password=password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py"
 
in authenticate
  60. user = backend.authenticate(**credentials)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/backends.py"
 
in authenticate
  17. if user.check_password(password):
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in check_password
  237. return check_password(raw_password, self.password, setter
)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
 
in check_password
  63. setter(password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in setter
  235. self.set_password(raw_password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/models.py"
 
in set_password
  227. self.password = make_password(raw_password)
File 
"/home/mario/.myprojenv/local/lib/python2.7/site-packages/django/contrib/auth/hashers.py"
 
in make_password
  85. return hasher.encode(password, salt)
File "/home/mario/myproj/myproj/drupal_hasher.py" in encode
  81. encoded_hash = self._apply_hash(password, self._digests[
digest], settings)
File "/home/mario/myproj/myproj/drupal_hasher.py" in _apply_hash
  68. password_hash = digest(password_hash + password).
digest()

Exception Type: UnicodeDecodeError at /auth/
Exception Value: 'ascii' codec can't decode byte 0xcf in position 0: 
ordinal not in range(128)


All source and destination database tables are converted to utf8_unicode_ci.

I am stock on this problem for days so really appreciate your help. 



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


[ANNOUNCE] Django bug fix releases issued: 1.7.4 and 1.4.19

2015-01-27 Thread Tim Graham
Today the Django project has issued bugfix releases in the 1.7 and 1.4 
release series.

Full details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2015/jan/27/bugfix-releases-issued/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0520af55-1a6b-44b0-90d5-9e690e867397%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django / tastypie - how to exclude a resource attribute from obj_create, but keep it for listing

2015-01-27 Thread Eugene Goldberg
  I have the following tastypie resource:

 class WorkloadResource(ModelResource):
# blueprints = ManyToManyField(Blueprint, 'blueprints')
blueprint = fields.OneToManyField('catalog.api.BlueprintResource', 
attribute='blueprint',
 related_name='workloads', full=True, 
null=True)

def obj_create(self, bundle, request=None, **kwargs):
# return super(WorkloadResource, self).obj_create(bundle, request, 
**kwargs)
return super(WorkloadResource, self).obj_create(bundle, 
request=request, **kwargs)

def obj_update(self, bundle, request=None, **kwargs):

workload = Workload.objects.get(id=kwargs.get("pk"))
workload.description = bundle.data.get("description")
workload.name = bundle.data.get("name")
workload.image = bundle.data.get("image")
workload.flavor = bundle.data.get("flavor")
workload.save()

def obj_delete(self, bundle, **kwargs):

return super(WorkloadResource, self).obj_delete(bundle)

def determine_format(self, request):
return 'application/json'

class Meta:
queryset = Workload.objects.all()
resource_name = 'workload'
authorization=Authorization()
filtering = {
"blueprint": ('exact', ),
}


 When I use curl to POST: 

 curl -i -H "Content-Type: application/json" -X POST -d 
 @wkl.json  http://localhost:8000/api/workload/

 where wkl.json is:

 { "name":"w 5", "description":"w 5 desc" }


 I get this error:

 AttributeError: 'Workload' object has no attribute 'blueprint'

 I do need to have this attribute, so I can list all child workloads for a 
given blueprint 
 like this:  GET /api/workload/?blueprint=1

 but I need to exclude this 'blueprint' attribute from participating in the 
obj_create

 What is the proper place and syntax to do this?


-Eugene



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


path to django from jython

2015-01-27 Thread Josh Stratton
Okay, stupid question, but how do I source django when jusing jython?  I
have django installed using pip and jython installed locally.  I've built
my project using python and after adding "doj" to the installed apps, I get
a path error building a war.

$ jython manage.py buildwar
Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
ImportError: No module named django

https://pythonhosted.org/django-jython/war-deployment.html

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


Re: django doubt

2015-01-27 Thread George Silva
what? english, please.
Em 27/01/2015 12:13, "termopro"  escreveu:

>
> Purpose well, libs clean, u happy.
> If don't use, don't use - problem no.
> The diff is some syntx sugr/ abilty do thngs ezly.
>
> On Tuesday, January 27, 2015 at 9:15:19 AM UTC+2, Kadhir Mani wrote:
>>
>> what pupose using virtualenv ?if don't use what hapend? what is diff bte
>> virtualwrpper and virtualenv
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c4a88bde-5dd5-45dd-91c5-16711bf399a9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: read GET and POST simultaneously?

2015-01-27 Thread Eric Abrahamsen
Tom Christie  writes:

> Absolutely no problem at all doing that. The only thing that's
> confusing here is that `request.GET` is a misleading name. The query
> parameters are available on any request, regardless of the HTTP
> method.
>
>> Is this reliable behavior across browsers?
>
> Yes.
>
>> Is it a dumb idea for reasons I haven't thought of?
>
> No.

Thank you very much!

> Cheers,
>
> Tom
>
> On Tuesday, 27 January 2015 03:26:52 UTC, Eric Abrahamsen wrote:
>
> As far as I can tell (testing with the Conkeror web browser), it's
> possible to read both GET and POST at once: if a user POSTs to a URL
> containing GET parameters, you can get them both in the view.
> 
> Is this reliable behavior across browsers? Is it a dumb idea for
> reasons I haven't thought of?
> 
> A bit of background, in case there's simply a better approach to
> this:
> 
> I'm using GET parameters to create custom model formsets:
> depending on those parameters, I construct different initial data, and
> set some of the form fields to use hidden input -- this makes it much
> easier for users to input bulk model instances without having to mess
> with endless drop-down menus.
> 
> But I need the same initial data when handling the POST request,
> which means I either need to re-read the GET parameters in the POST
> method (I'm not sure that's reliable), or I need to otherwise store
> the values of those parameters (ie in the session), and read them
> again from there during POST.
> 
> URL arguments would be stable, but there are many different
> possible parameters, half of which won't even be present for any given
> formset, and I don't know how to handle that using URL segments.
> 
> I'd be interested in hearing any thoughts on this!
> 
> Thanks, Eric

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


Re: django doubt

2015-01-27 Thread termopro

Purpose well, libs clean, u happy.
If don't use, don't use - problem no.
The diff is some syntx sugr/ abilty do thngs ezly.

On Tuesday, January 27, 2015 at 9:15:19 AM UTC+2, Kadhir Mani wrote:
>
> what pupose using virtualenv ?if don't use what hapend? what is diff bte 
> virtualwrpper and virtualenv
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c4a88bde-5dd5-45dd-91c5-16711bf399a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django doubt

2015-01-27 Thread George Silva
Virtualenv helps you isolate between environments. Imagine that you work
where you need to develop and maintain two applications.

One is written in Django.1.5 and the other one on Django 1.7.

How do you install two versions of Django inside your system python
environment? You can't. That's what virtualenv does, it allows you to
create multiple environments, each with it's own libraries.

If you don't use virtualenv, you will have a hard time maintain multiple
applications with the same development box.

Virtualenvwrapper is just a wrapper on top of virtualenv, allowing you to
type easier commands to create, remove, list virtual envs.

On Tue, Jan 27, 2015 at 5:15 AM, Kadhir Mani  wrote:

> what pupose using virtualenv ?if don't use what hapend? what is diff bte
> virtualwrpper and virtualenv
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/40cdc75b-4415-443c-8e09-12a7884f0173%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
George R. C. Silva
SIGMA Consultoria

http://www.consultoriasigma.com.br/

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


Looking for a way to broadcast live video streams. Is it possible with Django ?

2015-01-27 Thread Jeremy Hermelin
Hi everybody, 

I'm quite new in Django community. I've just learn the basics of the 
framework, and now that I know how to create a "blog-style" website, I'm 
wondering how to integrate video streams in my project. Do you have some 
advices about that ? Any existing app ? 

What I am looking for precisely : 
- Capturing video stream from a client's webcam (Maybe the easier will be 
using a script)
- Sending the stream to the server and then to hundreds of clients 
connected to this session. 

In fact, it's really close to Google Hangout. 

As I said, I'm new in Django, and also in Python, then I'm sorry if the 
answer is obvious. I've made some research on djangopackages but haven't 
find anything. 


Have an awesome and fantastic day, 

Jeremy

By the way : Wooohhh Django is so easy and powerful at the same time ! 

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


django doubt

2015-01-27 Thread Kadhir Mani
what pupose using virtualenv ?if don't use what hapend? what is diff bte 
virtualwrpper and virtualenv

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


Re: A sample project showing server side rendering with React and Django

2015-01-27 Thread Ustun Ozgur
Exactly, sorry for the confusion, I should have made it explicit that this 
is only if you want to have a server-side rendered page that reuses the 
react code. If you are just beginning with react or if your requirements do 
not need the SEO boost or slight performance boost (known as time to first 
tweet problem, see 
https://blog.twitter.com/2012/improving-performance-on-twittercom ) , there 
is no need for this integration.

Ustun


On Monday, January 26, 2015 at 7:19:42 PM UTC+2, bobhaugen wrote:
>
> Ustun, thanks a lot. I think I start to get it. So if I don't care about 
> server-side rendering of React templates (which I will try avoid in the 
> beginning stages, anyway), I can skip node.js.
>
> Learning React is on my todo list. Then I'll need to dig deeper. I suppose 
> then I might change my mind...;-)
>
> On Monday, January 26, 2015 at 10:14:33 AM UTC-6, Ustun Ozgur wrote:
>>
>> Hi Bob,
>>
>> On Sunday, January 25, 2015 at 5:52:00 PM UTC+2, bobhaugen wrote:
>>>
>>> Ustun,
>>>
>>> Please say more about the advantages? As in, what can you do by adding a 
>>> node.js server to the mix (and so requiring everybody else who wants to use 
>>> your Django project to do the same, learn and manage node.js, etc.) that 
>>> you could not do with just plain Django on the server and React.js on the 
>>> client? 
>>>
>>
>> The main issue here is duplication of templates, if you use plain Django 
>> on the server and React.js on the client. If you don't want to have any 
>> server side rendering, that's OK for some projects, for example in the 
>> current project I'm working on, we don't have that requirement, so Django 
>> mainly serves as an api; we use the template system of django very 
>> sparingly.
>>
>> Note that the amount of node.js in this project is very small, rather I 
>> assume the programmer is familiar with both react and django.
>>
>>
>>
>>> And why you would not just want to bite the bullet and use node.js 
>>> instead of django in the first place?
>>>
>>
>>  
>> As to why django instead of node.js, that's dependent on the requirements 
>> and age of a project. For most brown-field projects, that's not an option. 
>> Besides that, I believe that outside templating system, remaining parts of 
>> Django (models, managers etc) are solid, so I still prefer that as opposed 
>> to a node.js solution. But that's clearly a personal preference.
>>
>> Ustun
>>
>>
>>
>>
>>>
>>> On Sunday, January 25, 2015 at 9:41:33 AM UTC-6, Ustun Ozgur wrote:



 On Sunday, January 25, 2015, bobhaugen  wrote:

> Ustun, do you think it is necessary to use a node.js server to 
> interact with react.js on the client side? Seems like a lot of added 
> complexity. But I could be missing something important...
>

 Hi Bob,

 This is definitely not the only way but I don't  think it adds that 
 much complexity considering the advantages. You could have multiple 
 node.js 
 renderers, gain fault tolerance and performance via some distribution 
 scheme like round-robin.  The nodejs renderer here is stateless and could 
 be made even faster through memoization or caching (or cache could be 
 handled on python side too before communicating with node)

 Another alternative would be to use something like queues to handle 
 communication between node and django, but that is more complex. 

 The other alternative would be to fork a nodejs process on each call, 
 for a high traffic site, speed might be more of an issue there. Some 
 projects take that approach, I recently saw another django-react 
 integration that uses that. (See django-node for this)

 If you are on jvm, it is possible to use nashorn to do in process 
 rendering. 

 Best,

 Üstün



  

>
>
> On Saturday, January 24, 2015 at 7:13:56 AM UTC-6, Ustun Ozgur wrote:
>>
>> Last year I gave a conference talk at Djangocon EU where I introduced 
>> React.js to the community. Since then, I have been getting some emails 
>> asking for some sample code.
>>
>> I just published a sample project that simply uses a node.js server 
>> to delegate server side rendering from Django. Hope that this is useful 
>> to 
>> some newcomers. (Note that this sample doesn't show server side 
>> rendering 
>> via react-router, the route on the clientside is a single one) 
>>
>> I'm planning to write a blog post explaining the code if there is any 
>> interest.
>>
>> https://github.com/ustun/django-react-integration
>>
>>
>> Ustun
>>
>



  

>  -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/-7oLnG_MaGE/unsubscribe
> .
> To 

Re: read GET and POST simultaneously?

2015-01-27 Thread Tom Christie
Absolutely no problem at all doing that.
The only thing that's confusing here is that `request.GET` is a misleading 
name.
The query parameters are available on any request, regardless of the HTTP 
method.

> Is this reliable behavior across browsers?

Yes.

> Is it a dumb idea for reasons I haven't thought of? 

No.

Cheers,

  Tom

On Tuesday, 27 January 2015 03:26:52 UTC, Eric Abrahamsen wrote:
>
> As far as I can tell (testing with the Conkeror web browser), it's 
> possible to read both GET and POST at once: if a user POSTs to a URL 
> containing GET parameters, you can get them both in the view. 
>
> Is this reliable behavior across browsers? Is it a dumb idea for reasons 
> I haven't thought of? 
>
> A bit of background, in case there's simply a better approach to this: 
>
> I'm using GET parameters to create custom model formsets: depending on 
> those parameters, I construct different initial data, and set some of the 
> form fields to use hidden input -- this makes it much easier for users 
> to input bulk model instances without having to mess with endless 
> drop-down menus. 
>
> But I need the same initial data when handling the POST request, which 
> means I either need to re-read the GET parameters in the POST method 
> (I'm not sure that's reliable), or I need to otherwise store the values 
> of those parameters (ie in the session), and read them again from there 
> during POST. 
>
> URL arguments would be stable, but there are many different possible 
> parameters, half of which won't even be present for any given formset, 
> and I don't know how to handle that using URL segments. 
>
> I'd be interested in hearing any thoughts on this! 
>
> Thanks, 
> Eric 
>
>

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