Re: Problem with DetailView

2012-07-07 Thread Smaran Harihar
If I am not wrong. The issue is with the List View not Detail View.

You need to provide, List View with query set. If you are providing model
parameter, you will also need to give it a primary key 'pk', like you did
for Detail View.

Hope that helps,
Smaran
On Jul 7, 2012 3:36 PM, "Soviet"  wrote:

> Now that I have basic understanding of models, I encountered even more
> confusing subjects - views and urls. Now, the class-generic views are quite
> easy to grasp at basic level, but I fail to understand what's wrong with
> this code:
>
> urlpatterns = patterns('',
> (r'^$', ListView.as_view(
> model=Car,
> context_object_name="cars_list",
> template_name='data/cars_list.html',
> )),
> (r'^(?P\d+)/$', DetailView.as_view(
> model=Car,
> context_object_name="car_details",
> template_name='data/car_details.html',
> )),
> )
>
> The ListView is working fine, but when I try to get the details about
> single car, all I'm getting is error: "No car found matching the query". I
> tried adding 'queryset = Car.objects.all()' both in urls.py and in
> views.py, creating custom class, but the error persists.
>
> --
> 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/-/fQZA1sl13VkJ.
> 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: Model for ListView needed?

2012-07-07 Thread Smaran Harihar
Thanks for the reply Melvyn.

So by multiple model instances you mean the multiple records that poll app
has in it's database?

On Fri, Jul 6, 2012 at 3:22 AM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> On 6-7-2012 0:35, Smaran Harihar wrote:
> > Thanks for the reply Luigi, but when should we use queryset and when
> should
> > we use model?
>
> A queryset returns a /list/ of model instances. Thus you should queryset
> when you want more then one instance of the model displayed.
>
> From the above you should also understand that the DetailView wants a
> model and "something from which it can identify a single instance" - the
> pk (primary key) in the example.
>
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


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



Re: submit parameters to py script

2012-07-07 Thread Smaran Harihar
Once again thanks for the helpful guidance Melvyn and Babatunde.

Babatunde: I will go through the links you provided and come back with new
queries.

Melvyn : Ya, I am a newbie in Django but have Web Development exp. There is
one problem when I wish to create models and queryset for connecting to the
database and that is like this,

1. My settings.py points to Postgres database, which is my main database.
2. The data I wish to extract and display in CSV, is in another database
(mysql). What I have come to know after completing the basic tutorials of
Django is that we define the database in the settings.py and since I
already have the postgres defined, how can I also connect to this MySql
Database, using views/models? This is why I wanted to trigger an external
py script which will deal with this MySql database separately.

Is there a way to connect to multiple databases simultaneously? If so then
please let me know how?

Thanks,
Smaran

On Sat, Jul 7, 2012 at 4:01 AM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> On 7-7-2012 11:44, Smaran Harihar wrote:
> > Thanks for the reply Melvyn and Babatunde. So my script is, using the
> > parameters, to search in a database and then spitting out the output back
> > as CSV.
>
> This only makes sense in the django world, if your script is accessing a
> database that is not part of the application itself. For example an
> accounting program in django that replaces a firms older software.
> Access to previous years is then provided via a script that simply
> provides CSV format so data can be entered into a spreadsheet program
> and reports can be created. One would use this approach if converting
> the old data to the new application consumes too many resources for the
> few times the data will be used.
>
> I can't think of many other cases where I would use this approach, so ...
>
> > Ok, so adding it to view makes more sense, but how do i connect or
> execute
> > that view, on the click of the submit button??
>
> The key question is if you have models for the tables in this database?
> If so your best option is to translate the parameters to django's
> queryset syntax. If you don't understand what that means, you're
> probably new to django and we'll try to be more verbose.
>
> As a side note, especially when new to django but not unfamiliar with
> webdevelopment/databases, you need to learn to let go of your SQL
> knowledge and start thinking in models and querysets. Once you fully
> understand how this works and what you can do with it, you can apply
> your SQL knowledge to optimize what django's syncdb has created for you
> or even start working the other way around using inspectdb.
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


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



Re: submit parameters to py script

