Re: comparing custom template tag within if tag

2012-03-30 Thread Tom Evans
On Thu, Mar 29, 2012 at 5:42 PM, Nikhil Verma  wrote:
> Hi All
>
> I am still not able to solve this problem .Any more suggestions ?
>
> Thanks
>

Because there is no solution. You must rewrite the custom tag to set a
variable in the context, which you can then test in your 'if' tag.

The link in my first email explains how to do that.

Cheers

Tom

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using the backend database to secure a page on the frontend

2012-03-30 Thread vanderkerkoff
Hello there

I"m sure this question has been answered before but I just can't find
it, apologies.

We've got a django 1.1.2 site and I need to secure some sections of
the frontend, and use the users and groups model in the backend as the
database to provide authentication.

I really don't know where to start to be honest.

Any links to examples would be great.

What would be really great is if there's a way in the urls.py file to
do something like this.

from django.contrib.auth.models import *
urlpatterns += patterns('django.auth.authenticate',
   (r'^specificurl$',")
)

If I get it working on specific URLS first, I can then start to work
out how to incorporate the login section into parts of the app.  So
people could tick a page say as restricted, and then people would have
to login to see the page.

Any tips or links off to documentation would be really helpful.

Thanks

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using the backend database to secure a page on the frontend

2012-03-30 Thread Philip Mountifield
If you want to use the existing permission system, I think you'll find 
this is what you need: 
https://docs.djangoproject.com/en/1.4/topics/auth/#the-permission-required-decorator


You could add some extra permissions to your models too if you need 
them: https://docs.djangoproject.com/en/1.4/ref/models/options/#permissions


Kind regards
Phil

On 30/03/2012 10:28, vanderkerkoff wrote:

Hello there

I"m sure this question has been answered before but I just can't find
it, apologies.

We've got a django 1.1.2 site and I need to secure some sections of
the frontend, and use the users and groups model in the backend as the
database to provide authentication.

I really don't know where to start to be honest.

Any links to examples would be great.

What would be really great is if there's a way in the urls.py file to
do something like this.

from django.contrib.auth.models import *
urlpatterns += patterns('django.auth.authenticate',
(r'^specificurl$',")
)

If I get it working on specific URLS first, I can then start to work
out how to incorporate the login section into parts of the app.  So
people could tick a page say as restricted, and then people would have
to login to see the page.

Any tips or links off to documentation would be really helpful.

Thanks




--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.net
www.formac.net
www.telgas.net

--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Tweepy Image and Link display

2012-03-30 Thread coded kid
Hi guys, how can I get users twitter handle with link and display
their image in my django app. What I mean is this, I want the users
username should be clickable (so that when I click on it it will
direct me to the user profile), and display the user profile image by
their update. I hope you get my point?

Below are mu codes:

Views:

def tweetstream(request):
consumer_key=""
consumer_secret=""
access_token=""
access_token_secret=""
auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api=tweepy.API(auth)
statuses=api.friends_timeline(count=30)
for status in statuses:
status.__getstate__()
return render_to_response('tweets.html',{'statuses':
statuses}, context_instance=RequestContext(request))

Templates:

{% extends "base.html" %}


 {% block content %}


 {% for status in statuses %}
{{ status.author.screen_name}} :
   {{ status.text|safe }}  
  {{ status.created_at }}  Via: {{status.source}} 
{{ status.profile_image_url }}

 {% endfor %}



{% endblock %}

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using the backend database to secure a page on the frontend

2012-03-30 Thread vanderkerkoff
Thanks for getting back to me Phillip.

I'm using that page as a guide, and i've got a pages application that
has a registration_required boolean field setup.

In my urls file I've got this

(r'^login/$', 'django.contrib.auth.views.login'),

In my page view I'm doing this

print pg.registration_required
print request.user.is_authenticated()
if pg.registration_required and not request.user.is_authenticated():
  return HttpResponseRedirect('/login/?next=%s' % request.path)

I've setup the auth middleware and pg is the page.

I can see that pg.registration_required is true, and that
request.user.is_authenticated() is false, so the code is trying to
send me to the login page.

The docs say to create registration/login.html as that is the default.

I've created a folder called registration in my templates folder, and
a page called login.html in that folder, but the site is still
throwing me a template not found error

Request Method: GET
Request URL:http://127.0.0.1:8000/login/?next=/helpline2/
Django Version: 1.3 beta 1 SVN-15046
Exception Type: TemplateDoesNotExist
Exception Value:registration/login.html

I must be doing something dull, anyone got any ideas?





On Mar 30, 11:02 am, Philip Mountifield 
wrote:
> If you want to use the existing permission system, I think you'll find
> this is what you 
> need:https://docs.djangoproject.com/en/1.4/topics/auth/#the-permission-req...
>
> You could add some extra permissions to your models too if you need
> them:https://docs.djangoproject.com/en/1.4/ref/models/options/#permissions
>
> Kind regards
> Phil
>
> On 30/03/2012 10:28, vanderkerkoff wrote:
>
>
>
>
>
>
>
>
>
> > Hello there
>
> > I"m sure this question has been answered before but I just can't find
> > it, apologies.
>
> > We've got a django 1.1.2 site and I need to secure some sections of
> > the frontend, and use the users and groups model in the backend as the
> > database to provide authentication.
>
> > I really don't know where to start to be honest.
>
> > Any links to examples would be great.
>
> > What would be really great is if there's a way in the urls.py file to
> > do something like this.
>
> > from django.contrib.auth.models import *
> > urlpatterns += patterns('django.auth.authenticate',
> >     (r'^specificurl$',")
> > )
>
> > If I get it working on specific URLS first, I can then start to work
> > out how to incorporate the login section into parts of the app.  So
> > people could tick a page say as restricted, and then people would have
> > to login to see the page.
>
> > Any tips or links off to documentation would be really helpful.
>
> > Thanks
>
> --
>
> Philip Mountifield
> Formac Electronics Ltd
> tel  +44 (0) 1225 837333
> fax  +44 (0) 1225 430995
>
> pmountifi...@formac.netwww.formac.netwww.telgas.net

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template file not recognized for some strange reason

2012-03-30 Thread Juan Pablo Martínez
Try
TEMPLATE_DIRS = ("*C:*/Users/Documents/Music\ App/redlab/
templates",)

On Fri, Mar 30, 2012 at 12:58 AM, Mika  wrote:

> TEMPLATE_DIRS = ("/Users/Documents/Music\ App/redlab/
> templates",)
>



-- 
juanpex

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Doing something silly, I'm sure

2012-03-30 Thread vanderkerkoff
Sorry everyone, but this is driving me crazy

https://docs.djangoproject.com/en/1.2/topics/auth/

urls.py
(r'^accounts/login/$', 'django.contrib.auth.views.login'),

view.py
if pg.registration_required and not request.user.is_authenticated():
  return HttpResponseRedirect('/accounts/login/?next=%s' %
request.path)

Have I read the documentation wrong?  I've created a registration
folder in my templates folder and a login.html file in there, but
always with the template not found error

http://pastebin.com/dJ6TJWs1

Any tips or help greatly appreciated


-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: svm python

2012-03-30 Thread Jeff Heard
Look in Orange. http://orange.biolab.si/



On Mar 30, 2012, at 2:23 AM, dummyman dummyman  wrote:

> Is any one aware of svm implementation using python ? 
> Apart from using weka tool ?
> 
> 
> On Thu, Mar 29, 2012 at 9:21 AM, dummyman dummyman  wrote:
> Hi,
> 
> I am looking for svm classifier implementation in python. My input is a set 
> of feature vectors of the form 
> [Feature1,Feature2,[Feature3],Feature4] =>This is for a user
> 
> so the input is basically a multidimensional list in python
> 
> I have a set of users . So we have of multidimensional lists. 
> Output should be confusion matrix or a statistical analysis 
> 
> Which is the best implementation of svm python module which suits these needs 
> ?
> 
> 
> 
> -- 
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Doing something silly, I'm sure

2012-03-30 Thread Bill Freeman
Are you in debug mode so that the stack trace is displayed (on the development
server)?  Have you looked at the local variables in the trace to see
what template
it is trying to find?  Are the permissions on the template such that django can
read it?  On the development server, pdb.set_trace() is your friend. (Actually,
I've just learned how to use pdb under mod_wsgi, but you don't really want to
do that unless you can't duplicate your problem under the development server.)

(I like top posting.  It keeps me from having to scroll past stuff
I've already read.)

On Fri, Mar 30, 2012 at 8:11 AM, vanderkerkoff  wrote:
> Sorry everyone, but this is driving me crazy
>
> https://docs.djangoproject.com/en/1.2/topics/auth/
>
> urls.py
> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> view.py
> if pg.registration_required and not request.user.is_authenticated():
>  return HttpResponseRedirect('/accounts/login/?next=%s' %
> request.path)
>
> Have I read the documentation wrong?  I've created a registration
> folder in my templates folder and a login.html file in there, but
> always with the template not found error
>
> http://pastebin.com/dJ6TJWs1
>
> Any tips or help greatly appreciated
>
>
> --
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Doing something silly, I'm sure

2012-03-30 Thread Tom Evans
On Fri, Mar 30, 2012 at 1:11 PM, vanderkerkoff  wrote:
> Sorry everyone, but this is driving me crazy
>
> https://docs.djangoproject.com/en/1.2/topics/auth/

FYI to others, the stacktrace indicates OP is using 1.3 beta 1.

>
> urls.py
> (r'^accounts/login/$', 'django.contrib.auth.views.login'),
>
> view.py
> if pg.registration_required and not request.user.is_authenticated():
>  return HttpResponseRedirect('/accounts/login/?next=%s' %
> request.path)
>

You should just use the login_required decorator instead of rewriting it.

Also, I'm not sure why you are showing us view code. Your urlconf says
that you are pointing at the stock auth view, so why this snippet?

> Have I read the documentation wrong?  I've created a registration
> folder in my templates folder and a login.html file in there, but
> always with the template not found error
>
> http://pastebin.com/dJ6TJWs1
>
> Any tips or help greatly appreciated
>

So, nothing to do with auth, the real question is "Why isn't my
template found". OK. First things, stop using a beta. Update your
django to 1.3.1, so we can rule out any bug in the beta.

Next, you say you "created a registration folder in my templates
folder and a login.html file in there". Where is this template folder?
Show us the structure of your project and your pertinent apps.

Cheers

Tom

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template file not recognized for some strange reason

2012-03-30 Thread Tom Evans
2012/3/30 Juan Pablo Martínez :
> Try
> TEMPLATE_DIRS = ("C:/Users/Documents/Music\ App/redlab/
> templates",)
>

Unlikely to work on OS X.

Cheers

Tom

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template file not recognized for some strange reason

2012-03-30 Thread Sandro Dutra
Try something like this:

import os
abspath = lambda *p: os.path.abspath(os.path.join(*p))
PROJECT_ROOT = abspath(os.path.dirname(__file__))
[...]
TEMPLATE_DIRS = (abspath(PROJECT_ROOT, "templates"),)

2012/3/30 Tom Evans 

> 2012/3/30 Juan Pablo Martínez :
> > Try
> > TEMPLATE_DIRS = ("C:/Users/Documents/Music\ App/redlab/
> > templates",)
> >
>
> Unlikely to work on OS X.
>
> Cheers
>
> Tom
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: svm python

2012-03-30 Thread dummyman dummyman
Thanks a lot.Any other alternative ?

On Fri, Mar 30, 2012 at 5:51 PM, Jeff Heard wrote:

> Look in Orange. http://orange.biolab.si/
>
>
>
> On Mar 30, 2012, at 2:23 AM, dummyman dummyman  wrote:
>
> Is any one aware of svm implementation using python ?
> Apart from using weka tool ?
>
>
> On Thu, Mar 29, 2012 at 9:21 AM, dummyman dummyman wrote:
>
>> Hi,
>>
>> I am looking for svm classifier implementation in python. My input is a
>> set of feature vectors of the form
>> [Feature1,Feature2,[Feature3],Feature4] =>This is for a user
>>
>> so the input is basically a multidimensional list in python
>>
>> I have a set of users . So we have of multidimensional lists.
>> Output should be confusion matrix or a statistical analysis
>>
>> Which is the best implementation of svm python module which suits these
>> needs ?
>>
>>
>>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Working with List in Tweepy

2012-03-30 Thread samuel ayo
Hello, how can I make users create their list in my django app 
automatically? Since the  API.create_list() required parameters before it 
would work; 

*

Creates a new list for the authenticated user. Accounts are limited to 20 
lists.

Parameters: name (Required), mode (public/private default: public)

Returns: class:List object
*

So I want users to be able to create their list through my own app 
automatically and since I don't know the name they want to give their list 
and the member they want to add, how can I do it automatically?

Please kindly help me out! Thanks.
 



-- 
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/-/QxHsYXdQQ0wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Abridged summary of django-users@googlegroups.com - 38 Messages in 13 Topics

2012-03-30 Thread Peter F.


-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to model postal address in django ???

2012-03-30 Thread Ariel Isaac Romero Cartaya
Hi everybody, is there any model in Django to represent postal
address, I mean is there already models like Countries, provinces and
cities with theirs relations to make this, and how to model the others
attributes: streets, postal code, between streets and perhaps latitude
and longitude  to use google maps 

How hope you can help me.
Any help would be appreciated.

Regards,
Ariel

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to debug transaction management errors?

2012-03-30 Thread Marcin Tustin
I have a view which is causing the error that follows. I understand what it
means, but I am *certain* there is no way that my code should be causing
this error (Every single return is prefaced with either
transaction.commit() or transaction.rollback()).

Is there a good way to debug this error?

2012-03-30 12:37:11,163 ERROR Internal Server Error: /incorporate/
Traceback (most recent call last):
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/core/handlers/base.py",
line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/mainapp/decorators.py",
line 26, in _wrapped_view
return view_func(request, *args, **kwargs)
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/db/transaction.py",
line 209, in inner
return func(*args, **kwargs)
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/db/transaction.py",
line 203, in __exit__
self.exiting(exc_value, self.using)
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/db/transaction.py",
line 288, in exiting
leave_transaction_management(using=using)
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/db/transaction.py",
line 52, in leave_transaction_management
connection.leave_transaction_management()
  File
"/home/marcintustin/webapps/django/oneclickcosvirt/lib/python2.7/site-packages/django/db/backends/__init__.py",
line 119, in leave_transaction_management
raise TransactionManagementError("Transaction managed block ended with "
TransactionManagementError: Transaction managed block ended with pending
COMMIT/ROLLBACK


-- 
Marcin Tustin
Tel: 07773 787 105

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Http404 and process_exception

2012-03-30 Thread Justin Holmes
Russell,

Yeah, I see the inconsistency there, and my first thought was that
this is a bit backward.  However, the underlying distinction here is
that it's not the 404 (ie, the resource gone missin') that is the
exception but the Http404 object.

It remains straightforward enough for a developer to simply return
HttpResponseNotFound if they don't want their business logic treated
as an exception.

(Maybe this belongs on -dev) I do, however, think that the
get_object_or_404 documentation can be clearer that, as with .get(),
either failing case raises an exception.  Perhaps change the note to:

"As with .get(), an exception is raised unless exactly one object is
found for the given parameters.  A MultipleObjectsReturned exception
will be raised if more than one object is found.  However, unlike
.get(), Http404 is raised if no object is found."

This may not be necessary at all, as the Http404 page makes it clear
that it's an exception.



On Wed, Mar 28, 2012 at 7:22 PM, Russell Keith-Magee
 wrote:
>
>
> On 29/03/2012, at 12:10 AM, Justin Holmes wrote:
>
> > Russell,
> >
> > Thanks for the reply.
> >
> > Two reasons:
> >
> > 1) Up until now, I hadn't encountered a 404 that had triggered this 
> > particular process_exception.  It hadn't occurred to me that since 
> > get_object_or_404 actually raises the Http404 exception that the behavior 
> > was going to be different than, say, a try block whose exception clause 
> > returned HttpResponseNotFound.
> >
> > 2) Once I had encountered this phenomenon, a quick google search led me to 
> > this page from the book:
> >
> > http://www.djangobook.com/en/beta/chapter16/
> >
> > which seemed, at least for a moment, to verify my previous experience.
>
> Yes - that does seem to suggest 404's don't trigger exception middleware. 
> However, I've checked the code back to the magic-removal merge (in 2005) [1], 
> and I can't see any evidence that 404's have ever been a special case.
>
> [1] 
> https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py?rev=2809#L73
>
> The only change to this area that I can see is to make sure that the response 
> raised by the exception middleware is in recent times has been a modification 
> that means that if the exception middleware returns a response, that response 
> goes through the response middleware; back in the days of magic-removal, it 
> would be returned verbatim.
>
> > I think though that I simply hadn't raised Http404 since implementing this 
> > middleware.  It makes perfect sense that it behaves the way it does.
>
> Yes and no; yes, in that it's an exception; no, in that it's an interesting 
> inconsistency that 404s are (or can be) handled as exceptions, but no other 
> status code is handled as an exception.
>
> Yours,
> Russ Magee %-)
>
> --
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



--
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



OT: just posting at djangojobs when suddenly...

2012-03-30 Thread Marc Aymerich
... something familiar comes up :)
http://s18.postimage.org/j9dc6ufa1/Screenshot_5.png

-- 
Marc

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Implementing Tagging with Django

2012-03-30 Thread puddy
Hello,

I searched for tagging libraries for Django and found two (django-
tagging and django-taggit) but both are fairly old and haven't been
maintained.  I'd like to implement some sort of tagging on my site - a
bookmarking type service where each link has a set of tags.  I know of
how I would like to model the data at the DB level:

Bookmark Table:
bookmark_ID,title,link

Tag Table
tag_id,tag_name

TagWithBookmarkTable
tag_id,bookmark_id

I'm not quite sure how to do this at the Django Models level
though.Anyone able to help?: I feel like this is a common problem but
I haven't had much success with google searches for django tagging -
keep getting template tag results or old blog posts (maybe I should
just follow them?).

Thanks!

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How can I best create a blog that works similarly to Tumblr?

2012-03-30 Thread Willy
I know the question is kind of poorly phrased. But here goes, I've been 
working on a blog software and I want to have five distinct post types (in 
the same way Tumblr does) but I'm having a hard time figuring out how to 
create my index view and detail views as they are currently five different 
models that inherit from the same abstract base model.

Here is my models.py http://dpaste.com/724371/
as well as my views.py http://dpaste.com/724372/
and for safe measure, my urls.py within the app http://dpaste.com/724373/

How can I make this work? The current hack of using chain() isn't really 
working out because of the fact that it returns a list, not a queryset.
All together I feel like my code is quickly becoming unmaintainable but I 
would really like to know how to get this working as its early enough in 
the development to change.

-- 
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/-/c_lQ-PD0hXwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Implementing Tagging with Django

2012-03-30 Thread Willy
Django-taggit works quite well, I would suggest trying it over 
django-tagging. Even if it hasn't been updated in a while it's still a good 
solution, and you could always make changes to it and fork your own version 
if it doesn't meet all your needs. 

On Friday, March 30, 2012 1:56:07 PM UTC-6, puddy wrote:
>
> Hello, 
>
> I searched for tagging libraries for Django and found two (django- 
> tagging and django-taggit) but both are fairly old and haven't been 
> maintained.  I'd like to implement some sort of tagging on my site - a 
> bookmarking type service where each link has a set of tags.  I know of 
> how I would like to model the data at the DB level: 
>
> Bookmark Table: 
> bookmark_ID,title,link 
>
> Tag Table 
> tag_id,tag_name 
>
> TagWithBookmarkTable 
> tag_id,bookmark_id 
>
> I'm not quite sure how to do this at the Django Models level 
> though.Anyone able to help?: I feel like this is a common problem but 
> I haven't had much success with google searches for django tagging - 
> keep getting template tag results or old blog posts (maybe I should 
> just follow them?). 
>
> Thanks! 
>

-- 
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/-/vN0VnLBkSZQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



changelist link in change_form.html

2012-03-30 Thread Lee
I know this has to be simple but I'm not finding it in the archives or
google. I just want to include a link to the corresponding changelist
in every add/edit form. I assume I need to update the change_form.html
template, but what is the correct syntax to display the changelist
URL? A 1.3-compatible solution would be best.

Thanks for any help or ideas.

Lee

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Implementing Tagging with Django

2012-03-30 Thread Javier Guerra Giraldez
On Fri, Mar 30, 2012 at 3:02 PM, Willy  wrote:
> Django-taggit works quite well, I would suggest trying it over
> django-tagging

can you elaborate on why do you find it better?  i have only tried
django-tagging some time ago, and maybe on a soon project would like
to do better

-- 
Javier

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: svm python

2012-03-30 Thread Leotis buchanan
Try shogun,it has python bindings
Regards
Leotis Buchanan
Co-Founder
Exterbox




On Fri, Mar 30, 2012 at 8:24 AM, dummyman dummyman wrote:

> Thanks a lot.Any other alternative ?
>
>
> On Fri, Mar 30, 2012 at 5:51 PM, Jeff Heard 
> wrote:
>
>> Look in Orange. http://orange.biolab.si/
>>
>>
>>
>> On Mar 30, 2012, at 2:23 AM, dummyman dummyman 
>> wrote:
>>
>> Is any one aware of svm implementation using python ?
>> Apart from using weka tool ?
>>
>>
>> On Thu, Mar 29, 2012 at 9:21 AM, dummyman dummyman wrote:
>>
>>> Hi,
>>>
>>> I am looking for svm classifier implementation in python. My input is a
>>> set of feature vectors of the form
>>> [Feature1,Feature2,[Feature3],Feature4] =>This is for a user
>>>
>>> so the input is basically a multidimensional list in python
>>>
>>> I have a set of users . So we have of multidimensional lists.
>>> Output should be confusion matrix or a statistical analysis
>>>
>>> Which is the best implementation of svm python module which suits these
>>> needs ?
>>>
>>>
>>>
>>  --
>> 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 email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>  --
>> 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 email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: svm python

2012-03-30 Thread william ratcliff
Libsvm or scikit-learn are light
On Mar 30, 2012 6:19 PM, "Leotis buchanan" 
wrote:

> Try shogun,it has python bindings
> Regards
> Leotis Buchanan
> Co-Founder
> Exterbox
>
>
>
>
> On Fri, Mar 30, 2012 at 8:24 AM, dummyman dummyman wrote:
>
>> Thanks a lot.Any other alternative ?
>>
>>
>> On Fri, Mar 30, 2012 at 5:51 PM, Jeff Heard 
>> wrote:
>>
>>> Look in Orange. http://orange.biolab.si/
>>>
>>>
>>>
>>> On Mar 30, 2012, at 2:23 AM, dummyman dummyman 
>>> wrote:
>>>
>>> Is any one aware of svm implementation using python ?
>>> Apart from using weka tool ?
>>>
>>>
>>> On Thu, Mar 29, 2012 at 9:21 AM, dummyman dummyman 
>>> wrote:
>>>
 Hi,

 I am looking for svm classifier implementation in python. My input is a
 set of feature vectors of the form
 [Feature1,Feature2,[Feature3],Feature4] =>This is for a user

 so the input is basically a multidimensional list in python

 I have a set of users . So we have of multidimensional lists.
 Output should be confusion matrix or a statistical analysis

 Which is the best implementation of svm python module which suits these
 needs ?



>>>  --
>>> 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 email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>  --
>>> 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 email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>  --
>> 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 email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Questions about UnicodeDecodeError

2012-03-30 Thread Ali Mesdaq
I have a situation where I am reading data that I have no control over and
inserting it into a db. The data is http headers. I am storing them in
postgres db in a text field and the db encoding is SQL_ASCII. Since the
data can be anything even non compliant http headers with anything for its
values I don't want to modify the data before I store it in the db.
However this is causing issues with certain values causing the
UnicodeDecodeError. For example I have a specific case where the user
agent is set to 'KC\xd4\xda\xcf\xdf\xc9\xfd\xbc\xb6'. I have been trying
to look for a way to deal with these cases gracefully in the models
__unicode__ method but nothing I have tried has worked.

Thanks,
Ali Mesdaq
Security Researcher
Cell:  +1 (619) 952-8488  |  Fax:  +1 (408) 321-9818
Email:  ali.mes...@fireeye.com
 

Next Generation Threat Protection
http://www.FireEye.com 

 



-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



dummyman dummyman wants to chat

2012-03-30 Thread dummyman dummyman
---

dummyman dummyman wants to stay in better touch using some of Google's
coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-39f62065b4-6ab0f5cba8-Hyccil_bE1jMXGxY1w4coCCKTtA
You'll need to click this link to be able to chat with dummyman dummyman.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with dummyman dummyman, visit:
http://mail.google.com/mail/a-39f62065b4-6ab0f5cba8-Hyccil_bE1jMXGxY1w4coCCKTtA

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: changelist link in change_form.html

2012-03-30 Thread dummyman dummyman
inside your folder template create admin directory
all admin html files shud be placed here
inside it create a dir for ur app
inside ur app a dir for ur model

so typically url will be

http://localhost:8000/admin///add

On Sat, Mar 31, 2012 at 2:22 AM, Lee  wrote:

> I know this has to be simple but I'm not finding it in the archives or
> google. I just want to include a link to the corresponding changelist
> in every add/edit form. I assume I need to update the change_form.html
> template, but what is the correct syntax to display the changelist
> URL? A 1.3-compatible solution would be best.
>
> Thanks for any help or ideas.
>
> Lee
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin change form page validation

2012-03-30 Thread dummyman dummyman
Hi

unless u dont specify blank=True or null = True in modes for d
corresponding fields, django will throw an errror if u don fill up the field

On Sat, Mar 31, 2012 at 9:25 AM, Nikhil Verma wrote:

> Hi All
>
> How can i apply validation in admin on various fields when they are
> dependent on each other ?
>
> e.g. Let say in i have a  Field A(BooleanField)  and Field B (CharField)
> what i want to do is if in admin user select the Field A(checkbox) and does
> not enter anything in Field B
> and if he tries to save ,it should throw an error like a normal
> blank=False gives. So how can i do this kind of validation in admin .
>
> E.g  Use Case
>
> I have a table having the following structure :-
>
> INTERVIEW_TYPES = (
>
> ('default', 'None'),
> ('Paired Visit','Paired Visit'),
> ('Time Series', 'Time Series'),
>
> ),
>
> class Interview(models.Model):
> ic_number  = models.CharField(verbose_name ="Visit
> Configuration Number",max_length=20,unique=True,null =True,blank=True)
> ic_description = models.TextField(verbose_name ="Visit
> Configuration Description",null = True,blank=True)
> title  = models.CharField(verbose_name ="Visit
> Configuration Title",max_length=80,unique=True)
> starting_section   = models.ForeignKey(Section)
> interview_type = models.CharField(verbose_name = "Mapped
> Visit",choices=CHOICES.INTERVIEW_TYPES, max_length=80, default="Time
> Series")
> select_rating  =
> models.CharField(choices=CHOICES.QUESTION_RATING, max_length=80,
> default="Select Rating")
> view_notes = models.CharField(choices=CHOICES.VIEW_NOTES,
> max_length=80, default="Display Notes")
>  revisit= models.BooleanField(default=False)
> .and so on ..
>
> class Meta:
> verbose_name = 'Visit Configuration'
> verbose_name_plural = 'Visit Configurations'
># ordering = ('rpn_number',)
>
> def __unicode__(self):
> return self.title
>
> Its admin.py
>
> class InterviewAdmin(admin.ModelAdmin):
> list_display = ('id','title',
> 'starting_section','ic_number','show_prior_responses')
> raw_id_fields = ('starting_section',)
> admin.site.register(Interview, InterviewAdmin)
>
> In admin , If i select the checkbox of revisit and in the field
> interview_type(which will show a dropdown having choices None,Paired Visit
> , Time Series) if a User has selected None from that dropdown and then
> press save button it should throw me an error like a normal blank=False
> shows, saying "This field is required"
>
> How can i do this kind validation where fields are dependent on each other
> ?
>
> Please Ignore syntax error is any .
>
> Thanks
>
> --
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin change form page validation

2012-03-30 Thread Nikhil Verma
Hi

I understand that but the problem is its a condition which i have to add if
the revisit checkbox is selected and then in interview_type dropdown None
option is selected ; after pressing save it should throw an error .

None is an option in the dropdown . It is not blank=True and null =True

INTERVIEW_TYPES = (

('default', 'None'),
('Paired Visit','Paired Visit'),
('Time Series', 'Time Series'),

),

interview_type will show choices with dropdown 1) None 2) Paired Visit 3)
Time Series

On Sat, Mar 31, 2012 at 10:28 AM, dummyman dummyman wrote:

> Hi
>
> unless u dont specify blank=True or null = True in modes for d
> corresponding fields, django will throw an errror if u don fill up the field
>
> On Sat, Mar 31, 2012 at 9:25 AM, Nikhil Verma wrote:
>
>> Hi All
>>
>> How can i apply validation in admin on various fields when they are
>> dependent on each other ?
>>
>> e.g. Let say in i have a  Field A(BooleanField)  and Field B (CharField)
>> what i want to do is if in admin user select the Field A(checkbox) and does
>> not enter anything in Field B
>> and if he tries to save ,it should throw an error like a normal
>> blank=False gives. So how can i do this kind of validation in admin .
>>
>> E.g  Use Case
>>
>> I have a table having the following structure :-
>>
>> INTERVIEW_TYPES = (
>>
>> ('default', 'None'),
>> ('Paired Visit','Paired Visit'),
>> ('Time Series', 'Time Series'),
>>
>> ),
>>
>> class Interview(models.Model):
>> ic_number  = models.CharField(verbose_name ="Visit
>> Configuration Number",max_length=20,unique=True,null =True,blank=True)
>> ic_description = models.TextField(verbose_name ="Visit
>> Configuration Description",null = True,blank=True)
>> title  = models.CharField(verbose_name ="Visit
>> Configuration Title",max_length=80,unique=True)
>> starting_section   = models.ForeignKey(Section)
>> interview_type = models.CharField(verbose_name = "Mapped
>> Visit",choices=CHOICES.INTERVIEW_TYPES, max_length=80, default="Time
>> Series")
>> select_rating  =
>> models.CharField(choices=CHOICES.QUESTION_RATING, max_length=80,
>> default="Select Rating")
>> view_notes = models.CharField(choices=CHOICES.VIEW_NOTES,
>> max_length=80, default="Display Notes")
>>  revisit= models.BooleanField(default=False)
>> .and so on ..
>>
>> class Meta:
>> verbose_name = 'Visit Configuration'
>> verbose_name_plural = 'Visit Configurations'
>># ordering = ('rpn_number',)
>>
>> def __unicode__(self):
>> return self.title
>>
>> Its admin.py
>>
>> class InterviewAdmin(admin.ModelAdmin):
>> list_display = ('id','title',
>> 'starting_section','ic_number','show_prior_responses')
>> raw_id_fields = ('starting_section',)
>> admin.site.register(Interview, InterviewAdmin)
>>
>> In admin , If i select the checkbox of revisit and in the field
>> interview_type(which will show a dropdown having choices None,Paired Visit
>> , Time Series) if a User has selected None from that dropdown and then
>> press save button it should throw me an error like a normal blank=False
>> shows, saying "This field is required"
>>
>> How can i do this kind validation where fields are dependent on each
>> other ?
>>
>> Please Ignore syntax error is any .
>>
>> Thanks
>>
>>
>> --
>> Regards
>> Nikhil Verma
>> +91-958-273-3156
>>
>>  --
>> 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 email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Regards
Nikhil Verma
+91-958-273-3156

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-admin change form page validation

2012-03-30 Thread dummyman dummyman
ok. in admin,.py file


override the response_change method

def response_change(self,request,obj)

obj is the handler

so u can check using obj.field_name and take approp action

On Sat, Mar 31, 2012 at 10:34 AM, Nikhil Verma wrote:

> Hi
>
> I understand that but the problem is its a condition which i have to add
> if the revisit checkbox is selected and then in interview_type dropdown
> None option is selected ; after pressing save it should throw an error .
>
> None is an option in the dropdown . It is not blank=True and null =True
>
> INTERVIEW_TYPES = (
>
> ('default', 'None'),
> ('Paired Visit','Paired Visit'),
> ('Time Series', 'Time Series'),
>
> ),
>
> interview_type will show choices with dropdown 1) None 2) Paired Visit 3)
> Time Series
>
>
> On Sat, Mar 31, 2012 at 10:28 AM, dummyman dummyman wrote:
>
>> Hi
>>
>> unless u dont specify blank=True or null = True in modes for d
>> corresponding fields, django will throw an errror if u don fill up the field
>>
>> On Sat, Mar 31, 2012 at 9:25 AM, Nikhil Verma 
>> wrote:
>>
>>> Hi All
>>>
>>> How can i apply validation in admin on various fields when they are
>>> dependent on each other ?
>>>
>>> e.g. Let say in i have a  Field A(BooleanField)  and Field B (CharField)
>>> what i want to do is if in admin user select the Field A(checkbox) and does
>>> not enter anything in Field B
>>> and if he tries to save ,it should throw an error like a normal
>>> blank=False gives. So how can i do this kind of validation in admin .
>>>
>>> E.g  Use Case
>>>
>>> I have a table having the following structure :-
>>>
>>> INTERVIEW_TYPES = (
>>>
>>> ('default', 'None'),
>>> ('Paired Visit','Paired Visit'),
>>> ('Time Series', 'Time Series'),
>>>
>>> ),
>>>
>>> class Interview(models.Model):
>>> ic_number  = models.CharField(verbose_name ="Visit
>>> Configuration Number",max_length=20,unique=True,null =True,blank=True)
>>> ic_description = models.TextField(verbose_name ="Visit
>>> Configuration Description",null = True,blank=True)
>>> title  = models.CharField(verbose_name ="Visit
>>> Configuration Title",max_length=80,unique=True)
>>> starting_section   = models.ForeignKey(Section)
>>> interview_type = models.CharField(verbose_name = "Mapped
>>> Visit",choices=CHOICES.INTERVIEW_TYPES, max_length=80, default="Time
>>> Series")
>>> select_rating  =
>>> models.CharField(choices=CHOICES.QUESTION_RATING, max_length=80,
>>> default="Select Rating")
>>> view_notes =
>>> models.CharField(choices=CHOICES.VIEW_NOTES, max_length=80,
>>> default="Display Notes")
>>>  revisit= models.BooleanField(default=False)
>>> .and so on ..
>>>
>>> class Meta:
>>> verbose_name = 'Visit Configuration'
>>> verbose_name_plural = 'Visit Configurations'
>>># ordering = ('rpn_number',)
>>>
>>> def __unicode__(self):
>>> return self.title
>>>
>>> Its admin.py
>>>
>>> class InterviewAdmin(admin.ModelAdmin):
>>> list_display = ('id','title',
>>> 'starting_section','ic_number','show_prior_responses')
>>> raw_id_fields = ('starting_section',)
>>> admin.site.register(Interview, InterviewAdmin)
>>>
>>> In admin , If i select the checkbox of revisit and in the field
>>> interview_type(which will show a dropdown having choices None,Paired Visit
>>> , Time Series) if a User has selected None from that dropdown and then
>>> press save button it should throw me an error like a normal blank=False
>>> shows, saying "This field is required"
>>>
>>> How can i do this kind validation where fields are dependent on each
>>> other ?
>>>
>>> Please Ignore syntax error is any .
>>>
>>> Thanks
>>>
>>>
>>> --
>>> Regards
>>> Nikhil Verma
>>> +91-958-273-3156
>>>
>>>  --
>>> 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 email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>  --
>> 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 email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Regards
> Nikhil Verma
> +91-958-273-3156
>
>  --
> 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 email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/

Re: How can I best create a blog that works similarly to Tumblr?

2012-03-30 Thread Russell Keith-Magee

On 31/03/2012, at 4:01 AM, Willy wrote:

> I know the question is kind of poorly phrased. But here goes, I've been 
> working on a blog software and I want to have five distinct post types (in 
> the same way Tumblr does) but I'm having a hard time figuring out how to 
> create my index view and detail views as they are currently five different 
> models that inherit from the same abstract base model.
> 
> Here is my models.py http://dpaste.com/724371/
> as well as my views.py http://dpaste.com/724372/
> and for safe measure, my urls.py within the app http://dpaste.com/724373/
> 
> How can I make this work? The current hack of using chain() isn't really 
> working out because of the fact that it returns a list, not a queryset.

It sounds like most of your problems originate from the fact that you're using 
an abstract base class for posts.

If you make BasePost non-abstract, then you'll be able to generate a queryset 
of BasePost objects, rather than having to chain through querysets of the 
concrete subclasses. Once you have a BasePost instance, you can retrieve the 
specific details associated with each instance with a single attribute request. 
It also means that when you start introducing links to posts, you won't need to 
maintain 5 different foreign key types (i.e., link to a text post, link to an 
image post, etc) -- there's just one "link to a post".

The detail view is also simplified -- it's a detail view for BasePost, not some 
hybrid that is trying to handle 5 different subclasses.

The only other thing you might want to change is to make post_type a field on 
BasePost; this isn't strictly required, but it will make it easier to do 
CORBA-style "narrowing" (i.e., I have a BasePost instance; what type of Post is 
it, and how do I get an object of that type?).

Hope this helps!
 
Yours,
Russ Magee %-)

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.