Re: Adding view permission by default to auth_permission

2016-10-29 Thread Olivier Dalang
Indeed I just have to squash the commits then it can be merged. I'm out of
office until next week but will do so when back.

Bests

On 27 Oct 2016 23:23, "Luis Zárate"  wrote:

> This is alive in
>
> https://github.com/django/django/pull/6734
>
> The other PR was close because this have not merge conflict.
>
> I think this functionality is needed an will be included soon.
>
>
>
>
> El jueves, 27 de octubre de 2016, mmatt  escribió:
> > On another note, I believe django dev team needs to understand life is
> rarely boolean. That is, even the staff that you trust, you don't always
> trust 100% :) actually almost never trust 100% so good to have options.
> > Mehmet
> >
> > On Wednesday, June 1, 2016 at 4:59:47 AM UTC-5, Derek wrote:
> >>
> >> My own observation, from years on this mailing list, is that the dev
> team do not consider this a must-have for Django; their view (as far as I
> understand it!) is that the admin is designed for trusted users, so simply
> do not let them have access at all.  Having said that, there is a pull
> request underway for a feature that seems similar to what you want:
> >>
> >> https://github.com/django/django/pull/5297
> >>
> >> (P.S. Also bear in mind that Django, like most FOSS projects, is not
> actually a democracy - so something 'the people want" does not necessarily
> get done; not understanding this trips many people up...)
> >>
> >> On Monday, 30 May 2016 20:13:18 UTC+2, Ander Ustarroz wrote:
> >>>
> >>> I am surprised this feature is not implemented yet, at the moment when
> we create a new model  three permissions are created automatically:
> >>>
> >>> add_permission
> >>> change_permission
> >>> delete_permission
> >>>
> >>> We really missing the view_permission here, when we want staff to be
> able to see the content but not being able to modify it. Searching a bit,
>  you can find many different implementations to achieve this, but all of
> them are extending django.contrib.admin.ModelAdmin. Having so many people
> rewriting these methods in my opinion is a clear sign that this feature
> should be part of the core.
> >>>
> >>> Regards,
> >>>
> > --
> > 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 https://groups.google.com/group/django-users.
> > To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/3c4931c3-453f-4a80-a62d-16bc9873817b%40googlegroups.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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAG%2B5VyNvMr6Ch5zdDz%2Bb%3DWX5%
> 3D0-pnmnj%3DTykkU3N_KXQibHgiw%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAExk7p3S0p7qO-9CDUPgDc9tyt%3DR%2Bd2XPeJkMxt8QSP13XRCFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.10 "Cannot force an update in save() with no primary key", using model with composite primary key (unique_together)

2016-10-29 Thread info
Hi all,

I have a simple model whichs acts as custom many-to-many association table 
with additional data.

```
class NetworkLinkAssociation(models.Model):
"""
We use our own many-to-many association table, because we want to keep
track which links are added, and which links are deleted/disabled in
comparison to the parent network.
"""

network = models.ForeignKey('Network', related_name='links_assoc',
on_delete=models.CASCADE)
link = models.ForeignKey('Link', related_name='networks_assoc',
 on_delete=models.CASCADE)

type = enum.EnumField(AssociationType, 
default=AssociationType.UNCHANGED,
  null=True)

class Meta:
unique_together = ('network', 'link')

@property
def link_disabled(self):
return self.type == AssociationType.REMOVED
```

When trying to simply create a new object django raises an error:

```
link_assoc = NetworkLinkAssociation()
link_assoc.link = link
link_assoc.network = network
link_assoc.save()
```

"ValueError: Cannot force an update in save() with no primary key.". 

I'm 100% sure the `link` and `network` objects exist, so what else could 
the problem be? This used to work fine Django 1.9.

Possibly related bug on Github: 
https://github.com/jpwatts/django-positions/issues/49

Thanks in advance,
Lucas

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8397f59-203f-40e5-a6b2-ee850f50b83e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: question about returning file (pdf,image,zip...) in a request that made from temporary URL

2016-10-29 Thread Stefano Probst

Hello,
you can use X-Accel-Redirect. See django-downloadview 
 
and "Nginx, Django, and X-Accel-Redirects". 


