Re: App-structure: how to have a bunch of data in all the pages.

2013-02-05 Thread serkan sokmen
# I use mixins in a project where i need to show a list of Collection
objects in both list and detail views,
# maybe this method would help you if you are using generic class-based
views?

class CollectionSidebarMixin(object):
# Add collections to the context
def get_context_data(self, **kwargs):
context = super(CollectionSidebarMixin,
self).get_context_data(**kwargs)
context['collections'] = Collection.objects.all()
return context

# and you can use the mixin for list and detail views:
class CollectionList(CollectionSidebarMixin, ListView):
model = Collection
context_object_name = 'collections'

class CollectionDetail(CollectionSidebarMixin, DetailView):
model = Collection
context_object_name = 'current_collection'


On Tue, Feb 5, 2013 at 2:12 PM, Jonas Geiregat  wrote:

> On Tue, Feb 05, 2013 at 02:06:28AM -0800, Stefano Tranquillini wrote:
> > Now, i can create a base.html template where i render the data. but, how
> > should i do the population of these lists?
> > Should i create a middleware that for each request populates the lists?
> > or what?
> I think that a Context Processor will be a better option.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
*E. Serkan Sökmen*
Django / Front-end Developer @Teknolab 
Personal works: serkansokmen.com 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: NoReverseMatch at /my_account/

2013-02-05 Thread serkan sokmen
Yeah, i did the same once -)

On Tue, Feb 5, 2013 at 1:07 AM, frocco  wrote:

> Thank you, I can't tell you how long I struggled with this.
>
> On Monday, February 4, 2013 1:48:37 PM UTC-5, frocco wrote:
>>
>> I am getting NoReverseMatch at /my_account/
>> what is wrong with my urls?
>> Thanks
>>
>>
>> Reverse for 'order_info' with arguments '()' and keyword arguments '{}' not 
>> found.
>>
>>
>> main urls.py
>>
>> (r'^my_account/$', include('accounts.urls')),
>>
>>
>> accounts/urls.py
>>
>> urlpatterns = patterns('accounts.views',
>> (r'^$', 'my_account',
>>  {'template_name': 'registration/my_account.html'**}, 'my_account'),
>> (r'^order_info/$', 'order_info',
>>  {'template_name': 'registration/order_info.html'**}, 'order_info'),
>>  (r'^register/$', 'register',
>>  {'template_name': 'registration/register.html', 'SSL': 
>> settings.ENABLE_SSL }, 'register'),
>> (r'^order_info/$', 'order_info',
>>  {'template_name': 'registration/order_info.html'**}, 'order_info'),
>>  (r'^order_details/(?P[-\w]+)/$', 'order_details',
>>  {'template_name': 'registration/order_details.**html'}, 
>> 'order_details'),
>> )
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
*E. Serkan Sökmen*
Django / Front-end Developer @Teknolab 
Personal works: serkansokmen.com 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: NoReverseMatch at /my_account/

2013-02-04 Thread serkan sokmen
(r'^my_account/$', include('accounts.urls')),

here you should remove the $ sign because it closes the expression there;
if you want my_account/blahblah like urls, you shouldn't use the dollar
sign like:

(r'^my_account/', include('accounts.urls')),


On Mon, Feb 4, 2013 at 8:49 PM, frocco  wrote:

> My template has Edit Billing/Shipping
> Information
>
>
> On Monday, February 4, 2013 1:48:37 PM UTC-5, frocco wrote:
>>
>> I am getting NoReverseMatch at /my_account/
>> what is wrong with my urls?
>> Thanks
>>
>>
>> Reverse for 'order_info' with arguments '()' and keyword arguments '{}' not 
>> found.
>>
>>
>> main urls.py
>>
>> (r'^my_account/$', include('accounts.urls')),
>>
>>
>> accounts/urls.py
>>
>> urlpatterns = patterns('accounts.views',
>> (r'^$', 'my_account',
>>  {'template_name': 'registration/my_account.html'**}, 'my_account'),
>> (r'^order_info/$', 'order_info',
>>  {'template_name': 'registration/order_info.html'**}, 'order_info'),
>>  (r'^register/$', 'register',
>>  {'template_name': 'registration/register.html', 'SSL': 
>> settings.ENABLE_SSL }, 'register'),
>> (r'^order_info/$', 'order_info',
>>  {'template_name': 'registration/order_info.html'**}, 'order_info'),
>>  (r'^order_details/(?P[-\w]+)/$', 'order_details',
>>  {'template_name': 'registration/order_details.**html'}, 
>> 'order_details'),
>> )
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
*E. Serkan Sökmen*
Django / Front-end Developer @Teknolab 
Personal works: serkansokmen.com 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.