2012-07-07 Thread Smaran Harihar
Thanks for the reply Melvyn and Babatunde. So my script is, using the
parameters, to search in a database and then spitting out the output back
as CSV.
I wish to return the CSV and also display the output in the table on my
html template.
Ok, so adding it to view makes more sense, but how do i connect or execute
that view, on the click of the submit button??
On Jul 7, 2012 1:42 AM, "Melvyn Sopacua" <m.r.sopa...@gmail.com> wrote:

> On 7-7-2012 0:20, Smaran Harihar wrote:
>
> > I am trying to execute a python script on submit button on a html file.
> >
> > So i have created a view which renders a html template file and on
> > 'submit', I wish to send few parameters to the py script.
> >
> > I wanted to know,
> >
> > 1. where should I keep my py script?
>
> Anywhere you want. It's probably best you describe what your script
> does. We don't really understand why you want to execute a script and
> not just put that code in a view function.
> Other than that, a python script you want to execute is no different
> than a sh script or binary command, so you'll need to use python's
> subprocess or os module functions, pass arguments in proper shell syntax
> and read output.
> --
> Melvyn Sopacua
>
>
> --
> 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: submit parameters to py script

2012-07-06 Thread Smaran Harihar
Thanks for the reply Rohan. I am trying to create a Django App in which,
user will be adding some info in the text box and on clicking submit, I
wish to send the contents of the textbox to the py script. The output of
the py script, I wish to display it in a table on my HTML template.

I hope I was able to explain myself. Also where should I place my py sript,
which will be triggered on submitting the data.

Thanks,
Smaran

On Fri, Jul 6, 2012 at 6:14 PM, Rohan <roha...@gmail.com> wrote:

