Re: Exception happened during processing of request from ...

2019-02-11 Thread Jon bae


Am Freitag, 8. Februar 2019 13:24:01 UTC+1 schrieb Pedram Badakhchani:
>
> I am getting similar errors, also running Django 2.15 with python 3.72, 
> would be very interested if you have found a solution
>
> No, sadly I did not found a solution. Maybe django is not 100% compatible 
with python 3.7.2. At the moment I hope that my project runs later on the 
target (Linux) system, with a lower python version, normal... 

-- 
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/2a2d9cad-da8d-4d4b-927e-de9d04e6192b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Exception happened during processing of request from ...

2019-01-31 Thread Jon bae
Hello,
I'm running here *django 2.1.5* with *python 3.7.2* (installed with 
homebrew) on a macOS (mojave).

On a regular basis I get this error message:

Exception happened during processing of request from ('127.0.0.1', 54882)
Traceback (most recent call last):
  File 
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py"
, line 650, in process_request_thread
self.finish_request(request, client_address)
  File 
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py"
, line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File 
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py"
, line 720, in __init__
self.handle()
  File "/Users/User
/DEV/gogs/TV-Webpage/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py"
, line 171, in handle
self.handle_one_request()
  File 
"/Users/User/DEV/gogs/TV-Webpage/venv/lib/python3.7/site-packages/django/core/servers/basehttp.py"
, line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
  File 
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py"
, line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer


It comes for example when I open the admin page, but not always.


Have you any idea how I can fix that?

Have a nice day!

Jonathan

-- 
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/7a309d8d-139b-4de4-b110-9a36a832d7b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Constant Invalid HTTP_HOST header spam

2017-12-19 Thread Jon Ribbens
On Tuesday, 19 December 2017 13:37:06 UTC, Daniel Hepper wrote:
>
> This should ensure that only requests with valid Host headers reach your 
> application while still supporting Non-SNI clients. You can test it with 
> "open_ssl client" or "gnutls-cli":
>

Yes, that looks good to me. Many 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/677272d9-05eb-41d1-991c-3e322a5585a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Constant Invalid HTTP_HOST header spam

2017-12-19 Thread Jon Ribbens
On Tuesday, 19 December 2017 07:24:23 UTC, Antonis Christofides wrote:
>
> I may be wrong of course, but I don't recall SNI having anything to do 
> with it. Just using something like
>
> server {
> listen 80;
> listen 443 ssl;
> server_name my.django.site.com;
> ...
> }
>
> will only send requests for my.django.site.com to the django project. I 
> really don't know about SNI, but I recall having used SSL on Apache before 
> SNI existed and I don't remember any difference with respect to that. Why 
> does SNI affect this?
>

Because unless I'm misremembering something, if you *don't* add 
default_server to the listen directive then requests without SNI will not 
end up being served the desired SSL certificate, but if you *do* add 
default_server then requests with the wrong/missing/IP-literal Host: header 
will end up going to Django, which is what we wanted to avoid.

I guess I'll just have to decide which of lack-of-SNI support and 
alerting-on-wrong-Host I want to lose.

-- 
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/bf3e62f2-2584-4a28-8680-5cb83dd88753%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Constant Invalid HTTP_HOST header spam

2017-12-18 Thread Jon Ribbens
On 18 Dec 2017, at 23:26, Antonis Christofides  
wrote:
> the documentation describes how to silence this error at 
> https://docs.djangoproject.com/en/2.0/topics/logging/#django-security.
> 

It’s not obvious from that how to silence it only for IP literals. I’d still 
like to receive it for actual unknown hosts.
> How have you deployed your Django project? I always configure Apache or nginx 
> in such a way so that such invalid requests never reach Django.
> 
A couple of weeks. The nginx configuration idea is a good one, although I was 
trying to allow the site to work without SNI, but it’s probably not vital.

-- 
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/11A18532-A2F4-4F02-AA24-9B6AD9C90DE2%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Constant Invalid HTTP_HOST header spam

2017-12-18 Thread Jon Ribbens
I'm getting spammed with constant "Invalid HTTP_HOST header: 
'10.9.8.7:443'. You may need to add '10.9.8.7' to ALLOWED_HOSTS" emails, 
due to the Internet being the Internet. How can I disable these emails, 
without turning off error emails completely? I don't particularly want to 
add the IP address to the ALLOWED_HOSTS. It seems to me this email 
shouldn't be being generated if the HTTP_HOST value is an IP literal.

-- 
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/0f07d6ca-626c-4887-86e5-a5d10190bc49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


import different entries using filter

2017-06-19 Thread jon stan
hey im trying to import one set of info from a database based on the name 
of something else if that makes sense.

basically in the database its setup like this:

   food-
  restaurant-name   products type of service
  
 (burger-place)(burgers)   (fast food)
   ---

im trying to display the products and service type based on the name but i 
cant figure out how todo that. here's what i have:

 views.py
  name = food.objects.get(restaurant-name__icontains='burger-place')
  prod = 
food.objects.filter(restaurant-name__icontains='burger-place').filter(products__icontains='burgers')
  service = 
food.objects.filter(restaurant-name__icontains='burger-place').filter(service__icontains='fast
 
food')

but i cant get it to work correctly. i get 'burger-place' for the name, 
prod, and service variables for some reason. would i have to create 
completely separate models or is there a way i can get these variables 
based on the restaurant name?

-- 
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/14d6d935-63c7-4417-9944-f47bbf3dbd35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: type error issue

2017-06-19 Thread jon stan
That was it. thanks Andreas. 

-- 
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/296f98e8-4201-4d13-a644-006274013799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


type error issue

2017-06-12 Thread jon stan
So i keep getting this error every time i try to pass a variable in http.

in my template i have a link that contains the variable of a county in a 
state:   

   *template.html*
   {{ cnty }}

when you click the link i guess it goes to the urls file:
  
   *urls.py*
   url(r'^region', views.region, name='region'),

and then it gets picked up by the views file but i keep getting an error 
for some reason:

   *views.py*
   def region(request, cnty):
  
   return render(
   request, 'region.html', context={'cnty':cnty},
   )

the error says "region() takes 2 arguments 1 given", but i dont understand 
how im only giving 1 argument?

-- 
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/7762d655-1ae3-49fa-887a-0ade6bd3c00d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Python / Django newbie looking for mentorship

2017-03-19 Thread Jon Hickam
I have 20 years experience in software but am new to OO python and django, 
 I have a project I am tackling and would be most grateful if there is 
someone I could hire to clone my repo and give me advice as I navigate my 
first project, maybe once or twice a week at the beginning?  Schedule can 
be flexible.  If you are interested send me a quick note with what your 
experience is and what sort of compensation rate you would be looking for 
and we can work out a time to chat. 
Cheers!
Jon


 

-- 
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/d34aab02-afc1-4758-a57a-0a5f0062b1ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Foreign Key data not showing in formset

2017-02-08 Thread jon
 

As much as I hate to answer my own questions, I was calling instance of an 
empty Order() model rather than the instance of the populated model. So:


lineitem_formset = LineFormSet(instance=Orders())

should have been:


lineitem_formset = LineFormSet(instance=order)


On Wednesday, February 8, 2017 at 8:00:52 AM UTC-5, jon wrote:
>
> I have the following view with an inlineformset for two models: 
>
>1. Orders, the master / parent model 
>2. LineitemInfo, the detail / child model. 
>
> FormSet
>
>
> LineFormSet = inlineformset_factory(Orders, LineitemInfo,
>
> can_delete=True,
>
> exclude = ('ordernotes',))
>
>  
>
> The edit order_edit view works fine for the master / parent form, but does 
> not display the child records. I can add records to the child form and they 
> will save, they do not display however when I select that record (I checked 
> the database separately).
>
>
> def order_edit(request, pk):
>
> order = get_object_or_404(Orders, pk=pk)
>
> if request.method == "POST":
>
> form = OrderForm(request.POST, instance=order)
>
> if form.is_valid():
>
> order = form.save(commit=False)
>
> lineitem_formset = LineFormSet(request.POST, instance=order)
>
> if lineitem_formset.is_valid():
>
> order.save()
>
> lineitem_formset.save()
>
> return redirect('order_list')
>
> else:
>
> form = OrderForm(instance=order)
>
> lineitem_formset = LineFormSet(instance=Orders())
>
> return render(request, "orders/order_edit.html", {"form": form, 
> "lineitem_formset": lineitem_formset, })
>
>  
>
> I just get the empty fields on the child / detail form where the data 
> should display. What am I missing? TIA
>

-- 
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/48bdb601-7636-4faa-9af9-b8c10a65c0cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Foreign Key data not showing in formset

2017-02-08 Thread jon
 

I have the following view with an inlineformset for two models: 

   1. Orders, the master / parent model 
   2. LineitemInfo, the detail / child model. 

FormSet


LineFormSet = inlineformset_factory(Orders, LineitemInfo,

can_delete=True,

exclude = ('ordernotes',))

 

The edit order_edit view works fine for the master / parent form, but does 
not display the child records. I can add records to the child form and they 
will save, they do not display however when I select that record (I checked 
the database separately).


def order_edit(request, pk):

order = get_object_or_404(Orders, pk=pk)

if request.method == "POST":

form = OrderForm(request.POST, instance=order)

if form.is_valid():

order = form.save(commit=False)

lineitem_formset = LineFormSet(request.POST, instance=order)

if lineitem_formset.is_valid():

order.save()

lineitem_formset.save()

return redirect('order_list')

else:

form = OrderForm(instance=order)

lineitem_formset = LineFormSet(instance=Orders())

return render(request, "orders/order_edit.html", {"form": form, 
"lineitem_formset": lineitem_formset, })

 

I just get the empty fields on the child / detail form where the data 
should display. What am I missing? TIA

-- 
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/daa49199-da50-4be6-aa82-c28e84596580%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Master-Detail Form help needed

2017-01-16 Thread jon
I have been struggling mightily with Master-Detail forms in Django. I have 
done a number of online tutorials but have yet to find a complete tutorial 
which completely explains models, views, templates, URL patterns related to 
master-detail forms. I use the Oracle toolsets where creating a 
master-detail form is just a matter of feeding the template your master 
table (model) and then selecting your detail table (model). It generates a 
basic form for you with CRUD controls. Similar to how the Django admin tool 
works.  If someone could point me toward a good comprehensive book chapter 
or tutorial, I would be much appreciated. TIA.

-- 
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/c6d2-e561-409d-a356-724527431b66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django project beginner

2016-12-28 Thread jon
I would recommend the Django Girls tutorial. It is very well written and 
easy to follow. I covers most of the components that you will need to get 
started with Django and is a good starting point.

https://tutorial.djangogirls.org/en/

On Monday, December 26, 2016 at 6:39:25 AM UTC-5, imed chaabouni wrote:
>
> Hi everyone,
> I'm about to make my first project with Django as an end-of-year project, 
> so, could you recommand me some exemple as a beginner ?
> And if you've got some documentation that's would be great ( And yes I 
> already checked the doc of the official django website)
>
> Thanks, 
> Imed.
>

-- 
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/f8d7b6af-477a-4979-a8d0-d684b4162c04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


'RegexURLResolver' object has no attribute 'default_args'

2016-12-23 Thread jon
I am a newbie to Django, coming from PHP/Yii. I have gotten to the part 4 
of the official Django tutorial but can't seem to get by this error.

I have looked online and in this forum but cannot find anything on this 
specific error.

Error:

AttributeError at /polls/1/vote/

'RegexURLResolver' object has no attribute 'default_args'

Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/
Django Version: 1.8.4
Exception Type: AttributeError
Exception Value: 

'RegexURLResolver' object has no attribute 'default_args'



View: 

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,)))



-- 
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/eaf2b01a-9a29-4b1e-867a-382291af54cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: FileField with UUID filename

2016-09-06 Thread Jon Ribbens
On Tuesday, 6 September 2016 17:05:39 UTC+1, Tim Graham wrote:
>
> See https://code.djangoproject.com/ticket/4345 for the ticket that 
> disallowed primary_key/unique on FileField.
>

I've now opened a new ticket #27188 to suggest reversing this change ;-)
 

> You can write a custom field to get FileField to use a UUID in the 
> database (and likely also lift the other restrictions you want to bypass).
>

Yes, I was wondering how to do that because it's not at all obvious. 
However I have since decided that I simply need a custom Storage class like 
this:

class ChecksumStorage(FileSystemStorage):
"""Store files in the file system with filename based on file 
contents."""
def save(self, name, content, max_length=None):
checksum = hashlib.sha256()
for data in content.chunks():
checksum.update(data)
return super().save(checksum.hexdigest(), content)

and then I don't need a model at all, I can just refer to the files with a 
CharField(max_length=64).

-- 
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/04f78698-cf07-4a89-b8f0-225d1c5795fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


FileField with UUID filename

2016-09-04 Thread Jon Ribbens
I have a model which basically just represents a file. I want to use a UUID 
as the filename. I could do the following:

def _get_filename(instance, filename):
return str(uuid.uuid4())

class File(Model):
   content = FileField(db_index=True, upload_to=_get_filename)
   filetype = CharField("MIME Type", max_length=256)

which does work however it is sub-optimal in a couple of ways:

   - the UUID is stored as a VARCHAR in the database
   - the UUID is not used as the primary key
   - there is a pointless additional integer field as the primary key
   - you can't even add unique=True to the field

So I was wondering:

   - why does FileField refuse to allow its use in a unique index or as the 
   primary key?
   - how can I get FileField to use a UUID field in the database?

Any thoughts would be greatly 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/396e0394-3112-46db-9499-0cfbb8eb780a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Steadman

2016-01-06 Thread Jon Atkinson
I've alerted Mark off-list.

--Jon

On Wed, Jan 6, 2016 at 1:02 PM, Avraham Serour  wrote:

> virus people, don't click the link
>
> On Wed, Jan 6, 2016 at 2:29 PM, Steadman  wrote:
>
>> Please find the attached document referred to the mail subject.
>>
>> Steadman.io <http://steadman.io>
>> Blog <http://steadman.io/blog/> | Podcasts <http://poddle.fm/> | Twitter
>> <http://twitter.com/iamsteadman/> | Facebook
>> <https://www.facebook.com/iamsteadman>
>>
>> I do a *live podcast* every Monday night (8pm GMT) called the 2014 Show
>> <http://poddle.fm/2014/>. I'm always looking for guests. Shout if you
>> fancy sitting in the big Skype chair!
>>
>> Download / View <http://lauraairabusiness.igg.biz/>
>>
>> [image: Inline images 1] <http://lauraairabusiness.igg.biz/>
>>
>> --
>> 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/CAAcSLoM43EB_36hUtzhXX-YPGxRkv0o-i8Z9fH8aVPxXhgEEZw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAcSLoM43EB_36hUtzhXX-YPGxRkv0o-i8Z9fH8aVPxXhgEEZw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CAFWa6t%2BXaEz4iOOZ%3DYcKKA5KXMD541cDWNEmnsqgY3RTStQT8w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAFWa6t%2BXaEz4iOOZ%3DYcKKA5KXMD541cDWNEmnsqgY3RTStQT8w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CAO4CLk%3DhOMm5W3U0Wf%2B1YWn7kvC17C8X7x7pszC3NE%2BNFy%2Bn_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get all current active connected users

2015-12-09 Thread Jon Ribbens
On Wednesday, 9 December 2015 12:55:22 UTC, Jani Tiainen wrote:
>
> This is really problematic domain since as you know, Django works on HTTP 
> request-response cycle. After cycle is finished there is absolutely no way 
> to know "who is logged on".
>
> So first you have to determine factors that make up "currently active 
> user". Then you have to track that information somehow and after that it's 
> possible to gather a list of active/inactive users.
>

Users have a last_login field so you could easily say "users who have 
logged in in the last 24 hours" or whatever. 

-- 
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/7c5f0620-c094-4667-b474-82a23f432fa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-08 Thread Jon Ribbens
On Tuesday, 8 December 2015 00:44:02 UTC, knbk wrote:
>
> It seems a bit weird that that's not automatic.
>>
>
> That's what I thought, so it's automatic in 1.9.
>

Ah, brilliant.
 

> That still leaves the question of what Model.get_absolute_url() should do, 
>> given that it has no way to get the current app that I can see. Thank you 
>> for your very helpful comments though.
>>
>
> It can't know the current app. I never use it for anything but the helpful 
> "View on site" link in the admin. I have some plans to revisit this API, 
> but that depends on some other work I'm still finishing. 
>

Thanks. I think I have a vague idea what's going on now ;-) 

-- 
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/93a7eb69-03f9-41fa-a4e0-a09639f04b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-07 Thread Jon Ribbens
On Monday, 7 December 2015 23:40:51 UTC, knbk wrote:

> Namespaces are a mess, and have been for a while. 1.9 cleans this up a 
> bit. Some advice for 1.8 to stay in line with the 1.9 changes:
>
>- Always define an application namespace when using an instance 
>namespace.
>- An app shouldn't depend on the project's url configuration, so 
>always use the application namespace in the view name, i.e. 
>reverse('polls:view'), not reverse('author-polls:view').
>- A project that uses an app may point to a specific instance 
>namespace of that app when necessary, i.e. on the front page with links to 
>both author-polls and publisher-polls.
>- The currently active instance namespace is available as 
>request.resolver_match.namespace.
>- You can set request.current_app = request.resolver_match.namespace 
> before 
>rendering templates, and the {% url %} template tag will use the 
>current namespace for urls in the same application namespace.
>
> It seems a bit weird that that's not automatic.

>
>- You can explicitly pass the current namespace to current_app in 
>reverse() to do the same. 
>
> That still leaves the question of what Model.get_absolute_url() should do, 
given that it has no way to get the current app that I can see. Thank you 
for your very helpful comments though.

-- 
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/47d50462-b751-4203-a87f-5e9ad7fbbb50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-07 Thread Jon Ribbens
On Monday, 7 December 2015 21:14:45 UTC, Caique Reinhold wrote:
>
> Well, as this is implemented you have to know your namespaces during 
> development. But now i see what's your problem.
>
> I'm not sure, but i don't think it is encouraged to have multiple 
> instances of the same app in one project. I think the sites 
> contrib app or 
> some other method of having this author/publisher distinction within the 
> same app would better suit your needs.
>

I don't have any needs (the author/publisher thing is from the Django docs, 
not my app), I'm just trying to write an utterly simple app and I'm trying 
to find out the "best practices" way of doing it.

The impression I'm getting is that the documentation is misleading and the 
"instance namespace" feature does not actually really work. And that the 
answer to my question is that I should use an app namespace and put as part 
of the installation instructions for my app that the user must put 
app_name="foo" in their site's urls.py or the app will fail. I guess this 
is why one of the changes in 1.9 is that now you can define the app_name in 
the app rather than in the site.

-- 
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/03e579b4-7a69-419f-9f41-1ba13203ed2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-07 Thread Jon Ribbens
On Monday, 7 December 2015 20:09:34 UTC, Caique Reinhold wrote:
>
> You use the app namespace which you defined in the site for each app, not 
> the app_name. That's what pa xapy meant.
>
> In the example you gave it would be like: reverse('author-polls:view', 
> self.id).
>

But (a) the app cannot know that I might make an instance of it called 
'author-polls' (I might after all make an instance of it called anything at 
all) and (b) what if this is not the 'author-polls' instance?

-- 
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/7b91b904-8435-47ae-baa2-253926694962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to write Model.get_absolute_url()?

2015-12-07 Thread Jon Ribbens
On Monday, 7 December 2015 10:24:48 UTC, pa xapy wrote:
>
> there is two approaches:
> you can either create unique names for each url pattern entry like 
> url(, name='my_app_unique_view_name')
> or use namespace and pass it to reverse like 
> reverse('my-app-namespace:my-url-pattern-view-name')
>

But that doesn't account for either of the points in my question, i.e. that 
(a) the app does not know its "app_name" as that is defined by the site not 
the app, and (b) if you did somehow know and use the app_name then how does 
Django know which instance you mean?

-- 
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/64b17837-cd81-4572-8809-59684c8fc712%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to write Model.get_absolute_url()?

2015-12-05 Thread Jon Ribbens
I'm using Django 1.8. If I'm writing an app, and I want to add 
get_absolute_url() to a model, the question is: what do I put for the first 
argument to 'reverse'?

The documentation 
at https://docs.djangoproject.com/en/1.8/topics/http/urls/#url-namespaces 
implies that I need to know two things: the instance name, and the app 
name. The problem is that get_absolute_url() knows neither of these.

Imagine my app has a urlpattern like:

url(r'^view/(\d+)$', views.view, name="view")


I could just say reverse("view", self.id) but what if another app has a 
view called 'view'? What if my app is instanced twice - i.e. as shown in 
the docs:

url(r'^author-polls/', include('polls.urls', namespace='author-polls', 
app_name='polls')),
url(r'^publisher-polls/', include('polls.urls', 
namespace='publisher-polls', app_name='polls')),


?

-- 
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/89ed6fcc-c37a-4d6b-b7eb-01ff5561db08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hanging django/postgres idle connections

2015-11-23 Thread Jon Sandness
I'm seeing this same issue in OS X 10.11.1 - interestingly, the hang only 
occurs when I run migrations through Jenkins.  If I manually run the 
command inside of a VirtualBox session, it works as expected.

Jon

On Friday, August 1, 2014 at 6:41:53 AM UTC-7, Jani Kajala wrote:
>
> Haven't tried (yet), I'm new to Python & Django & Postgres, got on board 
> with Python 3.4.1 and Django 1.7c1. I'm starting to suspect this isn't 
> really Django related directly, since I can consistently reproduce the 
> problem following way: 1) Run e.g. test case, break it in debugger 2) Stop 
> debug session. Django cannot really do anything about me interrupting the 
> debugging session, but it should not block access to DB indefinitely. 
> However, it does. I tried also to install pgbouncer, but it made 
> interestingly situation worse, now even a single connection can block 
> access to DB even if I have pgbouncer max_connections set to 100. So maybe 
> this is something Windows/VirtualBox networking related.
>
> On Thursday, July 31, 2014 10:58:41 PM UTC+7, Collin Anderson wrote:
>>
>> Does it work fine on django 1.6? It could be a regression.
>>
>> On Wednesday, July 30, 2014 10:41:58 AM UTC-4, Jani Kajala wrote:
>>>
>>> Hi,
>>>
>>> I have a problem with leaking Postgres DB connections even if I 
>>> have CONN_MAX_AGE=0. Every time I start the server and stop it by 
>>> Ctrl+Break a DB connection is leaked.
>>>
>>> When I check from Postgres there is bunch of "idle" connections with 
>>> following content:
>>> SELECT "django_migrations"."app", "django_migrations"."name" FROM 
>>> "django_migrations"
>>>
>>> I'm running Python on Windows 8 + virtualenv with following installs:
>>> Django==1.7c1
>>> future==0.12.4
>>> psycopg2==2.5.3
>>> python3-memcached==1.51
>>> pytz==2014.4
>>> six==1.7.3
>>> sqlparse==0.1.11
>>> virtualenv==1.11.6
>>> xlwt-future==0.8.0
>>>
>>> Postgres is running in Ubuntu 14.04 in latest Oracle VirtualBox on same 
>>> Windows machine.
>>>
>>> Any ideas?
>>>
>>>
>>> Thanks,
>>> Jani
>>>
>>>

-- 
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/0a306fd7-1435-432c-8042-69d0553aae95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ValueError: Related model 'cms.Placeholder' cannot be resolved

2015-11-22 Thread Jon Ribbens
I changed a field from TextField to PlaceholderField (from Django-CMS) and 
now I get the above error when running 'migrate'.
I can't find a way to fix this, nor can I undo it as there appears to be no 
way to remove migrations.

I am using:
  Python 3.4.3
  Django 1.8.5
  Django-CMS 3.1.3

Does anyone have any ideas?

-- 
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/262c9cbe-c137-43cd-ac08-07150625e3c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Have mercy please!

2015-06-09 Thread Jon Foster
I've been involved with Django, on and off, since v0.96 or so. I love 
Django and think its the most productive way to build rich websites with 
custom defined content types. Throw in Django-CMS and things get pretty 
darn cool.

I was thrilled when Django reached v1.0 since it came with the promise of 
having a consistent and stable API, specifically a lack of backwards 
incompatible changes, unless required by security concerns. Unfortunately 
this promise is routinely violated for various excuses. The bottom line is 
none of the apps I've written have been able to survive any 2 point 
upgrades (v+0.2). Single point upgrades usually only cause minor breakage.

I realize the desire to grow things and I applaud it. But there is a 
business issue here. I can't, in good conscience recommend Django as a site 
platform to many of my small clients as they simply could not afford the 
upkeep of a Django powered site. Especially if the site is e-commerce 
related, where PCI, and responsible site operation, will require that we 
stay current. In order to do so would require staying up with the constant 
flow of backwards incompatible changes, combined with the time and effort 
to reverse engineer and maintain contributed apps, which aren't keeping 
pace either.

With the current method of development on the Django platform, if I had 
just a dozen sites of moderate complexity, it would become a full time job 
just keeping them updated. Its complicated enough just finding the apps 
that will actually work with each other to construct a site. But the 
carefully constructed house of cards is virtually guaranteed to break with 
the next update.

So I ask, PLEASE return to and stick with the promise of API stability? You 
promised and routinely point to that statement, while making backwards 
incompatible changes. I want to spend more time working with Django, but I 
need to know that my clients can rely on painless and cost effective 
upgrades.

Thanks for reading my complaint,
Jon

-- 
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/11e78690-2b5f-4e99-a377-62c19b74e333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: migrate does not store default values in the database

2014-10-24 Thread Jon Dufresne
On Fri, Oct 24, 2014 at 3:24 PM, Peter Coles  wrote:
> I'm trying out the migrations in Django 1.7 and I was surprised when my
> migrations did not set default values in the database. Can someone share the
> motivation for this functionality? (more details below)
>
> This was surprising given the documentation I read:
>
> the release notes for 1.7 suggest using `null=True` for new database
> columns, but only because of the potential performance impact during a site
> update (which seems odd, since the migrations don't set default values
> anyways…)
> the example of a migration file clearly shows a default value of `0` for the
> Author.rating field, even though it turns out the default isn't used
>
> Running `python manage.py sqlmigrate appname migrationnumber` for an example
> like the Author.rating addition in the docs would look something like this:
>
> BEGIN;
> ALTER TABLE "author" ADD COLUMN "rating" integer NOT NULL DEFAULT 0;
> ALTER TABLE "author" ALTER COLUMN "rating" DROP DEFAULT;
>
> COMMIT;
>
> However, looking in the source code, I can see: "(Django usually does not
> use in-database defaults)".
>
> I find it quite problematic for production site updates, since my updates
> generally look like:
>
> generate migrations
> run migrations on prod db, while old webserver code is still running
> after migrations, update webserver
>
> I cannot afford to have breaking problems between steps 2 & 3 if I want to
> add a new db column that is not null and has a default value.
>
> Does anyone here know the motivation for the existing no-defaults-in-the-db
> functionality? I'd like to know, since I'm putting together a backend
> derived from 'django.db.backends.postgresql_psycopg2' that is exactly the
> same, except for setting default values in the db, and I'd like to know what
> concerns there might be for a backend like this?

Before migrations were built-in there was a bug report about this:
<https://code.djangoproject.com/ticket/470>. It might be of some help.
It was closed as wontfix. Not sure if the addition of migrations has
changed anyone's mind.

Cheers,
Jon

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


Re: Is there a way to supress blank lines in the HTML?

2014-10-24 Thread Jon Dufresne
Try adding "import re" to the top to import the Python re module.


On Fri, Oct 24, 2014 at 8:35 AM, Daniel Grace  wrote:
> Thanks people for the info.  I was looking for a way to beautify the code,
> rather than for performance / compression.  In particular I came across this
> when I implemented a template tag which, under certain circumstances returns
> an empty string.  This works well but causes blank lines in the code, if
> they are present in the original template.  I did find the almostspaceless
> template tag on http://kuttler.eu/code/django-almost-spaceless-template-tag/
> but I could not get it to work, as I don't know where "re.sub" comes from.
>
> --
> 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/d4875909-54b2-4655-b459-c71c4bb7efc9%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/CADhq2b6C08sYgz4ubqJrtPr4oK3Kiqn5ht4o2GaO7H8Q%2BFeQAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there a way to supress blank lines in the HTML?

2014-10-24 Thread Jon Dufresne
> If you need this for some performance reasons like html compression, you are 
> doing it wrong.
> Instead you could use server-side GZIP compression when serving html which 
> will do the job much more efficiently.

