Re: Generic Views in Django Tutorial Not Working

2019-11-01 Thread Nijo Joseph
class IndexView(generic.ListView): template_name = 'polls/index.html' context_object_name = 'latest_question_list' def get_queryset(self): """Return the last five published questions.""" return Question.objects.order_by('-pub_date')[:5] the def get_queryset(self): f

Re: Generic Views in Django Tutorial Not Working

2019-11-01 Thread Kasper Laudrup
Hi Mike, On 01/11/2019 09.14, Mike Starr wrote: Hi! There's a lot of error message to copy and paste so please request what you would like to see specifically. I am at https://docs.djangoproject.com/en/2.2/intro/tutorial04/#use-generic-views-less-code-is-better in the Django tutorial and it se

Re: generic views empty args problem

2017-09-15 Thread Rafał Szymański
Does it help? return super(SampleUpdateView, self).get(request, project_name, *args, **kwargs) W dniu czwartek, 14 września 2017 13:25:06 UTC+2 użytkownik Adrian Jasiński napisał: > > > > When I have in my urlpatterns args and kwargs in any of generic views then > the view is loosing args (i

Re: Generic Views and Django.contrib.auth

2014-12-04 Thread Rootz
Thanks . It work using both the name and namespaces. On Thursday, December 4, 2014 8:45:27 AM UTC-5, Collin Anderson wrote: > > Hi, > > Not sure about namespaces, but you can certainly use name: > > urlpatterns = patterns('', > url(r'^about/', login_required(AboutView.as_view()), name='about')

Re: Generic Views and Django.contrib.auth

2014-12-04 Thread Collin Anderson
Hi, Not sure about namespaces, but you can certainly use name: urlpatterns = patterns('', url(r'^about/', login_required(AboutView.as_view()), name='about'), ) Or better yet, patterns() is deprecated so: urlpatterns = [ url(r'^about/', login_required(AboutView.as_view()), name='about'),

Re: Generic Views and Django.contrib.auth

2014-12-03 Thread Rootz
URL Reversing the view where login is required. On Tuesday, December 2, 2014 10:05:35 PM UTC-5, Collin Anderson wrote: > > Hi, > > It's probably possible. Do you mean url reversing the login view, or url > reversing the view where login is required? > > Collin > > On Sunday, November 30, 2014 11:

Re: Generic Views and Django.contrib.auth

2014-12-03 Thread Rootz
Yes On Tuesday, December 2, 2014 10:05:35 PM UTC-5, Collin Anderson wrote: > > Hi, > > It's probably possible. Do you mean url reversing the login view, or url > reversing the view where login is required? > > Collin > > On Sunday, November 30, 2014 11:07:42 PM UTC-5, Rootz wrote: >> >> Hi can th

Re: Generic Views and Django.contrib.auth

2014-12-03 Thread Marcus Cl
yes On Tue, Dec 2, 2014 at 10:05 PM, Collin Anderson wrote: > Hi, > > It's probably possible. Do you mean url reversing the login view, or url > reversing the view where login is required? > > Collin > > On Sunday, November 30, 2014 11:07:42 PM UTC-5, Rootz wrote: >> >> Hi can this work with url

Re: Generic Views and Django.contrib.auth

2014-12-02 Thread Collin Anderson
Hi, It's probably possible. Do you mean url reversing the login view, or url reversing the view where login is required? Collin On Sunday, November 30, 2014 11:07:42 PM UTC-5, Rootz wrote: > > Hi can this work with url reversing namespaced urls? > thanks > > On Thursday, October 16, 2014 11:54:

Re: Generic Views and Django.contrib.auth

2014-11-30 Thread Rootz
Hi can this work with url reversing namespaced urls? thanks On Thursday, October 16, 2014 11:54:45 AM UTC-5, Vijay Khemlani wrote: > > If you are usign class based generic views you can use the decorators in > the URL config of your app, for example > > urlpatterns = patterns('', > (r'^about/

Re: Generic Views and Django.contrib.auth

2014-10-19 Thread Rootz
Thanks. On Thursday, October 16, 2014 11:54:45 AM UTC-5, Vijay Khemlani wrote: > > If you are usign class based generic views you can use the decorators in > the URL config of your app, for example > > urlpatterns = patterns('', > (r'^about/', login_required(AboutView.as_view())), > ) > > > O

Re: Generic Views and Django.contrib.auth

2014-10-16 Thread Vijay Khemlani
If you are usign class based generic views you can use the decorators in the URL config of your app, for example urlpatterns = patterns('', (r'^about/', login_required(AboutView.as_view())), ) On Thu, Oct 16, 2014 at 12:49 PM, Rootz wrote: > Can I use both Generic View and the Django.contr

Re: Generic views and url issues

2013-01-24 Thread amy . cerrito
Updating my template code to use namespace:url_name did it! list url: List of all ad calls detail url: Thanks again for everyone's feedback! On Thursday, January 24, 2013 10:07:14 AM UTC-5, Tom Christie wrote: > > Hi Amy, > > I'd suggest you check the following... > > * Your > ROOT_URLCO

Re: Generic views and url issues

2013-01-24 Thread Tom Christie
Hi Amy, I'd suggest you check the following... * Your ROOT_URLCONFsetting is correct. * If the `urls.py` module you're referring to here is a project URL conf and not the root URL conf, make sure that it is being included by the

Re: Generic views and url issues

2013-01-24 Thread Bill Freeman
Have you tried it without the quotes around 'detail' in the url template tag invocation? If I'm remembering correctly, the need for the quotes depends on django version and options. Bill On Thu, Jan 24, 2013 at 9:01 AM, Amy Cerrito wrote: > Thanks for your response! > > Unfortunately, your sug

Re: Generic views and url issues

2013-01-24 Thread Amy Cerrito
Thanks for your response! Unfortunately, your suggestion did not eliminate the NoReverseMatch error. NoReverseMatch at /testadcall/ Reverse for 'detail' with arguments '()' and keyword arguments '{'object_id': 1}' not found. I have another example where I request the list view, which does not

Re: Generic views and url issues

2013-01-23 Thread mgc_django-users
On 24/01/2013 10:39 AM, amy.cerr...@cbsinteractive.com wrote: I've been trying to understand how to use generic views. I've followed some tutorials, and read through Django docs, but I can't get the url function to work in my templates. I get the error NoReverseMatch at /testadcall/ Reverse f

Re: Generic views and url issues

2013-01-23 Thread Sanjay Bhangar
(reply inline) On Thu, Jan 24, 2013 at 5:09 AM, wrote: > I've been trying to understand how to use generic views. I've followed some > tutorials, and read through Django docs, but I can't get the url function to > work in my templates. > > I get the error > NoReverseMatch at /testadcall/ > > Re

Re: Generic views and url issues

2013-01-23 Thread Sergiy Khohlov
try to check testaddcall/1/ please Many thanks, Serge +380 636150445 skype: skhohlov 2013/1/24 : > I've been trying to understand how to use generic views. I've followed some > tutorials, and read through Django docs, but I can't get the url function to > work in my templates. > > I get the

Re: Generic views create_object and prefill form data?

2012-05-23 Thread Andre Terra
Subject: Re: Generic views create_object and prefill form data? To: Django users Solved it by migrating to the class based generic views, then fed initial form data to the constructor of the form by overloading get_initial on the view class. Paul -- You received this message because you are

Re: Generic views create_object and prefill form data?

2012-05-23 Thread Paul
Solved it by migrating to the class based generic views, then fed initial form data to the constructor of the form by overloading get_initial on the view class. Paul -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

Re: Generic Views with flair?

2012-05-09 Thread sbrandt
There is another way: Class Based View decorators: http://djangosnippets.org/snippets/2668/ -- 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

Re: Generic Views with flair?

2012-05-07 Thread Daniel Sokolowski
For your first question you can: url(r'^people/$', login_required(ListView.as_view( queryset=Person.objects.all(, or in your view decorate the dispatch method: @method_decorator(login_required) def dispatch(self, *args, **kwargs): return super(ProtectedView, self

Re: Generic views parameter 'extra_context' didn't use form class?

2011-12-23 Thread Andre Terra
You've defined a class named *DevSrcForm* and you're calling super on *DevForm*. Since you haven't provided a full traceback or even the code from DevForm, I can't exactly explain what's going on. "Anything can happen" pretty much sums it up. Cheers, AT 2011/12/23 郁夫 > hi, I use a form class

Re: Generic views v.s. shortcuts

2011-03-23 Thread Andre Terra
Hello Kevin, Generic Views are much more powerful than simple shortcut functions. With a generic view, you can easily display a queryset, or details about a queryset item without writing much code. Shortcut functions only make the _call_ to rendering easier and lack the ability to "automagically"

Re: Generic views v.s. shortcuts

2011-03-23 Thread Kevin Renskers
Hi Andre, Well, it would be much easier if get_context_data only needs to return a dictionary. Guess I'll build my own class for that :) But apart from that, my real question is why there are generic views *and* shortcut functions. Which is recommended in which case? Cheers, Kevin -- You re

Re: Generic views v.s. shortcuts

2011-03-23 Thread Andre Terra
The rationale behind class-based views is that they are meant to be reused. While all of the listed approaches work, CBVs have greater functionality and modularity. It might seem like more code at first, but the possibility of using Mixins and overriding just bits and pieces of other views you have

Re: Generic views

2011-01-11 Thread Dorival Ben Molinari Martinez
Thank you. I am reading the tutorial 'Django - writing your first app'. version 1.2. 2011/1/11 Piotr Zalewa > On 01/11/11 14:02, martinez wrote: > > I would like to know if I could work without generic views. > > > Sure you can - simply define your own in [application]/views.py > > Please read t

Re: Generic views

2011-01-11 Thread Marc Aymerich
On Tue, Jan 11, 2011 at 3:02 PM, martinez wrote: > I would like to know if I could work without generic views. > > This issue was discussed in this list a couple months ago: http://groups.google.com/group/django-users/browse_thread/thread/a67d36c94efc2d3f/9cd7c5299ac74f13 -- Marc -- You rec

Re: Generic views

2011-01-11 Thread Piotr Zalewa
On 01/11/11 14:02, martinez wrote: > I would like to know if I could work without generic views. > Sure you can - simply define your own in [application]/views.py Please read the doc http://docs.djangoproject.com/en/1.2/#the-view-layer zalun -- blog http://piotr.zalewa.info jobs http://webdev

Re: Generic Views - do you use them?

2010-12-11 Thread Rainy
On Dec 10, 5:22 pm, Łukasz Rekucki wrote: > > On Fri, Dec 10, 2010 at 9:37 AM, Rainy wrote: > > >> Is there a doc somewhere that details what the limitations are? How > >> do you tell if some task is definitely too much for new generic views? > >> I'm not using 1.3 yet and generally what I've b

Re: Generic Views - do you use them?

2010-12-10 Thread R. Ted Tieken
>> Class based generic views still have the major drawbacks of the >> previous version.  They are a more powerful, more complicated version, >> but they're still a red-herring. > > Can you elaborate on this ? Taking your original concerns: Sure. First of all, I'm not opposed to class based views,

Re: Generic Views - do you use them?

2010-12-10 Thread Łukasz Rekucki
On 10 December 2010 22:47, Ted Tieken wrote: > Class based generic views still have the major drawbacks of the > previous version.  They are a more powerful, more complicated version, > but they're still a red-herring. Can you elaborate on this ? Taking your original concerns: > My biggest compl

Re: Generic Views - do you use them?

2010-12-10 Thread Ted Tieken
Class based generic views still have the major drawbacks of the previous version. They are a more powerful, more complicated version, but they're still a red-herring. Ted On Fri, Dec 10, 2010 at 9:37 AM, Rainy wrote: > On Dec 10, 4:04 am, Łukasz Rekucki wrote: >> You should try the new class-

Re: Generic Views - do you use them?

2010-12-10 Thread Rainy
On Dec 10, 4:04 am, Łukasz Rekucki wrote: > You should try the new class-based generic > views:http://docs.djangoproject.com/en/dev/topics/class-based-views/ > > They're much more flexible. Is there a doc somewhere that details what the limitations are? How do you tell if some task is definitel

Re: Generic Views - do you use them?

2010-12-10 Thread Łukasz Rekucki
You should try the new class-based generic views: http://docs.djangoproject.com/en/dev/topics/class-based-views/ They're much more flexible. On 10 December 2010 02:44, Rainy wrote: > On Nov 8, 6:42 pm, Ted wrote: >> What are their pros and cons?  How often do you use them when you're >> coding?

Re: Generic Views - do you use them?

2010-12-09 Thread Rainy
On Nov 8, 6:42 pm, Ted wrote: > What are their pros and cons?  How often do you use them when you're > coding? > > The more I code in django the less I find generic views to be useful > shortcuts (direct to template being the exception). > > My biggest complaints are: > * You don't end up saving m

Re: generic views template problem

2010-11-29 Thread Daniel Roseman
On Nov 29, 7:08 pm, Carlos Aboim wrote: > Guys, > Someone can tell me what is happening with my generic > views? > > I have the templates in my application folder 'templates' in the root > my project. > This folder is referenced in settings such as: > TEMPLATE_DIRS = ( >     os.path.join (PROJECT_

Re: Generic Views - do you use them?

2010-11-11 Thread Shawn Milochik
On Wed, Nov 10, 2010 at 4:35 AM, derek wrote: > I have not really understood when and why they are needed; I would be > interested to see an alternative also because it might improve my > understanding. > I've never used them before, and always avoided looking into them because I thought they wer

Re: Generic Views - do you use them?

2010-11-10 Thread SivaTumma
Every Framework is so difficult to understand that it is better to "code by own" the functionality provided by them. We would have better control + peace of mind. Frameworks unnecessarily bring hassle, irritation for a programmer. -- You received this message because you are subscribed to the Goo

Re: Generic Views - do you use them?

2010-11-10 Thread derek
I have not really understood when and why they are needed; I would be interested to see an alternative also because it might improve my understanding. On Nov 9, 3:27 pm, ringemup wrote: > I don't use them either for much the same reasons, and because I often > end up using custom render_to_respon

Re: Generic Views - do you use them?

2010-11-09 Thread ringemup
I don't use them either for much the same reasons, and because I often end up using custom render_to_response shortcuts that set common context or handle custom template loading. Although the new class- based views may make them more customizable. I don't see much need for an alternative, though

Re: Generic views & summary in the side bar

2010-06-10 Thread tsmets
Most combinations around the following syntax did not seem to have worked : [code] latest_news_nbr = { "queryset" : News.objects.all().count(), "template_object_name" : "latest_news_nbr", "extra_context" : {"latest_news_nbr" : News.objects.all().count()} } [/code] ... what I meant wit

Re: Generic views & summary in the side bar

2010-06-10 Thread Venkatraman S
On Thu, Jun 10, 2010 at 3:32 PM, tsmets wrote: > I thought I could use the generic views to fill the side bars with > summary data. > > Not sure what you mean - pass the vars to the template and use them accordingly wherever you want. IMHO, django doesnt know whether something is in the sidebar o

Re: generic views vs writing my own

2009-10-30 Thread bruno desthuilliers
On 29 oct, 17:51, Ross wrote: > For which cases would a user wish to write their own views rather than > using generic views? I'd rather formulate this the other way round : for which cases would you use generic views rather than your own ? And the answer is obvious : whenever your view ends u

Re: generic views 404 error

2009-10-27 Thread Brian McKeever
More info is needed. Could you post your urls? On Oct 25, 8:39 pm, Ross wrote: > I just neared the end of the poll application and converted everything > to generic views according to the tutorial. Once I started up the > server though, I could only find my admin page. I tried using the > newly

Re: generic views - please bring me to the point

2009-08-07 Thread aschmid
i got it!! the app was not in the pythonpath... :) On Aug 7, 3:00 pm, andreas schmid wrote: > hi all, > > im really going crazy now i cant figure out where the code is wrong... > i have a really simple model: > > from django.db import models > import datetime > >     class Post(models.Model): >

Re: Generic views problem

2009-07-07 Thread Owen Jeremiah
9 06:44:09 To: Django users Subject: Re: Generic views problem Do you have any Poll objects in the database? If not, add some using the admin interface. Assuming you do however, can we see your index view function? The one from step 3 of the tutorial under "Write views that actual

Re: Generic views problem

2009-07-07 Thread Andrew Fong
Do you have any Poll objects in the database? If not, add some using the admin interface. Assuming you do however, can we see your index view function? The one from step 3 of the tutorial under "Write views that actually do something". -- Andrew On Jul 7, 6:39 am, "Owen Jeremiah" wrote: > I'm

Re: Generic Views vs. Admin

2009-06-11 Thread phoebebright
Jashugan, I agree that generic views for non-admins make sense, just be nice to be able to say body_html = auto_generate(model, list/display/update etc.) or whatever admin is doing and stick that in a generic template. {% extends 'base.html' %} {% block main %} {{body_html}} {% endblock %}

Re: Generic Views vs. Admin

2009-06-11 Thread Jashugan
On Jun 11, 8:03 am, phoebebright wrote: > I have spent a good deal time researching this online and in this > group but can find no clear answer. I think the reason why is that it depends on what you want to do. > My instinct is that I should use the former, but do I really have to > go and wri

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread fabio natali
Ivan Sagalaev wrote: > fabio natali wrote: > > For the sake of clarity, my django project is named arteak, the models > > we are using belong to an app called "management". > > Ah! Then there should of course be get_model('management', > kwargs.pop('model')). I thought 'arteak' was the name of t

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: > For the sake of clarity, my django project is named arteak, the models > we are using belong to an app called "management". Ah! Then there should of course be get_model('management', kwargs.pop('model')). I thought 'arteak' was the name of the app. This is why it returns N

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread fabio natali
Dear Ivan, it sounds like we are closer to the solution, still not got it though. Ivan Sagalaev wrote: [...] > > http://dpaste.com/72639/ > > Oy! I've found it :-). It has nothing to do with model_view decorator or > anything that we're talking here about. It's in urls.py, on line 30: > >

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: > That's right! So here comes my current urls.py: > > http://dpaste.com/72638/ > > then the traceback I get at http://localhost:8000/: > > http://dpaste.com/72639/ Oy! I've found it :-). It has nothing to do with model_view decorator or anything that we're talking here abo

Re: Generic views list_detail

2008-08-20 Thread [EMAIL PROTECTED]
Thanks for the help Daniel. I think I'm making some progress now :-) --~--~-~--~~~---~--~~ 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 unsubsc

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread fabio natali
Hi Ivan! Ivan Sagalaev wrote: [...] > fabio natali wrote: > > I added the line > > > > import arteak.management.models > > It's not the same thing :-). This line won't load the name "models" into > your local environment. If you want import from some path this should be: > > from a

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: >> import models > > I added the line > > import arteak.management.models It's not the same thing :-). This line won't load the name "models" into your local environment. If you want import from some path this should be: from arteak.management import models

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread fabio natali
Ivan Sagalaev wrote: [...] > fabio natali wrote: > > KeyError at /manufacturer > > u'manufacturer' > > when accessing http://localhost:8000/manufacturer > > KeyError says that it can't find a key 'manufacturer' in dict > model_classes. This leads me to think that model_classes is empty. It > ca

Re: Generic Views and ModelAdmin: too much code?

2008-08-19 Thread Ivan Sagalaev
fabio natali wrote: > This is the urls.py I created: http://dpaste.com/72138/ > It doesn't work though: I get a > KeyError at /manufacturer > u'manufacturer' > when accessing http://localhost:8000/manufacturer > (manufacturer being one of my model) KeyError says that it can't find a key 'manufact

Re: Generic views list_detail

2008-08-19 Thread Daniel Roseman
On Aug 19, 11:59 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Daniel, > > I am working my way > throughhttp://www.djangoproject.com/documentation/db-api/#related-objects > at the moment trying to get a better grasp on how django handles SQL > relationships. > > The way I got the above cod

Re: Generic views list_detail

2008-08-19 Thread [EMAIL PROTECTED]
Found the solution to: {% for taskUpdate in object.taskUpdate_set.all %} {{ taskUpdate.comment }} {% endfor %} Djando lowercases model names when used in templates. But still I had to call it object.taskupdate_set.all and not task.taskupdate.set_all --~--~-~--~~~-

Re: Generic views list_detail

2008-08-19 Thread [EMAIL PROTECTED]
Daniel, I am working my way through http://www.djangoproject.com/documentation/db-api/#related-objects at the moment trying to get a better grasp on how django handles SQL relationships. The way I got the above code to work was (following your suggestion): {% for task in object.task_set.all %}

Re: Generic views list_detail

2008-08-19 Thread Daniel Roseman
On Aug 19, 9:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Daniel, > > Thank you for your reply. > > Following your advice I tried the following: > > task is the model that relates to project. > > > {% for task in project.task.all %} > {{ task.title }} > {% endfor %} > > > It doesn't s

Re: Generic views list_detail

2008-08-19 Thread [EMAIL PROTECTED]
My mistake, I must have made a typo as it is now working perfectly. Thanks Daniel! --~--~-~--~~~---~--~~ 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.

Re: Generic views list_detail

2008-08-19 Thread [EMAIL PROTECTED]
Daniel, Thank you for your reply. Following your advice I tried the following: task is the model that relates to project. {% for task in project.task.all %} {{ task.title }} {% endfor %} It doesn't show anything so I think I'm confusing my models. Am I missing something obvious ? I am only

Re: Generic views list_detail

2008-08-19 Thread Daniel Roseman
On Aug 19, 7:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > My urls.py looks like this: > > project_info = { >     "queryset" : project.objects.all(), > > } > > (r'^project/(?P[-\w]+)/', > login_required(list_detail.object_detail), dict(project_info, > slug_field='slug')), > > Projects ha

Re: Generic Views and ModelAdmin: too much code?

2008-08-18 Thread fabio natali
Dear Ivan, your help is priceless, thanks! Ivan Sagalaev wrote: [...] > In models.py you can get rid of repeating "Manufacturer" two extra times > by doing: > > class Manufacturer(models.Model): > name = models.CharField(max_length=30) > address = models.CharField(max_len

Re: Generic views and user's objects

2008-04-21 Thread picky
No idea ? Can't I use generic view in this case ? :-/ On 18 avr, 00:11, picky <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to usegenericview in my app and I have some problems with > objects related to the logged user. > > Here is a simplified version of my models : > > class Animal(models.

Re: Generic views and update

2008-04-09 Thread picky
I found it with follow argument : http://groups.google.fr/group/django-users/browse_thread/thread/e168a85cdd7cc405/df8ad70ae9dfc904?hl=fr&lnk=gst&q=update+generic+view#df8ad70ae9dfc904 On 9 avr, 19:27, picky <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to django and I'm looking how to use gener

Re: generic views - newforms

2008-03-30 Thread sector119
When you will read Michael's links on documentation you can use generic views on newforms: http://217.196.165.10/create_update.txt They have create and update preview support also, just use preview=True option. And object_delete can use id's like '1/2/3/4/5/10/128' to use url's like /people/person

Re: generic views - newforms

2008-03-30 Thread Michael
They are two very different animals really. Generic views work as a way to cut code from your views code (the code that creates the httpresponse, between the url handling and the template rendering). Newforms is the way that Django creates and handles forms. You will generally need to use a new f

Re: Generic Views: Variable Table Columns

2008-03-07 Thread Justin Fagnani
Coincidentally, this was just brought up in the django-dev list. I have a simple filter to do this that uses the template variable lookup functionality so that it behaves the same, including silent failure. from django.template import resolve_variable def lookup(value, key): return resolve_variabl

Re: Generic Views: Variable Table Columns

2008-03-05 Thread Darryl Ross
Just to follow up for the archives. What I was after is a getattr filter for the templates. Searching djangosnippets.org has found a couple. This one seems to do what I need: http://www.djangosnippets.org/snippets/411/ Regards Darryl Darryl Ross wrote: Hey All, I'm using the generic views

Re: generic views

2008-02-05 Thread LMZ
do it like this: return object_list( request, **CATEGORY_DETAIL ) read about this: http://docs.python.org/tut/node6.html#SECTION00672 concrete for this example: >>> def parrot(voltage, state='a stiff', action='voom'): ... print "-- This parrot wouldn't", action, ... pri

Re: generic views

2008-01-14 Thread Chris
Thanks so much for your help. Can I pass in the whole dictionary as you do in your example? When I attempt to do that I get this error. dict' object has no attribute '_clone'. Alternatively I can simpley pass in the individual variables suchas queryset and it works. I would like to pass it in as

Re: generic views

2008-01-14 Thread Alex Koshelev
If you want to apply additional filtering for query set with parameter that has catched from url so you have to "inherit" generic view with your own. Example for your case: #views.py from django.views.generic.list_detail import object_list def my_view( request, tag_category ): CATEGORY_DETAI

Re: generic views

2008-01-14 Thread Christos Τrochalakis
2008/1/14 Chris <[EMAIL PROTECTED]>: > > I still get that error. Just forgot to add in the details variable > when I dpasted. http://dpaste.com/31049/ but I still get the same > error that I was talking about. Should I put the details dictionary > definition below the urlpattern so that maybe the

Re: generic views

2008-01-14 Thread Chris
I still get that error. Just forgot to add in the details variable when I dpasted. http://dpaste.com/31049/ but I still get the same error that I was talking about. Should I put the details dictionary definition below the urlpattern so that maybe the variable is defined before I get to that point

Re: generic views

2008-01-14 Thread Alex Koshelev
You must specify details in pattern definitian http://www.djangoproject.com/documentation/generic_views/ On 14 янв, 20:08, Chris <[EMAIL PROTECTED]> wrote: > Hello I am working with a generic view and I am trying to grab the url > expression variable and pass it to a dictionary for the generic vi

Re: generic views and form templates

2007-11-21 Thread Martin
hi, michael thanks for the help.. i've tried this but it still doesn't work. i'm doing something wrong, but i don't know what. if i remove save(), object still gets created, just without slug. my question here is: does slug field needs to have blank=True? when that is set, object gets created, wi

Re: generic views and form templates

2007-11-21 Thread Michael
Hi Martin, On Nov 22, 7:59 am, Martin <[EMAIL PROTECTED]> wrote: > i wrote this at the end of my model (for which, slug must be created > after user creates it): > > def save(self): > if not self.id: > self.slug = title.slugify() > super(Kom

Re: generic views and form templates

2007-11-21 Thread Martin
btw, after this change, object gets created, but the slug field is empty.. so i can't view the object, because of (r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(? P[-\w]+)/$',object_detail, dict(komentar_date_dict, slug_field='slug')) thanks, martin --~--~-~--~~~---

Re: generic views and form templates

2007-11-21 Thread Martin
Thanks a lot, guys! i'm pretty new to django and i really didn't want to use newforms in my app. but RajeshD's idea is pretty cool. it just seems that i don't know how to use slugify().. if you have just a little more time, please help me for a minute: i wrote this at the end of my model (for w

Re: generic views and form templates

2007-11-21 Thread Michael
Hi Martin, Looking at your url conf above, I'm thinking that you're not currently using a form for your templates? I'd create a form (newform) for your model and then use this to ensure that entry of the slug field is not required [1] by the user when creating a post, and then update your form's

Re: generic views and form templates

2007-11-21 Thread RajeshD
> that work ok, when a user want to create an entry it opens > komentar_form.html and it's displayed right. but when user clicks > submit, it always returns a error for slug field. since user doesn't > write slug field (should be prepopulated, right?), No. That only happens in the admin and even

Re: generic views and form templates

2007-11-21 Thread Martin
ok, i'll rephrase this all.. i'm using django.views.generic.create_update.create_object to create an object, which has a slug field. i wrote custom template for creating objects. everytime i want to create an object i get an error, that the object with this title (or slug) already exists in my db

Re: generic views

2007-10-22 Thread jake elliott
On Mon, 2007-10-22 at 14:12 -0500, jake elliott wrote: > this is probably another really simple view. you can use > HttpResponseRedirect - or if you really want to end up using a generic > view remember that you can call them within your own views also. > > # views.py > from django.views.generi

Re: generic views

2007-10-22 Thread jake elliott
hi bernd, On Mon, 2007-10-22 at 18:40 +0200, Bernd wrote: > I want to use a generic view with an url that had a parameter. This > parameter should filter my queryset. > How does this work? I don't now what to write in the filter-option? > - > e = { > 'template': 'foo.html

Re: generic views

2007-10-11 Thread Marty Alchin
On 10/11/07, jake elliott <[EMAIL PROTECTED]> wrote: > > Marty Alchin wrote: > > You'd replace "what goes here" with what you put in > > "template_object_name": "author" (only without the quotes). Of course, > > it'd be a little more readable if you use the plural "authors", since > > you're getti

Re: generic views

2007-10-11 Thread Gigs_
yes i figure out that after marty replay On Oct 11, 10:01 pm, jake elliott <[EMAIL PROTECTED]> wrote: > Marty Alchin wrote: > > You'd replace "what goes here" with what you put in > > "template_object_name": "author" (only without the quotes). Of course, > > it'd be a little more readable if you

Re: generic views

2007-10-11 Thread jake elliott
Marty Alchin wrote: > You'd replace "what goes here" with what you put in > "template_object_name": "author" (only without the quotes). Of course, > it'd be a little more readable if you use the plural "authors", since > you're getting a list of more than one author. actually you'll use "author_l

Re: generic views

2007-10-11 Thread Gigs_
yes i know. this is just for learning. thanks On Oct 11, 8:06 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > You'd replace "what goes here" with what you put in > "template_object_name": "author" (only without the quotes). Of course, > it'd be a little more readable if you use the plural "autho

Re: generic views

2007-10-11 Thread Marty Alchin
You'd replace "what goes here" with what you put in "template_object_name": "author" (only without the quotes). Of course, it'd be a little more readable if you use the plural "authors", since you're getting a list of more than one author. -Gul --~--~-~--~~~---~--~---

Re: generic views

2007-10-11 Thread Gigs_
and here is urls from myapp from django.conf.urls.defaults import * from django.views.generic import list_detail, date_based, create_update from books.models import Publisher, Author, Book author_list_info = { 'queryset':Author.objects.all(), "template_object_name" : "author", "extra

Re: generic views

2007-10-11 Thread Gigs_
so if this is my template for that list my template my books app {% for name in "what goes here" %} {{ name }} {% endfor %} On Oct 11, 7:47 pm, Gigs_ <[EMAIL PROTECTED]> wrote: > so i cant get list from models? > from Author.objects.all() > > On Oct 11, 4:03 pm, Alex Koshelev <[EMAIL PRO

Re: generic views

2007-10-11 Thread Gigs_
so i cant get list from models? from Author.objects.all() On Oct 11, 4:03 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > the list you want to use in template must be in template context. use > "extra_context" value > > On 11 окт, 17:31, Gigs_ <[EMAIL PROTECTED]> wrote: > > > hi all > > > im learn

Re: generic views

2007-10-11 Thread Alex Koshelev
the list you want to use in template must be in template context. use "extra_context" value On 11 окт, 17:31, Gigs_ <[EMAIL PROTECTED]> wrote: > hi all > > im learning django with djangobook.com > im stuck in chapter 9 at Lists of objects. > i just cant get any list of objects in my template. > >

Re: Generic/Views implementation decision

2007-10-03 Thread Panos Laganakos
Thanks for the answer Lemuel :) I added a get_images method in the (example) Toy model, which returns a list of the pictures related to it. Which basically just wraps things up: def get_images(self): images = self.toypicture_set.all() return images Doing a select_related, sounds more ef

Re: Generic/Views implementation decision

2007-10-02 Thread Lemuel Formacil
On Sep 29, 2007, at 6:14 PM, Panos Laganakos wrote: > > > On Sep 28, 12:18 pm, Panos Laganakos <[EMAIL PROTECTED]> > wrote: >> Having two different models, ie: Toy, ToyPicture. >> >> ToyPicture, has a ForeignKey to Toy, so you can define many pictures, >> that relate to a specific toy. >> >> The

  1   2   >