>  For a cgi script or a wsgi script, all you need to do is add a script
> alias in your apache conf (if you're using apache). The parameters should
> be available as a a dictionary in both the cases (cgi.FieldStorage() and
> envrion).
>
> Although it would help to know why you want to do this. If you already
> have django up and running, you could just implement the functionality of
> your script as a view function
>
>
> On 7/6/2012 6:20 PM, Smaran Harihar wrote:
>
> Hey Djangoers,
>
>  I am trying to execute a python script on submit button on a html file.
>
>  So i have created a view which renders a html template file and on
> 'submit', I wish to send few parameters to the py script.
>
>  I wanted to know,
>
>  1. where should I keep my py script?
> 2. I have not modified my html into Django template, but what
> modifications will it need if I want to send parameters to py script on
> submit?
>
>  --
> 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.
>
>
>
>  --
> 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.
>



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



submit parameters to py script

2012-07-06 Thread Smaran Harihar
Hey Djangoers,

I am trying to execute a python script on submit button on a html file.

So i have created a view which renders a html template file and on
'submit', I wish to send few parameters to the py script.

I wanted to know,

1. where should I keep my py script?
2. I have not modified my html into Django template, but what modifications
will it need if I want to send parameters to py script on submit?

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



Re: Model for ListView needed?

2012-07-05 Thread Smaran Harihar
Thanks for the reply Luigi, but when should we use queryset and when should
we use model?


On Thu, Jul 5, 2012 at 3:25 PM, Luigi Castro <virtual.emplo...@gmail.com>wrote:

> They did not provide the model parameter because ca queryset was used,
> note the following line.
>
> queryset=Poll.objects.order_by**('-pub_date')[:5]
>
>
>
>
> On Thursday, July 5, 2012 1:13:38 PM UTC-6, Sam007 wrote:
>>
>> Hey Djangoers,
>>
>> In the fourth and last part of the Django tutorials,
>>
>> urlpatterns = patterns('',
>> url(r'^$',
>> ListView.as_view(
>> queryset=Poll.objects.order_by**('-pub_date')[:5],
>> context_object_name='latest_**poll_list',
>> template_name='polls/index.**html')),
>> url(r'^(?P\d+)/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='polls/detail.**html')),
>> url(r'^(?P\d+)/results/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='polls/results.**html'),
>> name='poll_results'),
>> url(r'^(?P\d+)/vote/$**', 'polls.views.vote'),)
>>
>>
>> There is a explanation that,
>>
>> "Each generic view needs to know what model it will be acting upon. This
>> is provided using the model parameter."
>>
>> But in the code above there was no 'model' parameter given for ListView?
>> So is model parameter only for DetailView? In the tutorial, was the generic
>> view suppose to be DetailView?
>>
>> --
>> Thanks & Regards
>> Smaran Harihar
>>
>>   --
> 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/-/VbSqnftQAVoJ.
> 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.
>



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



Re: check for edited views.py

2012-07-05 Thread Smaran Harihar
hmmm I guess you are right Nik. Will try it that way. Thanks

On Thu, Jul 5, 2012 at 3:12 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Well, the only way to know for sure would be regression testing
> (http://en.wikipedia.org/wiki/Regression_testing). If the project makes
> use of the Django testing functionality
> (https://docs.djangoproject.com/en/1.4/topics/testing/), then you could
> just run the tests.
>
> Otherwise, you would need to look at what you changed and try to
> exercise any code that may have been affected. For example, if you added
> a view and only modified a single views.py file, then exercise some of
> the other views in that file and make sure they still work.
>
> The best thing to do would be to cut your teeth on a new project (where
> you wouldn't have to worry about making a mistake). Then, once you're
> more familiar with Django, come back to the existing project to make
> whatever changes are needed.
>
> _Nik
>
> On 7/5/2012 2:44 PM, Smaran Harihar wrote:
> > Hey Djangoers,
> >
> > I am messing around with a big django project and adding my view by
> > editing the views.py in the project code. This is the code that I have
> > added,
> >
> > def current_datetime(request):
> >now = datetime.datetime.now()
> >html = "It is now %s." % now
> >return HttpResponse(html)
> >
> > By this code you must have understood that I am a newbie. So what I
> > want to know, is there a way to check, If my editing the views.py has
> > created some error in the pre-existing project? How can I detect it?
> >
> > --
> > 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.
>
>
> --
> 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.
>
>


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



check for edited views.py

2012-07-05 Thread Smaran Harihar
Hey Djangoers,

I am messing around with a big django project and adding my view by editing
the views.py in the project code. This is the code that I have added,

def current_datetime(request):
   now = datetime.datetime.now()
   html = "It is now %s." % now
   return HttpResponse(html)

By this code you must have understood that I am a newbie. So what I want to
know, is there a way to check, If my editing the views.py has created some
error in the pre-existing project? How can I detect it?

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



Re: Decoupling Urls

2012-07-05 Thread Smaran Harihar
Hey Nik,

Thanks for the detailed explanation. It is clear now.

Thanks,
Smaran

On Tue, Jul 3, 2012 at 5:47 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  Hi Smaran,
>
> Yes, by full path, I mean, for example, 'polls.urls'. And yes, it is a
> string. Django interprets it as a module path when it builds up the URLs.
> It's the same thing that happens in the polls.urls module when mapping the
> URL patterns to functions. The functions are all quoted as well (in the
> tutorial). In this case, you *don't* need to give the full path, since
> the 'polls.views' part is specified as the first argument of patterns. For
> example, looking at the last code snippet on the page you linked to, you
> could write the URL patterns in a few different ways:
>
> 1) as-is
> 2) with no 'prefix' given:
> urlpatterns = patterns('',
> url(r'^$', 'polls.views.index'),
> ...
> )
>
> 3) with a partial prefix:
> urlpatterns = patterns('polls',
> url(r'^$', 'views.index'),
> ...
> )
>
> 4) by passing in the function itself, rather than a string
> from polls.views import index
> ...
> urlpatterns = patterns('',
> url(r'^$', index),
> ...
> )
>
> This notion of using strings instead of actual references is used
> elsewhere too. For example, if you need to create a ForeignKey field in one
> model that references a model defined later in the same file:
> https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey (see
> first ForeignKey code example). It's also used in the settings file (all
> the apps and middleware classes are provided as strings; typically nothing
> is imported in the settings module).
>
> Does that make sense at all? In short, in many places where Django
> requires a function, class, or module, you can provide a direct reference
> to it, or provide a string instead. You'll still get an error if the module
> path in that string is not correct.
>
> _Nik
>
>
> On 7/3/2012 5:14 PM, Smaran Harihar wrote:
>
> Hey Nik,
>
>  Thanks for the reply. When you say, provide full path for the lazy
> quoted version, do you mean 'polls.url' ?
> Is that not relative path?
>
>  Also having the path in quotes 'polls.url', is it not a string?
>
>  Thanks,
> Smaran
>
> On Tue, Jul 3, 2012 at 5:02 PM, Nikolas Stevenson-Molnar <
> nik.mol...@consbio.org> wrote:
>
>>  If I understand correctly, you're asking about the difference between
>> include('polls.urls') and include(admin.site.urls)? Django will often let
>> you reference modules, functions, and classes 'lazily', meaning you don't
>> need to import them first. You could use the unquoted version for polls as
>> well, it would look something like
>>
>> import polls
>> ...
>> url(r'^polls/', include(polls.urls))
>>
>> *or*
>>
>> from polls import urls as poll_urls
>> ...
>> url(r'^polls/', include(poll_urls))
>>
>> Note that if you're using the 'lazy', quoted version you always need to
>> provide the full path.
>>
>> _Nik
>>
>>
>> On 7/3/2012 4:24 PM, Smaran Harihar wrote:
>>
>>  Hi Djangoers,
>>
>>  I just completed the tutorial 3 and got a little confused on the last
>> section<https://docs.djangoproject.com/en/dev/intro/tutorial03/#decoupling-the-urlconfs>of
>>  the tutorial,
>>
>>   urlpatterns = patterns('',
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', include(admin.site.urls)),)
>>
>> In this for the polls app, we are assigning the urls.py path in the
>> quotes 'polls.urls'
>> but for admin we are not?
>>
>>  So what is the difference and being it quotes how does it still pick up
>> the path? Does django not consider it to be simply string.
>>
>>  --
>> 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.
>>
>>
>>
>>  --
>> 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://grou

Re: Decoupling Urls

2012-07-03 Thread Smaran Harihar
Hey Nik,

Thanks for the reply. When you say, provide full path for the lazy quoted
version, do you mean 'polls.url' ?
Is that not relative path?

Also having the path in quotes 'polls.url', is it not a string?

Thanks,
Smaran

On Tue, Jul 3, 2012 at 5:02 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  If I understand correctly, you're asking about the difference between
> include('polls.urls') and include(admin.site.urls)? Django will often let
> you reference modules, functions, and classes 'lazily', meaning you don't
> need to import them first. You could use the unquoted version for polls as
> well, it would look something like
>
> import polls
> ...
> url(r'^polls/', include(polls.urls))
>
> *or*
>
> from polls import urls as poll_urls
> ...
> url(r'^polls/', include(poll_urls))
>
> Note that if you're using the 'lazy', quoted version you always need to
> provide the full path.
>
> _Nik
>
>
> On 7/3/2012 4:24 PM, Smaran Harihar wrote:
>
> Hi Djangoers,
>
>  I just completed the tutorial 3 and got a little confused on the last
> section<https://docs.djangoproject.com/en/dev/intro/tutorial03/#decoupling-the-urlconfs>of
>  the tutorial,
>
>   urlpatterns = patterns('',
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', include(admin.site.urls)),)
>
> In this for the polls app, we are assigning the urls.py path in the quotes
> 'polls.urls'
> but for admin we are not?
>
>  So what is the difference and being it quotes how does it still pick up
> the path? Does django not consider it to be simply string.
>
>  --
> 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.
>
>
>
>  --
> 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.
>



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



Decoupling Urls

2012-07-03 Thread Smaran Harihar
Hi Djangoers,

I just completed the tutorial 3 and got a little confused on the last
section<https://docs.djangoproject.com/en/dev/intro/tutorial03/#decoupling-the-urlconfs>of
the tutorial,

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),)

