Re: Scaling/Parallel patterns for a View executing complex database transaction

2015-06-14 Thread Javier Guerra Giraldez
On Sun, Jun 14, 2015 at 3:13 PM, Peter of the Norse
 wrote:
> Almost all of them are faster at key/value returns than PostgreSQL.


i seriously doubt that.

most "fast" key-value databases are only fast if you either: keep all
data in RAM, forget about durability, or distribute the load on
several shards while shifting consistency tradeoffs.

know what? a good SQL engine gets faster too if you do any of these things.

-- 
Javier

-- 
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/CAFkDaoQv3f2n8zCrNDgOHyENx2%3D7m1oNF9NHZ6sJ47dDdcOomw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to DRY, define a set of model-fields and reuse them as multiple instances

2015-06-14 Thread Peter of the Norse

> On Jun 10, 2015, at 10:33 AM, ThomasTheDjangoFan 
>  wrote:
> 
> Hi Bruno,
> 
> Abstract Base Models come close but they don't allow me to combine multiple 
> instances of the BaseModel in the DataHolderModel.
> 
> My goal is to store them all in one table without having to manually add all 
> the fields.
> 
> Any suggestions?


There’s a django-compound-field package that seems to be what you want, but it 
hasn’t been updated in five years, so it won’t work with any recent version.  
Still, it might be a place to start from.

Peter of the Norse
rahmc...@radio1190.org



-- 
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/6595F9D2-B97A-4E86-9C2B-E8EE1B302237%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Re: Scaling/Parallel patterns for a View executing complex database transaction

2015-06-14 Thread Peter of the Norse
On May 14, 2015, at 10:30 PM, Me Sulphur  wrote:
> 
> * It is a large key-value pair table (approaching ~ 1 bn rows) with an MD5 
> key and JSON  for value. The look ups depend on the business logic but are 
> necessary. Nevertheless, there are no more than 10-12 queries executed by 
> combining key look ups using WHERE IN queries and pg is surprisingly good 
> with IN queries.


If this is the case, then I strongly recommend switching to a NoSQL DB.  You 
aren’t using any of the Django ORM functionality, so there’s no need to switch 
to django-nonrel.  Almost all of them are faster at key/value returns than 
PostgreSQL.  

Peter of the Norse
rahmc...@radio1190.org



-- 
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/794491DD-ADB8-422A-AE03-0D4D8546E4E2%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.


Re: Running DJango with uWSGI with a user that has sudo access?

2015-06-14 Thread Carlos A. Carnero Delgado
> ... Should I try to use a user that is not a sudoer or does it not really
matter?

You should use the least privileged user you can. In the (unlikely or not)
event of an exploit and the user can gain access to console, what can
happen? Do you trust the system's configuration?

I think that in a production settings you should go for privilege
separation as far as possible. Besides, you could always host more than one
service in the same box with different credentials quite nicely.

HTH,
Carlos.

-- 
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/CAPjvz2%3D6SVOB7CpePNU4M-zk9q0Qh%2B2bY%2BUjpdpFBjVZKHwy3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running DJango with uWSGI with a user that has sudo access?

2015-06-14 Thread Gergely Polonkai
Hello,

the problem of the root access usually comes into play when your site gets
hacked (or if you don't trust the framework written by someone else, which
is not always a bad idea). Up until then, you can safely run your
application under root privileges.

When your site gets hacked, the main goal is to reduce the attacker's
playground. If the attacker gets in with the user's password, it can do
anything. If sudo is configured that it doesn't even ask for a password,
it's ever worse.

All in all, the best thing is to prepare for the worst case scenario.
Assume that the attacker is already on the computer. Make his place as
small as possible.

Best,
Gergely
On 14 Jun 2015 20:50, "Paul Koepke"  wrote:

> I'm running a Django app using uWSGI and nginx. I already saw in the uWSGI
> documentation that I should not run uWSGI as root. But does it matter if
> the user I run uWSGI has sudo access? Should I try to use a user that is
> not a sudoer or does it not really matter?
>
> --
> 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/7b28bd49-a1df-428a-b828-a085662100a1%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/CACczBU%2BVwgade0BfxT5SYKO5WyTqA5Dky3SkfsS1Bx7-ekDz%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: potential bug

2015-06-14 Thread 'Tom Evans' via Django users
On Sun, Jun 14, 2015 at 3:24 PM, Mark Nesterovych
 wrote:
> Hello.
> I've just finished small django site, and keep going on creating tests.
> I've found and issue with Model.objects.values_list  method.
> Looks like it disregard test database and looks into production one.
>
> Some details.
> I have a form with a filed customer =
> forms.ChoiseField(choises=Customer.objects.values_list('id', 'name'))
>
> When this form initing during tests, it loads data from production database.
>
> My test looks like this.
> class CustomerFormTest(TestCase):
> def setUp:
>  self.customer = Customer.objects.create(name='test name')
>
> def test_form_creation(self):
> form = CustomerLoginForm()
> self.assertIn('test name', form.as_ul())
>
>
> Assertion fails, and when I printing form content, I see select widget with
> options from production database objects.
>
> Can somebody confirm it's a bug ?
> Thank you.

It's not a bug. You are specifying the choices when the form is
defined, and at that point there is nothing in the database and so the
form has no choices. Since the field is never redefined in the form,
the choices will be whatever existed in the database when the form is
defined, which is a bad way of designing the form.

Typically, when your choices are instances of a model, you would not
use ChoiceField, but ModelChoicefield. ModelChoiceField takes a
queryset when defining the form, and avoids evaluating the queryset
until the form is instantiated, which avoids the issue. The
documentation also explains how you can specify the queryset more
dynamically if that is required.

https://docs.djangoproject.com/en/1.8/ref/forms/fields/#modelchoicefield

(I'm assuming that the typo "choises" is only present in your email,
and your code correctly says "choices" and "ChoiceField")

Cheers

Tom

-- 
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/CAFHbX1LerMfvVs056hVnFY8Jqm0gqtLDm0wcpWqgjC4V88fpBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to serialize one record with Django / REST?

2015-06-14 Thread James Schneider
Instead of using .get(), try using .filter() instead, since get_queryset()
needs to return a query set and not the actual object (even though the
query set will only contain a single result).

Your code for the get_queryset() override is actually better suited as an
override for get_object() in the view itself.

I think you can get away without the overrides entirely if you set
'pk_url_kwarg = "pid" ' (without the single quotes) on your detail view,
and you should be able to use the same serializer for both your list and
detail views.

-James
On Jun 14, 2015 11:37 AM, "Daniel Grace"  wrote:

> I can serialize all objects using the following.  In views:
>
> class ProductDetail(generics.ListAPIView):
> serializer_class = ProductSerializer
> def get_queryset(self):
> return Product.objects.all()
>
> In serializers:
>
> class ProductSerializer(serializers.ModelSerializer):
> class Meta:
> model = Product
> fields = ('code', 'name', 'description')
>
> When I try to restrict this to one record, I get an error:
>
> class ProductDetail(generics.RetrieveAPIView):
> serializer_class = ProductSerializer
> def get_queryset(self):
> pid = int(self.kwargs['pid'])
> return Product.objects.get(id=pid)
>
> Exception Type: AttributeError
> Exception Value:'Product' object has no attribute 'model'
>
> I am guessing that get_queryset is not the right thing to use in this
> situation.
>
>  --
> 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/1a4a658e-4728-4577-a0f6-9fdd5e110f09%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/CA%2Be%2BciUWtkWSRAcEpmkDMJbqbAOPEQYcFT7BQE%2B%3Dpnv_pZSs1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Running DJango with uWSGI with a user that has sudo access?

2015-06-14 Thread Paul Koepke
I'm running a Django app using uWSGI and nginx. I already saw in the uWSGI 
documentation that I should not run uWSGI as root. But does it matter if 
the user I run uWSGI has sudo access? Should I try to use a user that is 
not a sudoer or does it not really matter?

-- 
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/7b28bd49-a1df-428a-b828-a085662100a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to serialize one record with Django / REST?

2015-06-14 Thread Daniel Grace
I can serialize all objects using the following.  In views:

class ProductDetail(generics.ListAPIView):
serializer_class = ProductSerializer
def get_queryset(self):
return Product.objects.all()

In serializers:

class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ('code', 'name', 'description')

When I try to restrict this to one record, I get an error:

class ProductDetail(generics.RetrieveAPIView):
serializer_class = ProductSerializer
def get_queryset(self):
pid = int(self.kwargs['pid'])
return Product.objects.get(id=pid)

Exception Type: AttributeError
Exception Value:'Product' object has no attribute 'model'

I am guessing that get_queryset is not the right thing to use in this 
situation.

-- 
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/1a4a658e-4728-4577-a0f6-9fdd5e110f09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Forum app

2015-06-14 Thread Luis Zárate
Those links maybe can help you

https://github.com/vicalloy/LBForum
https://github.com/nitely/Spirit


