DetailView

2012-11-21 Thread David
Hello I am trying to use a class based generic view (DetailView) to view user profiles. What I am trying to achieve is: if no user PK is provided in the URL show the logged in user. If there is a user PK in the URL show that user. Thus reducing the need to have 2 views. My code currently

AW: DetailView

2012-11-21 Thread Szabo, Patrick (LNG-VIE)
David Gesendet: Mittwoch, 21. November 2012 16:45 An: django-users@googlegroups.com Betreff: DetailView Hello I am trying to use a class based generic view (DetailView) to view user profiles. What I am trying to achieve is: if no user PK is provided in the URL show the logged in user. If there is a

Re: DetailView

2012-11-21 Thread Tom Evans
On Wed, Nov 21, 2012 at 3:45 PM, David wrote: > Hello > > I am trying to use a class based generic view (DetailView) to view user > profiles. > > What I am trying to achieve is: if no user PK is provided in the URL show > the logged in user. If there is a user PK in the URL

Re: DetailView

2012-11-21 Thread David
Thank you for you reply Tom. I am now getting: "Generic detail view home must be called with either an object pk or a slug." I have tried using the pk line you pointed to in the get_queryset method. Should I instead be trying to use def get: ? -- You received this message because you are sub

Re: DetailView

2012-11-21 Thread David
Think I now have this working with the following: def get_queryset(self): self.kwargs['pk'] = self.kwargs.get('pk', self.request.user.id) UserModel = get_user_model() profile = UserModel.objects.filter(pk=self.kwargs['pk']) return profile Thanks for your replie

Re: DetailView

2012-11-21 Thread David
Hi Patrick The error exists on this line: pk = self.kwargs['pk'] KeyError at /accounts/profile/ 'pk' Request Method: GET Request URL: http://127.0.0.1:8000/accounts/profile/ Django Version: 1.5 Exception Type: KeyError Exception Value: 'pk' Exception Location: C:\Users\DavidWills.DELTAGEM\Dja

Re: DetailView