Best regards

Am Freitag, 28. Oktober 2016 16:59:53 UTC+2 schrieb ali Eblice:
>
> hello
> think of a downloading website:
> when we create a temporary link in django and map it to actual URL or file 
> path in database like this:
>
> id -- temporary_URL -- origin_URL  --  file_path
>
> so when a user used a temporary URL and directed to some view , how should 
> i return that file from that view for user to be able to download that file?
> i know that i can use "FileResponse"  or  "StreamingHttpResponse" but in 
> django documentation says that we should use these for short-lived requests 
> but downloading a big file can take long time, so what should i do ?
> i appreciate any help and idea 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4577820d-6643-400d-9746-62b46b394163%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Convert PostgreSQL tables to django

2016-10-29 Thread Rich Shepard

  Is there a tool to convert postgres DDL to django model syntax? It would
sure save a lot of time and effort if there is a converter.

Rich


Re: Convert PostgreSQL tables to django

2016-10-29 Thread m1chael
https://docs.djangoproject.com/en/1.10/howto/legacy-databases/

On Sat, Oct 29, 2016 at 1:02 PM, Rich Shepard 
wrote:

>   Is there a tool to convert postgres DDL to django model syntax? It would
> sure save a lot of time and effort if there is a converter.
>
> Rich
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAuoY6OhHtVjA_LELPymxgGF3rd6Xkatv-gLPrNkoyHmQn3_Pw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Convert PostgreSQL tables to django

2016-10-29 Thread Rich Shepard

On Sat, 29 Oct 2016, m1chael wrote:


https://docs.djangoproject.com/en/1.10/howto/legacy-databases/


  I missed seeing that. Thanks very much.

Rich


Re: Newbie question - data structure for game

2016-10-29 Thread Bob Gailer
On Oct 28, 2016 7:59 PM, "Ken Albright"  wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in
Python. I'd like to put it on a web page with Django. However, I'm not sure
of the best way to structure the data. The original quote and the encrypted
quote need to have a one-to-one relationship at the letter level. So it
could be two strings on the same row (same id)

That is the simplest, and I see no need for anything more complex.

or a set of tuples, a dictionary, or ???
>
> How to set up the database

What do you mean?

and models.py?

class Quote:
plain= Models.CharField()
crypt = Models.CharField()

> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b37833bf-e474-4b15-844d-4ef8d8e854b6%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP1rxO7uhPGRD8MdDaZxPM9ZWpViMMoFdy0_dBfb5ahuZiEB4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Migrating custom mysql application to django orm

2016-10-29 Thread Yaşar Arabacı
Hi,

I am trying to migrate my mysql application into django orm. I need help 
converting my sql statements into it. Here are my models

class SearchableText(models.Model):
searchable_text = models.TextField()
class SearchTerm(models.Model):
searchabletext = models.ForeignKey(SearchableText, on_delete=models.CASCADE)
term = models.CharField(max_length=100)


This is basically a table to store some textual information, and another 
table to use as index of searchable terms.

Consider it like this

SearchableText
id   searchable_text
1"this is text"
2"this is another text"

SearchTerm
id  searchable_text term
1   1this
2   1is
3   1text
4   2this
5   2is
6   2another
7   2text

I would normally do a sql query like this;

Select SearchableText.*
Right Join SearchTerm on SearchTerm.searchable_text = SearchableText.id
Where term in ("is","another")
group by SearchTerm.searchable_text ORDER BY COUNT(SearchTerm.term ) DESC 
LIMIT

Right now, I don't even know where to start writing a complex sql like this 
using django-orm so any help is appreciated.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6481fa3-1d35-4957-b70e-3d9912715546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Yaşar Arabacı
I am also quite new to django, but I will go with something like this;

class Quote(models.Model):
quote= models.CharField(max_length=100)

class EncryptedQuote(models.Model)
quote = models.ForeignKey(Quote, on_delete=models.CASCADE)
encrypted_quote = models.CharField(max_length=100)


So, you can have multiple encryptions of any quote.