For more see

https://www.djangopackages.com/grids/g/forums/


2015-06-14 4:32 GMT-06:00 Arindam :

> What are the stable forum apps ?
>
> --
> 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/0011nou1sf8nkt4yxvseugcs.1434277926253%40email.android.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyOROeO93SVRSF0HvYh38GXjATku_HbuXTFN8Z4BJ%3DBz8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Heroku: without NULL bytes error with "2 scoops" structure

2015-06-14 Thread Martin Torre Castro
I resolved this. I was doing wrong and not making git commit when editing 
requirements.txt files.

On Saturday, 13 June 2015 10:00:18 UTC+2, Martin Torre Castro wrote:
>
> Hello,
>
> I posted this because I can't deploy a webapp with Heroku. Any ideas?
>
>
> http://stackoverflow.com/questions/30816367/heroku-string-without-null-bytes-with-several-requirements-files
>
> Thanks for reading
>

-- 
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/0bc141eb-e0b0-42c3-a88e-0744fd8ba8ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


potential bug

2015-06-14 Thread Mark Nesterovych
Hello.
I've just finished small django site, and keep going on creating tests.
I've found and issue with Model.objects.values_list  method.
Looks like it disregard test database and looks into production one.

Some details.
I have a form with a filed customer = 
forms.ChoiseField(choises=Customer.objects.values_list('id', 'name'))

When this form initing during tests, it loads data from production database.

My test looks like this.
class CustomerFormTest(TestCase):
def setUp:
 self.customer = Customer.objects.create(name='test name')

def test_form_creation(self):
form = CustomerLoginForm()
self.assertIn('test name', form.as_ul())


Assertion fails, and when I printing form content, I see select widget with 
options from production database objects.

Can somebody confirm it's a bug ?
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/1cae35ab-e9c1-4870-8e7e-18c2b9e1c22a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Forum app

2015-06-14 Thread Arindam
What are the stable forum apps ?

-- 
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/0011nou1sf8nkt4yxvseugcs.1434277926253%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Re: What are some good 3rd party django apps to build a user dashboard and folder management (similar to a Google drive account)

2015-06-14 Thread Derek
I have not had this use case; but I assume you have looked at:
https://www.djangopackages.com/grids/g/file-managers/
Perhaps one there is close to what you need; and you could extend/enhance 
it to match exact requirements.  They range from really simple to 
full-fledged EDMS such as Mayan.

(Note: you may need supplementary apps as well - bearing in mind Django's 
modular (vs monolithic) design - so look at something 
like https://www.djangopackages.com/packages/p/django-guardian/ to handle 
object permissions rather than expecting this to appear in a package 
dealing with file uploads or folder organisation.)

On Friday, 12 June 2015 15:51:31 UTC+2, Shanu Kumar wrote:
>
> Hi,
>
> I have been trying to find an app which helps build a user-specific 
> file/folder management system.
>
> An example for this could be an app that is exactly similar to your google 
> drive account. The operations performed by the app could be a subset of 
> what a google drive account does:
> 1. Organization of folders into Shared with me, Starred, Recent.
> 2. Showing details and activity associated with a specific folder
> 3. Displaying the permission level that each user has with a folder etc.
>
> I tried searching for this but could not find an app that could meet these 
> specifics.
>
> 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/bd95d1b3-1279-4723-b4e9-c38feed65137%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add multiple objects of same model at the same time in admin

2015-06-14 Thread Carlos Arturo Sanchez Rivera


It is easier with decorators

@admin.register(Transfer)
class TransferAdmin(admin.ModelAdmin):
pass



El sábado, 13 de junio de 2015, 4:28:38 (UTC-5), Robin Lery escribió:
>
> I have a model to upload pictures:
>
> models.py:
>  
>
>> class Snap(models.Model):
>> image = models.ImageField(upload_to=get_upload_file_name)
>> caption = models.CharField(max_length=150, blank=True, null=True)
>> date = models.DateField(default=date.today)
>>
>
> admin.py:
>
> class SnapAdmin(admin.ModelAdmin):
>> class Meta:
>> model = Snap
>>
>> admin.site.register(Snap, SnapAdmin)
>>
>
> In the admin it contains all the Snap's field (i.e. one field to upload 
> an image ,its caption and the pubdate) which is as expected. How do I add 
> multiple record of Snap's in one go, without having to save it one by 
> one. I hope I was clear, if not please ask. Your help and guidance will be 
> very much appreciated. 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/5f3a3841-6605-4250-9299-ff4922c8421f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.