Re: Basic note/trello app - how to link model object IDs

2018-02-18 Thread Lylio
Hi everyone,

I've unfortunately hit another brick wall with my Django app. I have my 
list of card objects, and when one of them is clicked, I'd like a new page 
to open that contains the details for the card that was clicked. I found 
out how to create a URL using {{ card.id }}:

{% for card in cards.all %}
{{ card.title 
}} 
{% endfor %}


and in views the card def is simply:

def card(request):
return render(request, 'scrumbuddy/card.html')


So, for example if I click on the third card object in the list, the URL 
returned is http://127.0.0.1:8000/scrumbuddy/card/3

But I'm unsure of how to populate 
the http://127.0.0.1:8000/scrumbuddy/card/3 page with the database info for 
card 3. Hopefully this screenshot can demonstrate:























On Monday, 12 February 2018 21:00:53 UTC, Lylio wrote:
>
> Hi everyone,
>
> I'm new to Django and currently working on a very simple app. It's 
> basically a note app, a bit like a Trello board but aimed at creating 
> user-story cards for software development teams (code at 
> https://github.com/Lylio/scrumbuddy_project).
>
> I made a mock-up in Photoshop of how it's supposed to look:
>
>   
>
>
> I've got some basic functionality up and running - users can register and 
> create a user-story card. When a new card is created, a title, description, 
> time estimation are inputted. Cards are just displayed as list items in 
> columns. I'm trying to add a button to the cards so that when it's clicked, 
> the details of the card open up in a new and a user can edit the card info 
> or delete it. 
>
> A couple of noob questions:
>
> 1. To click on a card so it opens up and displays the details, am I right 
> to say I should create a card.html file in the templates folder for this? 
>
> 2. I'm confused about how Django keeps track of the cards in my app - I 
> presume each card object has an ID in the database and I'd need this ID in 
> order to retrieve the card's details when it's clicked - but I'm unsure of 
> how to link the two. In the two pictures above, say someone clicked on the 
> 'class progression' card on the left... I'd like a new page to open up that 
> display the details for that card and allows the user to edit the info or 
> completely delete the card.
>
> I'm maybe asking a bit much here - but I'm unsure of how complex these 
> requirements are. It feels like it should be *fairly *straightforward. 
> Any thoughts or advice would be greatly appreciated.
>
> Thanks for your time
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e39f472-d372-42b8-a5fe-ac1c3a0d75ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Basic note/trello app - how to link model object IDs

2018-02-14 Thread Lylio
Thanks for the reply Melvyn - I'm slowly getting there!

So, I now understand how to insert the unique object reference. After 
creating card.html, and defining card in views, my list element URL is:

{% for card in cards.all %}
{{ card.title 
}} 
{% endfor %}

And if I click on the second card object in the list, it opens 
up http://127.0.0.1:8000/scrumbuddy/card/2 - hooray, progress!

Ok, so now I understand what *card.id* is and I use this to references the 
model object instances. So, I presume I need to use that ID to render the 
details of each card into the body block of card.html.

Would that require editing the card view? All I have at the moment is:

def card(request):
return render(request, 'scrumbuddy/card.html')


So somewhere in here I'd create a reference to *card.id, *and perhaps pass 
the id within a context variable?

Thanks again guys, it feels good to be making some progress! Really 
appreciate your help.

On Wednesday, 14 February 2018 16:07:32 UTC, Melvyn Sopacua wrote:
>
> On woensdag 14 februari 2018 16:14:40 CET Lylio wrote: 
>
> > I'd like to click on one of the items in the list and open up a new page 
> > showing all the database details for that particular list item (title, 
> > description, time of creation, etc). Roughly, would I change the list 
> items 
> > into links: 
> > 
> >  
> >{% for card in cards.all %} 
> > > return render(request, 'scrumbuddy/card.html', context) 
> > 
>
> > On Tuesday, 13 February 2018 14:18:25 UTC, Gonzalo Delgado wrote: 
>
> > > I can assure you using Django for a project like yours is *very* 
> > > straightforward. 
> > > When in doubt, revisit the Django tutorial. This part is a good one 
> for 
> > > where you're at: 
> https://docs.djangoproject.com/en/2.0/intro/tutorial03/ 
>
>
> You did not follow this advice, or you would already know how to tie the 
> url 
> to the primary key of a model instance. It is spelled out there in detail. 
> -- 
> Melvyn Sopacua 
>

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


Re: Basic note/trello app - how to link model object IDs

2018-02-14 Thread Melvyn Sopacua
On woensdag 14 februari 2018 16:14:40 CET Lylio wrote:

> I'd like to click on one of the items in the list and open up a new page
> showing all the database details for that particular list item (title,
> description, time of creation, etc). Roughly, would I change the list items
> into links:
> 
> 
>{% for card in cards.all %}
> return render(request, 'scrumbuddy/card.html', context)
> 

> On Tuesday, 13 February 2018 14:18:25 UTC, Gonzalo Delgado wrote:

> > I can assure you using Django for a project like yours is *very*
> > straightforward.
> > When in doubt, revisit the Django tutorial. This part is a good one for
> > where you're at: https://docs.djangoproject.com/en/2.0/intro/tutorial03/


You did not follow this advice, or you would already know how to tie the url 
to the primary key of a model instance. It is spelled out there in detail.
-- 
Melvyn Sopacua

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


RE: Basic note/trello app - how to link model object IDs

2018-02-14 Thread Matthew Pava
You’ll want to use card.get_absolute_url.
See https://docs.djangoproject.com/en/2.0/ref/models/instances/#get-absolute-url
In your get_absolute_url, you should probably use the reverse method to use the 
name of a URL rather than hard-coding it in the method.  That’s the second 
example in that section.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Lylio
Sent: Wednesday, February 14, 2018 9:15 AM
To: Django users
Subject: Re: Basic note/trello app - how to link model object IDs

Thanks for the reply Gonzalo, I really appreciate the feedback.

So, conceptually I understand how the remaining pieces of this app fit together 
- but could I ask for just a little more of your help as I'm struggling with 
coding the details of what's needed.

Let's start basic - I've got some 'cards' in my database and on one of the web 
pages the title of the card is presented in a list (with some CSS styling to 
present the list item as a rectangle):


   {% for card in cards.all %}
   {{ card.title }}  
   {% endfor %}


I'd like to click on one of the items in the list and open up a new page 
showing all the database details for that particular list item (title, 
description, time of creation, etc). Roughly, would I change the list items 
into links:


   {% for card in cards.all %}
1. To click on a card so it opens up and displays the details, am I right
> to say I should create a card.html file in the templates folder for this?

It isn't necessary, but it is a good idea
What you need is to create a view that renders such template.
I suggest you write your own view function that does that, but what
you'd usually do is just use a generic view and either pass it the
template you want to use, or name the template in a way the generic view
will find it on its own.
See:
https://docs.djangoproject.com/en/2.0/topics/class-based-views/generic-display/

> 2. I'm confused about how Django keeps track of the cards in my app - I
> presume each card object has an ID in the database and I'd need this
ID in
> order to retrieve the card's details when it's clicked - but I'm
unsure of
> how to link the two. In the two pictures above, say someone clicked on
the
> 'class progression' card on the left... I'd like a new page to open up
that
> display the details for that card and allows the user to edit the info or
> completely delete the card.

Yes, in general, every Django model instance has an id (unless you
specifically tell it not to), and you can use it to create urls for the
detail view I mentioned earlier. This is a good start, but you'll later
want to add a SlugField to your Card model, and use that instead of the
id so urls look nicer.

> I'm maybe asking a bit much here - but I'm unsure of how complex these
> requirements are. It feels like it should be *fairly *straightforward.
Any
> thoughts or advice would be greatly appreciated.

I can assure you using Django for a project like yours is *very*
straightforward.
When in doubt, revisit the Django tutorial. This part is a good one for
where you're at: https://docs.djangoproject.com/en/2.0/intro/tutorial03/


--
Gonzalo Delgado
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eee70b8a-daff-453f-bb46-b4c2769d33e9%40googlegroups.com<https://groups.google.com/d/msgid/django-users/eee70b8a-daff-453f-bb46-b4c2769d33e9%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

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


Re: Basic note/trello app - how to link model object IDs

2018-02-14 Thread Lylio
Thanks for the reply Gonzalo, I really appreciate the feedback.

So, conceptually I understand how the remaining pieces of this app fit 
together - but could I ask for just a little more of your help as I'm 
struggling with coding the details of what's needed.

Let's start basic - I've got some 'cards' in my database and on one of the 
web pages the title of the card is presented in a list (with some CSS 
styling to present the list item as a rectangle):


   {% for card in cards.all %}
   {{ card.title }}  
   {% endfor %}



I'd like to click on one of the items in the list and open up a new page 
showing all the database details for that particular list item (title, 
description, time of creation, etc). Roughly, would I change the list items 
into links:


   {% for card in cards.all %}
   
> Hi Lylio, 
>
> On 12/2/18 16:20, Lylio wrote: 
> > 1. To click on a card so it opens up and displays the details, am I 
> right 
> > to say I should create a card.html file in the templates folder for 
> this? 
>
> It isn't necessary, but it is a good idea 
> What you need is to create a view that renders such template. 
> I suggest you write your own view function that does that, but what 
> you'd usually do is just use a generic view and either pass it the 
> template you want to use, or name the template in a way the generic view 
> will find it on its own. 
> See: 
>
> https://docs.djangoproject.com/en/2.0/topics/class-based-views/generic-display/
>  
>
> > 2. I'm confused about how Django keeps track of the cards in my app - I 
> > presume each card object has an ID in the database and I'd need this 
> ID in 
> > order to retrieve the card's details when it's clicked - but I'm 
> unsure of 
> > how to link the two. In the two pictures above, say someone clicked on 
> the 
> > 'class progression' card on the left... I'd like a new page to open up 
> that 
> > display the details for that card and allows the user to edit the info 
> or 
> > completely delete the card. 
>
> Yes, in general, every Django model instance has an id (unless you 
> specifically tell it not to), and you can use it to create urls for the 
> detail view I mentioned earlier. This is a good start, but you'll later 
> want to add a SlugField to your Card model, and use that instead of the 
> id so urls look nicer. 
>
> > I'm maybe asking a bit much here - but I'm unsure of how complex these 
> > requirements are. It feels like it should be *fairly *straightforward. 
> Any 
> > thoughts or advice would be greatly appreciated. 
>
> I can assure you using Django for a project like yours is *very* 
> straightforward. 
> When in doubt, revisit the Django tutorial. This part is a good one for 
> where you're at: https://docs.djangoproject.com/en/2.0/intro/tutorial03/ 
>
>
> -- 
> Gonzalo Delgado 
>

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


Re: Basic note/trello app - how to link model object IDs

2018-02-13 Thread Gonzalo Delgado
Hi Lylio,

On 12/2/18 16:20, Lylio wrote:
> 1. To click on a card so it opens up and displays the details, am I right
> to say I should create a card.html file in the templates folder for this?

It isn't necessary, but it is a good idea
What you need is to create a view that renders such template.
I suggest you write your own view function that does that, but what
you'd usually do is just use a generic view and either pass it the
template you want to use, or name the template in a way the generic view
will find it on its own.
See:
https://docs.djangoproject.com/en/2.0/topics/class-based-views/generic-display/

> 2. I'm confused about how Django keeps track of the cards in my app - I
> presume each card object has an ID in the database and I'd need this
ID in
> order to retrieve the card's details when it's clicked - but I'm
unsure of
> how to link the two. In the two pictures above, say someone clicked on
the
> 'class progression' card on the left... I'd like a new page to open up
that
> display the details for that card and allows the user to edit the info or
> completely delete the card.

Yes, in general, every Django model instance has an id (unless you
specifically tell it not to), and you can use it to create urls for the
detail view I mentioned earlier. This is a good start, but you'll later
want to add a SlugField to your Card model, and use that instead of the
id so urls look nicer.

> I'm maybe asking a bit much here - but I'm unsure of how complex these
> requirements are. It feels like it should be *fairly *straightforward.
Any
> thoughts or advice would be greatly appreciated.

I can assure you using Django for a project like yours is *very*
straightforward.
When in doubt, revisit the Django tutorial. This part is a good one for
where you're at: https://docs.djangoproject.com/en/2.0/intro/tutorial03/


-- 
Gonzalo Delgado

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c13ffca9-7a4a-e153-86d8-198a4a2d197a%40gonzalodelgado.com.ar.
For more options, visit https://groups.google.com/d/optout.


Basic note/trello app - how to link model object IDs

2018-02-12 Thread Lylio
Hi everyone,

I'm new to Django and currently working on a very simple app. It's 
basically a note app, a bit like a Trello board but aimed at creating 
user-story cards for software development teams (code at 
https://github.com/Lylio/scrumbuddy_project).

I made a mock-up in Photoshop of how it's supposed to look:

  


I've got some basic functionality up and running - users can register and 
create a user-story card. When a new card is created, a title, description, 
time estimation are inputted. Cards are just displayed as list items in 
columns. I'm trying to add a button to the cards so that when it's clicked, 
the details of the card open up in a new and a user can edit the card info 
or delete it. 

A couple of noob questions:

1. To click on a card so it opens up and displays the details, am I right 
to say I should create a card.html file in the templates folder for this? 

2. I'm confused about how Django keeps track of the cards in my app - I 
presume each card object has an ID in the database and I'd need this ID in 
order to retrieve the card's details when it's clicked - but I'm unsure of 
how to link the two. In the two pictures above, say someone clicked on the 
'class progression' card on the left... I'd like a new page to open up that 
display the details for that card and allows the user to edit the info or 
completely delete the card.

I'm maybe asking a bit much here - but I'm unsure of how complex these 
requirements are. It feels like it should be *fairly *straightforward. Any 
thoughts or advice would be greatly appreciated.

Thanks for your time

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0c63ef85-83be-4822-9aa8-0937b4213276%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.