In this for the polls app, we are assigning the urls.py path in the quotes
'polls.urls'
but for admin we are not?

So what is the difference and being it quotes how does it still pick up the
path? Does django not consider it to be simply string.

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



Raise 404

2012-07-03 Thread Smaran Harihar
Hey Djangoers,

I am on my tutorial 3 and I was on this
topic<https://docs.djangoproject.com/en/dev/intro/tutorial03/#raising-404>
.

And now if I try to access http://localhost:8000/polls/1/ it gives me the
same error page, which it gives for other errors.

I know the error is because I have not yet created the detail.html page but
is this the output for 'raise Http404' ?

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



Re: Tutorial three '-pub_date'

2012-07-03 Thread Smaran Harihar
Thanks Vincent and Elliot.

On Tue, Jul 3, 2012 at 11:41 AM, cubells <vic...@vcubells.net> wrote:

> It means "in descending order"
>
> , Vicent Cubells.
>
>
> - Reply message -
> De: "Smaran Harihar" <smaran.hari...@gmail.com>
> Para: <django-users@googlegroups.com>
> Asunto: Tutorial three '-pub_date'
> Fecha: mar., jul. 3, 2012 20:33
>
>
> Hey Djangoers,
>
> I am on the tutorial 
> 3<https://docs..djangoproject.com/en/dev/intro/tutorial03/#write-views-that-actually-do-something>,
> and found this code where we are modifying the view index()
>
> def index(request):
> latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
> output = ', '.join([p.question for p in latest_poll_list])
> return HttpResponse(output)
>
> What I did not understand, was why did we state,
>
> order_by('-pub_date'), what does that *'-'* mean before 'pub_date' ?
>
> --
> 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.
>
> --
> 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.
>



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



