Re: List of default Django tags that are "mid-block" like else

2014-02-15 Thread Ram Rachum
Thanks!


On Fri, Feb 14, 2014 at 4:27 PM, Tom Evans  wrote:

> On Fri, Feb 14, 2014 at 1:08 PM, Ram Rachum  wrote:
> > Thanks!
> >
> > But empty and the various forloop don't concern me because they're {{ }}
> > rather than {% %}, they don't start a block.
> >
> > Anything else?
> >
>
> If you are truly interested, look at the source for
> django/template/defaulttags.py.
>
> Start by looking at calls to parser.parse(..), eg for the ifequal tag:
>
> def do_ifequal(parser, token, negate):
> bits = list(token.split_contents())
> if len(bits) != 3:
> raise TemplateSyntaxError("%r takes two arguments" % bits[0])
> end_tag = 'end' + bits[0]
> nodelist_true = parser.parse(('else', end_tag))
> token = parser.next_token()
> if token.contents == 'else':
> nodelist_false = parser.parse((end_tag,))
> parser.delete_first_token()
> else:
> nodelist_false = NodeList()
> val1 = parser.compile_filter(bits[1])
> val2 = parser.compile_filter(bits[2])
> return IfEqualNode(val1, val2, nodelist_true, nodelist_false, negate)
>
> This, plus some investigation, should give you what you want.
>
> Cheers
>
> Tom
>
> --
> 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/ZgStwyheqn4/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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1KgdA4Wp83%3D4Ypud%2BGqNbULEMk6_1BHzYkAVs46EwTe9A%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANXboVaoY06DE5WPQBezxLJW%3DryyO%3DczqNG9rsxntiO9mM01KQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Not pure Django. Chrome versus Safari discrepancy

2014-02-15 Thread Andrew Taylor
Thanks will experiment.

On Friday, 14 February 2014 16:18:53 UTC, C. Kirby wrote:
>
> You can try using the @never_cache decorator on the view that captures the 
> page view
>
> from django.views.decorators.cache import never_cache
>
> That should instruct safari not to cache the page.
> Sometimes that won't work due to how browsers respect the headers. You can 
> also try the decorator:
>
>
> from django.views.decorators.cache import cache_control
>
> @cache_control(no_cache=True, must_revalidate=True, no_store=True)
>
>  
>
> On Friday, February 14, 2014 5:55:03 AM UTC-6, Andrew Taylor wrote:
>>
>> Hi,
>>
>> I have been working my way through the tango with django tutorial, which 
>> I have to say I have found to be excellent. 
>> http://www.tangowithdjango.com/book/chapters/tango_too.html
>>
>> There is one section (above link) whereby you track the number of times a 
>> url has been clicked. This is done by publishing links to an internal url, 
>> and routing that through a track/redirect view which converts and redirects 
>> to the real url and increments the page views at the same time.
>>
>> However, safari was doing this on an inconsistent basis but seemed to 
>> work when the browser was first opened. After debugging this for a while I 
>> concluded the problem was not the code but my safari browser. It occurred 
>> to me that safari does this weird caching thing where you can go 
>> back/forward through pages immediately. On switching to Chrome the page 
>> counts increment as expected. I have tried setting 'disable caches' in the 
>> Develop menu in safari to no effect
>>
>> Can someone with more experience than me explain why I am seeing these 
>> effects, and what a real world cross-browser solution to tracking page 
>> views would be?
>>
>> The relevant code is below:
>>
>> 1. Track/redirect view:
>>
>> *def* track_url(request):
>>
>> context = RequestContext(request)
>>
>> page_id = None
>>
>> url = '/rango/'
>>
>> *if* request.method == 'GET':
>>
>> *if* 'page_id' *in* request.GET:
>>
>> page_id = request.GET['page_id']
>>
>> *try*:
>>
>> page = Page.objects.get(id=page_id)
>>
>> page.views = page.views + 1
>>
>> page.save()
>>
>> url = page.url
>>
>> *except*:
>>
>> *pass*
>>
>>
>> *return* redirect(url)
>>
>>
>> 2. The internal url published in template:
>>
>>
>> {% if pages %}
>>
>> **
>>
>> {% for page in pages %}
>>
>> **
>>
>> **{{page.title}}
>> **
>>
>> {% if page.views > 1 %}
>>
>> - ({{ page.views }} views)
>>
>> {% elif page.views == 1 %}
>>
>> - ({{ page.views }} view)
>>
>> {% endif %}
>>
>> **
>>
>> {% endfor %}
>>
>> **
>>
>> {% else %}
>>
>> **No pages currently in category.**
>>
>> {% endif %}
>>
>>
>>
>> Thanks,
>>
>>
>> Andy
>>
>