Just a heads up. Compressing dynamic responses over HTTPS is
considered insecure due to the BREACH attack.
<http://en.wikipedia.org/wiki/BREACH_%28security_exploit%29>

Django documentation also contains a blurb about this:
<https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.gzip>

I don't know the specifics here, but the issue is relevant.

Cheers,
Jon

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


Re: Restricting file access to users who uploaded the file.

2014-10-21 Thread Jon Dufresne
On Tue, Oct 21, 2014 at 7:09 AM, Ben Lopatin  wrote:
> Presuming you're working with Nginx or
> Apache and local files, you can use X-Accel-Redirects or X-Sendfile to do
> this. Basically the request for a file is made to your Django app, e.g.
> /files/some-file-name.doc, and the app checks if the user can access it. If
> so, the app returns the request with a new header (x-accel-redirect) and the
> file path - this isn't immediately sent to the client, but is instead
> resolved by the web server (i.e. Nginx or Apache) by returning the file from
> its location on the file system. Django verifies, Nginx/Apache does the file
> serving (full explanation here:
> http://wellfireinteractive.com/blog/nginx-django-x-accel-redirects/).

If you're looking for a nice Django app that does this bit for you
with a simple API, check out Django Sendfile
<https://github.com/johnsensible/django-sendfile>. However, you'll
still need to configure the web server end.

Cheers,
Jon

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


entering data directly into a postgreSQL database

2014-10-18 Thread Jon Joseph
Hello: I'm using django 1.7 and I've have the following simple model:

from django.db import models


class RegisteredUser(models.Model):
user_name=models.CharField("Name", max_length=200)
register_date=models.DateTimeField('Registration Date')

def __str__(self):
return self.user_name

class ProblemList(models.Model):
problem_number=models.CharField("Number", max_length=100)
problem_statement=models.CharField("Problem", max_length=500)

def __str__(self):
return self.problem_number + '\n' + self.problem_statement

I would like to populate the database by using the PostgreSQL specific
command:

COPY solutions_problemlist from 'filename'

where filename is a file with tab delimited data.  The table exists and I
can populate from the django admin app but I keep getting a "value too long
for type character varying(10)" from the PostgreSQL COPY command.

Any ideas, any more information needed?

Thanks, Jon Joseph
josco@gmail.com

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


Re: File Storage API: save file to DB model and disk: separate disk path from file name

2014-10-17 Thread Jon Dufresne
On Fri, Oct 17, 2014 at 4:45 PM, Russell Keith-Magee
 wrote:
> Achievable? probably. Easy? No. You're going to be digging in the weeds on
> this one.
>
> If I were trying to do this, I wouldn't try and get this to work with the
> existing FileField - I'd be writing my own Field definition. You can crib
> extensively from the existing definition, but everywhere that the current
> model points at it's own storage to get a filename, you use the foreign key
> to get the full file name.
>
> Essentially, it's going to be a merger of FileField and ForeignKey. I
> haven't done this myself, but my gut tells me this is in the realm of the
> "possible, but complicated".
>
> The other way that might be worth looking into is to follow the lead of
> GenericForeignKey. That's an example of a field that "looks" like a single
> column, but is implemented as two columns under the hood. You'll be looking
> to do a similar thing - write a "wrapper" field that points at the name and
> path fields to produce a composite "full file path" field. That composite
> field will be a lot closer to what FileField is expecting, so it might be a
> little easier to merge *that* with FileField than to merge FileField with
> ForeignKey. Then, you put the composite field on the StoredFile model, and
> traverse down the foreign key relation whenever you need to access the file.

Thanks for the feedback and suggestions.

I'll play around a bit and give it a shot.

My fear with this approach is third party applications with FileFields
will now now handle files differently. Luckily this doesn't affect me
at the moment, but may in the future.

Cheers,
Jon

-- 
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/CADhq2b7r4KOFjizyNimP4x9vzjD%2B%2BS%2Bh_b0jEq91fz_e_D-5-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


File Storage API: save file to DB model and disk: separate disk path from file name

2014-10-17 Thread Jon Dufresne
Hi,

I'm trying to use the File Storage API to create a custom handler for
files. Here are my goals:

Stored files are represented both in the database and on disk with the
following model:

class StoredFile(models.Model):
name = models.CharField(max_length=255)
path = models.CharField(max_length=255, unique=True)

The "name" attribute represents the filename presented to the user:
"My document.txt". The path attribute represents the basename as the
file exists on the disk in MEDIA_ROOT, usually created with mktemp:
"tmpAsdf123" in "/path/to/media". The goal of this configuration:

1. Files are stored on disk
2. There are no filename collisions (duplicate names can exist but the
paths will be unique)
3. Uploaded files preserve the name exactly, may be downloaded later,
are never mangled
4. All files are stored in an identical manner

You can think of "name" as an abstract user-oriented name, and path as
the actual on disk representation.

What I want, saving a file should save the file to path and record an
entry for the StoredFile model. Ideally FileFields would be a FK to
this model--currently it is a string.

I'm having a little trouble getting started. Some issues:

1. FileFields store strings, would like it to be a one-to-one FK (or
an intereger id)
2. Most of the storage API takes a single argument "name" Should this
be the name as stored on disk? The name as presented to the user? The
PK from the StoredFile model?

Is what I'm trying to do achievable? Am I approaching the problem correctly?

This design was taken from an existing application, so
interoperability is also a goal.

Cheers,
Jon

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


Looking for Django developers in the UK

2014-07-23 Thread Jon Atkinson
Hi,

I'm Tech Director at FARM, a digital agency based in the Manchester, UK.
We're looking for Django developers, both junior and senior, to join the
team. No recruiters involved.

There's information about the company, and the role at
http://jobs.wearefarm.com - if you're around Manchester, and want a chat,
get in touch with me off-list and I'll buy you lunch :-)

--Jon

-- 
 [image: FARM Digital Logo] *Jon Atkinson* | Technical Director | FARM
Digital Limited
Studio: 24/26 Lever Street, Manchester, M1 1DZ
HQ: Crown House, High Street, Hartley Wintney, Hampshire, RG27 8NW
Phone: 01252 494 060Mobile: 07939924720Email: j...@wearefarm.com

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


assertXMLEqual behaviour

2014-04-30 Thread Jon Dunleavy
Hi,

I am using django 1.6 but I can't find any information on the bugtracker as 
to whether this has changed but is this intentional behaviour of 
assertXMLEqual:

# this passes
self.assertXMLEqual(
"Value",
"""Value""",
)

# this fails
self.assertXMLEqual(
"Value",
"""
Value
""",
)

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/b00120b0-56bd-4deb-8f49-08614b0afdcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Nesting custom template tags

2014-03-29 Thread Jon Dufresne
Hi,

I am trying to create a custom template tag that generates a repetitive 
HTML snippet. This tag is an anchor tag "a" with extra classes and styles, 
plus some logic to apply additional classes and styles. I want the syntax 
in the template to look something like:

{% my_anchor URL %}this is text between opening and closing tags{% 
end_my_anchor %}

Where URL is set to the href attribute of the anchor tag.

The rendered result should look something like:

this is 
text between opening and closing tags

I also do not want to hard code my URLs. So as one might expect, I am using 
the "url" template tag to create correct URLs. Naively, I tried to nest the 
tags:

{% my_anchor {% url ... %} %}this is text between opening and closing 
tags{% end_my_anchor %}

But this is invalid syntax. Is there a way to handle this?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/e3f4e619-0560-4f62-ad28-dd4775e2e3c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model field's verbose_name from database?

2014-02-05 Thread Jon Dufresne
> Why not use dictionary to Map user-level names to database-fields

I'm not sure I fully follow what you're suggesting. But it sounds like
you're suggesting I move the configuration of field name out of the
database and into a Python file using a dictionary to map actual
fields to preferred field names. Is this correct?

I can't do this because:

* I do not know the user's preference ahead of time
* Their preference could change as time goes on
* It is unreasonable (in my case) to expect my users to modify python files
* These preferences could be different across different installations

For this reason, these fields are configured as a sort of "user
setting". The user is in complete control. But, once they are set,
they should be used everywhere.

Cheers,
Jon

-- 
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/CADhq2b7%3D_EmMiQtpnLVHUOSPY3wvjBsdiKF%2BbP2WHL%3DhJocvNg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Model field's verbose_name from database?

2014-02-04 Thread Jon Dufresne
Hi,

I have a model with fields that allows the user to modify the
user-facing names of these fields. Think "first name", "last name",
"email", the user may prefer these be displayed as "given name",
"surname", "email address". This is configured exactly once throughout
the system. So in this example *all* instances of "first name" should
instead be displayed as "given name". Is it possible have a model
where "verbose_name" is not a static string, but instead comes from
the database? Perhaps with some lazy loading trickery? I want to do
something in the spirit of:

first_name = models.CharField(..., verbose_name=lazy_load_name_from_db())

My hope is to eliminate the need to think about what to call this
field when displayed to the user.

Thanks,
Jon

-- 
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/CADhq2b6hoXB66hE2oWkhXe4TsvNmfWE%2Bw72dHj2ipkyYRGv1bw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Spammed with 'Invalid HTTP_HOST header' messages

2013-12-06 Thread Jon Dufresne
> Can you not add a filter to your logger handler? 
> http://stackoverflow.com/a/19534738

I will give this a shot.

But what I don't understand is that the post claims that this is fixed
in newer versions. I am using version 1.6. By "fixed" does he simply
mean 500 error is now a 400 error? Or is he implying this should not
be emailed anymore? I assumed the latter which makes me think
something is wrong with my configuration, but I could easily be wrong.

-- 
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/CADhq2b6RSzLPorvAgPESxqHKiOmS1-8cPhcjEZbjyYk%3D%3DUDnbA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Spammed with 'Invalid HTTP_HOST header' messages

2013-12-06 Thread Jon Dufresne
On Fri, Dec 6, 2013 at 7:47 AM, Zach Borboa  wrote:
> SuspiciousOperation should now return a 400 error [1].

It is true, the response is a 400 Bad Request error, but I still
receive emails going to my admins/managers email account. I thought
400 errors shouldn't be mailed out. I would prefer to avoid installing
Sentry if there is a simple fix. Any ideas?

-- 
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/CADhq2b7C7X2%2Bx%3DOUkaECzBMftNBoxM%3D_h%2BhHJbPmZ%3DfV3X%2B3kA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Spammed with 'Invalid HTTP_HOST header' messages

2013-12-05 Thread Jon Dufresne
I am running Django 1.6.

I receive a lot of false positive errors from my Django application
when accessed with an invalid HTTP_HOST. I have verified that these
are in fact HTTP_HOST values that I am not interested in. So I *do*
want to return an error to the user. However, it doesn't help me as an
admin to receive an email every time this happens.

What is the most straight forward way to prevent these errors from
emailing the admins? I want to continue to receive other errors.

Thanks,
Jon

-- 
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/CADhq2b4hnhJvnocevJVw46Euhf%3Dtz2DizzVPUo91gTQa_NMa2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django Developers wanted, junior and senior. Remote welcome, European timezones.

2013-11-27 Thread Jon Atkinson


Hi,

I’m Technical Director at FARM Digital. We’re a digital agency based in the 
UK. We’re currently looking for Django developers, both junior and senior. 
There are two job descriptions on our website, available at:

Senior Developer - http://farmd.co.uk/1bhm1Cn

Junior Developer - http://farmd.co.uk/1dvcBVw 

We’re made up of 15 people, split over two UK offices, with most of our 
delivery team working remotely. We’re committed to a strong engineering 
culture, and we do things the right way. We’re also keenly involved in 
community events, and we run the Django Weekly newsletter (
http://www.djangoweek.ly).

If this is of interest, you can either apply directly (information is in 
the links above), or you can email me for more information. I’m also on 
Freenode as `JonA`.

Thanks!

--Jon

-- 
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/ebf0589d-4e41-4d04-b075-10c6e3c89760%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Apache environment variables in Django 1.6

2013-11-22 Thread Jon Dufresne
> With you setup is it possible to run into some race conditions when two 
> simultaneous request coming for the first time when _application is still 
> uninitialized?

That is a good question, to which I do not have a good answer. If you
come across any issues with this solution I'd be interested to hear
about them.

I filed a ticket #21486 <https://code.djangoproject.com/ticket/21486>.
If you have any useful information to provide, please add it to the
ticket. This concern over race conditions might be a good thing to
mention.

Cheers,
Jon

-- 
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/CADhq2b5nO2RBXmAOT91rxE1vwfJVVACR0vHEjKhPvBGsGau-3w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Apache environment variables in Django 1.6

2013-11-21 Thread Jon Dufresne
On Thu, Nov 21, 2013 at 8:46 AM, Mike Starov  wrote:
> I encountered same issue in my deployment. Have you found a solution?
>

Yes I did. I am still not sure if this is a bug or intentional. It
appears that in 1.6, settings.py is now imported *before* the first
run of the WSGI application. Therefore the settings.py is loaded
before the environment variables can be setup. I now load the WSGI
application as late as possible using the following code. This way,
the settings.py isn't imported until I've received the environ from
Apache. Please feel free to use it to fix your project:

---
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
_application = None

def application(environ, start_response):
os.environ['MY_SETTING'] = environ['MY_SETTING']
global _application
if _application is None:
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()
return _application(environ, start_response)
---

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


Apache environment variables in Django 1.6

2013-11-20 Thread Jon Dufresne
Hi,

I recently upgraded my Django application from 1.5 to 1.6. This
application runs on Apache with mod_wsgi. After upgrading, Django
seems unable to access environment variables set by Apache using
SetEnv and SetEnvIf. Using Django 1.5 I was able to access this using
the following recipe in wsgi.py:

---
import os

from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()

def application(environ, start_response):
os.environ['MY_SETTING'] = environ['MY_SETTING']
return _application(environ, start_response)
---

Then, in settings.py, I would access MY_SETTING using os.environ['MY_SETTING'].

Is this a bug that this no longer works in Django 1.6? Is there a
better way to access Apache environment variables?

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/CADhq2b5vxuURi4Zq%2B77dL2EAiDzyrA3C9RHwhiTK6dssAkEqYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Logging warnings inside settings.py

2013-11-01 Thread Jon Dufresne
Hi,

I am trying to log warnings inside settings.py. I want to log warnings
when settings (from an outside source) are not provided, but the
application can continue. Is this possible? It seems like this might
not work as logging requires settings.py in order to be configured,
but I want to log earlier than that.

Thanks,
Jon

-- 
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/CADhq2b7%3DuvtQpffe3%3DEBZnbKUxe-YNTbc0ykdQEROdWF58TH1A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


ModelMultipleChoiceField ignore invalid choices?

2013-10-07 Thread Jon Dufresne
Hi,

I am using a ModelForm with a ModelMultipleChoiceField. I would like
for this field to silently ignore invalid choices instead of creating
a form error. Here is my use case:

* User A opens form select model choice 1, 2, and 3
* User B (different browser) deletes model choice 3 entirely from system
* User A submits form and receives error

I understand why this should be an error in the general case, but in
my case, I want this to silently ignore the invalid choice 3 and
continue with choice 1 and 2? Is this possible?

Thanks,
Jon

-- 
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/CADhq2b5R3owKd%3D%3DGAeJpJD8UBaG4xyq13%2B0mKT%2BXCyeUSckTQA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Advice on deploying multiple Django instances to single Apache server

2013-08-23 Thread Jon Dufresne
Hi,

I am getting ready to deploy my Django application. This application must
serve several independent parties. In the past, I've done this with
multiple instances of a PHP application on the server. Is this the right
approach in the Django world?

My server is running Apache and MySQL. Each instance of the application
will have its own configuration and database. These instances will not
communicate with each other in any way. These instances are all (possibly)
different versions of the same application running in their own virtualenv.

My instinct is to go with the Apache mod_wsgi approach. As Apache is
already running successfully on the server serving PHP an static files.

Any advice or good resources on how to accomplish what I am doing? All the
documentation seems to be targeted at one server with one Django
application.

Thanks,
Jon

-- 
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.


Adding custom WHERE conditions to query sets (MySQL user defined functions)

2013-08-20 Thread Jon Dufresne
Hi,

My Django application was ported from a legacy application. This legacy
application has some MySQL user defined functions that are frequently used
in the WHERE clause of queries. Is it possible to use these stored
functions and still return query sets? I want to do something like

MyModel.objects.filter(field_one='blah',
field_two='blah').call('my_function(,
)').order_by('field_three')

Is anything like this possible or do I need to resort to custom SQL? I
don't mind if I need to write a custom QuerySet or Manager. I am concerned
about using custom SQL as most operation and views seem to prefer lazy
query sets instead of lists of models.

Thanks for any help.
Jon

-- 
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: Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
On Thu, Aug 1, 2013 at 2:38 PM, Phil  wrote:

> Could you post the entire content of your script? There is no way those 2
> lines (and the necessary "os" import) can cause this error.
>
>
>
You are right. I investigated much deeper. Turns out this is what I did.

1. Script imported root URL conf
2. Through an URL include, many other URL confs were imported
3. Many URL confs import CBVs from views.py
4. These views.py may import models or import modules that import models
5. At some point a queryset was evaluated during an import

In this particular case, it was a choices field on a form. I have since
changed this to use ModelMultipleChoiceField.

I guess I'll need to be really careful to not evaluate a queryset or stop
using CBV (to avoid the imports). Seems a bit fragile.

-- 
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.




Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
Hi,

I am trying to write a script that outputs information about all URLs in
the project. The script should be able to do this without having a database
populated or even created.

Right now the script gets to the following line:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from project import urls

However, this raises an exception _mysql_exceptions.OperationalError:
(1049, "Unknown database 'project'").

It appears that Django is trying to connect to the database, but all I want
to do is analyze the URLs. Is this possible?

-- 
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.




Forms with fields created dynamically client side

2013-07-26 Thread Jon Dufresne
Hi,

I am creating a form for the user to add, edit, and remove all tags in the
database. The tag models are handled by taggit. The form will look like like

_Tag1_[del]
_Tag2_[del]
__<--- User enters next tag here

[add tag]

Clicking add tag will fire some javascript to add a new text input to the
form. I trying to create this form in Django to handle the request. This is
what I have so far. I am curious if I am going about this the right way. It
all seems very... roundabout. Thoughts? One part that bothers me is I must
inspect the incoming data to decide how many form elements to create.

Coming from PHP, I would create form names with array notation (tags[pk] =
name) and iterate over the array during the request.

The existing_tag dictionary allows me to map form names to tag objects. The
new_tags list allows me to iterate over tag fields that must be created as
new tags.

class TagsForm(forms.Form):
def __init__(self, data=None, *args, **kwargs):
super(TagsForm, self).__init__(data, *args, **kwargs)

self.existing_tags = {}
self.new_tags = []

for tag in Tag.objects.all():
name = 'tag%i' % tag.pk
self.fields[name] = forms.CharField(
initial=tag.name,
required=False)
self.existing_tags[name] = tag

if data:
for name in data:
if name.startswith('newtags'):
self.fields[name] = forms.CharField(required=False)
self.new_tags.append(name)
else:
name = 'newtags'
self.fields[name] = forms.CharField(required=False)
self.new_tags.append(name)

-- 
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: Every view requires authentication

2013-07-18 Thread Jon Dufresne
On Thu, Jul 18, 2013 at 1:36 AM, Tom Evans  wrote:

> On Thu, Jul 18, 2013 at 1:11 AM, Jon Dufresne 
> wrote:
> >  Oh, I see what you're saying. The login_required does not need to be
> added
> > explicitly, because it is added implicitly by the authorization check.
> Yeah
> > that makes sense. As every page will require some different authorization
> > anyway, there is no need for extra middleware. Is that right?
> >
>
> No, that's not what he's saying.
>
> "authentication" -> "who am I?"
> "authorization" -> "am I allowed to do this?"
>
> His point was, even though every view requires authentication, it will
> also require authorization - checking that the user has permission to
> access that specific page. Presumably each page will have it's own,
> different permissions check - it's not something you can add with a
> single piece of middleware - and the way that one adds permission
> checks in django is an extension of the login_required decorator.
>
> IE, since you will need to add authorization checks to each view, this
> will implicitly have the same effect as adding login_required to each
> view.
>

Yeah. That is what I said. Authorization check implies an authentication
check.

-- 
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: Every view requires authentication

2013-07-17 Thread Jon Dufresne
On Wed, Jul 17, 2013 at 4:24 PM, Arnold Krille  wrote:

> Still interesting that you need authentication while not needing any
> authorization...


 Oh, I see what you're saying. The login_required does not need to be added
explicitly, because it is added implicitly by the authorization check. Yeah
that makes sense. As every page will require some different authorization
anyway, there is no need for extra middleware. Is that right?

-- 
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: Every view requires authentication

2013-07-17 Thread Jon Dufresne
On Wed, Jul 17, 2013 at 1:25 PM, Arnold Krille  wrote:

> On Wed, 17 Jul 2013 11:22:36 -0700 Jon Dufresne
>  wrote:The standard-way depende on your views:
>  - If its function-based views, use the @login_required-decorator.
>  - For class-based views we use the LoginRequiredMixin from
>django-braces.
>

Thanks.

This is a whitelist approach to the problem. That is, I must specify every
view that requires login. As nearly 99% of my views will require
authentication, I'd prefer to take a blacklist approach. That is, all views
are assumed to require login, unless I annotate the views to not require a
login. This avoids accidentally leaving views publicly accessible when
someone forgets the login_required decorator (or CBV equivalent).

I can achieve this with middleware (and maybe a decorator), but it occurred
to me that others probably already do this as well. I am curious if there
is a canonical approach or implementation that others use for this very
purpose.

Thanks,
Jon

-- 
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.




Every view requires authentication

2013-07-17 Thread Jon Dufresne
My application requires an authenticated user for every view (with very few
exceptions). Is there a standard correct way to handle this or should I
roll my own middleware? I'm probably not the first have this requirement.

-- 
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: or-ing to QuerySets turns INNER into LEFT OUTER joins?

2013-07-16 Thread Jon Dufresne
I too would be interested to know if there is a solution. A LEFT OUTER JOIN
can really hurt performance when an INNER JOIN are more appropriate,.


On Mon, Jul 15, 2013 at 8:41 AM, Carsten Fuchs wrote:

> Hi all,
>
> we have two queries/QuerySets Q_a and Q_b, each of which use INNER joins
> in the generated SQL when evaluated individually.
>
> When I use a Q object to "OR" these two QuerySets, the INNER joins turn
> into LEFT OUTER joins -- which in turn cause a huge performance drop
> (several hundred times slower than with INNER joins).
>
> Why is this, and can I do anything against it at the Django ORM level?
>
>
> Details:
>
> My environment:
> Django 1.5.1 on Ubuntu 10.04 (Python 2.6.5) with Oracle database 10g
>
>
> FirstDay = date(2013, 5, 1)
> LastDay = date(2013, 5, 31)
> SomeDep = ...   # the department with ID == 1
>
>
> Q_a = Staff.objects. \
>   filter(bereiche=SomeDep).**distinct()
>
> Q_b = Staff.objects. \
>   filter(erfasst__datum__gte=**FirstDay,
>  erfasst__datum__lte=LastDay,
>  erfasst__bereich=SomeDep).**distinct()
>
> Q_a_or_b = Staff.objects. \
>   filter(Q(bereiche=SomeDep) |
>  Q(erfasst__datum__gte=**FirstDay,
>erfasst__datum__lte=LastDay,
>erfasst__bereich=SomeDep)).**distinct()
>
>
> In the following output, to improve readability I used the "*" to manually
> shorten the list of selected fields:
>
>
> print Q_a.query
>
> SELECT DISTINCT "STAFF".* FROM "STAFF"
> INNER JOIN "STAFF_BEREICHE" ON ("STAFF"."ID" = "STAFF_BEREICHE"."STAFF_ID")
> WHERE "STAFF_BEREICHE"."BEREICH_ID" = 1
>
>
> print Q_b.query
>
> SELECT DISTINCT "STAFF".* FROM "STAFF"
> INNER JOIN "ERFASST" ON ("STAFF"."KEY" = "ERFASST"."KEY")
> WHERE ("ERFASST"."DATUM" <= 2013-05-31  AND "ERFASST"."DATUM" >=
> 2013-05-01  AND "ERFASST"."BEREICH_ID" = 1 )
>
>
> print Q_a_or_b.query
>
> SELECT DISTINCT "STAFF".* FROM "STAFF"
> LEFT OUTER JOIN "STAFF_BEREICHE" ON ("STAFF"."ID" =
> "STAFF_BEREICHE"."STAFF_ID")
> LEFT OUTER JOIN "ERFASST" ON ("STAFF"."KEY" = "ERFASST"."KEY")
> WHERE ("STAFF_BEREICHE"."BEREICH_ID" = 1  OR ("ERFASST"."DATUM" <=
> 2013-05-31  AND "ERFASST"."DATUM" >= 2013-05-01  AND "ERFASST"."BEREICH_ID"
> = 1 ))
>
>
> In the last SQL statement, when I replace "LEFT OUTER JOIN" with "INNER
> JOIN" and manually run it, the result seems to be the same, but the query
> completes one hundred to several hundred times faster.
>
> So, from the above observations, I was wondering if the use of "LEFT OUTER
> JOIN" is what is supposed to happen for Q_a_or_b in the first place? Is it
> the expected behavior?
> And if so, can it be changed via the Django ORM?
>
> Many thanks for your help!
>
> Best regards,
> Carsten
>
>
>
> --
> Dipl.-Inf. Carsten Fuchs
>
> Carsten Fuchs Software
> Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
> Internet: http://www.cafu.de | E-Mail: i...@cafu.de
>
> Cafu - the open-source game and graphics engine for multiplayer 3D action
>
> --
> 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+unsubscribe@**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: Choosing a JS framework to go together with Django

2013-07-14 Thread Jon
The idea is to generate pure HTML views for non JS clients like search bots. If 
your view depends on AJAX calls, then it defies the purpose.

I've been developing native mobile apps for the past year, so I get your 
argument about providing REST end points for your data.

The point of my original post was to NOT do two different views; one for search 
bots and one for browsers.
 I agree that providing a REST interface is the "right" way to provide data for 
both browsers and mobile apps. To that end, the project I was suppose to work 
on, used tastypie.

// Jon

On 14/07/2013, at 15.16, Phang Mulianto  wrote:

> Hi ,
> 
> Why not using REST for serving your data to the Front End app, it can be from 
> mobile app or just web app with HTML + javascript.
> 
> With that you don't need to worry about redo the template side in django and 
> in your front end js app.
> With REST serving JSON, no template / html needed for the response. 
> 
> You can use Tastypie or Django rest framework which still using Django engine 
> . This way also your application server no need to rendering the HTML view in 
> every request from the first time.
> 
> Any front end will be able to process the JSON with javascript. 
> 
> Regards,
> 
> Mulianto
> 
> 
> On Sun, Jul 14, 2013 at 8:18 PM, dotnetCarpenter  
> wrote:
>> In the end, my project stalled due to lack of resources. We might pick it up 
>> but it's been abandoned for quite some time. I haven't had any django 
>> projects since. Hence, I can't make any recommendations.
>> 
>> DjangoAjax looks promising but might lack the community support you expect. 
>> It is however based on jQuery and ASP.NET MVC, so if you can see past the M$ 
>> cruft, some guides etc are available.
>> 
>> --
>> 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 a topic in the Google 
> Groups "Django users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/django-users/X_9qJJjiDfE/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Is there any small and easy website example available for Django?

2012-10-09 Thread Jon Crowell
I am also using djangobook.com.  If it is outdated and not
recommended, then what resource should we use instead? Also, I find it
fairly relevant and easy to follow, so I'm curious what specific
objections there are to it. Incidentally, I'm using the version on
github that is being updated:
https://github.com/jacobian/djangobook.com

Jon


On Tue, Oct 9, 2012 at 9:28 AM, lacrymol...@gmail.com
 wrote:
>
> First of all, djangobook.com is outdated, and not recommended, at least last 
> time i checked it.
>
> Secondly, for what seems to be your need, i'd recommend django-cms or some 
> other cms application for django since without some kind of cms app, building 
> a static content site would rapidly become, imo, very repetitive and highly 
> hardcoded
>
> -Mensaje original-
> De: Sarbjit singh
> Enviados:  09/10/2012 02:46:26
> Asunto:  Is there any small and easy website example available for Django?
>
> I am very new to Django and I just finished first seven chapters from
> Djangobook.com. I am wondering how can we implement a small static content
> website using Django. I mean website should have Home Page and few other
> pages along with some menu options. I searched a lot on google for example
> of this small website, but was not successful. I could only found examples
> for implementing Wiki, Blog but i am new to Django, so i am looking for an
> easy example.
>
> Can anyone please point me to the link for such example?
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/z8aE98t9ZTUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there any small and easy website example available for Django?

2012-10-09 Thread Jon Crowell
I have just installed Pinry, which is a nice small django project.  It
isn't static, though.  But it is small enough and simple enough that
you can easily look through the source code and understand what is
going on.  I think it is well-suited to learning Django.

You can find Pinry here:

http://overshard.github.com/pinry/
https://github.com/overshard/pinry

Installing on a Mac or Linux machine is straightforward.  (If you run
into trouble with JPEG image support, you can check out my blog post
at: 
http://joncrowell.org/2012/10/installing-pillow-1-7-7-and-solving-the-jpeg-support-not-available-and-_imaging-c-module-error-in-python-pil-errors-all-for-pinry/)

Jon


On Tue, Oct 9, 2012 at 1:46 AM, Sarbjit singh  wrote:
> I am very new to Django and I just finished first seven chapters from
> Djangobook.com. I am wondering how can we implement a small static content
> website using Django. I mean website should have Home Page and few other
> pages along with some menu options. I searched a lot on google for example
> of this small website, but was not successful. I could only found examples
> for implementing Wiki, Blog but i am new to Django, so i am looking for an
> easy example.
>
> Can anyone please point me to the link for such example?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/z8aE98t9ZTUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Cant Import mysite.urls

2012-09-13 Thread Jon Blake
Hi Patrick,
  just got Apache + mod_wsgi to serve part 1 of the tutorial as per Django 
document "How to use Django with Apache and mod_wsgi". Your point taken 
about assuming things are going to be harder than they actually are - my 
redo of part 1 of the tutorial worked pretty well "out of the box" after a 
good night's sleep.

Now to get serving the admin files to work...

On Wednesday, September 12, 2012 9:37:56 AM UTC+10, patrick wrote:
>
> On Tuesday, September 11, 2012 1:44:22 AM UTC-3, Jon Blake wrote:
>>
>> Thanks, Patrick. My reference to utils.py should have been to urls.py, 
>> which I have in my mysite app package.
>>
>> I'm seeing this import error on mysite.urls when I'm attempting to get 
>> Apache + mod_wsgi to serve my app. I don't remember seeing this error with 
>> the development server when I first tried out the tutorials. Probably got 
>> my configs wrong, somewhere in my second try.
>>
>> I'll start a new app, now that I know a little bit more about how this 
>> all works. It's a steep learning curve!
>
>
> It will get better. At one point, I found that the biggest problem I was 
> having that I was expecting things to be harder than they actually were.
>
> You might want to also take a look at the tutorials at: 
> http://lightbird.net/dbe/
>
> They were written for Django 1.2, but should still work in Django 1.4 and 
> get you to build other types of apps, so you'll get more insight into what 
> Django has to offer. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/p_822C3uc9IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to Set Up for Apace and Mod_wsgi

2012-09-12 Thread Jon Blake
I'm not making any progress on this. I have redone part 1 of the Django 1.4 
tutorial, and it all works nicely with my Oracle back-end database and the 
development server. I'm now trying to progress this app to be served by 
Apache + mod_wsgi. After starting Apache, command  httpd -M lists 
wsgi_module (shared), and syntax OK. URL http://localhost/ shows the 
expected Apache test page.

I have added directive 

> WSGIScriptAlias / /home/jon/djangodemo/mysite/mysite/wsgi.py to 
> /etc/httpd/conf/httpd.conf
>
as per one example of setting up a production site server I have found, and 
restarted Apache. I've made no changes to my app's wsgi.py module at this 
point. Now, URL http://localhost/ displays a "500 Internal Server Error" 
page. The Apache error_log includes line:

> ImportError: Could not import settings 'mysite.settings' (Is it on 
> sys.path?): No module named mysite.settings
>

Any suggestions on how to get this working? There are a number of articles 
out there on how to set up a Django app for serving by Apache + mod_wsgi, 
with different instructions - confusing. I'm after a the simplest approach 
on to how to get my Django tutorial app running from a production server.

Any advice appreciated! My background is Oracle DBA/development + Python. 
Very little experience with configuring Apache.

Regards,
  Jon

On Friday, September 7, 2012 4:43:09 PM UTC+10, Jon Blake wrote:
>
>  On 09/03/2012 04:46 PM, Michael Crawford wrote: 
>
> Basically the entry in the httpd.conf file points to the dejango.wsgi 
> file.  Instead of apache/django.wsgi, point it to the location of yours.  I 
> did the same since django now creates a default wsgi file when you create 
> the project.   
>
>  Those entries can go anywhere in the file as long as they are not 
> embedded in any other tags.
>
>  Those mod wsgi modules are probably the same.   In my version the logs 
> for the module are written to the standard apache error log so you might 
> have a look in there if it doesn't start up correctly.
>
>  It sounds like your version of apache uses the httpd.conf file for 
> turning the modules on and off.  If I remember correctly from configuring 
> mod_php in the past there may be something you have to do to actually turn 
> the mod on in your particular configuration.   In ubuntu it doesn't use the 
> conf file for this purpose, the mere presence of the module in the 
> appropriate place turns it on.   If it doesn't appear to be turning on, I 
> would suggest googling how to turn on mod_php as it should be the same type 
> of thing I would assume.   
>
>  Mike
>
>  
>  On Sep 3, 2012, at 2:36 AM, Jon Blake > 
> wrote:
>
> Thanks, Mike, that fills in the gaps. 
>
> Eddy Chan's notes discusses file apache/django.wsgi. This appears somewhat 
> similar to wsgi.py in my project package - how do these two files relate to 
> each other? And the entries in httpd.conf - they can go pretty well 
> anywhere?
>
> Eddy's notes refer to installing Apache2, along with libapache2-mod-wsgi. 
> Is libapache2-mod-wsgi something different from the mod_wsgi 3.2 package I 
> have already installed? 
>
> TIA, Jon
>
> On Monday, September 3, 2012 3:06:19 PM UTC+10, dalupus wrote: 
>>
>>
>> http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to
>>  
>>
>>  Have a look at this post.   I followed it friday and now have a working 
>> django install on ubuntu.  Steps should be almost the same for fedora.
>>
>>  Mike
>>
>>  
>>  On Sep 3, 2012, at 1:01 AM, Jon Blake  wrote:
>>
>> I've worked through parts 1 and 2 of the tutorial using the development 
>> server, and I have reviewed the doco on how to use Django with Apache and 
>> mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, 
>> but the provided instructions assume some familiarity with configuring the 
>> Apache environment.
>>
>> I have Apache/2.2.17 (Unix) installed on my development box and I have 
>> installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to 
>> go from here. Can anyone point me to a a concrete example of file edits 
>> (eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to 
>> serve my application? I have a path to the application package, and I want 
>> URL http://localhost/polls/ to run it.
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ.
>> To post to this group, se

Re: Possible spam from mailing list? ("China Mobile")

2012-09-12 Thread Jon Blake
I've had a coup[le of these, now.

On Tuesday, September 11, 2012 5:27:59 AM UTC+10, Kurtis wrote:
>
> I just received a very unusual e-mail that included a recent post's 
> subject. The post in question was: "Re: form doesn't validate when trying 
> to upload file". It was sent directly to my email address; by-passing the 
> User Group.
>
> Google roughly translated this email as coming from "China Mobile" and 
> included the domain "139.com". Has anyone else seen this sort of thing? 
> Unfortunately, I am unable to read the language and the Google Translation 
> isn't very clear; but it's definitely displayed using a very clean and 
> fancy template. I'm not sure if it's spam or something else.
>
> Just figured I'd see if anyone else has gotten an email similar to this. 
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/yZnQCJfOEekJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Cant Import mysite.urls

2012-09-10 Thread Jon Blake
Thanks, Patrick. My reference to utils.py should have been to urls.py, 
which I have in my mysite app package.

I'm seeing this import error on mysite.urls when I'm attempting to get 
Apache + mod_wsgi to serve my app. I don't remember seeing this error with 
the development server when I first tried out the tutorials. Probably got 
my configs wrong, somewhere in my second try.

I'll start a new app, now that I know a little bit more about how this all 
works. It's a steep learning curve!


On Tuesday, September 11, 2012 10:59:02 AM UTC+10, patrick wrote:
>
> On Monday, September 10, 2012 8:29:12 PM UTC-3, Jon Blake wrote:
>>
>> Working through getting Django to work with Apache, mod_wsgi and Oracle 
>> database back end. When I enter my site URL, I get a "ImportError at /" 
>> page, with an exception value of "No module named mysite.urls".
>>
>> Part 3 of the tutorial refers to line ROOT_URLCONF = 'mysite.urls', which 
>> I have in my settings.py module. I don't have a file mysite.urls. The 
>> tutorial then goes on to discuss editing utls.py, (which I do have) and 
>> states that Django will load this module (utils.py) because ROOT_URLCONF 
>> points to it. I don't understand that bit - what's the connection between 
>> mysite.urls and utils.py, and how does Django import mysite.urls if it does 
>> not exist?
>>
>
>
> It can be a bit confusing the first time you run into it, but 
> "mysite.urls" isn't a file. It's a namespaced import path. So in this case, 
> it is looking for an urls.py file in the mysite directory.
>
> In the tutorial it's assumed that you named your project mysite. If you 
> called it something else (say tutorial), the import path would be 
> "tutorial.urls".
>
> If you are using Django 1.4 and followed the tutorial by using the 
> django-admin.py startproject command (which builds a project skeleton for 
> you), the urls.py file should be in the same directory as your settings.py 
> file.
>
> I couldn't find a reference to utils.py in the tutorial so I assume it 
> must be an accidental typo and probably the cause of the error you're 
> seeing.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/C02LpMhCyaAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Cant Import mysite.urls

2012-09-10 Thread Jon Blake
Working through getting Django to work with Apache, mod_wsgi and Oracle 
database back end. When I enter my site URL, I get a "ImportError at /" 
page, with an exception value of "No module named mysite.urls".

Part 3 of the tutorial refers to line ROOT_URLCONF = 'mysite.urls', which I 
have in my settings.py module. I don't have a file mysite.urls. The 
tutorial then goes on to discuss editing utls.py, (which I do have) and 
states that Django will load this module (utils.py) because ROOT_URLCONF 
points to it. I don't understand that bit - what's the connection between 
mysite.urls and utils.py, and how does Django import mysite.urls if it does 
not exist?

TIA,
  Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/p0jhLE_JkFYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't Find libclntsh.so.11.1 With Oracle Backend

2012-09-10 Thread Jon Blake
Thanks, Jani and Ian. I've used the ldconfig approach to fix this problem. 
Now getting a "ImportError at /" page, for which I'll post another question.

On Tuesday, September 11, 2012 6:15:57 AM UTC+10, Jani Tiainen wrote:
>
> I've been using ldconfig to handle libs. It's easy as runnig following few 
> commands as a root. (Though I always use oracle instantclient, it's just 
> simpler in many cases):
>
> $ echo  /oracle/product/11.1.0/db_1/**lib  > /etc/ld.so.conf.d/oracle.conf
> $ ldconfig
>
> On Mon, Sep 10, 2012 at 7:11 PM, Ian >wrote:
>
>> On Sunday, September 9, 2012 10:41:00 PM UTC-6, Jon Blake wrote:
>>>
>>> It looks like I have to tell my app what my path to libclntsh.so.11.1 
>>> is. I have added:
>>>
>>> os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/**lib'
>>>>
>>>
>>> to my app's wsgi.py file, but this does resolve my problem.
>>>
>>>
>> LD_LIBRARY_PATH has to be set before the process starts to be honored.  
>> So it's not sufficient to set it in the wsgi file with os.environ; you need 
>> to use an Apache SetEnv directive, or use a script to export it in the 
>> Apache process's environment variables when Apache is started.  Or as a 
>> third option, use ldconfig to make the Oracle library path globally visible.
>>
>> Cheers,
>> Ian
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/z8aKjhUtm3QJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/imnCF82L9_EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Tutorial

2012-09-09 Thread Jon Blake
Hi David, you might have stumbled over a problem I had when I first tried 
out the tutorial a week ago. I'm using an Oracle database back end, and on 
my first try of python manage.py syncdb, I also missed the prompt to create 
a superuser account. The problem was finally identified as a missing 
privilege for my identified database account. After granting missing 
privileges, and starting again, everything was fine. 

What back end database are you using? Is dictionary DATABASES in 
settings.py correctly edited for your installed database and user account? 
Does the account have required privileges to create objects in your 
account's schema? 

HTH, Jon

On Sunday, September 9, 2012 11:02:14 AM UTC+10, David Perez wrote:
>
> Hi,
>
> I am new to Django, I am actually starting its tutorial. On part 2 it 
> enables the admin site, but I can't log in to it. The following error comes 
> up (see at the bottom):
>
> If I remember correctly I did not get prompt to create a superuser when I 
> wrote *python manage.py syncdb*, so I am not sure if I do not have a 
> superuser. I tried to create it with *python manage.py createsuperuser 
> --username=david* but it is not working.
>
> I am most certain it is something simple...and I tried to follow the steps 
> as exact as I could. I appreciate your help.
>
> David
>
>
> DoesNotExist at /admin/
>
> Site matching query does not exist.
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.4.1Exception Type:DoesNotExistException Value:
>
> Site matching query does not exist.
>
> Exception 
> Location:/Library/Python/2.7/site-packages/django/db/models/query.py 
> in get, line 366Python Executable:/usr/bin/pythonPython Version:2.7.1Python 
> Path:
>
> ['/Users/Dperezc/Desktop/Estudios independientes/Django/Proyecto1_Poll',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
>  '/Library/Python/2.7/site-packages']
>
> Server time:Sat, 8 Sep 2012 18:45:28 -0600
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VKu-Ajyx3R0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't Find libclntsh.so.11.1 With Oracle Backend

2012-09-09 Thread Jon Blake
Just an edit to my original post: ... but this does *not* resolve my 
problem. Sorry for any confusion.

On Monday, September 10, 2012 2:41:00 PM UTC+10, Jon Blake wrote:
>
> I have worked through the Django tutorial parts 1 and 2 with an Oracle 
> back end using the development server. Everything worked fine. I now want 
> to use a real server - Apache + mod_wsgi. I've got to the point where I get 
> an "Improperly Configured at /" page, which shows the following:
>
> Exception Type: ImproperlyConfigured
>> Exception Value: Error loading cx_Oracle module: libclntsh.so.11.1: 
>> cannot open shared object file: No such file or directory
>> Exception Location: 
>> /usr/lib/python2.7/site-packages/django/db/backends/oracle/base.py in 
>> , line 46
>>
>
> Line 46 raises exception ImproperlyConfigured on a try block which imports 
> cx_Oracle.
>
> cx_Oracle is properly installed. In my desktop environment:
>
> $ python
>> >>> import cx_Oracle
>>
>
> works fine. I also export LD_LIBRARY_PATH which points to where 
> libclntsh.so.11.1 resides. If I clear this environment
> variable, import cx_Oracle fails with:
>
> ImportError: libclntsh.so.11.1: cannot open shared object file: No such 
>> file or directory
>>
>
> It looks like I have to tell my app what my path to libclntsh.so.11.1 is. 
> I have added:
>
> os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/lib'
>>
>
> to my app's wsgi.py file, but this does resolve my problem.
>
> Can anyone assist with how to progress this?
>
> Environment:
>   O/S: Fedora14
>   Apache: 2.2.17
>   Python: 2.7
>   mod_wsgi: 3.2
>   cx_Oracle: 5.1
>   Django: 1.4.1
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/icR_sZguPy8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Can't Find libclntsh.so.11.1 With Oracle Backend

2012-09-09 Thread Jon Blake
I have worked through the Django tutorial parts 1 and 2 with an Oracle back 
end using the development server. Everything worked fine. I now want to use 
a real server - Apache + mod_wsgi. I've got to the point where I get an 
"Improperly Configured at /" page, which shows the following:

Exception Type: ImproperlyConfigured
> Exception Value: Error loading cx_Oracle module: libclntsh.so.11.1: 
> cannot open shared object file: No such file or directory
> Exception Location: 
> /usr/lib/python2.7/site-packages/django/db/backends/oracle/base.py in 
> , line 46
>

Line 46 raises exception ImproperlyConfigured on a try block which imports 
cx_Oracle.

cx_Oracle is properly installed. In my desktop environment:

$ python
> >>> import cx_Oracle
>

works fine. I also export LD_LIBRARY_PATH which points to where 
libclntsh.so.11.1 resides. If I clear this environment
variable, import cx_Oracle fails with:

ImportError: libclntsh.so.11.1: cannot open shared object file: No such 
> file or directory
>

It looks like I have to tell my app what my path to libclntsh.so.11.1 is. I 
have added:

os.environ['LD_LIBRARY_PATH'] = '/oracle/product/11.1.0/db_1/lib'
>

to my app's wsgi.py file, but this does resolve my problem.

Can anyone assist with how to progress this?

Environment:
  O/S: Fedora14
  Apache: 2.2.17
  Python: 2.7
  mod_wsgi: 3.2
  cx_Oracle: 5.1
  Django: 1.4.1

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/wyRYrwZnIVwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to Set Up for Apace and Mod_wsgi

2012-09-07 Thread Jon and Chiarina Blake

On 09/03/2012 04:46 PM, Michael Crawford wrote:
Basically the entry in the httpd.conf file points to the dejango.wsgi 
file.  Instead of apache/django.wsgi, point it to the location of 
yours.  I did the same since django now creates a default wsgi file 
when you create the project.


Those entries can go anywhere in the file as long as they are not 
embedded in any other tags.


Those mod wsgi modules are probably the same.   In my version the logs 
for the module are written to the standard apache error log so you 
might have a look in there if it doesn't start up correctly.


It sounds like your version of apache uses the httpd.conf file for 
turning the modules on and off.  If I remember correctly from 
configuring mod_php in the past there may be something you have to do 
to actually turn the mod on in your particular configuration.   In 
ubuntu it doesn't use the conf file for this purpose, the mere 
presence of the module in the appropriate place turns it on.   If it 
doesn't appear to be turning on, I would suggest googling how to turn 
on mod_php as it should be the same type of thing I would assume.


Mike


On Sep 3, 2012, at 2:36 AM, Jon Blake <mailto:jc.bla...@gmail.com>> wrote:



Thanks, Mike, that fills in the gaps.

Eddy Chan's notes discusses file apache/django.wsgi. This appears 
somewhat similar to wsgi.py in my project package - how do these two 
files relate to each other? And the entries in httpd.conf - they can 
go pretty well anywhere?


Eddy's notes refer to installing Apache2, along with 
libapache2-mod-wsgi. Is libapache2-mod-wsgi something different from 
the mod_wsgi 3.2 package I have already installed?


TIA, Jon

On Monday, September 3, 2012 3:06:19 PM UTC+10, dalupus wrote:


http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to

<http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to>


Have a look at this post.   I followed it friday and now have a
working django install on ubuntu.  Steps should be almost the
same for fedora.

    Mike


On Sep 3, 2012, at 1:01 AM, Jon Blake > wrote:


I've worked through parts 1 and 2 of the tutorial using the
development server, and I have reviewed the doco on how to use
Django with Apache and mod_wsgi. I want to trial a production
environment on my Fedora 14 dev box, but the provided
instructions assume some familiarity with configuring the Apache
environment.

I have Apache/2.2.17 (Unix) installed on my development box and
I have installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm
not sure where to go from here. Can anyone point me to a a
concrete example of file edits (eg, httpd.conf, wsgi.conf) I
need to do to set up Apache and mod_wsgi to serve my
application? I have a path to the application package, and I
want URL http://localhost/polls/ to run it.

-- 
You received this message because you are subscribed to the

Google Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ
<https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ>.
To post to this group, send email to django...@googlegroups.com
.
To unsubscribe from this group, send email to
django-users...@googlegroups.com .
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>.



--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Jeuh5iHKhScJ.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.
OK, back to this. I'm confused. I've read Eddy Chan's article, which 
refers to the modwsgi Integration With Django article. Eddy's article 
indicates he has edited /etc/httpd/conf.d/wsgi.conf and created 
apache/django.wsgi as per instructions in the article. On reading the 
article, it's not clear (to this reader) what goes where.


Are you able to supply example contents of files wsgi.conf and django.wsgi?

TIA,
  Jon

--
Y

Re: How to Set Up for Apace and Mod_wsgi

2012-09-02 Thread Jon Blake
Thanks, Mike. I'll get back to this next Friday. Assistance much 
appreciated.

Jon

On Monday, September 3, 2012 4:47:16 PM UTC+10, dalupus wrote:
>
> Basically the entry in the httpd.conf file points to the dejango.wsgi 
> file.  Instead of apache/django.wsgi, point it to the location of yours.  I 
> did the same since django now creates a default wsgi file when you create 
> the project.   
>
> Those entries can go anywhere in the file as long as they are not embedded 
> in any other tags.
>
> Those mod wsgi modules are probably the same.   In my version the logs for 
> the module are written to the standard apache error log so you might have a 
> look in there if it doesn't start up correctly.
>
> It sounds like your version of apache uses the httpd.conf file for turning 
> the modules on and off.  If I remember correctly from configuring mod_php 
> in the past there may be something you have to do to actually turn the mod 
> on in your particular configuration.   In ubuntu it doesn't use the conf 
> file for this purpose, the mere presence of the module in the appropriate 
> place turns it on.   If it doesn't appear to be turning on, I would suggest 
> googling how to turn on mod_php as it should be the same type of thing I 
> would assume.   
>
> Mike
>
>
> On Sep 3, 2012, at 2:36 AM, Jon Blake > 
> wrote:
>
> Thanks, Mike, that fills in the gaps. 
>
> Eddy Chan's notes discusses file apache/django.wsgi. This appears somewhat 
> similar to wsgi.py in my project package - how do these two files relate to 
> each other? And the entries in httpd.conf - they can go pretty well 
> anywhere?
>
> Eddy's notes refer to installing Apache2, along with libapache2-mod-wsgi. 
> Is libapache2-mod-wsgi something different from the mod_wsgi 3.2 package I 
> have already installed? 
>
> TIA, Jon
>
> On Monday, September 3, 2012 3:06:19 PM UTC+10, dalupus wrote:
>>
>>
>> http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to
>>
>> Have a look at this post.   I followed it friday and now have a working 
>> django install on ubuntu.  Steps should be almost the same for fedora.
>>
>> Mike
>>
>>
>> On Sep 3, 2012, at 1:01 AM, Jon Blake  wrote:
>>
>> I've worked through parts 1 and 2 of the tutorial using the development 
>> server, and I have reviewed the doco on how to use Django with Apache and 
>> mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, 
>> but the provided instructions assume some familiarity with configuring the 
>> Apache environment.
>>
>> I have Apache/2.2.17 (Unix) installed on my development box and I have 
>> installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to 
>> go from here. Can anyone point me to a a concrete example of file edits 
>> (eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to 
>> serve my application? I have a path to the application package, and I want 
>> URL http://localhost/polls/ to run it.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ.
>> To post to this group, send email to django...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/Jeuh5iHKhScJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QzxJpUAcZjYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to Set Up for Apace and Mod_wsgi

2012-09-02 Thread Jon Blake
Thanks, Mike, that fills in the gaps. 

Eddy Chan's notes discusses file apache/django.wsgi. This appears somewhat 
similar to wsgi.py in my project package - how do these two files relate to 
each other? And the entries in httpd.conf - they can go pretty well 
anywhere?

Eddy's notes refer to installing Apache2, along with libapache2-mod-wsgi. 
Is libapache2-mod-wsgi something different from the mod_wsgi 3.2 package I 
have already installed? 

TIA, Jon

On Monday, September 3, 2012 3:06:19 PM UTC+10, dalupus wrote:
>
>
> http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to
>
> Have a look at this post.   I followed it friday and now have a working 
> django install on ubuntu.  Steps should be almost the same for fedora.
>
> Mike
>
>
> On Sep 3, 2012, at 1:01 AM, Jon Blake > 
> wrote:
>
> I've worked through parts 1 and 2 of the tutorial using the development 
> server, and I have reviewed the doco on how to use Django with Apache and 
> mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, 
> but the provided instructions assume some familiarity with configuring the 
> Apache environment.
>
> I have Apache/2.2.17 (Unix) installed on my development box and I have 
> installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to 
> go from here. Can anyone point me to a a concrete example of file edits 
> (eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to 
> serve my application? I have a path to the application package, and I want 
> URL http://localhost/polls/ to run it.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Jeuh5iHKhScJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to Set Up for Apace and Mod_wsgi

2012-09-02 Thread Jon Blake
I've worked through parts 1 and 2 of the tutorial using the development 
server, and I have reviewed the doco on how to use Django with Apache and 
mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, 
but the provided instructions assume some familiarity with configuring the 
Apache environment.

I have Apache/2.2.17 (Unix) installed on my development box and I have 
installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to 
go from here. Can anyone point me to a a concrete example of file edits 
(eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to 
serve my application? I have a path to the application package, and I want 
URL http://localhost/polls/ to run it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb Error With Oracle Database - IntegrityError Exception

2012-08-31 Thread Jon Blake
Thanks, Ian, I did miss that. Bookmarked for future reference.

On Saturday, September 1, 2012 3:16:38 PM UTC+10, Ian wrote:
>
> On Fri, Aug 31, 2012 at 10:03 PM, Jon Blake > 
> wrote: 
> > Querying column timestamp of view user_objects for tables, sequences and 
> > triggers appears to confirm my understanding of what base.py does. I'll 
> drop 
> > and recreate my user account, and try again. I'll advise how this goes. 
> Does 
> > the Django doco have any specific documentation for the Oracle back end? 
> If 
> > so, I missed it! I'm happy to provide specific doco for the Oracle back 
> end 
> > if that would assist... 
>
> Yes, please see: 
>
> https://docs.djangoproject.com/en/1.4/ref/databases/#oracle-notes 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/cs7WQZmkJGQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb Error With Oracle Database - IntegrityError Exception

2012-08-31 Thread Jon Blake
I've just dropped and re-created my user account with required privileges, 
and all has gone as expected. Table auth_permission has 18 rows.

At the point where I'm prompted to create a superuser account, I made the 
mistake of resizing my terminal window, which resulted in exception 
EOFError being raised on the call to raw_input() in procedure 
create_superuser(). Sigh, and start again... This exception can be handled 
by calling raw_input() in a try block, and handling exception EOFError by 
(for example) shifting the cursor up one row by printing chr(27) +'[A' . 
HTH.

Again, many thanks. I'm on my way with Django - looking like a great 
framework!
  Jon

On Saturday, September 1, 2012 2:03:42 PM UTC+10, Jon Blake wrote:
>
> Thanks, Ian and Amyth, for your responses.
>
> I encountered the CREATE TRIGGER privilege issue early in my trials with 
> Django with the Oracle database back end - Django propagated an Oracle 
> "insufficient privileges" exception. That was quickly sorted by granting 
> the required privilege to my user account.
>
> On looking at ticket #17015 you pointed me to, it looks like I might have 
> stumbled over the same issue as in the reply to ikelly. My user did not 
> have the CREATE TRIGGER privilege the first time I tried to run syncdb, but 
> did have the CREATE_TABLE and CREATE_SEQUENCE privileges. After granting 
> the missing privilege and running syncdb again, I then got the ORA-01400 
> exception on table auth_permission.
>
> I'm guessing that the first table that oracle back end base.py creates is 
> auth_permission, and that the table and its primary key sequence were 
> successfully created, because the user had the required privileges. Module 
> base.py then terminated on attempting to create the trigger for the table. 
> After granting CREATE TRIGGER and running syncdb again, base.py noted that 
> table auth_permission exists, so nothing more needed to be done for that 
> table. Module base.py then went on and created the remaining tables, 
> sequences and triggers. Missing trigger auth_permission_tr -> no primary 
> key raised from auth_permission_sq -> ORA-01400 on table auth_permission 
> inserts.
>
> Querying column timestamp of view user_objects for tables, sequences and 
> triggers appears to confirm my understanding of what base.py does. I'll 
> drop and recreate my user account, and try again. I'll advise how this 
> goes. Does the Django doco have any specific documentation for the Oracle 
> back end? If so, I missed it! I'm happy to provide specific doco for the 
> Oracle back end if that would assist...
>
> Once again, many thanks
>
> Jon
>
>
> On Saturday, September 1, 2012 1:23:28 AM UTC+10, Ian wrote:
>>
>> On Friday, August 31, 2012 12:10:54 AM UTC-6, Amyth wrote:
>>>
>>> Hey Jon,
>>>
>>> I guess this is because of a bug in django. Django already has a open 
>>> ticket for this bug. Check it out 
>>> here<https://code.djangoproject.com/ticket/17015>
>>> . 
>>>
>>>
>> As described in that ticket, the reason for the problem is probably just 
>> that the Django user does not have the CREATE TRIGGER privilege, which it 
>> needs.  The bug in Django is just that this condition is not detected and 
>> reported at the time the table is created, instead of getting a rather more 
>> obscure error message at the time the table is populated.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/MrFmP3gYrF0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb Error With Oracle Database - IntegrityError Exception

2012-08-31 Thread Jon Blake
Thanks, Ian and Amyth, for your responses.

I encountered the CREATE TRIGGER privilege issue early in my trials with 
Django with the Oracle database back end - Django propagated an Oracle 
"insufficient privileges" exception. That was quickly sorted by granting 
the required privilege to my user account.

On looking at ticket #17015 you pointed me to, it looks like I might have 
stumbled over the same issue as in the reply to ikelly. My user did not 
have the CREATE TRIGGER privilege the first time I tried to run syncdb, but 
did have the CREATE_TABLE and CREATE_SEQUENCE privileges. After granting 
the missing privilege and running syncdb again, I then got the ORA-01400 
exception on table auth_permission.

I'm guessing that the first table that oracle back end base.py creates is 
auth_permission, and that the table and its primary key sequence were 
successfully created, because the user had the required privileges. Module 
base.py then terminated on attempting to create the trigger for the table. 
After granting CREATE TRIGGER and running syncdb again, base.py noted that 
table auth_permission exists, so nothing more needed to be done for that 
table. Module base.py then went on and created the remaining tables, 
sequences and triggers. Missing trigger auth_permission_tr -> no primary 
key raised from auth_permission_sq -> ORA-01400 on table auth_permission 
inserts.

Querying column timestamp of view user_objects for tables, sequences and 
triggers appears to confirm my understanding of what base.py does. I'll 
drop and recreate my user account, and try again. I'll advise how this 
goes. Does the Django doco have any specific documentation for the Oracle 
back end? If so, I missed it! I'm happy to provide specific doco for the 
Oracle back end if that would assist...

Once again, many thanks

Jon


On Saturday, September 1, 2012 1:23:28 AM UTC+10, Ian wrote:
>
> On Friday, August 31, 2012 12:10:54 AM UTC-6, Amyth wrote:
>>
>> Hey Jon,
>>
>> I guess this is because of a bug in django. Django already has a open 
>> ticket for this bug. Check it out 
>> here<https://code.djangoproject.com/ticket/17015>
>> . 
>>
>>
> As described in that ticket, the reason for the problem is probably just 
> that the Django user does not have the CREATE TRIGGER privilege, which it 
> needs.  The bug in Django is just that this condition is not detected and 
> reported at the time the table is created, instead of getting a rather more 
> obscure error message at the time the table is populated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LXuXcxvnlnkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Instaling django

2012-08-30 Thread Jon Blake
What O/S?

I installed Django 1.4.1 today on my Linux F14 box today by:

1. Downloading Django-1.4.1.tar.gz from 
https://www.djangoproject.com/download/
2. As root:
# tar xzvf Django-1.4.1.tar.gz
# cd Django-1.4.1
# python setup.py install
# exit
3. Test it:
$ python
>>> import django
>>> print django.get_version()
1.4.1

HTH,
  Jon

On Thursday, August 30, 2012 4:28:40 PM UTC+10, Balle wrote:
>
> Hi,  I have been trying to download django with every options but when i 
> run pyhton on the terminal and then asks to import django.  It always says 
> no mudule named django.  Could you pls help, donload it.  Thank you in 
> advance
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Q47WcAEp6vMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Syncdb Error With Oracle Database - IntegrityError Exception

2012-08-30 Thread Jon Blake
Just discovered Django and trying out the Django 1.4 tutorial with an 
Oracle backend database. In my database, I have created user django with 
privs create session, create table, create sequence, create trigger. The 
DATABASES dictionary in settings has been edited to set the default 
settings to the Oracle engine, and the database name, user and password 
specified.

When I run:

$ python manage.py syncdb

I see tables are created, but I also get a traceback ending with:

File "/usr/lib/python2.7/site-packages/django/db/backends/oracle/base.py", 
line 675, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.IntegrityError: ORA-01400: cannot insert NULL into 
("DJANGO"."AUTH_PERMISSION"."ID")

I did not see a prompt to create a superuser account.

Oracle SQL*Developer shows that schema django contains 9 tables (including 
auth_permission), 16 indexes, 7 triggers and 8 sequences. Table 
django_content_type contains three rows, and the others are empty.

Can anyone advise on how to resolve the ORA-01400 error?

Run-time environment:
  O/S: Fedora 14
  Django: 1.4.1
  Python: 2.7
  DB: Oracle Database 11.1.0.6.0
  cx_Oracle client: 11.1.0.6.0



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/O5XePWI1ee4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Checkbox checking

2012-08-01 Thread Jon Underwood
Hi,

My checkboxes are giving me grief.

I want to make it required for the user to check a checkbox before being 
allowed to submit a forms.

I'm using model forms so the checkbox is defined as a models.BooleanField 
in my models.py. I have included blank=False, though this should be the 
default.

In the admin the checkboxes aren't required to be checked. When displaying 
the form in a template I can set required="True" as follows: 

This works in most browsers, though not Safari for some reason.

Is there a better method? I've messed around with this for ages!

Thank you in advance.

Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4bBr_gr_Z44J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Prioritise 0.1 released

2012-07-14 Thread Jon Black
Thanks for the kind words. I skipped unit tests to make learning django
simpler. I fully intend to add unit tests in future updates. Thanks for
the reminder, though :)

On 07/14/2012 05:31 PM, George Silva wrote:
> HI Jon,
> 
> Congratulations of your first public Django project. It seems very
> useful. Nice coding style, good follow of the guidelines, etc :D.
> 
> THe only thing missing that I've found are unit tests, since they might
> demonstrate to the public how much your product is reliable and
> incentivate usage.
> 
> Other than that, congratulations.
> 
> On Sat, Jul 14, 2012 at 5:35 AM, Jon Black  <mailto:jon_bl...@mm.st>> wrote:
> 
> I'm pleased to announce the very first release of my django-powered task
> manager called prioritise, released under the BSD license.
> 
> This is my first ever django project, which I started learning two
> months ago. So whilst I encourage your comments, please be nice. :)
> 
> I've written a blog post with more details, including the ubiquitous
> screenshot, here:
> http://jonblack.org/2012/07/14/prioritise-0-1-released/
> 
> If you just want the code to try it out (yay!), go here:
> https://github.com/jonblack/prioritise
> 
> Thanks!
> 
> --
> Jon Black
> www.jonblack.org <http://www.jonblack.org>
> 
> 
> 
> 
> -- 
> George R. C. Silva
> 
> Desenvolvimento em GIS
> http://geoprocessamento.net
> http://blog.geoprocessamento.net
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.




signature.asc
Description: OpenPGP digital signature


Prioritise 0.1 released

2012-07-14 Thread Jon Black
I'm pleased to announce the very first release of my django-powered task
manager called prioritise, released under the BSD license.

This is my first ever django project, which I started learning two
months ago. So whilst I encourage your comments, please be nice. :)

I've written a blog post with more details, including the ubiquitous
screenshot, here: http://jonblack.org/2012/07/14/prioritise-0-1-released/

If you just want the code to try it out (yay!), go here:
https://github.com/jonblack/prioritise

Thanks!

--
Jon Black
www.jonblack.org



signature.asc
Description: OpenPGP digital signature


Re: Release considerations

2012-07-10 Thread Jon Black
Thanks Reinout, that's a great checklist - much more than I thought of.
-- 
Jon Black
www.jonblack.org


On Tue, Jul 10, 2012, at 22:15, Reinout van Rees wrote:
> On 10-07-12 08:24, Jon Black wrote:
> > I've been working on a task management project and am at a point where
> > I'm happy to make my first release. The idea is that people can install
> > the project on their own server (at home, at work, wherever) and use it
> > to manage their tasks.
> >
> > What should I consider doing before making the code available to both
> > make life easier for the users/keep private information out of the
> > repository?
> 
> First you have to get the basics right like a proper setup.py, a README, 
> a changelog, that sort of stuff.
> 
> If you're looking at how-to-package-a-django-site examples, I'd look at 
> sentry. I liked the way they packaged it. Install it in a virtualenv and 
> it'll set up a django site for you. A custom settings file is installed 
> in some ~/.sentry directory, with defaults imported from a sentry 
> default settings file. Works fine. Pretty clear.
> 
> Make sure you've got example configurations on how to integrate it with 
> a webserver (apache/nginx).
> 
> 
> Reinout
> 
> -- 
> Reinout van Reeshttp://reinout.vanrees.org/
> rein...@vanrees.org http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Release considerations

2012-07-09 Thread Jon Black
I've been working on a task management project and am at a point where
I'm happy to make my first release. The idea is that people can install
the project on their own server (at home, at work, wherever) and use it
to manage their tasks.

What should I consider doing before making the code available to both
make life easier for the users/keep private information out of the
repository?

--

Jon Black
www.jonblack.org



signature.asc
Description: OpenPGP digital signature


Re: insert html into a form from Django code (not template)

2012-07-05 Thread Jon Black
I've never done this, so I'm just throwing out ideas to try and
be helpful. I've found your stackoverflow post as well, which has
more information.
(http://stackoverflow.com/questions/11341118/printing-repeated-dj
ango-form-fields-individually)

Have you tried looping over the fields in the template? I know
this is in the template, but you can add the text you want still:

{% for field in form %}
  Some stuff I want here that form.as_p won't do for me
  
 {{ field.errors }}
 {{ field.label_tag }}: {{ field }}
  
{% endfor %}

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 03:20, angelika wrote:

  Thanks, but I am asking if there is a way to insert html into
  a form from the backend code, and not in the template?
  On Thursday, July 5, 2012 11:57:57 AM UTC+2, angelika wrote:

  Is there a way to insert arbitrary html into a form from the
  Django code, and not in the template? The equivalent of
  #markup in a Drupal form.



/Angelika


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [1]https://groups.google.com/d/msg/django-users/-/y7Inar5KaoEJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. https://groups.google.com/d/msg/django-users/-/y7Inar5KaoEJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: insert html into a form from Django code (not template)

2012-07-05 Thread Jon Black
This
(https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs
#customizing-the-form-template) and more generally the entire
page explains how to work with forms.
--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:57, angelika wrote:

  Is there a way to insert arbitrary html into a form from the
  Django code, and not in the template? The equivalent of
  #markup in a Drupal form.



/Angelika


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [1]https://groups.google.com/d/msg/django-users/-/ErDblgugM7wJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. https://groups.google.com/d/msg/django-users/-/ErDblgugM7wJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: DetailView - invalid literal for int() with base 10:

2012-07-05 Thread Jon Black
Hit send too soon then. My guess is that your kwargs being passed
to filter() contains some suspect things.
--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 11:27, Jon Black wrote:

That doesn't help so much as there's no context information. Nice
to see the 'sysadmin' bit which wasn't in your original post.
Google throws up a lot of things for that:

http://www.google.nl/search?q=invalid+literal+for+int%28%29+with+
base+10%3A+%27sysadmin

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:17, Barry Morrison wrote:

  Apologies, here is the error output if it helps.

ValueError at /favs/Reddit/sysadmin/

invalid literal for int() with base 10: 'sysadmin'

Request Method: GET
Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/
Django Version: 1.4
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'sysadmin'

Exception Location:
/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/
site-packages/django/db/models/fields/__init__.py in
get_prep_value, line 537
Python Executable:
/home/bmorriso/LocalRepository/Myosotis/venv/bin/python
Python Version: 2.7.3
Python Path:
['/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/requests/packages',
 '/home/bmorriso/LocalRepository/Myosotis',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/plat-linux2',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-old',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
']

Server time: Thu, 5 Jul 2012 02:03:21 -0700

  On Thursday, July 5, 2012 2:13:59 AM UTC-7, Jon Black wrote:

I'm not sure without running it, which I can't do now. I have
noticed that your slug is not and id, but the field PostSubReddit
is a foerignkey which might expect an id.

Unrelated, I think your models shouldn't be pluralised (e.g. Post
instead of Posts). If you want the table name to be plural, use
the Meta class.

--
Jon Black
[1]www.jonblack.org


On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote:

  I've been beating my head against this all night and now into
  the morning...I have NO idea what I'm doing wrong and Google
  and Stack Overflow haven't been as helpful as I had hoped.
  [2]https://gist.github.com/7dc0b98a2fe056379ae8
  Any help or guidance would be greatly appreciated!
  Thanks!!


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [3]https://groups.google.com/d/msg/django-users/-/
  zgmrTPX9yIEJ.
  To post to this group, send email to
  [4]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [5]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [6]http://groups.google.com/group/django-users?hl=en.



  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [7]https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.



  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. http://www.jonblack.org/
2. https://gist.github.com/7dc0b98a2fe056379ae8
3. https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ
4. mailto:django-users@googlegroups.com
5. mailto:django-users%2bunsubscr...@googlegroups.com
6. http://groups.google

Re: DetailView - invalid literal for int() with base 10:

2012-07-05 Thread Jon Black
That doesn't help so much as there's no context information. Nice
to see the 'sysadmin' bit which wasn't in your original post.
Google throws up a lot of things for that:

http://www.google.nl/search?q=invalid+literal+for+int%28%29+with+
base+10%3A+%27sysadmin

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:17, Barry Morrison wrote:

  Apologies, here is the error output if it helps.

ValueError at /favs/Reddit/sysadmin/

invalid literal for int() with base 10: 'sysadmin'

Request Method: GET
Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/
Django Version: 1.4
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'sysadmin'

Exception Location:
/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/
site-packages/django/db/models/fields/__init__.py in
get_prep_value, line 537
Python Executable:
/home/bmorriso/LocalRepository/Myosotis/venv/bin/python
Python Version: 2.7.3
Python Path:
['/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/requests/packages',
 '/home/bmorriso/LocalRepository/Myosotis',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/setuptools-0.6c11-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
/pip-1.1-py2.7.egg',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/plat-linux2',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-old',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/bmorriso/LocalRepository/Myosotis/venv/local/lib/python2.7/site-pa
ckages',
 '/home/bmorriso/LocalRepository/Myosotis/venv/lib/python2.7/site-packages
']

Server time: Thu, 5 Jul 2012 02:03:21 -0700

  On Thursday, July 5, 2012 2:13:59 AM UTC-7, Jon Black wrote:

I'm not sure without running it, which I can't do now. I have
noticed that your slug is not and id, but the field PostSubReddit
is a foerignkey which might expect an id.

Unrelated, I think your models shouldn't be pluralised (e.g. Post
instead of Posts). If you want the table name to be plural, use
the Meta class.

--
Jon Black
[1]www.jonblack.org


On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote:

  I've been beating my head against this all night and now into
  the morning...I have NO idea what I'm doing wrong and Google
  and Stack Overflow haven't been as helpful as I had hoped.
  [2]https://gist.github.com/7dc0b98a2fe056379ae8
  Any help or guidance would be greatly appreciated!
  Thanks!!


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [3]https://groups.google.com/d/msg/django-users/-/
  zgmrTPX9yIEJ.
  To post to this group, send email to
  [4]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [5]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [6]http://groups.google.com/group/django-users?hl=en.



  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [7]https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. http://www.jonblack.org/
2. https://gist.github.com/7dc0b98a2fe056379ae8
3. https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ
4. mailto:django-users@googlegroups.com
5. mailto:django-users%2bunsubscr...@googlegroups.com
6. http://groups.google.com/group/django-users?hl=en
7. https://groups.google.com/d/msg/django-users/-/aXIXIb3UGegJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: DetailView - invalid literal for int() with base 10:

2012-07-05 Thread Jon Black
I'm not sure without running it, which I can't do now. I have
noticed that your slug is not and id, but the field PostSubReddit
is a foerignkey which might expect an id.

Unrelated, I think your models shouldn't be pluralised (e.g. Post
instead of Posts). If you want the table name to be plural, use
the Meta class.

--
Jon Black
www.jonblack.org


On Thu, Jul 5, 2012, at 02:07, Barry Morrison wrote:

  I've been beating my head against this all night and now into
  the morning...I have NO idea what I'm doing wrong and Google
  and Stack Overflow haven't been as helpful as I had hoped.
  https://gist.github.com/7dc0b98a2fe056379ae8
  Any help or guidance would be greatly appreciated!
  Thanks!!


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [1]https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. https://groups.google.com/d/msg/django-users/-/zgmrTPX9yIEJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re:

2012-07-04 Thread Jon Black
Do you mean github? If so, see the github documentation.
Do you mean creating a git repository? If so, see the git
documentation.

--
Jon Black
www.jonblack.org


On Wed, Jul 4, 2012, at 02:25, Bharati Sharma wrote:

  I want to upload my project on the git ...kindly help me
  please..


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error : need more than 1 value to unpack

2012-07-04 Thread Jon Black
You're also returning mimetype="application/json" outside of the
request.is_ajax check. I doubt you want that.
On Wed, Jul 4, 2012, at 01:20, rafiee.nima wrote:

  Oh

I find out my mistake :D
On Wednesday, July 4, 2012 12:38:11 PM UTC+4:30, rafiee.nima
wrote:

  Hi I got below error from my view which handle ajax request

hotel_instance=Hotel.objects.get(id=request.POST['hotel'])

 need more than 1 value to unpack



here is my code



def add_room(request):
context={}
status=''
if request.is_ajax:
if request.POST:
hotel_instance=Hotel.objects.
get(request.POST['hotel'])
if request.POST['id'] > 0 :
room=HotelRoom.objects.get(id=request.POST['id'])
room.hotel=hotel_instance
room.number=request.POST['number']
room.bed_count=request.POST['bed_count']
room.ground_sleep=request.POST['ground_sleep']
room.view=request.POST['view']
room.reserved=request.POST['reserved']
[1]room.tv=request.POST['tv']
room.phone=request.POST['phone']
room.refrigerator=request.POST['refrigerator']
room.air_condition=request.POST['air_condition']
room.toilet=request.POST['toilet']
room.creator=request.user
room.save()
else:
room = HotelRoom(
hotel=hotel_instance,
number=request.POST['number'],
bed_count=request.POST['bed_count'],
ground_sleep=request.POST['ground_sleep'],
view=request.POST['view'],
reserved=request.POST['reserved'],
tv=request.POST['tv'],
phone=request.POST['phone'],
refrigerator=request.POST['refrigerator'],
air_condition=request.POST['air_condition'],
toilet=request.POST['toilet'],
creator=request.user )
room.save()

return HttpResponse({status:'success'},
mimetype="application/json")


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [2]https://groups.google.com/d/msg/django-users/-/fNXaSuOjeKcJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. http://room.tv/
2. https://groups.google.com/d/msg/django-users/-/fNXaSuOjeKcJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Developer, Washington, D.C.

2012-07-03 Thread Jon Black
And also on http://djangogigs.com/
-- 
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 11:03, Itamar Reis Peixoto wrote:
> On Tue, Jul 3, 2012 at 10:43 AM, Andrew Moore 
> wrote:
> > Hello group.
> >
> > National Geographic is seeking Django developers, for permanent full-time
> > positions at their Washington, D.C. headquarters.
> >
> > If I can share more details, please let me know. propensitygr...@gmail.com
> > or and...@themidtowngroup.com.
> >
> > Thanks!
> >
> 
> 
> I think you can post this job at python.org job board.
> 
> 
> 
> 
> -- 
> 
> 
> Itamar Reis Peixoto
> msn, google talk: ita...@ispbrasil.com.br
> +55 11 4063 5033 (FIXO SP)
> +55 34 9158 9329 (TIM)
> +55 34 8806 3989 (OI)
> +55 34 3221 8599 (FIXO MG)
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Filter FieldError

2012-07-03 Thread Jon Black
I think you need a double underscore:

fieldname__startswith

On Tue, Jul 3, 2012, at 02:47, Saroja Parameswaran wrote:

While using filters on Django objects, I get the below error
message. Except equals, all the other options like _startswith,
_exact, _iexact shows the same error. I am using Django 1.4.



  FieldError: Cannot resolve keyword 'fieldname_exact' into
  field. Choices are:



 Can anyone tell me the solution?


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To view this discussion on the web visit
  [1]https://groups.google.com/d/msg/django-users/-/NJDqAyZcunAJ
  .
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. https://groups.google.com/d/msg/django-users/-/NJDqAyZcunAJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: to add counter in the project

2012-07-03 Thread Jon Black
It sounds like you have different user's (User) with different
roles (Group with permission set) that have a resume:

class Resume(models.Model):
  resume = models.FileField()
  date_uploaded = models.DateTimeField()

You can then query by aggregating across the group and
date_uploaded fields. That's one option.

--
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 01:08, Bharati Sharma wrote:

  thanks Jon...

actually I am making project of faculty management system of my
college.I have added some of the faculty member's resume in the
database. i want a counter in my project that should increment
its value whenever a new faculty member's resume is added into
the database. yes, it will require filter also as i want it
should count no of assistant professors,no of associate
professors etc seperatelyhelp me please..
On Tue, Jul 3, 2012 at 12:48 AM, Jon Black <[1]jon_bl...@mm.st>
wrote:

That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
[2]www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

I want to add counter in my project so that the value in the
table increases as the data is put in the database. Can anyone
help me plz.


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]http://groups.google.com/group/django-users?hl=en.



  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [6]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [7]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [8]http://groups.google.com/group/django-users?hl=en.


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. mailto:jon_bl...@mm.st
2. http://www.jonblack.org/
3. mailto:django-users@googlegroups.com
4. mailto:django-users%2bunsubscr...@googlegroups.com
5. http://groups.google.com/group/django-users?hl=en
6. mailto:django-users@googlegroups.com
7. mailto:django-users%2bunsubscr...@googlegroups.com
8. http://groups.google.com/group/django-users?hl=en

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't figure out how to obtain organized list of my friends

2012-07-03 Thread Jon Black
I agree with Kenneth. Your models seem odd. Why not use a
ManyToManyField? The django docs even provides quite a nice example
(see:
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical):

  class Person(models.Model):
  friends = models.ManyToManyField("self")

You could adapt this to your UserProfile I suppose.

-- 
Jon Black
www.jonblack.org


On Tue, Jul 3, 2012, at 12:57, kenneth gonsalves wrote:
> On Mon, 2012-07-02 at 20:31 -0700, Keith D. Cardin wrote:
> > I'm trying to create a "my friends" page, which will list the user's 
> > friends listed in alphabetical order.
> > I have two classes involved with this data: Profile [and] Friendship
> > 
> > *class Friendship(models.Model):*
> > friend= models.ForeignKey(User,
> > related_name='friend1')
> > friendwith  = models.ForeignKey(User,
> > related_name='friend2')
> > 
> > *class Profile(models.Model):*
> > user = models.OneToOneField(User,
> > unique=True,
> > verbose_name=_('user'),
> > related_name='profile')
> > first_name   = models.TextField(max_length=50)
> > last_name   = models.TextField(max_length=50)
> > 
> > The exact raw SQL query [successfully tested] is as follows:: 
> > *select profiles_profile.first_name,profiles_profile.last_name FROM 
> > profiles_profile, friends_friendship WHERE profiles_profile.user_id = 
> > friends_friendship.friendwith_id AND friends_friendship.friend_id =
> > 30 
> > ORDER BY first_name ASC;*
> > *
> > *
> > My problem is I'm not sure how to do this in Python. 
> > '30' is the user's id/pk. 
> 
> to get a list of friends of a particular user this may work:
> 
> first get the user:
> me = Profile.objects.get(user = myuser)
> 
> then get the friend1
> friends = me.fiiend1_set.all()
> 
> the confusing thing about your models is that it seems to me that your
> Friendship model should be split into two models.
> -- 
> regards
> Kenneth Gonsalves
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: to add counter in the project

2012-07-03 Thread Jon Black
That's quite a vague requirement. You could override form_valid()
in your view and increment a counter in your model manually
before saving. It might pay to ask yourself why you need a
counter. Does it make more sense to record the actions in a
separate table and count the records? Will the count require
filtering later (e.g. number of counts each month, week, day).

--
Jon Black
www.jonblack.org


On Mon, Jul 2, 2012, at 23:25, Bharati Sharma wrote:

  I want to add counter in my project so that the value in the
  table increases as the data is put in the database. Can anyone
  help me plz.


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Same virtual-env for all django projects

2012-07-03 Thread Jon Black
Bear in mind that you may want different packages in your
environments depending on the project. For example, you may have
a project that uses a maps app (from pip) which isn't required by
others. The general purpose of virtualenv is to setup clean,
self-contained environments. What would you do if one project had
a dependency that required a new version of another package that
another project can't use. :) Moreover, if you start using
virtualenvwrapper hooks (e.g. switch to the project directory
when 'workon' is called), it won't make sense anymore if you
share an environment.

Maybe I'm being a bit extreme, but it was a thought. Only you can
judge your needs.

--
Jon Black
www.jonblack.org


On Mon, Jul 2, 2012, at 16:19, Smaran Harihar wrote:

  Thanks Musicman

On Mon, Jul 2, 2012 at 4:17 PM, Lachlan Musicman
<[1]data...@gmail.com> wrote:

On Tue, Jul 3, 2012 at 10:52 AM, Smaran Harihar
<[2]smaran.hari...@gmail.com> wrote:
> Hi Djangoers,
>
> I am using virtual-env for my django project and I wanted to
know that is it
> ok to use the same virtual-env for all the django projects on
my system?
>
> or do I need to create a virtual-env for every other django
project?


  Of course you can! It's not necessarily a good idea for
  production
  sites, but it is fine.
  Cheers
  L.
  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  [3]django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  [4]django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  [5]http://groups.google.com/group/django-users?hl=en.




  --
  Thanks & Regards

Smaran Harihar


  --
  You received this message because you are subscribed to the
  Google Groups "Django users" group.
  To post to this group, send email to
  django-users@googlegroups.com.
  To unsubscribe from this group, send email to
  django-users+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/django-users?hl=en.

References

1. mailto:data...@gmail.com
2. mailto:smaran.hari...@gmail.com
3. mailto:django-users@googlegroups.com
4. mailto:django-users%2bunsubscr...@googlegroups.com
5. http://groups.google.com/group/django-users?hl=en

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: jquery, json and forms

2012-07-02 Thread Jon Black
One approach is to pass json/html data in the response after saving and
use jQuery to update the page.

On 07/02/2012 05:12 PM, David wrote:
> Hello
> 
> I have a form that saves, and displays errors correctly when using
> javascript and without.
> 
> However, when my form saves I need to refresh the form with the new form
> data. How can I pass the form object through json back to my template
> please?
> 
> Thank you for any help.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/83FaoYuJjFQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.




signature.asc
Description: OpenPGP digital signature


Re: advantages and disadvantages of Raw sql queries in django

2012-06-29 Thread Jon Black
Also, using ORM means you're less likely to be tied to a specific
database...or in other words, your hand-crafted SQL is likely to be
specific to certain databases.

On 06/30/2012 08:33 AM, Mike Dewhirst wrote:
> I firmly believe in using the ORM for everything until i am forced to
> use handwritten SQL.
> 
> The main reason is transparency of intentions when the source is
> examined by a non-DBA.
> 
> I want my code to be maintainable by other people and provably correct.
> I suppose you can unit-test code with embedded SQL but it adds an extra
> layer of complexity.
> 
> I could also argue against custom SQL because it contains business logic
> and i prefer to keep that all in one place, ie., in models in python code.
> 
> So the bottom line for me is to avoid it where possible.  Once
> everything is profiled and the last remaining bottlenecks are
> significant and cannot be removed unless I use custom SQL, that's when
> I'll do it.
> 
> Haven't gotten there yet.
> 
> -Original message-
> 
> *From: *vijay shanker *
> To: *Django users *
> Sent: *Sat, 30 Jun 2012, 14:35:54 AEST*
> Subject: *advantages and disadvantages of Raw sql queries in django
> 
> hi
> i want to know pros and cons associated with running raw sql queries
> over django's ORM .
> googled it out but couldn find many useful links.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.




signature.asc
Description: OpenPGP digital signature


  1   2   3   4   >