Simple Login Problem

2014-11-27 Thread Rootz
I have a django app but I having problems with my login views and logout 
views. I do not have a html template designated to handle user login/logout 
view.
Django project is configured as follows:

INSTALLED_APPS 

 setting:

   1. 'django.contrib.auth' contains the core of the authentication 
   framework, and its default models.
   2. 'django.contrib.contenttypes' is the Django *content type system* 
   , which 
   allows permissions to be associated with models you create.
   3. 'django.contrib.sessions',
   
 MIDDLEWARE_CLASSES 

 setting:

   1. SessionMiddleware 
   

manages *sessions* 
    across 
   requests.
   2. AuthenticationMiddleware 
   

 associates 
   users with requests using sessions.
   3. csrf.CsrfViewMiddleware 


Using Django Template Language and Template inheritance. The login form is 
on the base template on other templates extends from this base template.

All my login attempts result in some of the views rendering the user info 
(username to welcome user back) while other views rendering the page as if 
the user is an anonymous user. If I try to login in again I get an error 
page stating that there is a missing csrf token or incorrect. Adding to 
this I have identified many instances where I have tried to logout and it 
does not seem to log me out because it is still showing the last user login 
info. For my base template I have hard coded the form (meaning not using 
Django Form class).

Can You identify the possible fault in how i am implementing the login and 
logout views?

 
 Here is a copy of my login and logout views

def members_login(request):

if request.method == 'POST':
password = request.POST['password']
username = request.POST['username']
user = authenticate(username=username,password=password)

if user is not None:
if user.is_active:
login(request,user)
return redirect('members:index')
else:
#inactive users required to re-register
return redirect('members:index')
else:
#no account required to register to create one
return redirect('members:register')

else:
#test if login is a regular get request then redirect
return HttpResponseRedirect(reverse('members:index'))


def members_logout(request):
logout(request)
return redirect('members:index')

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f55242f9-ea84-4620-a90d-d4b81640885d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-27 Thread Sarbjit singh
What web2py GRID does is, that it takes the SQL table/query as argument, 
and return the records satisfying the query. 

Records which are returned are seen in bootstrap enabled table with 
features having pagintation, sorting, search, ability to edit/delete/view 
individual record, add new record etc.

(See for link - web2py grid snapshot as well 

)

*What I want?*

I just wanted to have the end result similar to as of web2py grid where 
records (satisfying any query) can be seen inside a tabular form with the 
ability to search, sort, edit/delete individual record etc. 

Since, I am new to Django, I am not sure if Django provides such a thing 
out of box or any third party app provides this capability.

If you just click on web2py link above, snapshot of web2py grid will give 
you a clear idea.

-Sarbjit

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/719e8cc9-4c8e-4aaa-900b-a030c73eb1e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Test client to a redirect requiring a login doesn't set redirect_chain properly?

2014-11-27 Thread Tim Chase
On 2014-11-27 20:15, Tim Chase wrote:
> However my test fails with:
> 
>   AssertionError: Response redirected to
>   'http://testserver/admin/common/region/add/', expected
>   'http://testserver/accounts/login/?next=/admin/common/region/add/'
> 
> Where am I going wrong?  Do admin pages not have @login_required as
> I expect?  Does the test-client not fully follow when follow=True?

As a bit of follow-up information, if I use runserver and browse to
the view, it redirects me to /admin/common/region/add/ but it
displays as the login screen.  Am I missing why this wouldn't do a
redirect to my named login URL?

(this at least demonstrates that the test-client and browser/server
behavior is consistent; I'm just unsure why I'm not getting the login
url)

Thanks,

-tim



-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20141127203236.094a6939%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Test client to a redirect requiring a login doesn't set redirect_chain properly?

2014-11-27 Thread Tim Chase
I have a view that can redirect to /admin/common/region/add/ but that
url (being an admin page) should require login (right?).  My test that
logs-in works as expected.

However, when I try to do an assertRedirects() without logging in
first, the assertRedirects() doesn't seem to follow through to the
login URL.

def test_no_region_not_logged_in(self):
# if we have no regions and attempt to visit
# the "home" page, the site has been misconfigured so
# it should redirect to the admin page (via login)
# where a new region can be created.

url = reverse("home") # the URL that
# should redirect to /admin/common/region/add/
# via the login page

# self.client is instantiated in setUp()
response = self.client.get(url, follow=True)

# print repr(response.redirect_chain)
# the redirect_chain contains just has one entry
# rather than the two I'd expect