Tutorial three '-pub_date'

2012-07-03 Thread Smaran Harihar
Hey Djangoers,

I am on the tutorial
3<https://docs.djangoproject.com/en/dev/intro/tutorial03/#write-views-that-actually-do-something>,
and found this code where we are modifying the view index()

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
output = ', '.join([p.question for p in latest_poll_list])
return HttpResponse(output)

What I did not understand, was why did we state,

order_by('-pub_date'), what does that *'-'* mean before 'pub_date' ?

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



Re: unable to connect freenode

2012-07-02 Thread Smaran Harihar
Hi Kenneth,

Thanks for the reply. How can i register?
On Jul 2, 2012 10:46 PM, "kenneth gonsalves" <law...@thenilgiris.com> wrote:

> On Mon, 2012-07-02 at 10:32 -0700, Smaran Harihar wrote:
> > And so I tried clicking on the link where it said #django on
> > irc.freenode.net and then I get a popup of application launching which
> > will
> > connect to the freenode.net for #django channel and I ok it, but then
> > nothing happens.
>
> you need to register your nick and be identified, otherwise #django will
> not let you in
> --
> 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: Same virtual-env for all django projects

2012-07-02 Thread Smaran Harihar
Thanks Musicman

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

> On Tue, Jul 3, 2012 at 10:52 AM, Smaran Harihar
> <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 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.
>
>


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



Same virtual-env for all django projects

2012-07-02 Thread Smaran Harihar
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?

So what I am doing is that I have the virtual-env dir in my folder django
and I have just started my project on Django called mysite (following the
tutorial). So now if I wish to create a new django project, can I again do
`source django-env/bin/activate` and then create the new app?

or new dir and new virtual-env??

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



Re: Unable to obtain c.poll

2012-07-02 Thread Smaran Harihar
Also when we are taking,

 c = p.choice_set.filter(choice_text__startswith='Just hacking')>>> c.delete()


Are we deleting the object or just that filter queryset choice?

On Mon, Jul 2, 2012 at 1:02 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:

> On Monday, 2 July 2012 20:47:40 UTC+1, Sam007 wrote:
>>
>> Hi Djangoers,
>>
>> I am almost completing my first tutorial but got stuck at the last point.
>> So I am assigning Choice object to 'c',
>>
>> c = p.choice_set.filter(choice_**text__startswith='Just')
>>
>> And I am getting this output when I check 'c'
>>
>> []
>>
>> And I am also getting the right output for 'p'
>>
>> 
>>
>> But when I am executing,
>>
>>  c.poll
>>
>>
>> This is my output,
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'QuerySet' object has no attribute 'poll'
>>
>> Not sure where I am going wrong?
>>
>> --
>> Thanks & Regards
>> Smaran Harihar
>>
>>
> You're not assigning a Choice object to `c`. You're assigning a queryset
> (basically, a list) of one Choice objects to c - hence the square brackets
> when you print it. As the documentation explains, `filter` *always* returns
> a queryset, even if only one object matches.
>
> You can do c[0] to get the Choice object, or use `get()` instead of
> `filter()` (although note that will raise an exception if zero or > 1
> objects match).
> --
> DR.
>
> --
> 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-sNQq_41PUJ.
> 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.
>



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



Re: Unable to obtain c.poll

2012-07-02 Thread Smaran Harihar
Thanks DR. Now I understand the difference between filter and get.

On Mon, Jul 2, 2012 at 1:02 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:

> On Monday, 2 July 2012 20:47:40 UTC+1, Sam007 wrote:
>>
>> Hi Djangoers,
>>
>> I am almost completing my first tutorial but got stuck at the last point.
>> So I am assigning Choice object to 'c',
>>
>> c = p.choice_set.filter(choice_**text__startswith='Just')
>>
>> And I am getting this output when I check 'c'
>>
>> []
>>
>> And I am also getting the right output for 'p'
>>
>> 
>>
>> But when I am executing,
>>
>>  c.poll
>>
>>
>> This is my output,
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'QuerySet' object has no attribute 'poll'
>>
>> Not sure where I am going wrong?
>>
>> --
>> Thanks & Regards
>> Smaran Harihar
>>
>>
> You're not assigning a Choice object to `c`. You're assigning a queryset
> (basically, a list) of one Choice objects to c - hence the square brackets
> when you print it. As the documentation explains, `filter` *always* returns
> a queryset, even if only one object matches.
>
> You can do c[0] to get the Choice object, or use `get()` instead of
> `filter()` (although note that will raise an exception if zero or > 1
> objects match).
> --
> DR.
>
> --
> 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-sNQq_41PUJ.
> 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.
>



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



Re: Foreign Key needs quotes?

2012-07-02 Thread Smaran Harihar
ok thanks Tom

On Mon, Jul 2, 2012 at 12:06 PM, Thomas Lockhart <tlockhart1...@gmail.com>wrote:

> ...
>
>  So I wanted to know, which is the right way to go or it does not matter?
>>
> I prefer without quotes for most cases. But for cases when a model is not
> yet defined (for example, you want to define a foreign key to a model which
> comes later in the source file) then you need to use the quotes to keep
> python from complaining about an undefined class.
>
> hth
>
>  - Tom
>
> --
> 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+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@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>
> .
>
>


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



Foreign Key needs quotes?

2012-07-02 Thread Smaran Harihar
Hi Djangoers,

I am following the tutorial and found something I am not sure if is right
or wrong? So here is my question,

In the tutorial 01 where we need to create two models in
models.py<https://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-models>,
we are providing the ForeignKey to the 'Choice' model for 'Poll' model
without quotes,

class Choice(models.Model):
poll = models.ForeignKey(Poll)


But when I went to read about Foreign key a bit more in
detail<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey>,
I found that the model 'Car' is being given the 'Manufacture' ForeignKey in
quotes,


class Car(models.Model):


manufacturer = models.ForeignKey('Manufacturer')


So I wanted to know, which is the right way to go or it does not matter?
-- 
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.



unable to connect freenode

2012-07-02 Thread Smaran Harihar
Hi guys,

I was going through the first step of the tutorial where I found this,

Where to get help:
If you're having trouble going through this tutorial, please post a message
to django-users or drop by #django on irc.freenode.net to chat with other
Django users who might be able to help.

And so I tried clicking on the link where it said #django on
irc.freenode.net and then I get a popup of application launching which will
connect to the freenode.net for #django channel and I ok it, but then
nothing happens.

Am I doing it wrong? I am on Ubuntu.

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



Re: locating the functionality behind the HTML element

2012-06-28 Thread Smaran Harihar
Hey Clifford,

Thanks, this is what I am looking for, where can I locate this
django-debug-toolbar? Do i need to add it like it is stated in the git hub?
or is there a UI which i can use?

Thanks,
Smaran

On Thu, Jun 28, 2012 at 2:38 PM, CLIFFORD ILKAY
<clifford_il...@dinamis.com>wrote:

> On 06/27/2012 08:55 PM, Smaran Harihar wrote:
>
>> Hi Guys,
>>
>> I am new to Django and have completed the initial basic tutorials in the
>> django doc. I am presently working on a pre-customized django application.
>> I was wondering how I can use FireBug to locate the code in a specific
>> element (like button). In the sense, in general the web development once we
>> are able to locate the button we are able to then locate the class of the
>> specific element and JS attached to it and CSS. But in Django this cannot
>> be done since everything is located in separate directories.
>>
>> Since I am entering into the Django code, where should I start looking
>> for the CSS and JS files?
>>
>>
> Hi Smaran,
>
> You can install django-debug-toolbar. That will tell you which templates
> are used to render a given page. You'll also see the whole template
> inheritance hierarchy. Knowing the URL and those two bits of information,
> you'll be able to mentally trace a request as it's handled by urls.py,
> dispatched to a view function, which in turn feeds a template. You can work
> forward from the URL or backward from the template.
>
> --
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3230 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
>
> <http://dinamis.com>
> +1 416-410-3326
>
>
> --
> 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+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@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>
> .
>
>


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