-- 
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/684db6f2-d03e-455d-8a17-198786f334c7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


is this (online tutorial) code calling a view from a view?

2014-02-15 Thread Andrew Taylor
Hi,

I've been following an online tutorial but been debugging. I've traced my 
issue to this line in the view function below:

return category(request, category_name_url)


Is this view effectively calling another view directly without going via 
the urls file (in the exception case)? If so can you advise me if this is 
good or bad practice?

Thanks,


Andy



from rango.forms import PageForm
def add_page(request, category_name_url):
context = RequestContext(request)

category_name = decode_url(category_name_url)
if request.method == 'POST':
form = PageForm(request.POST)

if form.is_valid():
# This time we cannot commit straight away.
# Not all fields are automatically populated!
page = form.save(commit=False)

# Retrieve the associated Category object so we can add it.
# Wrap the code in a try block - check if the category actually 
exists!
try:
cat = Category.objects.get(name=category_name)
page.category = cat
except Category.DoesNotExist:
# If we get here, the category does not exist.
# We render the add_page.html template without a context 
dictionary.
# This will trigger the red text to appear in the template!
return render_to_response('rango/add_page.html', {}, context)

# Also, create a default value for the number of views.
page.views = 0

# With this, we can then save our new model instance.
page.save()

# Now that the page is saved, display the category instead.
return category(request, category_name_url)
else:
print form.errors
else:
form = PageForm()

return render_to_response( 'rango/add_page.html',
{'category_name_url': category_name_url,
 'category_name': category_name, 'form': form},
 context)

-- 
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/eb10a86f-80fd-415e-8a72-8ba189faeba8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Form that includes one2many relation

2014-02-15 Thread ctm7
Hello Users,

I am currently developing my get to know django project an Invoicing 
application. I currently developing my forms and I'm trying to figure out 
how to make a form that allows you to create an invoice *and* at the same 
time make invoice lines. My invoice line model has a foreign key relation 
to my invoice model.

This *is* possible within the Admin interface and is as simple as adding an 
inline view to my InvoiceAdmin model.

Any suggestion for which direction to go in?

Many thanks,

T

-- 
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/f5f3c4d4-e036-4958-920d-f095bc6f5323%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django + PostgresSQL. I'm a newbie.

2014-02-15 Thread João Aparício
Витали, говорите по-русский? Именно с чем вам нужно помочь?


On Friday, February 14, 2014 7:42:18 PM UTC, Віталій Лисенко wrote:
>
> As work in the Postgres Sql in Django. Give a link to the desired site or 
> explain in detail.
>

-- 
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/32337ae6-f77a-408c-8bd9-d02a20afa604%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Как выложить проект на GitHub в Aptana Studio 3 / How to put a project on the GitHub in Aptana Studion 3.

2014-02-15 Thread Віталій Лисенко
Как я понимаю, сначала создаем репозиторий. Затем создаем проект на 
 компьютере. 
Затем:
git init
git add *
git commit "first commit"
git remote orange "http:project_name.git"
git push
у меня все работает кроме последней. появляются ошибки

-- 
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/324f6d35-bd3a-4545-98c5-0953d268955e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Python-requests call within view hangs LiveServerTestCase

2014-02-15 Thread Ashwin Raju
I have implemented a REST api using django rest framework. I am now 
implementing a website to prove consumption of the rest api. So in my view 
code, I validate the form input then use python-requests to call the api. 
This is so that in the future, mobile clients can directly consume the api.

I have a functional test for this using LiveServerTestCase and Selenium. 
When I do the scenario manually, it works correctly. However, the 
functional test hangs on the python-requests call. I've used a POST in this 
example, but GET using the python-requests api has the same effect.

My sample code is in this stackoverflow 
question: 
http://stackoverflow.com/questions/21690718/liveservertestcase-hangs-at-python-requests-post-call-in-django-view
 