On Saturday, October 29, 2016 at 3:00:14 AM UTC+3, Ken Albright wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in 
> Python. I'd like to put it on a web page with Django. However, I'm not sure 
> of the best way to structure the data. The original quote and the encrypted 
> quote need to have a one-to-one relationship at the letter level. So it 
> could be two strings on the same row (same id) or a set of tuples, a 
> dictionary, or ???
>
> How to set up the database and models.py?
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc31d02e-8345-4467-99df-0e4688a76a48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.10 "Cannot force an update in save() with no primary key", using model with composite primary key (unique_together)

2016-10-29 Thread Tim Graham
Try bisecting to find the commit in Django where the behavior changed:

https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#bisecting-a-regression

On Saturday, October 29, 2016 at 9:57:53 AM UTC-4, in...@lucasvandijk.nl 
wrote:
>
> Hi all,
>
> I have a simple model whichs acts as custom many-to-many association table 
> with additional data.
>
> ```
> class NetworkLinkAssociation(models.Model):
> """
> We use our own many-to-many association table, because we want to keep
> track which links are added, and which links are deleted/disabled in
> comparison to the parent network.
> """
>
> network = models.ForeignKey('Network', related_name='links_assoc',
> on_delete=models.CASCADE)
> link = models.ForeignKey('Link', related_name='networks_assoc',
>  on_delete=models.CASCADE)
>
> type = enum.EnumField(AssociationType, 
> default=AssociationType.UNCHANGED,
>   null=True)
>
> class Meta:
> unique_together = ('network', 'link')
>
> @property
> def link_disabled(self):
> return self.type == AssociationType.REMOVED
> ```
>
> When trying to simply create a new object django raises an error:
>
> ```
> link_assoc = NetworkLinkAssociation()
> link_assoc.link = link
> link_assoc.network = network
> link_assoc.save()
> ```
>
> "ValueError: Cannot force an update in save() with no primary key.". 
>
> I'm 100% sure the `link` and `network` objects exist, so what else could 
> the problem be? This used to work fine Django 1.9.
>
> Possibly related bug on Github: 
> https://github.com/jpwatts/django-positions/issues/49
>
> Thanks in advance,
> Lucas
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2fd25feb-93f5-4463-9a24-c79cdcf54456%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


WOrking with checkbox Multiple Select FIeld - Django Admin

2016-10-29 Thread Bernardo Garcia
HI, friends.

Someone know how to work with a field that allow perform a multiple 
selection in a field?, like a checkbox. In django admin,

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/670c3379-cea2-4819-91e8-5fbe804d1c88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Ken Albright
Sounds good. Thanks for the advice. Now if I could only figure out how to 
get forms to expand and contract to match the size of the quote...

Thanks.

On Friday, October 28, 2016 at 5:00:14 PM UTC-7, Ken Albright wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in 
> Python. I'd like to put it on a web page with Django. However, I'm not sure 
> of the best way to structure the data. The original quote and the encrypted 
> quote need to have a one-to-one relationship at the letter level. So it 
> could be two strings on the same row (same id) or a set of tuples, a 
> dictionary, or ???
>
> How to set up the database and models.py?
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d97d972b-ec64-483a-8aaf-e69482a4050e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Stephanie&stephan Statsmann
K

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fd2efe41-c1dc-455d-9597-a931186c6382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: WOrking with checkbox Multiple Select FIeld - Django Admin

2016-10-29 Thread M Hashmi
Form ModelForm if you need to check a single field then you set it as
BooleanField in your models.py but if you need to use kind of condition
that requires multiple checkboxes to be True. Then its better to define
condition in your view like

models.py
a = models.BooleanField(default=False)
b = models.BooleanField(default=False)
c = models.BooleanField(default=False)

Views.py
if a and b == True
return "correct".

Makes sense?

Regards,
Mudassar

On Sat, Oct 29, 2016 at 3:43 PM, Bernardo Garcia  wrote:

> HI, friends.
>
> Someone know how to work with a field that allow perform a multiple
> selection in a field?, like a checkbox. In django admin,
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/670c3379-cea2-4819-91e8-5fbe804d1c88%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts7E%2BTPngOpz4D6YBdsK9j5XopXNpmR-zEzZLe%2BJ8zrZjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.