Re: Restrict access to user-uploaded files to authorized users

2013-09-26 Thread Frank Bieniek

Django filer might be usefull
http://django-filer.readthedocs.org/en/latest/secure_downloads.html

Am 26.09.13 03:24, schrieb m1chael:

I think Xsendfile is what you want


On Wed, Sep 25, 2013 at 12:51 PM, Mattias Linnap > wrote:


> Are there any obvious solutions that I have over looked?  Or am
I stuck having to use django to serve the files?

Depending on the security that you aim to achieve, one option
would be to add a custom file storage implementation that
overrides

https://github.com/django/django/blob/master/django/core/files/storage.py#L63
to give all uploads randomly generated filenames - and therefore
unguessable URLs. In addition, Apache can be configured to
redirect any accesses to non-existing files in the media directory
to a login page.

Only the original uploading user would know the URL, and be able
to access the file. However, this approach would still allow the
user to share a direct link to the file to other people.

Mattias




--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Restrict access to user-uploaded files to authorized users

2013-09-26 Thread Sanjay Bhangar
On Thu, Sep 26, 2013 at 6:54 AM, m1chael  wrote:

> I think Xsendfile is what you want
>
>
+1. I know the OP said it maybe hard to install apache modules, but I would
really try and check with the host, etc. - it should ideally not be such an
issue to install mod-xsendfile, and this is exactly the use-case that it
facilitates .. I would strongly recommend reading up on XSendfile and
seeing if implementation is feasible, because it's really the best,
non-hacky way to do this ..

Any-how, all the best :-)
-Sanjay

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Executing validation on entry to class-based views

2013-09-26 Thread Daniel Roseman
On Thursday, 26 September 2013 07:29:38 UTC+1, dspruell wrote:

> Greetings, 
>
> I have an app with a CBV for the main functionality that I'd like to 
> do some validation on config settings (in settings.py) before carrying 
> out the view. 
>
> My particular view in this case is a FormWizard, but I'd like to know 
> general to any CBV; what is the correct pattern for doing this? Is 
> there a standard way to execute validation code upon entering a view 
> that allows one to access the request object (e.g. for setting 
> messages) and redirecting clients? 
>
> My initial thought was to override __init__() and perform it there but 
> IIANM it lacks self.request at that point. 
>
> What I'd like to implement: 
>
> if not settings.SOMEAPP_SETTINGS.get('sender_address'): 
> messages.error(self.request, "Configuration error: 
> submission sender address not found. Configure SOMEAPP_SETTINGS in 
> your project settings file.") 
> return redirect('index') 
>
> -- 
> Darren Spruell 
> phatb...@gmail.com  
>


One way would be to override `dispatch()`.  You have access to the request 
there and can choose whether to call the super method to do the actual 
dispatching, or redirect instead.
--
DR.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django Crispy Form Layout

2013-09-26 Thread Tushar Patil
Hi,

 I use a django crispy form and Bootstrap

in which i want a layout field first_Name, Middle_Name, Last_Name like this,

   First Name   Middle Name   Last Name
Trust Admin Name[input field]   [input field]  [input Field]

I am using span3 out of span12 for sideber  i have to arrange this only in
remaining span9

I am completely new to django and crispy form, i am already spent a whole
day to find solution, Please give me reply ASAP





Thanks,
Tushar Patil.
Mob - +917798789759.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Crispy Form Layout

2013-09-26 Thread Lachlan Musicman
You probably need to give some indication of the things you have
tried, and versions.

For instance - are you using the latest bootstrap (3.0)?

If so, did you try this?

http://django-crispy-forms.readthedocs.org/en/latest/crispy_tag_forms.html#bootstrap3-inline-forms

cheers
L.

On 26 September 2013 19:02, Tushar Patil  wrote:
>
> Hi,
>
>  I use a django crispy form and Bootstrap
>
> in which i want a layout field first_Name, Middle_Name, Last_Name like this,
>
>First Name   Middle Name   Last Name
> Trust Admin Name[input field]   [input field]  [input Field]
>
> I am using span3 out of span12 for sideber  i have to arrange this only in
> remaining span9
>
> I am completely new to django and crispy form, i am already spent a whole
> day to find solution, Please give me reply ASAP
>
>
>
>
>
> Thanks,
> Tushar Patil.
> Mob - +917798789759.
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
When you used to be punk, and now you are still punk but not as punk,
are you post-punk or decaying punk or ex-punk or just not punk anymore

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-26 Thread Christiano Anderson
I have the same stack, GeoDjango + PostGIS (and all its dependencies like
GDAL, Proj, GEOS, etc). My notebook runs Debian (also I have a Mac Book
Pro, but I prefer to work on Linux) and I use Digital Ocean to host my
projects, also running Debian boxes. Since Debian keeps an older version of
PostGIS, I have created my own .deb package of PostGIS 2.1.

IMHO VirtualEnv and VirtualEnvWrapper is the best way to keep your
environment updated with the same versions. I also keep a requirements.txt
file into the project (I use Git and Bitbucket) with the output of pip
freeze command.

best regards,


On 25 September 2013 15:01, Jorge Arevalo  wrote:

> Hello,
>
> First of all, many thanks for your response. Sorry for the delay answering
> this. I was in a business trip.
>
> So, you basically have 2 environments: your own machine, and the Linode
> box. You make the development and testing in your machine, and Linode is
> for production purposes. And you connect both environments via dvcs
> push/pull. Right?
>
> I like it because it's simple and doesn't seem to be specially prone to
> errors. I'd just like to add a third scenario here, to end up with:
>
> - Development environment: my own machine (Mac OS X) with all the software
> stack installed.
> - Testing environment: my new addition. I would like to put this
> environment outside of my machine
> - Production environment: the Linode box.
>
> I can do the communication via push/pull, if there's no other way to
> "deploy" software to production with Python/Django (it's simple, I like
> it). And maybe I can have 2 urls (testing and production) in the Linode
> box. Testing just accessible to developers and testers, and production open
> to normal users. Does it make sense?
>
> Thanks again
>
> On Tuesday, September 17, 2013 3:50:55 PM UTC+2, Vernon D. Cole wrote:
>>
>>
>> I installed a client for my favourite distributed version control system
>> on my Linode instance.  I have a private repository on a public IP.
>> (github, bitbucket, or launchpad will work, depending on your dvcs of
>> choice -- I have used all three, and other times I have used a private dvcs
>> host, including my Linode server itself.) I "cloned" a "checkout" of my
>> django system to the Linode. When I am happy from testing a new version of
>> my application:  I push it to the repository,  log in to my Linode using
>> ssh, and do a pull.  Easy and error free.  (My django environment is almost
>> exactly like yours with PostGIS, etc.)
>> --
>>
>> On Monday, September 16, 2013 6:33:49 PM UTC+1, Jorge Arevalo wrote:
>>>
>>> Hello,
>>>
>>> I'm going to start a project based on (Geo)Django + PostgreSQL/PostGIS +
>>> OpenLayers/LeafLet + Bootstrap/Foundation. The project will be deployed to
>>> a Linode box. That box will be created with something like this:
>>> https://manager.linode.**com/linodes/deploy/**
>>> linode393074?StackScriptID=**6482
>>>
>>> My work box is a MacBook with Mac OS X 10.6.8. There will be 2 people
>>> working on the web app (me and another guy). I have almost total freedom to
>>> choose, so I want to choose wisely. The whole point is that these
>>> constraints should be satisfied:
>>>
>>> - I need a reliable way to upload the application to the test/production
>>> environments. At least the production environment will be a Linode box. I
>>> just don't want to upload files via FTP, or manually copy them with rsync,
>>> or any other practice easily subject to errors. How do the professional
>>> django developers set up their environment in order to deploy the app?
>>>
>>> - I'm not sure about which IDE/editor choose. I don't want to start an
>>> editor war, and I've used several options in the past. My main interest is:
>>> I want to focus on develop. If Eclipse/Aptana/Eric/PyCharm/**any IDE
>>> can be easily "linked" to my environment, that's my choice. For example, if
>>> I can deploy my app to test/production environment with a couple of clicks
>>> or commands, thanks to a plugin or script, that's great. Like deploying to
>>> Heroku or EC2, but with Linode. Is there any IDE specially friendly with
>>> this kind of development environment?
>>>
>>> - The other(s) developer(s) must be up&running ASAP. They can't spend
>>> half a day installing and configuring stuff to start being productive. I
>>> guess a VirtualBox machine + Vagrant would be a good choice here. But,
>>> would it make more difficult the deployment cycle? And using a virtual
>>> machine to just open the IDE and develop sounds like a resource waste to
>>> me. Is there any other solution?
>>>
>>> I think I should use, at least, VirtualEnv, VirtualEnvWrapper and PIP,
>>> like I've read in these useful links
>>>
>>> http://www.slideshare.net/**ryan_blunden/virtualenv-and-**
>>> pip-isolated-python-**environments
>>> http://www.slideshare.net/**ajdiaz/isola

Responsive design

2013-09-26 Thread Jasvir Singh
Could anyone please tell me, how to make responsive design
in django?
-- 
Jasvir Singh Grewal
Blog: jasvirsinghgrewal91.wordpress.com

:
[ GNU/Linux One Stanza Tip (LOST) ]###

Sub : awk tips [#13] LOST #473

# Print sequence number and then column 1 of file:
$  awk '{print NR, $1}' textfile
   
[banduji (at) symonds.net]
:

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Responsive design

2013-09-26 Thread Rafael E. Ferrero
Do it in your templates, its just html and javascript

xadmin  its responsive for your
admin, here its the demo 


2013/9/26 Jasvir Singh 

> Could anyone please tell me, how to make responsive design
> in django?
> --
> Jasvir Singh Grewal
> Blog: jasvirsinghgrewal91.wordpress.com
>
> :
> [ GNU/Linux One Stanza Tip (LOST) ]###
>
> Sub : awk tips [#13] LOST #473
>
> # Print sequence number and then column 1 of file:
> $  awk '{print NR, $1}' textfile
>
> [banduji (at) symonds.net]
> :
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Bootstrap - django-bootstrap3 or django-crispy-forms

2013-09-26 Thread Nigel Legg
Hi, I've been looking into using Bootstap3 on the django app I'm working
on.  It seems you can do this with both django-bootstrap and crispy-forms.
Am I right in thinking that django-bootstap allows you to use bootstrap
across the whole site, while crispy forms is just for forms?  So you can
use both together? Or am I missing something?

Cheers, Nigel
07914 740972

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Responsive design

2013-09-26 Thread Rafael E. Ferrero
And you can use bootstrap with Django Bootstrap
Toolkit



2013/9/26 Rafael E. Ferrero 

> Do it in your templates, its just html and javascript
>
> xadmin  its responsive for your
> admin, here its the demo 
>
>
> 2013/9/26 Jasvir Singh 
>
>> Could anyone please tell me, how to make responsive design
>> in django?
>> --
>> Jasvir Singh Grewal
>> Blog: jasvirsinghgrewal91.wordpress.com
>>
>> :
>> [ GNU/Linux One Stanza Tip (LOST) ]###
>>
>> Sub : awk tips [#13] LOST #473
>>
>> # Print sequence number and then column 1 of file:
>> $  awk '{print NR, $1}' textfile
>>
>> [banduji (at) symonds.net]
>> :
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Rafael E. Ferrero
>



-- 
Rafael E. Ferrero

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


django admin: integrate django-modeltranslation + django-ckeditor into 3rd party module

2013-09-26 Thread Roberto López López

Hi,

I want to integrate django-modeltranslation into the cmsplugin_news
package. I mean, register some fields in the News class to have a
translation in the DB for each of the settings.LANGUAGES defined.


class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'slug', 'excerpt', 'content',
'is_published', 'pub_date')
widgets = {
'content': CKEditorWidget(),
'excerpt': CKEditorWidget(),
}

class NewNewsAdmin(TranslationAdmin):
form = NewNewsForm

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
)
css = {
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

admin.site.register(News, NewsAdmin)


This works ok, if we just take into account django-modeltranslation. But
the django-ckeditor widget is not loading. Using firebug I have seen
that some static files are not loaded, so I tried loading them manually
by modifying the Media class. Anyhow the editor continues not working:

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
'ckeditor/ckeditor/ckeditor.js',
'ckeditor/ckeditor/config.js?t=D26D',
'ckeditor/ckeditor/styles.js?t=D26D',
)
css = {
'all': [cms_static_url(path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
'css/plugin_editor.css',
)],
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

Does anyone have any idea about how to make the editor work? Thank you
very much!

Regards,

Roberto

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Responsive design

2013-09-26 Thread Christiano Anderson
Django gives you all the freedom to create responsive layouts or not.

To be responsive or not is not related to Django, but to the templates you
create. You can also use a CSS framework like Bootstrap,  BluePrint or your
favourite to create your templates as you like.

Cheers


On 26 September 2013 05:18, Jasvir Singh  wrote:

> Could anyone please tell me, how to make responsive design
> in django?
> --
> Jasvir Singh Grewal
> Blog: jasvirsinghgrewal91.wordpress.com
>
> :
> [ GNU/Linux One Stanza Tip (LOST) ]###
>
> Sub : awk tips [#13] LOST #473
>
> # Print sequence number and then column 1 of file:
> $  awk '{print NR, $1}' textfile
>
> [banduji (at) symonds.net]
> :
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Christiano Anderson
http://christiano.me/
http://twitter.com/dump/

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django query Advanced

2013-09-26 Thread Hélio Miranda
I am trying a query like this:

result = json.dumps([a.get_json() for a in 
Player.objects.filter((Q(name=namepost) | Q(surname="Coimbra")))])
   return HttpResponse (result, content_type = 'application / json')

But it gives me the following error: Not a query object: (AND: ('surname', 
'Coimbra'), ('name', u'Rui ')). Did you intend to use key = value?

get_json def (self):
  return {
'name': self.name,
'surname': self.surname,
'country': [{'name': b.name} for b in self.country]
   }

If I do well

result = json.dumps([a.get_json() for a in 
Player.objects.filter(name=namepost)])

works well

What am I doing wrong? Someone can help me?

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


How to use selenium test against different browsers using LiveServerTestCase

2013-09-26 Thread Tianyi Wang
Hi guys,

So follow the Django doc example, 
https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase

In the example, the test only test against Firefox. How can I test against 
different browsers without duplicate the example code?

Thanks

Tianyi

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to use selenium test against different browsers using LiveServerTestCase

2013-09-26 Thread Rafael Durán Castañeda
Hi,

I don´t know any out-of-the-box solution for this, but sure you can write your 
own test runner/suite, so any selenium test is run by multiple browsers (maybe 
just using settings to select the browser). However, if you are really 
concerned about testing on multiple browsers, multiples version for each one, 
multiple OS,… you might look at any of the available solutions for cross 
browser testing as a service.

HTH

El 26/09/2013, a las 18:46, Tianyi Wang  escribió:

> Hi guys,
> 
> So follow the Django doc example, 
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
> 
> In the example, the test only test against Firefox. How can I test against 
> different browsers without duplicate the example code?
> 
> Thanks
> 
> Tianyi
> 
> -- 
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-26 Thread Ezequiel
On Wednesday, September 25, 2013 3:06:55 PM UTC-3, Jorge Arevalo wrote:

> Fine. I don't think my boss is going to pay for PyCharm license, so I'll 
> probably go for Eclipse now (I don't really like it too much, but if works, 
> it's ok for me)
>

PyCharm, which is my favorite IDE, has now a Free Community 
Edition: https://twitter.com/pycharm/status/382549991165673472

Best,
Ezequiel
http://flickrock.com/mikelpierre

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to use selenium test against different browsers using LiveServerTestCase

2013-09-26 Thread Evan Leis
Alright, tested tried and True:

The following code provides the ability to decorate tests so that a whole 
list of drivers is used... see the docs for examples...

import functools


def test_drivers(pool_name='drivers', target_attr='selenium'):
"""
Run tests with `target_attr` set to each instance in the `WebDriverPool`
named `pool_name`.

For example, in you setUpClass method of your LiveServerTestCase:

# Importing the necessaries:
from selenium import webdriver

### In your TestCase:

# Be sure to add a place holder attribute for the driver variable
selenium = None

# Set up drivers
@classmethod
def setUpClass(cls):
cls.drivers = WebDriverList(
webdriver.Chrome(),
webdriver.Firefox(),
webdriver.Opera(),
webdriver.PhantomJS,
)
super(MySeleniumTests, cls).setUpClass()

# Tear down drivers
@classmethod
def tearDownClass(cls):
cls.drivers.quit()
super(MySeleniumTests, cls).tearDownClass()

# Use drivers
@test_drivers()
def test_login(self):
self.selenium.get('%s%s' % (self.live_server_url, '/'))
self.assertEquals(self.selenium.title, 'Awesome Site')

This will run `test_login` with each of the specified drivers as the
attribute named "selenium"

"""
def wrapped(test_func):
@functools.wraps(test_func)
def decorated(test_case, *args, **kwargs):
test_class = test_case.__class__
web_driver_pool = getattr(test_class, pool_name)
for web_driver in web_driver_pool:
setattr(test_case, target_attr, web_driver)
test_func(test_case, *args, **kwargs)
return decorated
return wrapped

class WebDriverList(list):
"""
A sequence that has a `.quit` method that will run on each item in the 
list.
Used to easily "quit" a list of WebDrivers.
"""

def __init__(self, *drivers):
super(WebDriverList, self).__init__(drivers)

def quit(self):
for driver in self:
driver.quit()


On Thursday, September 26, 2013 10:46:43 AM UTC-6, Tianyi Wang wrote:
>
> Hi guys,
>
> So follow the Django doc example, 
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
>
> In the example, the test only test against Firefox. How can I test against 
> different browsers without duplicate the example code?
>
> Thanks
>
> Tianyi
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to use selenium test against different browsers using LiveServerTestCase

2013-09-26 Thread Arnold Krille
On Thu, 26 Sep 2013 09:46:43 -0700 (PDT) Tianyi Wang
 wrote:
> So follow the Django doc example, 
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
> In the example, the test only test against Firefox. How can I test
> against different browsers without duplicate the example code?

I would propose this:
In your classes __init__ (or in the init of your mixin specially for
this) check for an environment-variable or a django-setting to tell you
the browser to use. With a fallback if nothing is defined.

Then when you run the tests locally, you can decide which browser to
use. And when run in jenkins, the browser is a matrix-variable giving
you functional tests with all the defined browsers.

Have fun,

Arnold


signature.asc
Description: PGP signature


Re: IntegrityError with proxy model but not with parent?

2013-09-26 Thread Rafael Durán Castañeda
Hi,

As long as I know, a model form needs the fields to be included in order to get 
validation working, so I suspect you did something like this:

class ProxyForm(forms.ModelForm):
class Meta:
model = models.Myproxy
fields = ('name', )

Since stuff field is not included in the form fields validation doesn't work 
for it, however you can get it working with something like this:

class ProxyForm(forms.ModelForm):
stuff = forms.CharField(widget=forms.HiddenInput, initial='stuff')
class Meta:
model = models.Myproxy
fields = ('name', 'stuff',)

Thought you probably need customize validation/error messages or you will get 
messages like:

Parent with this Name and Stuff already exists.

for a form that does´t include stuff as a hidden input.

HTH
El 25/09/2013, a las 20:15, Derek  escribió:

> I am working with a proxy model that does not seem to work with the 
> 'unique_together' of the model being proxied.
> 
> What I have is:
> 
> class Parent(Model):
> id = AutoField(primary_key=True)
> name = CharField()
> stuff = CharField()
> 
> class Meta:
> ordering = ['name']
> unique_together = (('name', 'stuff'),)
> 
> class Myproxy(Parent):
> 
> class Meta:
> proxy = True
> 
> def __init__(self, *args, **kwargs):
> super(Myproxy, self).__init__(*args, **kwargs)
> self.stuff = "test"
> 
> If I use the Parent model and try to enter, 'myname' and 'test' as the 
> name/stuff entries twice, I get the usual warning on the second attempt; the 
> admin telling me that this model entry already exists.
> 
> However, if I try the same thing on the Myproxy model (which has a form 
> without the stuff field; as its meant to be a preset value), I get an:
> 
> IntegrityError at /admin/../add/
> (1062, "Duplicate entry 'myname-test' for key 'name'")
> 
> The stack trace is as follows:
> 
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in 
> get_response
>   115. response = callback(request, *callback_args, 
> **callback_kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in wrapper
>   372. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in 
> _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" 
> in inner
>   202. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapper
>   25. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> bound_func
>   21. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in 
> inner
>   223. return func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in add_view
>   1007. self.save_model(request, new_object, form, False)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in save_model
>   740. obj.save()
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
>   546.force_update=force_update, 
> update_fields=update_fields)
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in 
> save_base
>   591.update_fields=update_fields)
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in 
> save_base
>   650. result = manager._insert([self], fields=fields, 
> return_id=update_pk, using=using, raw=raw)
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in 
> _insert
>   215. return insert_query(self.model, objs, fields, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in 
> insert_query
>   1675. return query.get_compiler(using=using).execute_sql(return_id)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in 
> execute_sql
>   937. cursor.execute(sql, params)
> File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in 
> execute
>   41. return self.cursor.execute(sql, params)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py" in 
> execute
>   122. six.reraise(u

Re: Bootstrap - django-bootstrap3 or django-crispy-forms

2013-09-26 Thread Sam Lai
Yep.  django-bootstrap-* and django-crispy-forms only provide helpers
for outputting HTML with bootstrap CSS classes. Neither are really
necessary to use Bootstrap (just makes it slightly easier), which is
applied through HTML and CSS and Django doesn't place any restrictions
on how your HTML/CSS is structured.

On 26 September 2013 22:53, Nigel Legg  wrote:
> Hi, I've been looking into using Bootstap3 on the django app I'm working on.
> It seems you can do this with both django-bootstrap and crispy-forms.
> Am I right in thinking that django-bootstap allows you to use bootstrap
> across the whole site, while crispy forms is just for forms?  So you can use
> both together? Or am I missing something?
>
> Cheers, Nigel
> 07914 740972
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to do 2-ModelForm-in-1-CVB right?

2013-09-26 Thread Yu Chen
Inlineformset may solve your problem, and this 
http://haineault.com/blog/155/ is a good example.


在 2013年9月26日星期四UTC+8下午1时19分41秒,Adam写道:
>
> Hi,
>
> I am trying to handle 2 ModelForm in 1 view. Is that possible with CBV 
> solution? Does any best practise exist?
>
> Here is the problem in details.
>
> ## models.py
>
> class UserProfile(HasJPAddresses, models.Model):
>
> user = models.OneToOneField(User)
> birthdate = models.DateField(default='1900-01-01')
>
> ## forms.py
>
> class UserProfileUpdateForm(forms.ModelForm):
> class Meta:
> model = UserProfile
>
> class UserUpdateForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ['first_name', 'last_name']
>
> ## views.py
>
> class UserProfileUpdateView(FormView): <<< How could I handle two 
> forms at once in a view? 
>
> Thanks,
> /Adam
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bootstrap - django-bootstrap3 or django-crispy-forms

2013-09-26 Thread Lachlan Musicman
this is probably the answer you want:

http://stackoverflow.com/a/11795186

L.

On 27 September 2013 09:23, Sam Lai  wrote:
> Yep.  django-bootstrap-* and django-crispy-forms only provide helpers
> for outputting HTML with bootstrap CSS classes. Neither are really
> necessary to use Bootstrap (just makes it slightly easier), which is
> applied through HTML and CSS and Django doesn't place any restrictions
> on how your HTML/CSS is structured.
>
> On 26 September 2013 22:53, Nigel Legg  wrote:
>> Hi, I've been looking into using Bootstap3 on the django app I'm working on.
>> It seems you can do this with both django-bootstrap and crispy-forms.
>> Am I right in thinking that django-bootstap allows you to use bootstrap
>> across the whole site, while crispy forms is just for forms?  So you can use
>> both together? Or am I missing something?
>>
>> Cheers, Nigel
>> 07914 740972
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
When you used to be punk, and now you are still punk but not as punk,
are you post-punk or decaying punk or ex-punk or just not punk anymore

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bootstrap - django-bootstrap3 or django-crispy-forms

2013-09-26 Thread Nigel Legg
Thanks both.

Cheers, Nigel
07914 740972



On 27 September 2013 06:19, Lachlan Musicman  wrote:

> this is probably the answer you want:
>
> http://stackoverflow.com/a/11795186
>
> L.
>
> On 27 September 2013 09:23, Sam Lai  wrote:
> > Yep.  django-bootstrap-* and django-crispy-forms only provide helpers
> > for outputting HTML with bootstrap CSS classes. Neither are really
> > necessary to use Bootstrap (just makes it slightly easier), which is
> > applied through HTML and CSS and Django doesn't place any restrictions
> > on how your HTML/CSS is structured.
> >
> > On 26 September 2013 22:53, Nigel Legg  wrote:
> >> Hi, I've been looking into using Bootstap3 on the django app I'm
> working on.
> >> It seems you can do this with both django-bootstrap and crispy-forms.
> >> Am I right in thinking that django-bootstap allows you to use bootstrap
> >> across the whole site, while crispy forms is just for forms?  So you
> can use
> >> both together? Or am I missing something?
> >>
> >> Cheers, Nigel
> >> 07914 740972
> >>
> >> --
> >> 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.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >
> > --
> > 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.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
> When you used to be punk, and now you are still punk but not as punk,
> are you post-punk or decaying punk or ex-punk or just not punk anymore
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.