One thing that is interesting about this pattern is that the web server 
will receive a second request from within the first request. I don't think 
this is a db lock issue since LiveServerTestCase derives from 
TransactionTestCase, which doesn't take any transaction locks. So why does 
this scenario fail with LiveServerTestCase when it passes with manage.py 
runserver?

Thanks,
Ashwin

-- 
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/162cd72b-a6c1-4fa2-9f29-9b89bf091531%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Programmers that work in Aptana from GitHub answer me

2014-02-15 Thread Віталій Лисенко
I need your help. Please.

-- 
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/aec615fb-2b2a-4afc-b9b1-8d29751985e1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django TodayArchiveView showing the date for next day

2014-02-15 Thread rroyales


I just followed instructions on django website 
*https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/*DayArchiveView
 was working and TodayArchiveView was showing the date for 
the next day.

-- 
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/a306bd00-75b5-4829-ae61-e0d5f77c6e98%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-15 Thread simone monteleone
Hi Russ,

My goal is to load the csv file directly in the database.

So my idea is define a script containing the follow pseudo-code:

 while(1) and receive_csv():

value1, value2 = read_csv()
   
MyModel.objects.create(field1=value1, field2=value2) 

The script run on the server, ex http://127.0.0.1:8000/admin

At this point it's possible using the script reported?







*import requestsurl = 'http://127.0.0.1:8000/admin'files = {'file': 
open('log', 'rb')}r = requests.post(url, files=files)*

I don't understand where send the file respect the Django server.

Thanks very much.

SM  

Il giorno venerdì 14 febbraio 2014 00:10:44 UTC+1, Russell Keith-Magee ha 
scritto:
>
>
> On Thu, Feb 13, 2014 at 4:11 PM, simone monteleone 
> 
> > wrote:
>
>> Hi all,
>>
>> I have to send a file (ex. csv file) to the Django server.
>>
>> I think to use the requests python module.
>>
>> Is this the best way?
>>
>
> The "best" way will depend on your exact requirements - I'll come back to 
> this in a moment. However, Requests will certainly make it easy to write a 
> Python script that will send a file to a Django server.
>  
>
>> Second question; Django can receive this file?
>>
>
> If it can be sent over HTTP, Django can receive it.
>  
>
>> And also in this case, what it is the best way?
>>
>
> Django's file handling documentation contains details on how to set up 
> this sort of thing:
>
> https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/
>
> My goal is to load the csv file information in the dabatase handles by 
>> django,
>>
>  
> We need to be clear about your needs here.
>
> Do you actually need to do this over HTTP? I.e., you may want the data to 
> be put into your database, but is there actually a requirement to upload 
> that file? Could you just load the file onto the database directly? 
>
> Django contains a bunch of tools for uploading files directly, without 
> going through a web interface. Look into loaddata management command for 
> details.
>
> https://docs.djangoproject.com/en/1.6/ref/django-admin/
>
> There isn't a native CSV importer, but there are a couple floating around 
> the web that you might be able to use.
>
> The other approach - just write the data directly to the database. Write 
> some code to read the CSV file, and use Django's model objects to write the 
> data directly; e.g., if you've got a model called MyModel, with two fields 
> field1 and field2:
>
>   MyModel.objects.create(field1=value1, field2=value2) 
>
> will create a record in the database with those values.
>
> Yours,
> Russ Magee %-)
>  

-- 
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/a6d9b203-8f37-4e5b-b49e-d12c96981c0a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


help with GEOS and PROJ.4 in windows 7

2014-02-15 Thread Nicholas Perez
Hello i am trying to install these libraries *GEOS and 
PROJ.4*to
 use with geodjango(according to tutorial on the website). I am new to 
this so any help would be greatly appreciated. i have sqlite3 installed in 
windows 7 and want to use Spatialite but i need these (GEOS and PROJ.4) 
before proceeding. Thank you for your time.

Nicholas Perez

ps: please include proper instructions to install this in windows 7 since 
that is the platform i am currently using. Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b8366ed-80c4-4b43-86a4-4a3b155c161b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-15 Thread François Schiettecatte
Hi

See this:

https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/

Cheers

François

On Feb 15, 2014, at 1:53 PM, simone monteleone  wrote:

> Hi Russ,
> 
> My goal is to load the csv file directly in the database.
> 
> So my idea is define a script containing the follow pseudo-code:
> 
>  while(1) and receive_csv():
> 
> value1, value2 = read_csv()
>
> MyModel.objects.create(field1=value1, field2=value2) 
> 
> The script run on the server, ex http://127.0.0.1:8000/admin
> 
> At this point it's possible using the script reported?
> 
> import requests
> 
> url = 'http://127.0.0.1:8000/admin'
> 
> files = {'file': open('log', 'rb')}
> 
> r = requests.post(url, files=files)
> 
> I don't understand where send the file respect the Django server.
> 
> Thanks very much.
> 
> SM  
> 
> Il giorno venerdì 14 febbraio 2014 00:10:44 UTC+1, Russell Keith-Magee ha 
> scritto:
> 
> On Thu, Feb 13, 2014 at 4:11 PM, simone monteleone  wrote:
> Hi all,
> 
> I have to send a file (ex. csv file) to the Django server.
> 
> I think to use the requests python module.
> 
> Is this the best way?
> 
> The "best" way will depend on your exact requirements - I'll come back to 
> this in a moment. However, Requests will certainly make it easy to write a 
> Python script that will send a file to a Django server.
>  
> Second question; Django can receive this file?
> 
> If it can be sent over HTTP, Django can receive it.
>  
> And also in this case, what it is the best way?
> 
> Django's file handling documentation contains details on how to set up this 
> sort of thing:
> 
> https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/
> 
> My goal is to load the csv file information in the dabatase handles by django,
>  
> We need to be clear about your needs here.
> 
> Do you actually need to do this over HTTP? I.e., you may want the data to be 
> put into your database, but is there actually a requirement to upload that 
> file? Could you just load the file onto the database directly? 
> 
> Django contains a bunch of tools for uploading files directly, without going 
> through a web interface. Look into loaddata management command for details.
> 
> https://docs.djangoproject.com/en/1.6/ref/django-admin/
> 
> There isn't a native CSV importer, but there are a couple floating around the 
> web that you might be able to use.
> 
> The other approach - just write the data directly to the database. Write some 
> code to read the CSV file, and use Django's model objects to write the data 
> directly; e.g., if you've got a model called MyModel, with two fields field1 
> and field2:
> 
>   MyModel.objects.create(field1=value1, field2=value2) 
> 
> will create a record in the database with those values.
> 
> Yours,
> Russ Magee %-)
> 
> -- 
> 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/a6d9b203-8f37-4e5b-b49e-d12c96981c0a%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Programmers that work in Aptana from GitHub answer me

2014-02-15 Thread Alex Mandel
On 02/15/2014 11:59 AM, Dennis Lee Bieber wrote:
> On Sat, 15 Feb 2014 09:30:53 -0800 (PST), ??? ???
>  declaimed the following:
> 
>> I need your help. Please.
> 
>   Then I suggest you find some group specific to Aptana...
> 
>   Based upon the Aptana web page, it is a product for developing
> web-sites, with an emphasis on Ruby-on-Rails... The only relationship it
> has to Django is that Django is a product for developing web-sites that
> uses Python as the base.
> 
>   They are completely separate products; someone using Django is unlikely
> to be using Aptana.
> 

Not exactly, Aptana does have PyDev as part of it (might be optional).
Which gets you about the same as Eclipse+Pydev. For those that don't
know Aptana is a custom variant of Eclipse oriented to web development.

Pydev is django aware and virtualenv capable. If you have pydev
installed you'll notice that you can start a new Django project from the
Eclipse menus.

Look for information about Pydev and Django it should be relevant to Aptana.

The steps I would take, make new django project in the IDE. git init,
add, commit and push this structure to your github repo. Make sure to
gitignore the file you store your database password in.

Enjoy,
Alex

-- 
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/52FFCA61.8080809%40wildintellect.com.
For more options, visit https://groups.google.com/groups/opt_out.


First tutorial - 404

2014-02-15 Thread Steve Booth
I've been Googling on this for several hours.  Time to ask.

I'm just trying to run through the very first tutorial, and frankly, it's 
been a nightmare. Running under Fedora 18, Python 2.7, Django version is 
1.4.5.

So, I got the 1.4 tutorial up, created the site.. all works fine.  Fire up 
the server -- looks great.  Browse to http://127.0.0.1:800..

And I do NOT get the nice, blue Django page, I get a Page Not Found 404 
error telling me the URLconf in mysite.urls does not match '^admin/'

Well... YEA!  So either the 1.4 tutorial doc's are wrong, or the default 
site doesnt work, or I dont know what I'm doing.

Any help would be greatly appreciated. 

I shouldn't have to be asking this ... it should just work.

-- 
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/b8be3c8b-9c0a-4812-89b3-777ded918b65%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie Question - Where to store application constants?

2014-02-15 Thread Camilo Torres
To round this, for the price of gold, and if you are using the 
django.contrib.admin interface, you can use Django Solo or similar 
singleton model. That way you can edit your "business properties" within 
the admin interface:
https://pypi.python.org/pypi/django-solo


On Friday, February 14, 2014 12:24:09 PM UTC-4:30, ke1g wrote:
>
> It depends on the complexity of the issue.
>
> The price of gold does fluctuate.  On the grounds that I might want to 
> change it more often than I would want to ssh in, edit a file, and restart, 
> I would tend to put price of gold in the database, that is, in a model of 
> which there may only be one instance.  Implementing limits on who has 
> permission to change it is a separate fun topic, which may not be needed if 
> very few people have admin logins.
>
> Then there are application specific configuration options, which tent to 
> never change once an installation is up and running.  You can require that 
> they be set in settings.py if the constants are highly likely to differ 
> site to site (or if there is only one site in the world using this app), 
> but it is probably worthwhile providing defaults which can be overridden in 
> settings.py .  A common way to do the latter is to have another settings 
> file in the app directory (usually also called settings.py, since it can be 
> qualified with the app name) which defines constants as the result of 
> calling gettattr on the main settings object, and providing the default 
> value as teh third argument to getattr.  The other parts of the app get the 
> constants from the app specific settings file.
>
> Another kind of constant is truly never expected to change, such as 
> physical or algorithmic constants, defined so that they can be used 
> symbolically.  Sometimes they are only used quite locally, and can be 
> defined in that module, but if they are used by two or more modules, they 
> should probably be defined once, and imported in modules that use them.  
> While it is possible to define them in any module (such as the one that 
> uses them the most) and to import from that module in others that need the 
> constant(s), you must beware of circular import problems, so it is often 
> easier to create a constants.py or the like (if you already have an app 
> specific settings module, it is a fine place for you constants).  But your 
> models.py module, if you have only one, is a pretty safe place to put 
> constants, since it doesn't tend to import your other modules (unless you 
> have an app specific settings module), so you won't (typically)  have 
> circularity if you import from it.
>
> Bill
>
>
> On Fri, Feb 14, 2014 at 11:13 AM, Mark Phillips <
> ma...@phillipsmarketing.biz > wrote:
>
>> Where should one put application specific constants - those that change 
>> sometimes(1) and those that never change? For example, I am creating a 
>> simple inventory application for my mother's estate. Several quotes for 
>> her jewelry are based on the weight of the jewelry and the current price of 
>> gold.
>>
>> In the Estimate model, I have a field for weight, and then a property 
>> that looks something like:
>>
>> @property
>> def estimate_by_weight():
>> return self.weight * PRICE_OF GOLD
>>
>> Where would I put the PRICE_OF_GOLD constant? Some ideas that came to 
>> mind:
>>
>> 1. Settings.py - but then I have to edit that file every time I want to 
>> update the price of gold
>>
>> 2. Maybe a model so I can update it in the admin screens?
>>
>> 3. A form somewhere? But I think this would mean a model, so this is 
>> probably the same as #2.
>>
>> Where would one put a non-changing constant like the speed of light in a 
>> django application? 
>>
>> Thanks!
>>
>> Mark
>>
>> (1) Yes, I realize that terms 'constant' and 'changes sometimes' are 
>> mutually exclusive, but I hope you get the gist of what I am asking 
>> regardless of my imprecise description..
>>  
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%40mail.gmail.com
>> .
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/djan

Re: Aptana Studio 3 + PyDev + Git

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 12:28:42 PM UTC-4:30, Віталій Лисенко wrote:
>
> I badly speak and write English, but i have question:
>
> 1. describe the main advantages of development in Aptana Studio 3 
> Django proects
> 2.write a detailed ìnfstrukcìû of how to lay out a project on github, 
> I have nothing
>

1. You can get it right from the Aptana site:
http://www.aptana.com/products/studio3

2. Read this:
 
http://www.jeffknupp.com/blog/2013/08/16/open-sourcing-a-python-project-the-right-way/

-- 
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/303421de-d24f-4086-ad0f-0c32c770e7cf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Creating database in windows

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 1:20:09 PM UTC-4:30, Nicholas Perez wrote:
>
> Hello. I am currently using Django version 1.6.2 trying to learn to use 
> Geodjango on a windows machine.
> My issue is that i have followed Geodjango installation for windows to the 
> letter(everything is installed in the default directory). my geodjango 
> folder is on my desktop
>
> As i follow the tutorial it tells me to run this command in my terminal: 
>
> createdb -T template_postgis geodjango
>
> how it says that createdb command is not recognized
>
> i skip that downloaded my zip to my world\data folder in my geodjango 
> folder(and by skip i mean continuing to the next instruction)
> and run this command:ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
>
> and it says ogrinfo command is not recognized 
>
> Please help out. I would be appreciate it.
>
>
1. createdb is a Postgres utility for the command line. May be you don't 
have Postgres propertly installed or configured in your system.
2. ogrinfo is an utility from the GDAL project:
 http://www.gdal.org/ogrinfo.html
may be you don't have it properly installed or configured

-- 
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/f8be2a72-fc4d-430c-9e5f-79c4f613e57f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: or-ing to QuerySets turns INNER into LEFT OUTER joins?

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 4:58:21 PM UTC-4:30, sha wrote:
>
> What I would like to know is: 
> 1. Is there a reason why mysql performance is so slow on left outer join? 
> (even with indexes)
>
>>
>>
That is not a MySQL issue with outher joins, nor any other RDBMS issue with 
outher join. That depends so much in the way you wrote your query and the 
conditions for joining you are putting in; you can be doing a full table 
scan or cartesian product of two (or more) relations. The index are used 
whenever possible or whenever the RDBMS is able to use them.

Carsten's manual optimization seems better than that of the ORM for this 
case.

-- 
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/122ba3f2-3d9f-4059-8da1-0ce7364bd28c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: persistent db connections and postgresql_psycopg2 InterfaceError

2014-02-15 Thread Connor23
I have a very similar configuration and I get the exact same error.

Have you open a ticket? Thanks.

On Wednesday, December 18, 2013 2:23:57 AM UTC-8, Pavel Lurye wrote:
>
> Hi,
> CONN_MAX_AGE=None.
> Of course, restarting will fix the problem, but that's not what I'm 
> expecting from django.
> I think this is django bug, but I want to be sure.
>
> вторник, 17 декабря 2013 г., 18:59:46 UTC+4 пользователь Prashanth B 
> написал:
>>
>> I suspect restarting your Web server will fix it as you'll get fresh 
>> connections. What is your CONN_MAX_AGE? 
>> On Dec 17, 2013 4:57 AM, "Pavel Lurye"  wrote:
>>
>>> Hi,
>>> does anyone have used django1.6 persistent connections with postgresql?
>>> I've done a simple test and I'm not sure, that django behaves correctly.
>>> Django can't recover after DB restart, and all further db requests lead 
>>> to server error:
>>> ---
>>> Traceback (most recent call last):
>>>   File 
>>> "/venv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", 
>>> line 194, in __call__
>>> signals.request_started.send(sender=self.__class__)
>>>   File 
>>> "/venv/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", 
>>> line 185, in send
>>> response = receiver(signal=self, sender=sender, **named)
>>>   File "/venv/local/lib/python2.7/site-packages/django/db/__init__.py", 
>>> line 95, in close_old_connections
>>> conn.close_if_unusable_or_obsolete()
>>>   File 
>>> "/venv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", 
>>> line 466, in close_if_unusable_or_obsolete
>>> if self.is_usable():
>>>   File 
>>> "/venv/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py",
>>>  
>>> line 196, in is_usable
>>> self.connection.cursor().execute("SELECT 1")
>>> psycopg2.InterfaceError: connection already closed
>>> ---
>>>
>>> So, InterfaceError is not catched by django in 
>>> postgresql_psycopg2.DatabaseWrapper.is_usable.
>>>
>>> My test environment is:
>>> Ubuntu 13.10
>>> postgresql 9.1
>>>
>>> Django==1.6.1
>>> psycopg2==2.5.1
>>> uWSGI==1.9.21.1
>>>
>>>  -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/77922966-a48e-4284-badd-e93f052fff54%40googlegroups.com
>>> .
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c037361c-498d-438c-9bbc-13f0a8ebd8e5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-15 Thread Russell Keith-Magee
Hi Simone,

On Sun, Feb 16, 2014 at 2:53 AM, simone monteleone wrote:

> Hi Russ,
>
> My goal is to load the csv file directly in the database.
>
> So my idea is define a script containing the follow pseudo-code:
>
>  while(1) and receive_csv():
>
> value1, value2 = read_csv()
>
> MyModel.objects.create(field1=value1, field2=value2)
>
> The script run on the server, ex http://127.0.0.1:8000/admin
>

Do you want the *file*, or the *data contained in the file*?

Based on the script you've provided, you want the *data*. If so, you don't
run a script like this at a URL. You run it at a Python prompt.

When you went through the Django tutorial, the first steps were all done at
a prompt. Those commands let you inspect the data that was in the database.
You can also use the prompt to *create* data in the database - that's what
your script needs to do.

You don't need to upload the script to the server, or write any view code -
you're writing a set of commands that you will run at a prompt to open a
file, read some data, and write to the database. Then you can start your
Django server, and see that data *on* your server.

Is that more clear?

Yours
Russ Magee %-)

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


Re: First tutorial - 404

2014-02-15 Thread yati sagade
The tutorial for 1.4 can be found here:
https://docs.djangoproject.com/en/1.4/intro/tutorial01/ (For other
versions, just change the 1.4 in that URL to the version you'd like). I am
curious, is there a reason you want to continue learning with 1.4, like you
are stuck with it for some reason? If not, why not just upgrade? (I'm sure
you'd have thought about this, but as I said, I'm curious :))


On Sun, Feb 16, 2014 at 2:41 AM, Steve Booth  wrote:

> I've been Googling on this for several hours.  Time to ask.
>
> I'm just trying to run through the very first tutorial, and frankly, it's
> been a nightmare. Running under Fedora 18, Python 2.7, Django version is
> 1.4.5.
>
> So, I got the 1.4 tutorial up, created the site.. all works fine.  Fire up
> the server -- looks great.  Browse to http://127.0.0.1:800..
>
> And I do NOT get the nice, blue Django page, I get a Page Not Found 404
> error telling me the URLconf in mysite.urls does not match '^admin/'
>
> Well... YEA!  So either the 1.4 tutorial doc's are wrong, or the default
> site doesnt work, or I dont know what I'm doing.
>
> Any help would be greatly appreciated.
>
> I shouldn't have to be asking this ... it should just work.
>
> --
> 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/b8be3c8b-9c0a-4812-89b3-777ded918b65%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Yati Sagade

Software Engineer at mquotient 


Twitter: @yati_itay  | Github:
yati-sagade

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

-- 
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/CANpY%2BHmh3u%2B7Jfbdf11hk4eMEijkMU%3DAP6kG-XB%3DzdnzHF96tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Python-requests call within view hangs LiveServerTestCase

2014-02-15 Thread Ashwin Raju
Ping. Anybody?


On Saturday, February 15, 2014 8:31:05 AM UTC-8, Ashwin Raju wrote:
>
> I have implemented a REST api using django rest framework. I am now 
> implementing a website to prove consumption of the rest api. So in my view 
> code, I validate the form input then use python-requests to call the api. 
> This is so that in the future, mobile clients can directly consume the api.
>
> I have a functional test for this using LiveServerTestCase and Selenium. 
> When I do the scenario manually, it works correctly. However, the 
> functional test hangs on the python-requests call. I've used a POST in this 
> example, but GET using the python-requests api has the same effect.
>
> My sample code is in this stackoverflow question: 
> http://stackoverflow.com/questions/21690718/liveservertestcase-hangs-at-python-requests-post-call-in-django-view
>  
>
> One thing that is interesting about this pattern is that the web server 
> will receive a second request from within the first request. I don't think 
> this is a db lock issue since LiveServerTestCase derives from 
> TransactionTestCase, which doesn't take any transaction locks. So why does 
> this scenario fail with LiveServerTestCase when it passes with manage.py 
> runserver?
>
> Thanks,
> Ashwin
>

-- 
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/1b3420e8-d4eb-47b4-9197-98a960a74c3b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.