Re: locating the functionality behind the HTML element

2012-06-28 Thread Smaran Harihar
Thanks Jon

On Thu, Jun 28, 2012 at 12:41 AM, Jon Black <jon_bl...@mm.st> wrote:

>  If I understand you correctly, you want to find the django code
> responsible for rendering the view. Rather than look at the html, the most
> obvious place is to look at the url. There should be an entry in one of
> your urls.py files, which will tell you which view is being used. You can
> then trace that view to the template.
>
>  --
>  Jon Black
>  www.jonblack.org
>
>
>  On Wed, Jun 27, 2012, at 17:55, Smaran Harihar wrote:
>
> Hi Guys,
>
>  I am new to Django and have completed the initial basic tutorials in the
> django doc. I am presently working on a pre-customized django application.
> I was wondering how I can use FireBug to locate the code in a specific
> element (like button). In the sense, in general the web development once we
> are able to locate the button we are able to then locate the class of the
> specific element and JS attached to it and CSS. But in Django this cannot
> be done since everything is located in separate directories.
>
>  Since I am entering into the Django code, where should I start looking
> for the CSS and JS files?
>
> --
> 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.
>
>
>
> --
> 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.
>



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



locating the functionality behind the HTML element

2012-06-27 Thread Smaran Harihar
Hi Guys,

I am new to Django and have completed the initial basic tutorials in the
django doc. I am presently working on a pre-customized django application.
I was wondering how I can use FireBug to locate the code in a specific
element (like button). In the sense, in general the web development once we
are able to locate the button we are able to then locate the class of the
specific element and JS attached to it and CSS. But in Django this cannot
be done since everything is located in separate directories.

Since I am entering into the Django code, where should I start looking for
the CSS and JS files?

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



Re: interpretting urls

2012-06-27 Thread Smaran Harihar
The doc did not give details for *r'^(?:index/?)?$'*, in

(r'^(?:index/?)?$', 'geonode.views.index')

Thanks,
Smaran

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
>>
>> Hi,
>>
>> I am bit confused about what exactly do these urls imply in the url.py
>>
>>
> This is all documented here :
> https://docs.djangoproject.com/en/dev/topics/http/urls/
>
>  --
> 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/-/Zo3bjY0ZFvgJ.
> 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.
>



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



Re: interpretting urls

2012-06-27 Thread Smaran Harihar
Going thru the doc link you gave, I did not understand the term middleware
request processing?

but if the incoming HttpRequest object has an attribute called urlconf (set
by middleware *request
processing*<https://docs.djangoproject.com/en/dev/topics/http/middleware/#request-middleware>),
its value will be used in place of the
ROOT_URLCONF<https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ROOT_URLCONF>
 setting.

On Wed, Jun 27, 2012 at 4:16 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On Tuesday, June 26, 2012 6:52:06 PM UTC+2, Sam007 wrote:
>>
>> Hi,
>>
>> I am bit confused about what exactly do these urls imply in the url.py
>>
>>
> This is all documented here :
> https://docs.djangoproject.com/en/dev/topics/http/urls/
>
>  --
> 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/-/Zo3bjY0ZFvgJ.
> 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.
>



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



interpretting urls

2012-06-26 Thread Smaran Harihar
Hi,

I am bit confused about what exactly do these urls imply in the url.py

urlpatterns = patterns('',
 (r'^(?:index/?)?$', 'geonode.views.index'),
(r'^(?Phelp)/?$', 'geonode.views.static'),
(r'^developer/?$', 'geonode.views.developer'),
url(r'^lang\.js$', 'django.views.generic.simple.direct_to_template',
   {'template': 'lang.js', 'mimetype': 'text/javascript'},
'lang'),
(r'^maps/', include('geonode.maps.urls'))


I know that a simple url syntax like this,

url(r'^data/$', 'geonode.maps.views.browse_data')

implies, that it will execute the function browse_data in views.py in the
maps directory, inside the geonode dir.

But not sure what the above urls imply. I am absolutely new to Django so
can u explain in simple terms.

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