add_region_url = reverse("admin:common_region_add")
login_url = reverse("login")
expected_url = "%s?next=%s" % (
login_url,
quote(add_region_url)
)
self.assertRedirects(response, expected_url)

However my test fails with:

  AssertionError: Response redirected to
  'http://testserver/admin/common/region/add/', expected
  'http://testserver/accounts/login/?next=/admin/common/region/add/'

Where am I going wrong?  Do admin pages not have @login_required as I
expect?  Does the test-client not fully follow when follow=True?

For what it's worth, this is Django 1.6.7 (I need something pre-1.7
because my hosting-provider's target environment only has Python 2.6,
not 2.7)

Thanks for any hints you might be able to offer.

-tkc



-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20141127201514.09a0b667%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Re: strange question when i access related object

2014-11-27 Thread James Schneider
Try throwing in an event.save() after creating the eventdate_date. The
event.dates.all() is spawning a new query, and you are trying to list
changes that haven't yet been committed to the database.

-James
On Nov 27, 2014 6:32 AM, "daedae11"  wrote:

> My EventDate model has a ForeignKey to Event shown as follows:
>
> *class EventDate( models.Model ): # {{{1*
> *""" stores dates for events """*
> *eventdate_name = models.CharField( *
> *_( u'Name' ), blank = False, null = False,*
> *max_length = 80, help_text = _( *
> *"Example: call for papers" ) )*
> *eventdate_date = models.DateField( _( u'Date' ), blank = False,*
> *null = False, db_index = True, validators = [validate_year] )*
> *event = models.ForeignKey( Event, related_name = 'dates' )*
> *objects = models.GeoManager()*
>
> The shell output is:
> In [10]: event.dates.create(eventdate_name='start',
> eventdate_date=datetime.date.today())
> Out[10]: 
> In [11]: event.dates.all()
> Out[11]: []
>
> Why is event.dates.all() empty?
>
> Does anyone have some advance?
>
>
>  --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4655197f.1380a.149f1aab0f2.Coremail.daedae11%40126.com
> 
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXc-%2BxOM7Wm990XKiH3GRfB%2BH75nW4poHrauWVWRd5pAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-27 Thread Kanchan Prasad
my model.py is
class BlogPost(models.Model):
title= models.CharField(max_length=100)
text = models.TextField()
created_on   = models.DateTimeField(auto_now_add=True,auto_now=False)
updated_on   = models.DateTimeField(auto_now_add=False,auto_now=True)
submitted_by = models.ForeignKey(User)
slug = models.SlugField(max_length=100,unique=True)
def __str__(self):
return self.title
def save(self, *args, **kwargs):
if not self.id:
self.slug = slugify(self.title)
super(BlogPost,self).save(*args,**kwargs)

urls.py

url(r'^profile/latest-quotation/(?P[\w-]+)/$',add_view, 
name='add_view'),

views.py
def add_view(request,slug):
blog = get_object_or_404(BlogPost, slug=slug)
com_form = CommentForm(request.POST or None)
if com_form.is_valid():
form = com_form.save(commit=False)
form.blogpost = blog
form.name = request.user
form.save()
return HttpResponseRedirect(reverse('socialnetwrok:add_view'))
return 
render(request,'socialnetwork/detailview.html',{'blog':blog,'com_form':com_form})

my template where i am using it
{% for quotation in latest_quotation_list %}

{{quotation.title}}

{{quotation.text|truncatewords:100}}

please help me i need help

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/45cb3726-5fd5-469b-b076-0eab453b95b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: not thread-safe function can break a django application?

2014-11-27 Thread Fabio Caritas Barrionuevo da Luz
Collin, Thanks for the explanation.


Em segunda-feira, 24 de novembro de 2014 20h01min55s UTC-3, Collin Anderson 
escreveu:
>
>
>
> On Saturday, November 22, 2014 4:46:56 AM UTC-5, Fabio Caritas Barrionuevo 
> da Luz wrote:
>>
>> I was trying to answer a question in a Brazilian forum about django.
>>
>> one of the proposed solutions utilized the function locale.setlocale() 
>> from locale module.
>>
>> according to the documentation[1] locale.setlocale() function is not 
>> thread-safe
>>
>> the question is: 
>>
>> not thread-safe function can break a django application?
>>
>  Yes
>
> If so, how? 
>>
> You can have "race conditions" where _sometimes_ you get unpredictable 
> results.
>
> Which scenario I would have problems? 
>>
> One request in one thread could set locale to English and then use the 
> locale, meanwhile, another thread could set it to Spanish and then use the 
> locale. If they did that at the same time, the English request might get 
> the Spanish locale, or the Spanish request might get the English locale.
>
> some easily reproducible example of problems using not thread-safe 
>> function?
>>
> import threading
> state = {}
>
> def english():
> state['locale'] = 'english'
> assert state['locale'] == 'english'
>
> def spanish():
> state['locale'] = 'spanish'
> assert state['locale'] == 'spanish'
>
> while 1:
> threading.Thread(target=english).start()
> threading.Thread(target=spanish).start()
>  
> (press ctrl+c to stop)
>
> Also, note that it says "If the locale is not changed thereafter, using 
> multithreading should not cause problems." So, if you only set it once and 
> never change it, you should be fine.
>
> Collin
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/30559735-cf14-4e67-8db5-7587e6a96073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Newbie help - running django-admin.py produces empty mysite folder