2012-11-22 Thread Sergiy Khohlov
I would like to say that this code is really bad : def get_queryset(self): UserModel = get_user_model() pk = self.kwargs['pk'] if not pk: profile = UserModel.objects.filter(pk=self.request.user) else: profile = UserModel.objects.filter(

Re: DetailView

2012-11-22 Thread David
Sergiy Some of your points cover my old code (which was very much a first draft). This is the updated version: class home(DetailView): context_object_name = 'profile' template_name = 'view_profile.html' def get_context_data(self, **kwargs): contex

Re: DetailView

2012-11-22 Thread Sergiy Khohlov
ch was very much a first draft). > This is the updated version: > > class home(DetailView): > context_object_name = 'profile' > template_name = 'view_profile.html' > > def get_context_data(self, **kwargs): > context = super(home,

Re: DetailView

2012-11-22 Thread David
Hi Sergiy That line outputs: 1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/p3yEqcw-2_cJ. To post to this group, send email to django-users@googlegrou

Re: DetailView

2012-11-22 Thread Sergiy Khohlov
good news ! pk key is ok , But your database does not contain record for this user. you can do this by manually investigating database or by next code: rom django.core.exceptions import ObjectDoesNotExist try: MyModel = UserModel.objects.get(id=1) except ObjectDoesNotExist: prin

Problem with DetailView

2012-07-07 Thread Soviet
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(

Help with DetailView

2018-08-15 Thread Carlos Wilfrido Montecinos
t; articles = tag.article_set.all().order_by('-created_at') > context = { > 'tag': tag, > 'articles': articles, > } > return render(request, 'default/index.html', context) > I somehow made it work like this: class TagDetailView(DetailVie

ListView and DetailView

2019-09-25 Thread Simona Meli
Hi, I have 2 question: 1. every single django app (of a project) has its tables or can they be used for all? I have a user app with its tables: user, company, tipout, from which to extract data with ListView and Detailview. Now I would like to create another app in which to manage company data

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:

Re: Problem with DetailView

2012-07-07 Thread kooliah
On 07/07/2012 10: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('

Re: Problem with DetailView

2012-07-07 Thread Soviet
But the ListView is working fine. And they don't use in the documentation, just this, which I modified to fit my model: urlpatterns = patterns('', (r'^publishers/$', ListView.as_view( model=Publisher, )), ) W dniu sobota, 7 lipca 2012 22:44:23 UTC+2 użytkownik Sam007 napisał: >

Re: Problem with DetailView

2012-07-08 Thread Thomas Orozco
Could you give us the fill error message displaying what ended up being passed to the view? Also, are you sure a car exists with the id / pk you're passing? Le 7 juil. 2012 23:10, "Soviet" a écrit : > But the ListView is working fine. And they don't use in the > documentation, just this, which

Re: Problem with DetailView

2012-07-08 Thread Soviet
> Also, are you sure a car exists with the id / pk you're passing? Turns out that's the problem. I wanted to use a field from my Car model: car_id, so the link on the website would look like: www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the car_id is not the same as .

RE: Problem with DetailView

2012-07-08 Thread lacrymol...@gmail.com
More data would be nice. What url are you goimg to that's failing, exactly? Are you clicking a link from your ListView? If so, could you show your template? -Mensaje original- De: Soviet Enviados: 07/07/2012 18:10:17 Asunto: Re: Problem with DetailView But the ListView is wo

Re: Problem with DetailView

2012-07-08 Thread Tomas Neme
> Turns out that's the problem. I wanted to use a field from my Car model: > car_id, so the link on the website would look like: > www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the > car_id is not the same as . Can I achieve something like that with class what's car_id and

Re: Problem with DetailView

2012-07-08 Thread Soviet
That's because of my example. I have a LEGO Set model: class Set(models.Model): lego_id = models.CharField(max_length=32, primary_key=True, blank=True) #lego_id stores the unique number that's on every Lego box text_name = models.CharField(max_length=64) #... And I resolved my proble

Re: Problem with DetailView

2012-07-08 Thread Soviet
That's because of my example. I have a LEGO Set model: class Set(models.Model): lego_id = models.CharField(max_length= 32, primary_key=True, blank=True) #lego_id stores the unique number that's on every Lego box text_name = models.CharField(max_length=64) #... And I resolved my probl

Re: Problem with DetailView

2012-07-08 Thread Tomas Neme
% block title %}{{ set.text_name }}{% endblock %} > > {% block content %} > Set: > > {{ set.theme }} - {{ set.subtheme }} > {% endblock %} and where, pray, would that 'set' variable be populated when you very explicitly told the DetailView you wanted your contex

Re: Problem with DetailView

2012-07-08 Thread Soviet
{ set.text_name }}{% endblock %} > > > > {% block content %} > > Set: > > > > {{ set.theme }} - {{ set.subtheme }} > > {% endblock %} > > and where, pray, would that 'set' variable be populated when you very > explicitly told the DetailView

RE: Problem with DetailView

2012-07-08 Thread lacrymol...@gmail.com
t view calls it 'objects'. The template name doesn't need to be set up either, if you don't want to, it will default to '/_list.html (or _detail.html) -Mensaje original- De: Soviet Enviados: 08/07/2012 15:47:06 Asunto: Re: Problem with DetailView Ha! Thank you and s

Using FormMixin with DetailView

2015-07-27 Thread Ioannis Latousakis
I am on the exact same situation as the one described in the documentation here: https://docs.djangoproject.com/en/1.7/topics/class-based-views/mixins/#using-formmixin-with-detailview I have followed the documentation but I get the following exception: __init__() takes exactly 1 argument (3

Django query in DetailView

2014-10-29 Thread Ronaldo Bahia
*This question is also in http://stackoverflow.com/questions/26635406/django-query-in-detailview I have DetailVIew wich returns a list of related objects (m2m throught). It works just fine! But I need to search for objects'names and it is returning all objects instead of only the related

Generic display views / DetailView

2019-04-09 Thread John
Hello maybe someone could help me, Im working on an example similar to the DetailView for Generic Display Views https://docs.djangoproject.com/en/2.2/ref/class-based-views/generic-display/#detailview <https://docs.djangoproject.com/en/2.2/ref/class-based-views/generic-display/#detailview&

ImportError cannot import name DetailView

2011-01-04 Thread Anthony Pearce
le error I could not see. Exception Location: C:\DjangoProjects\mysite\polls\urls.py in , line 2 Copy of line 2 of urls.py. from django.views.generic import DetailView, ListView Anyone have any ideas? -- You received this message because you are subscribed to the Google Groups "Django u

Re: Using FormMixin with DetailView

2015-07-27 Thread Gergely Polonkai
on > here: > https://docs.djangoproject.com/en/1.7/topics/class-based-views/mixins/#using-formmixin-with-detailview > > > I have followed the documentation but I get the following exception: > > __init__() takes exactly 1 argument (3 given) > > Request Method

Re: Using FormMixin with DetailView

2015-07-27 Thread Gergely Polonkai
ut I'd like to be sure. > > Best, > Gergely > On 28 Jul 2015 00:46, "Ioannis Latousakis" wrote: > >> I am on the exact same situation as the one described in the >> documentation here: >> https://docs.djangoproject.com/en/1.7/topics/class-based-view

Re: Using FormMixin with DetailView

2015-07-28 Thread Ioannis Latousakis
alid(): new_comment = form.save(commit=False) new_comment.parent_post = parent_fk new_comment.save() return HttpResponseRedirect(request.META.get('HTTP_REFERER' )) class PostView(DetailView): """ A view for displaying a single po

Re: Using FormMixin with DetailView

2015-07-28 Thread Ioannis Latousakis
The override is this, I was experimenting with save.. > class CommentForm(forms.ModelForm): > class Meta: > model = Comment > exclude = ("parent_post","created_at") > > > def create_view(request, **kwargs): > print "IN VIEW" > if request.method == "POST": >

Re: Using FormMixin with DetailView

2015-07-28 Thread James Schneider
Is there a specific reason you aren't just using CreateView rather than trying to mix in a bunch of classes and trying to roll the post() logic yourself? You can probably cut a very large portion of code out and make this super simple. https://docs.djangoproject.com/en/1.6/topics/class-based-views

Re: Using FormMixin with DetailView

2015-07-28 Thread Ioannis Latousakis
Hello James, The reason I am following this approach is because this is what was suggested in the documentation, for the scenario where you need to have a form within a DetailsView. Although even when I got my code to be identical to the documentation example, I still dont get an object created

Re: Using FormMixin with DetailView

2015-07-28 Thread James Schneider
Are you sure you're using 1.7? Your original error posting begs to differ: Django Version:1.6.11 The particular portion of docs that you are reading is meant to show how various mixin's can be used together to address specific edge cases, but other generic classes exist that are much better suite

Re: Using FormMixin with DetailView

2015-07-28 Thread Ioannis Latousakis
Right.. I miss read the requirements.txt. Im new to django so started from a simple app base and building on top. On first look nothing broke when upgrading to 1.7. Ill check the docs you posted now. On Tuesday, 28 July 2015 11:54:55 UTC+3, James Schneider wrote: > > Are you sure you're using 1.

Re: Using FormMixin with DetailView

2015-07-28 Thread James Schneider
I've reviewed your code a bit more and I see what you're trying to do, I think. With that being said, I'll recant what I said about the CreateView. Your trouble stems from the fact that FormView by default does not perform a form.save() operation anywhere (it only validates the form). CreateView

Re: Using FormMixin with DetailView

2015-07-28 Thread Ioannis Latousakis
Hello James, Following your advice I turned to using CreateView, and now all the functionality I wanted seems to work fully. As you suggested there is no need for a form.py using this method. When I got more time I might investigate further how to make the original approach work for future ref

Re: Django query in DetailView

2014-10-30 Thread Collin Anderson
Hello, I _think_ your code looks right to me, though the query / or_query code is confusing. Print statements could be helpful there to be sure it's actually filtering something. Does this code work? def searchcandidate(request): query_string = request.GET.get('q', '').strip() found_en

Redirect to DetailView with success_url.

2018-03-06 Thread j . romeroc97
Hi!, I have a question and I hope you guys can help me, I wanna redirect to a DetailView using the success_url from my CreateView. How is this, I have a CreateView to save a device, and I wanna do that once the device is saved, redirect to DetailView to show a QR Code and vinculate with

Re: Generic display views / DetailView

2019-04-09 Thread Sithembewena L. Dube
com/?utm_source=SentWithShift&utm_campaign=Sent%20with%20Shift%20Signature&utm_medium=Email%20Signature&utm_content=General%20Email%20Group>* On Tue, Apr 9, 2019 at 8:51 PM John wrote: > Hello maybe someone could help me, Im working on an example similar to the > DetailView f

Re: Generic display views / DetailView

2019-04-09 Thread Sithembewena L. Dube
tps://tryshift.com/?utm_source=SentWithShift&utm_campaign=Sent%20with%20Shift%20Signature&utm_medium=Email%20Signature&utm_content=General%20Email%20Group>* On Tue, Apr 9, 2019 at 8:51 PM John wrote: > Hello maybe someone could help me, Im working on an example similar to the >

Re: Using FormMixin with DetailView

2020-09-07 Thread Abdu-H
Hello, i realise this is a very old post, but i am trying to implement your code here, but it seems some code are missing, i was able to get a form, but the contents of my detailView isn't showing, what code am i suppose to put here " A view for displaying a single post ". yo

Re: Using FormMixin with DetailView

2020-09-13 Thread latu...@gmail.com
is is a very old post, but i am trying to implement > your code here, but it seems some code are missing, i was able to get a > form, but the contents of my detailView isn't showing, what code am i > suppose to put here " A view for displaying a single post ". your help wil

Restricting url access in DetailView

2019-12-05 Thread Thiago Luiz Parolin
I have a form that when submitted (using POST) results in a ListView page. Clicking on the record displayed by ListView opens a detail page (DetailView). The initial form has a captcha that is validated to access the ListView page, but by using the DetailView url I can access the records without

Re: ImportError cannot import name DetailView

2011-01-04 Thread Daniel Roseman
and > paste the code, rather than typing it as I usually do, just in case I > made a simple error I could not see. > > Exception Location: C:\DjangoProjects\mysite\polls\urls.py in > , line 2 > > Copy of line 2 of urls.py. from django.views.generic import > D

Re: ImportError cannot import name DetailView

2011-01-04 Thread Anthony Pearce
r I could not see. > > > Exception Location: C:\DjangoProjects\mysite\polls\urls.py in > > , line 2 > > > Copy of line 2 of urls.py. from django.views.generic import > > DetailView, ListView > > > Anyone have any ideas? > > You're using the docs for the dev

Don't understand regex-urls and DetailView...

2015-03-11 Thread inoyon artlover KLANGRAUSCH
gth=100, null=True, blank=True) slug = models.SlugField(unique=True, null=True, blank=True) my views.py class ProductView(DetailView): model = models.ShopList template_name = "product.html" and finally urls.py url(r'^(P?\w+)$', views.ProductView.as_view()), W

Class-Based_views | DetailView | send_email with attachments

2021-02-16 Thread Sachin KODAD
Hello Django Users, I need help with one of my views in Django DetailView. I want to send_mail from my HTML form (post method). Requrirement: 1. HTML Form (method=post) 2. Django DetailView (send_mail with attachments) *** I have already set up my send_mail and email config in setting.py

Help : Embedding pdf in Django detailview

2022-03-16 Thread Dexterr Jay
Hello guys, I'm developing a job board, and I want to display uploaded files in job detailview without downloading the file. When job seakers open a posted job I want the uploaded file from employer to be rendered in web browser -- You received this message because you are subscribed t

Re: Don't understand regex-urls and DetailView...

2015-03-11 Thread inoyon artlover KLANGRAUSCH
y models.py > > class ShopList(models.Model): > name = models.CharField(max_length=100, null=True, blank=True) > description = models.CharField(max_length=100, null=True, blank=True) > slug = models.SlugField(unique=True, null=True, blank=True) > > my views.py

How to set response headers in DetailView

2014-08-22 Thread Lucas Simon Rodrigues Magalhaes
Hello, I see this tutorial [1] to control the response header and caching of pages in django. So I'm trying to enable this response header in a generic class DetailView. I did a search and found this code [2] at the end of the page and also the source code [3] of View. But are confuse

Related records on same page with DetailView

2021-06-23 Thread David Crandell
pulls all the records from the entire table for every entry in the Category table. This seems like it should be so simple. I'm really starting to get discouraged here. This is my VIEW. Below are my models. class CatDetailView(DetailView): model = Category template_name = 'ohnet/c

Re: Help : Embedding pdf in Django detailview

2022-03-17 Thread RANGA BHARATH JINKA
Hi, Please try this. https://stackoverflow.com/questions/11779246/how-to-show-a-pdf-file-in-a-django-view On Thu, Mar 17, 2022 at 12:12 PM Dexterr Jay wrote: > Hello guys, I'm developing a job board, and I want to display uploaded > files in job detailview without downloading the f

Re: Help : Embedding pdf in Django detailview

2022-03-18 Thread Dexterr Jay
;> Hello guys, I'm developing a job board, and I want to display uploaded >> files in job detailview without downloading the file. >> When job seakers open a posted job I want the uploaded file from employer >> to be rendered in web browser >> >> -- >> You r

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

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

Proble understanding DetailView url doesn't match the slug

2015-02-13 Thread inoyon artlover KLANGRAUSCH
Hi there, there is something I obviously don't understand. According to django reference, the DetailView has to be provided a slug or pk. I do it in the url but django constantly doesn't recognize the slug in the url. 'current url doesn't match etc.' what is wrong here

Re: How to set response headers in DetailView

2014-08-22 Thread André Luiz
> I see this tutorial [1] to control the response header and caching of > pages in django. > > So I'm trying to enable this response header in a generic class > DetailView. I did a search and found this code [2] at the end of the page > and also the source code [3] of View. &

Re: How to set response headers in DetailView

2014-08-22 Thread Lucas Simon Rodrigues Magalhaes
after much research [1] managed to do this [2] in the ListView class. Now I apply the DetailView. [1] https://docs.djangoproject.com/en/dev/topics/conditional-view-processing/ [2] https://github.com/lucassimon/pywatch.com.br/blob/cache-techniques/screencasts/views.py#L75-L95 Em sexta-feira

what's the difference between TemplateView, ListView and DetailView ?

2018-09-23 Thread Gear Crew
I want to know when I use TemplateView , ListView and DetailView on my template code -- 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-user

what's the difference between TemplateView, ListView and DetailView ?

2018-09-23 Thread Mateusz
My answer was not fully on the topic. You shouldn't do what you want to do but if there's a real need for that... You can add context by overriding get_context() method. (context = super().get_context(); context['type'] = list; return context). {% if type == list %} This is a list {% elif type

DetailView only works with slug and primary key?

2019-01-02 Thread Osezele Orukpe
I would like to know if django DetailView can be used with other fields apart from slug and primary key? -- 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

Using ModelForm to get labels in a DetailView

2021-09-19 Thread bnmng
I don't know if this is good practice, but to get field labels in a DetailView, it seems to work fine if you just add a form to the context: views.py: class ItemDetailView(DetailView): model = Item context_object_name = "item" def get_context_data

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

2012-07-05 Thread Jon Black
I'm not sure without running it, which I can't do now. I have noticed that your slug is not and id, but the field PostSubReddit is a foerignkey which might expect an id. Unrelated, I think your models shouldn't be pluralised (e.g. Post instead of Posts). If you want the table name to be plural, us

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

2012-07-05 Thread Barry Morrison
Apologies, here is the error output if it helps. ValueError at /favs/Reddit/sysadmin/ invalid literal for int() with base 10: 'sysadmin' Request Method: GET Request URL: http://127.0.0.1:8000/favs/Reddit/sysadmin/ Django Version: 1.4 Exception Type: ValueError Exception Value: invalid

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

2012-07-05 Thread Jon Black
That doesn't help so much as there's no context information. Nice to see the 'sysadmin' bit which wasn't in your original post. Google throws up a lot of things for that: http://www.google.nl/search?q=invalid+literal+for+int%28%29+with+ base+10%3A+%27sysadmin -- Jon Black www.jonblack.org On Th

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

2012-07-05 Thread Jon Black
Hit send too soon then. My guess is that your kwargs being passed to filter() contains some suspect things. -- Jon Black www.jonblack.org On Thu, Jul 5, 2012, at 11:27, Jon Black wrote: That doesn't help so much as there's no context information. Nice to see the 'sysadmin' bit which wasn't in yo

properly passing form post data to get_context_data() in detailview

2013-06-04 Thread Greg Maruszeczka
Hi, I'm trying to process a form through a detailview that adds a comment to a blog post. Here's my view code: class PostDetailView(DetailView): model = Post template_name = 'blog_detail.html' queryset = Post.objects.filter(published=True) form_class = Commen

Re: Proble understanding DetailView url doesn't match the slug

2015-02-14 Thread Daniel Roseman
On Saturday, 14 February 2015 04:28:40 UTC, inoyon artlover KLANGRAUSCH wrote: > > > urlpatterns = patterns('', > url(r'^admin/', include(admin.site.urls)), > url(r'^(?P)$',List.as_view()), > ) > That regex will never match anything. You need to give it some character classes to match:

Re: Proble understanding DetailView url doesn't match the slug

2015-02-14 Thread Adailton (Dhelbegor)
models.py slug = models.SlugField(verbose_name='Slug', unique=True) @models.permalink def get_absolute_url(self): return ('myapp:List', (), {'slug': self.slug}) admin.py from .models import List01 class ArticleAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("name",)} admin.s

Re: Proble understanding DetailView url doesn't match the slug

2015-02-19 Thread inoyon artlover KLANGRAUSCH
Many thanks! Now I got it! :) Am Samstag, 14. Februar 2015 05:28:40 UTC+1 schrieb inoyon artlover KLANGRAUSCH: > > Hi there, there is something I obviously don't understand. According to > django reference, > the DetailView has to be provided a slug or pk. I do it in the

Re: Proble understanding DetailView url doesn't match the slug

2015-02-19 Thread 严超
LANGRAUSCH: >> >> Hi there, there is something I obviously don't understand. According to >> django reference, >> the DetailView has to be provided a slug or pk. I do it in the url but >> django constantly doesn't >> recognize the slug in the url. &#x

errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread Malik Rumi
File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 23, in url(r'^code/(?P)/', CodeDetailView.as_view(), name='family'), TypeError: 'function' object has no attribute '__getitem__' I understand that DetailView does not have _

Re: what's the difference between TemplateView, ListView and DetailView ?

2018-09-23 Thread Mateusz
bjects. Use it when you want to represent multiple objects from your database on a list (single template with multiple objects -- e.g. a list of products that are available in the shop or list of to-dos...). DetailView (docs <https://docs.djangoproject.com/pl/2.1/ref/class-based-views/generic

Re: DetailView only works with slug and primary key?

2019-01-02 Thread Andréas Kühne
Hi, The DetailView has a method "get_object" that you can override and use to return the object via any source you choose. You can also override the pk_url_kwarg or slug_url_kwarg properties on the DetailView to retrieve the information from the url in any way you want. Regards, And

Re: properly passing form post data to get_context_data() in detailview

2013-06-07 Thread Greg Maruszeczka
to be assigned and I found it in the inherited class' methods. Anyway, after some refactoring, trial-and-error and reading code I've revised the view to this: class PostDetailView(DetailView): template_name = 'blog_detail.html' context_object_name = 'post&#

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread James Schneider
On Fri, Feb 26, 2016 at 2:27 PM, Malik Rumi wrote: > File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 23, in > > url(r'^code/(?P)/', CodeDetailView.as_view(), name='family'), > TypeError: 'function' object has no attribute

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread Malik Rumi
> > > On Fri, Feb 26, 2016 at 2:27 PM, Malik Rumi > wrote: > >> File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 23, in >> >> url(r'^code/(?P)/', CodeDetailView.as_view(), name='family'), >> TypeError: 'fu

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread Malik Rumi
And here is the code from the original error: #!/usr/bin/python # -*- coding: utf-8 -*- from django.conf.urls import include, url, patterns from . import views from django.views.generic.base import TemplateView from essell.models import Code from essell.views import CodeListViewAll #from essell.vi

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread Malik Rumi
JAMES wrote: >>> Can you post the entire section for your urls.py, as well as the entire traceback? Nothing is immediately jumping out at me. Do you get this error when you start the Django server, or when you visit the page that matches this URL? *This error comes when I try to start the serv

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread Malik Rumi
*OK, so maybeMAYBE I've got this figured out. The problem is here:* https://docs.djangoproject.com/en/1.9/ref/urls/#django.conf.urls.url *I knew this, but note the examples still use the parens()* https://docs.djangoproject.com/en/1.9/ref/urls/#patterns *but that's what patterns is. It i

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-26 Thread James Schneider
On Feb 26, 2016 5:55 PM, "Malik Rumi" wrote: > > And here is the code from the original error: > > #!/usr/bin/python > # -*- coding: utf-8 -*- > from django.conf.urls import include, url, patterns > from . import views > from django.views.generic.base import TemplateView > from essell.models impor

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-27 Thread James Schneider
On Fri, Feb 26, 2016 at 6:38 PM, Malik Rumi wrote: > *OK, so maybeMAYBE I've got this figured out. The problem is here:* > > https://docs.djangoproject.com/en/1.9/ref/urls/#django.conf.urls.url > > > *I knew this, but note the examples still use the parens()* > > > https://docs.djangoproject.

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-27 Thread James Schneider
> > > urlpatterns = patterns(['', > > url(r'^$', TemplateView.as_view(template_name='library.html')), > > url(r'code/', > CodeDetail.as_view(template_name='code_family_detail')), > > You've got CodeDetail instead of CodeDetailView, is that correct? That's > not the class that you posted ear

Re: errors while trying to add extra context (detailview, __getitem__)

2016-02-27 Thread James Schneider
On Fri, Feb 26, 2016 at 6:04 PM, Malik Rumi wrote: > JAMES wrote: >>> Can you post the entire section for your urls.py, as > well as the entire traceback? Nothing is immediately jumping out at me. Do > you get this error when you start the Django server, or when you visit the > page that matches

Including DetailView context in ListView page in the Order history page using Django

2018-07-14 Thread Samir Tendulkar
https://stackoverflow.com/questions/51341215/including-detailview-context-in-listview-page-in-the-order-history-page-using-dj Hi Djangonauts, I would like to add some Order details(DetailView) in the Order history page(ListView), See image example below ( I have made the image on photoshop

Including DetailView context in ListView page in the Order history page using Django

2018-07-14 Thread Simon McConnell
item.product.image from your template points to nothing. Product is a CharField so I don't see it having any image attribute. Try to display some text for item.product or item.price and see how you go. -- You received this message because you are subscribed to the Google Groups "Django users"

Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-10 Thread Bernd Wechner
ike a dream. The ModelForm works a dream and on the edit link I can simply display the form by including {{ form }} in a generic template. What a beautifully fficient generic way of rendering quick test forms and such. Love it. Now I want to do same with a DetailView, i.e. render a page that

Re: Including DetailView context in ListView page in the Order history page using Django

2018-07-15 Thread Samir Tendulkar
Thanks I realized I made a mistake there. I changed the models to from Cjarfield to product = models.ForeignKey(Product, on_delete=models.CASCADE) Still stuck on the view On Sat, Jul 14, 2018 at 3:55 PM, Simon McConnell wrote: > item.product.image from your template points to nothing. Product i

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Bernd Wechner
mport force_text from django.forms.models import model_to_dict, fields_for_model class DetailViewWithHTML(DetailView): fields = None field_data = None def __init__(self, instance): self.fields = fields_for_model(self.model) self.field_data = model_to_dict(ins

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Mike Dewhirst
safestring importmark_safe fromdjango.utils.html importconditional_escape fromdjango.utils.encoding importforce_text fromdjango.forms.models importmodel_to_dict,fields_for_model classDetailViewWithHTML(DetailView):   fields =None   field_data =None   def__init__(self,instance):     s

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Bernd Wechner
Mike, Thanks. This was just a quick hack ripped off from ModelForm (although not as quick as I'd have liked as reverse engineering never is and had to read through ModelForm and get my head around bits) In any case wouldn't be ready for adding to Django as is, but others could improve it to mee

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Mike Dewhirst
On 13/08/2015 7:20 AM, Bernd Wechner wrote: Mike, Thanks. This was just a quick hack ripped off from ModelForm (although not as quick as I'd have liked as reverse engineering never is and had to read through ModelForm and get my head around bits) In any case wouldn't be ready for adding to Djang

Hello, everybody! I've tried using FormMixin with DetailView and I get error 405 on post method. Can anybody help me? Thanks a lot.

2019-08-22 Thread Catalina Popescu
views.py class BookDisplay(DetailView): model = Book template_name = 'books/book_detail.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['form'] = WishBookForm() return con

Re: Hello, everybody! I've tried using FormMixin with DetailView and I get error 405 on post method. Can anybody help me? Thanks a lot.

2019-08-22 Thread James Schneider
Post the full error message and/or traceback reported by the server when the error occurs. -James On Thu, Aug 22, 2019, 12:31 PM Catalina Popescu < catalina.t.pope...@gmail.com> wrote: > views.py > > class BookDisplay(DetailView): > model = Book > template_name = &#

Re: Hello, everybody! I've tried using FormMixin with DetailView and I get error 405 on post method. Can anybody help me? Thanks a lot.

2019-08-22 Thread Catalina Popescu
essage and/or traceback reported by the server when > the error occurs. > > -James > > On Thu, Aug 22, 2019, 12:31 PM Catalina Popescu > wrote: > >> views.py >> >> class BookDisplay(DetailView): >> model = Book >> template_name = 'books

Re: Hello, everybody! I've tried using FormMixin with DetailView and I get error 405 on post method. Can anybody help me? Thanks a lot.

2019-08-23 Thread Mehmet Demirkaya
> On Thu, Aug 22, 2019, 12:31 PM Catalina Popescu >> wrote: >> >>> views.py >>> >>> class BookDisplay(DetailView): >>> model = Book >>> template_name = 'books/book_detail.html' >>> >>> def get_context_

Re: Hello, everybody! I've tried using FormMixin with DetailView and I get error 405 on post method. Can anybody help me? Thanks a lot.

2019-08-23 Thread Catalina Popescu
0/ HTTP/1.1" 405.0 >> >> >> On Friday, August 23, 2019 at 12:28:27 AM UTC+3, James Schneider wrote: >> >>> Post the full error message and/or traceback reported by the server when >>> the error occurs. >>> >>> -James >>&g

  1   2   >