how should i make a non downloadable image in my django website

2016-07-08 Thread deepak manupati
how should i make a non downloadable image in my django website

-- 
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/b22b97f8-626f-43a6-a4f8-1089b9a2c69b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hebrew in Raw Query Like Clause

2016-07-08 Thread Art Zemon
Michal,

Actually, your syntax didn't quite work. It threw a couple of warnings and 
seemed to match all records in the database. But you got me on the right 
track. This syntax does work properly:

select ... where word like concat('%%', %s, '%%')


Thanks for getting me pointed in the right direction.

-- Art Z.

-- 
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/a9b37167-bc7a-460e-a32c-8b6dde5b08ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hebrew in Raw Query Like Clause

2016-07-08 Thread Art Zemon


On Friday, July 8, 2016 at 8:34:00 AM UTC-5, Michal Petrucha wrote:
>
> I may be wrong, but it seems to me that you're using wrong quoting in 
> that raw query; I think it should be:: 
>
> select sortkey, book, chapter, verse, hebrew_text 
> from bible_bible 
> where hebrew_text like '%%' || %s || '%%' 
>
> The DBAPI will already take care of the proper quoting for the string 
> argument, you just need to properly concatenate it with percent signs 
> on both sides. 
>

Michal,

You're a genius! That did it. Thank you.

-- Art Z. 

-- 
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/1c749501-45a6-4884-8859-2e2a62515695%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ValueError: invalid literal for int() with base 10: 'on'

2016-07-08 Thread Gary Roach

On 07/08/2016 04:58 PM, James Schneider wrote:


> The polls,detail.html is:
>
> {{ question.question_text }}
>
> {% if error_message %}{{ error_message }}
> {% endif %}
>
> http://question.id> 
%}" method="post">

> {% csrf_token %}
>
> {% for choice in question.choice_set.all %}
>  id="choice{{forloop.counter }}"
> value"{{ choice.id  }}" />

It looks like your value attribute is missing an equals (=) sign. I 
think that the value is set to 'on' if the box is selected by the user 
and you haven't specified a value attribute.


If that's not it, can you post the entire traceback? This is an error 
from within the Django framework itself, likely from receiving a str 
value when it was expecting an int. The full traceback will hopefully 
tell us what portion of your code made the initial call.


-James


Thank you.

I mistyped the code string. and left out the = sign.. Things work as 
they should now. I guess I need to be a little more careful when 
proofing my code.


Thanks again

Gary Rl


--

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/CA%2Be%2BciWu76QWG4WTzr57T3euwRvi1eDwfFiUAT9q1wiWDSiP1Q%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/ffd16516-6d2e-2597-f516-85eb6c4c96f6%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: ValueError: invalid literal for int() with base 10: 'on'

2016-07-08 Thread James Schneider
> The polls,detail.html is:
>
> {{ question.question_text }}
>
> {% if error_message %}{{ error_message }}
> {% endif %}
>
> 
> {% csrf_token %}
>
> {% for choice in question.choice_set.all %}
>  id="choice{{forloop.counter }}"
> value"{{ choice.id }}" />

It looks like your value attribute is missing an equals (=) sign. I think
that the value is set to 'on' if the box is selected by the user and you
haven't specified a value attribute.

If that's not it, can you post the entire traceback? This is an error from
within the Django framework itself, likely from receiving a str value when
it was expecting an int. The full traceback will hopefully tell us what
portion of your code made the initial call.

-James

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


ValueError: invalid literal for int() with base 10: 'on'

2016-07-08 Thread Gary Roach

Hi all,

I'm working on the official django 1.9 tutorial part 4 , Python 3.5 and 
Django 1.9 are encapsulated in a virtualenv file in my /opt/ directory.


OS Debian Linux with KDE desktop

IDE Eclipse with PyDev plugin.

Every time I try to vote the program errors out with the following:

  File 
"/opt/python-virtual-environments/py3.5dj1.9.7/lib/python3.5/site-packages/django/db/models/fields/__init__.py", 
line 976, in get_prep_value