2014-11-27 Thread David Pride
Title says it all really. Have just installed Django 1.8, can test django 
version and get correct response so am *fairly* happy it's installed 
correctly. I have had Python 2.7 installed and been using perfectly for 
several months. 

Altered the PATH variable as discussed so it points to correct directory. 

However when I run...

django-admin.py startproject mysite 

The mysite folder is created - but it is empty, none of the following is 
created...

mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py

All tips gratefully received!

Many thanks, 

D.P. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/178021ee-aa7a-4280-aff5-4886341a3d52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-27 Thread Avraham Serour
maybe you'll get a better chance of responding if you explained what this
web2py feature does exactly

currently you have a very low chance of getting a response because you need
from someone knowledgeable in both django and web2py.

What do you need? an html table with database data?

On Thu, Nov 27, 2014 at 8:33 AM, Sarbjit singh 
wrote:

> Hi,
>
> I have been using web2py for sometime. I am exploring Django now, in
> web2py there is a way to generate data grids (using SQLFORM.grid) which
> generates very net grid based on the data model with support to add new
> field/edit record/delete record/view record etc.
>
> Does Django (or any other package based on django) provides this
> capability?
>
> Regards,
> Sarbjit
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/405d6d64-54a1-457f-95d9-3cbf078f10b7%40googlegroups.com
> 
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tKV8eSaBd4%3DvM%3DPto-2Kkz4o%3Dn4Y%2BqkFrFpvqHdyY4%2BAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


strange question when i access related object

2014-11-27 Thread daedae11
My EventDate model has a ForeignKey to Event shown as follows:

class EventDate( models.Model ): # {{{1
""" stores dates for events """
eventdate_name = models.CharField(
_( u'Name' ), blank = False, null = False,
max_length = 80, help_text = _(
"Example: call for papers" ) )
eventdate_date = models.DateField( _( u'Date' ), blank = False,
null = False, db_index = True, validators = [validate_year] )
event = models.ForeignKey( Event, related_name = 'dates' )
objects = models.GeoManager()

The shell output is:
In [10]: event.dates.create(eventdate_name='start', 
eventdate_date=datetime.date.today())
Out[10]: 
In [11]: event.dates.all()
Out[11]: []

Why is event.dates.all() empty?

Does anyone have some advance?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4655197f.1380a.149f1aab0f2.Coremail.daedae11%40126.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re: How to make database queries that “filters” results according to tuples of values?

2014-11-27 Thread Vijay Khemlani
Remember that |= is just a shorthand for

query = query | ... rest of parameters

So in the end it is just an "or" like you say, nothing magical about that

Glad I could help

Regards!

On Thu, Nov 27, 2014 at 4:56 AM,  wrote:

> Hi Vijay,
>
> thank you very much. I have not known, that |= also could be used on Q().
> Thought Q is only there for making "or" "not" and so stuff of calls! Great!
>
> Best Regards,
> Mike
>
> *Gesendet:* Mittwoch, 26. November 2014 um 20:30 Uhr
> *Von:* "Vijay Khemlani" 
> *An:* django-users@googlegroups.com
> *Betreff:* Re: How to make database queries that “filters” results
> according to tuples of values?
>  I think you could construct a Q object like this:
>
> from django.db.models import Q
>
> query = Q()
> for preference in user.preferences.all():
> query |= Q(dish=preference.dish) & Q(ingredient=preference.ingredient)
>
> Meal.objects.filter(query)
>
> That returns the meals where their (ingredient, dish) combination match at
> least one of the preferences of the user.
>
> On Wed, Nov 26, 2014 at 3:54 PM,  wrote:
>>
>>   Hi,
>> let’s assume I have the following model:
>>
>> *class Ingredient(models.Model):*
>> *ingredient= models.CharField(max_length=255)*
>> *class Dish(models.Model):*
>> *BREAKFAST = 'bf'*
>> *LUNCH = 'l'*
>> *DINNER = 'D'*
>> *DISH_CHOICES = (*
>> *(BREAKFAST, 'Breakfast'),*
>> *(LUNCH, 'Lunch'),*
>> *(DINNER, 'Dinner'),*
>> *)*
>> *dish =
>> models.CharField(max_length=32,choices=DISH_CHOICES,unique=True)*
>>
>> *class Preference(models.Model):*
>> *ingredient= models.ForeignKey(Ingredient)*
>> *dish = models.ForeignKey(Dish)*
>> *date_created = models.DateTimeField(auto_now_add=True)*
>> *date_updated = models.DateTimeField(auto_now=True,
>> verbose_name='Date updated')*
>> *owner  = models.ForeignKey(User, related_name='preferences')*
>>
>> *class Meal(models.Model):*
>> *name = models.CharField(max_length=255)*
>> *ingredient= models.ManyToManyField(Ingredient)*
>> *kalorins = models.IntegerField()*
>> *thumbnail = models.URLField(blank=True)*
>> *dish= models.ForeignKey(Dish)*
>>
>> I want to execute a database query in the view resulting all meals that
>> would match the preference’s of a user.
>> But something like: *result =
>> Meal.objects.filter(ingredient__in=user.request.name.pfreferences) *will
>> select all the meals witch are in the preference list of the user,
>> regardless his choice of the “Dish Type”. So if a person only likes tomatos
>> for breakfast, he also will get all meals with tomates for lunch and dinner.
>>
>> So I am looking for a way, which returns only the “*Meal*s” where the
>> *ingredient*s and the *dish *BOTH match the *ingredient*s and the *dish *of
>> the *user’s Preference.*
>> I haven’t found anything in the django books I have or the documentation
>> Thanks a lot.
>> Best Regards,
>> Mike
>>
>>
>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/trinity-f0d51c02-a559-4c2a-b1d1-e807598864ff-1417028087688%403capp-gmx-bs08
>> 
>> .
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei0t_uWYDK7wk9ems1M9ZV8vRuXbTVT9MSTynuxUGhYWiQ%40mail.gmail.com
> 
> .
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: Newbie: How to implement a app/module, which I can include from my html?

2014-11-27 Thread Mario Gudelj
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags
here you go chief
On 27/11/2014 8:04 pm, "ThomasTheDjangoFan" <
stefan.eichholz.ber...@googlemail.com> wrote:

> Oh ok.
>
> so it would be something like:
>
> in home.html
> {% include 'category-list.html' %}
>
> in category-lists.html
> {% load those_categories %}
> 
>
> ?
>
> Am Donnerstag, 27. November 2014 09:55:50 UTC+1 schrieb James Bennett:
>>
>> The usual way would be to write a custom template tag that fetches the
>> objects and puts them into the template context.
>>
>  --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d88ef650-0d18-4d6d-bad9-8a6a990524bf%40googlegroups.com
> 
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbj%3DB75vLYB77QnHYXGy5%3De0ZroTY2EUhq5No4z9_9cnDnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: How to implement a app/module, which I can include from my html?

2014-11-27 Thread ThomasTheDjangoFan
Oh ok.

so it would be something like:

in home.html
{% include 'category-list.html' %}

in category-lists.html
{% load those_categories %}


?

Am Donnerstag, 27. November 2014 09:55:50 UTC+1 schrieb James Bennett:
>
> The usual way would be to write a custom template tag that fetches the 
> objects and puts them into the template context.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d88ef650-0d18-4d6d-bad9-8a6a990524bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: How to implement a app/module, which I can include from my html?

2014-11-27 Thread James Bennett
The usual way would be to write a custom template tag that fetches the
objects and puts them into the template context.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL13Cg8YOQsAOQ5qPGwNiYfQTrrRMRBN%3DMoM4thL2ZQKjoR-rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Newbie: How to implement a app/module, which I can include from my html?

2014-11-27 Thread ThomasTheDjangoFan
Hi guys,

I want to display a block of category-links in various places of the 
website. Those links are populated by making a Category.objects.all request 
in a view. So right now it seems like each view that should contain those 
links needs to put the "Category" Model in its context.

Now I would be really thankful for a tip on how to NOT repeat myself (DRY):
Is there a way to "{% include 'category-links.html' %}" and have the .html 
get its content from a specific view?

Kind regards
Thomas

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3b775f43-a8fc-49c8-8371-f79f95bfbac8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.