return int(value)
ValueError: invalid literal for int() with base 10: 'on'
[07/Jul/2016 16:21:41] "POST /polls/1/vote/ HTTP/1.1" 500 120688

*The code at line 976 is:*

def get_prep_value(self, value):
value = super(AutoField, self).get_prep_value(value)
if value is None:
return None
return int(value)

*My project layout is:*

mysite

src

mysite

...

settings.py

urls.py

wsgi.py

polls

migrations

templates

polls

detail.html

index.html

results.html

admin.py

apps.py

models.py

urls.py

views.py

db.sqlite3

manage.py



*My mysite.settings file Installed apps looks like:*

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

*My polls.views file is :*

#Include any python library functions you wish.

from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.core.urlresolvers import reverse


from polls.models import Choice, Question


def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
context = {'latest_question_list': latest_question_list }
return render(request, 'polls/index.html', context)

def detail(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/detail.html', {'question': question})


def results(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/results.html', {'question':question})


def vote(request, question_id):
question = get_object_or_404(Question, pk=question_id)
try:
selected_choice = question.choice_set.get(
  pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render(request, 'polls/detail.html',
  {'question': question, 'error_message':
   "You didn't select a choice.",}
  )
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse('polls:results',
   args=(question.id,)))

*The polls,detail.html is:*

{{ question.question_text }}

{% if error_message %}{{ error_message }}
{% endif %}


{% csrf_token %}

{% for choice in question.choice_set.all %}


{{ choice.choice_text }}
{% endfor %}





I am not very familiar with the Eclipse PyDev debugger and can't seem to 
find the problem. Any help will be sincerely appreciated.


Gary R.


--
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/5ea0dbd8-f080-7d03-eaab-428a2e117cd1%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Substring Searching for Hebrew Text

2016-07-08 Thread Art Zemon
Never mind... this is s duplicate of a post that I made via email last 
night. The emailed one finally showed up. I guess it had been held for 
moderation.

-- Art Z.

-- 
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/ea3b0e6f-c48f-4c99-a56a-dd0a173ff6c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Substring Searching for Hebrew Text

2016-07-08 Thread Art Zemon
Hello,

I have a column in a table that contains Hebrew text. I need to do a query 
with a LIKE clause on the Hebrew text. The query works if I execute the SQL 
directly, either in a SQL window of phpMyAdmin or in a command line mysql 
client. But I cannot get it to work within Django.

I tried Bible.objects.filter(hebrew_text__contains('דֶּשֶׁא') and I get 
nothing back.

I tried a raw query in a custom manager:

class BibleManager(models.Manager):
def contains_hebrew_word(self, word='דֶּשֶׁא'):
sql = """select sortkey, book, chapter, verse, hebrew_text
 from bible_bible
 where hebrew_text like '%%%s%%' """
raw_query_set = self.raw(sql, [word])
result_list = []
for b in raw_query_set:
result_list.append(b)
return result_list

but I get this error:

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL 
syntax; check the manual that corresponds to your MySQL server version for 
the right syntax to use near 'דֶּשֶׁא'%'' at line 3")


I am using 

   - Django 1.9
   - Python 3
   - mysqlclient 1.3.7
   - MySQL 5.5.49

Any ideas?

-- Art Z.

-- 
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/f7249a9d-ab78-4bc3-806a-5ab9bef20125%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin - customize use jquery inside and custom fields.

2016-07-08 Thread Luis Zárate
See https://docs.djangoproject.com/en/1.9/topics/forms/media/

2016-07-08 10:58 GMT-06:00 Luis Zárate :

>
> 2016-07-08 10:24 GMT-06:00 :
>
>> and save the new im
>
>
> You can start reading how to set css and js to form and admin site.
>
> See
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>


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


Django Admin - customize use jquery inside and custom fields.

2016-07-08 Thread sevenrrainbow
I want to implement in Django Admin a jquery plugin that "adjust" and 
image(http://guillotine.js.org/), them get the coordinates with ImageKit 
and save the new image.

I need some tutorials and advises how to do it.

-- 
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/33577f4d-aadb-4c37-857b-2c03261d2c05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST header in shared server

2016-07-08 Thread Luis Zárate
nobody knows how to solve this problem?

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


Re: Django - File or Image Delete

2016-07-08 Thread Mstislav Kazakov
Just pass empty value in file field.
If blank=True and null=True, everything should work fine and image will be 
removed.

пятница, 8 июля 2016 г., 17:23:42 UTC+5 пользователь sevenr...@gmail.com 
написал:
>
> The user has the possibility to add/delete image and documents.
>
>
> I used GCBV UpdateView and a FormModel for this. 
>
>
> How can I offer the possibility to the user to delete the file/image ?
>

-- 
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/47154174-4951-45ad-b939-320a7fbcd147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hebrew in Raw Query Like Clause

2016-07-08 Thread Michal Petrucha
On Thu, Jul 07, 2016 at 11:23:21PM -0500, Art Zemon wrote:
> Hello,
> 
> I have a column in a table that contains Hebrew text. I need to do a query
> with a LIKE clause on the Hebrew text. The query works if I execute the SQL
> directly, either in a SQL window of phpMyAdmin or in a command line mysql
> client. But I cannot get it to work within Django.
> 
> I tried Bible.objects.filter(hebrew_text__contains('דֶּשֶׁא') and I get
> nothing back.

Here, one thing you might want to try is to use django-debug-toolbar's
debugsqlshell, run the query inside that, and take a look at the
actual SQL query generated for that; maybe it will reveal some oddity.

> I tried a raw query in a custom manager:
> 
> class BibleManager(models.Manager):
> def contains_hebrew_word(self, word='דֶּשֶׁא'):
> sql = """select sortkey, book, chapter, verse, hebrew_text
>  from bible_bible
>  where hebrew_text like '%%%s%%' """
> raw_query_set = self.raw(sql, [word])
> result_list = []
> for b in raw_query_set:
> result_list.append(b)
> return result_list
> 
> but I get this error:
> 
> django.db.utils.ProgrammingError: (1064, "You have an error in your SQL
> syntax; check the manual that corresponds to your MySQL server version for
> the right syntax to use near 'דֶּשֶׁא'%'' at line 3")

I may be wrong, but it seems to me that you're using wrong quoting in
that raw query; I think it should be::

select sortkey, book, chapter, verse, hebrew_text
from bible_bible
where hebrew_text like '%%' || %s || '%%'

The DBAPI will already take care of the proper quoting for the string
argument, you just need to properly concatenate it with percent signs
on both sides.

Good luck,

Michal

-- 
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/20160708133324.GG22177%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Hebrew in Raw Query Like Clause

2016-07-08 Thread Art Zemon
Hello,

I have a column in a table that contains Hebrew text. I need to do a query
with a LIKE clause on the Hebrew text. The query works if I execute the SQL
directly, either in a SQL window of phpMyAdmin or in a command line mysql
client. But I cannot get it to work within Django.

I tried Bible.objects.filter(hebrew_text__contains('דֶּשֶׁא') and I get
nothing back.

I tried a raw query in a custom manager:

class BibleManager(models.Manager):
def contains_hebrew_word(self, word='דֶּשֶׁא'):
sql = """select sortkey, book, chapter, verse, hebrew_text
 from bible_bible
 where hebrew_text like '%%%s%%' """
raw_query_set = self.raw(sql, [word])
result_list = []
for b in raw_query_set:
result_list.append(b)
return result_list

but I get this error:

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near 'דֶּשֶׁא'%'' at line 3")


I am using

   - Django 1.9
   - Python 3
   - mysqlclient 1.3.7
   - MySQL 5.5.49

Any ideas?

-- Art Z.

-- 
http://CheerfulCurmudgeon.com/ 

*"If I am not for myself, who is for me? And if I am only for myself, what
am I? And if not now, when?" Hillel*

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


Django - File or Image Delete

2016-07-08 Thread sevenrrainbow
 

The user has the possibility to add/delete image and documents.


I used GCBV UpdateView and a FormModel for this. 


How can I offer the possibility to the user to delete the file/image ?

-- 
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/50fe0c3e-961d-4842-8f83-75071ff1e64c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.