django-cache-machine with Redis

2013-03-28 Thread Alan Johnson
How does one configure this?  The documentation only explains how to use 
locmem or memcached, and yet the commit logs reference Redis multiple 
times, so it must be doable. Does anybody have any advice or experience 
with this?

-- 
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.




[ANN] Django 1.5.1 released

2013-03-28 Thread Jacob Kaplan-Moss
Hi folks --

We've just released Django 1.5.1, a bug fix release that cleans up a
couple issues with last month's 1.5 release.

The biggest fix is for a memory leak introduced in Django 1.5. Under
certain circumstances, repeated iteration over querysets could leak
memory - sometimes quite a bit of it.

For more details, see our announcement:

https://www.djangoproject.com/weblog/2013/mar/28/django-151/

Thanks for using Django!

Jacob

-- 
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: Displaying And Selecting Tags in Admin Site

2013-03-28 Thread Pankaj Singh
Hey,

You will need to use custom widget for tag field. Please have a look at
https://bitbucket.org/fabian/django-taggit-autosuggest and below screenshot.

[image: Inline image 1]

On Thu, Mar 28, 2013 at 7:03 PM, Jonathan Harris
wrote:

> Hi All
>
> New to Django and coding in general, so sorry if this has been covered - I
> did search the group postings, have read the documentation, trawled the net
> etc, but couldn't find anything directly relevant
>
> I have been following various tutorials (django homepage, youtube etc) for
> how to start creating a blog site
>
> What I would like to do seems really simple, but I cannot find a solution
>
> Django 1.5 on Ubuntu Server 12.04LTS
>
> It uses Taggable Manager, so in models.py we see
>
> #models.py
>
> from taggit.managers import TaggableManager
>
> class Post(models.Model):
> title = models.CharField(max_length=100)
> 
> tags = TaggableManager()
>
> #admin.py
>
> from blog.models import Post
>
> class PostAdmin(admin.ModelAdmin):
> fieldsets = [
> ('Title',  {'fields': ['title']}),
> ..
> ('Tags', {'fields': ['tags'], 'classes': ['collapse']}),
> ]
>
> admin.site.register(Post, PostAdmin)
>
> 
>
> This works fine
>
> What I would like to do is change the way that tags can be viewed and
> selected in the admin site
>
> Currently, it is as a comma separated list
>
> I would like to pre-create the tags, then see them in a drop down, or
> table, or similar, so that one or more may be selected
> The view I am looking to achieve would be as if 'filter_horizontal =
> ['tags']' had been applied
>
> However, I cannot find a way to do it
>
> I have tried to give the tags a separate class, with a ManyToManyField
> link into Post, but any tags that are created are not displayed - and this
> is probably really not the right approach
>
> So is it possible to change the way that tags from TaggableManager is
> displayed? Can it be as a selection box, or check boxes or anything else?
> Or are we stuck with the list approach?
>
> Any advice would be gratefully received
>
> Many Thanks
>
> Jon
>
> --
> 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.
>
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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: management commands in namespaced apps

2013-03-28 Thread Pankaj Singh
This is a known bug in django - https://code.djangoproject.com/ticket/14087.

On Thu, Mar 28, 2013 at 7:17 PM, Alexis Roda <
alexis.roda.villalo...@gmail.com> wrote:

> Hi all,
> I'm having a hard time making management commands defined in a namespaced
> app available to "manage.py".
>
> I have a namespace python package "dja.skel.core" that provides some
> functionality and a namespace app "dja.skel.django_skel" which defines
> functionality specific to django, a management command named "skel".
>
> "dja.skel.django_skel" is in INSTALLED_APPS but when I run "python
> manage.py help" the "skel" management command is not listed.
>
> Tracking down the problem it seems to be caused by the "imp.find_module()"
> function in "django.core.management.find_**management_module()".
>
> When calling imp.find_module("dja", None) it returns
> '/home/alex/prog/dja_skel/dja.**skel.core/dja' for the path, so locating
> "dja.skel.django_skel.**management" will fail as it is being searched for
> in "dja.skel.core".
>
> So my question is if is this a bug or namespace apps are no supported by
> django in the way I'm trying to use them?
>
>
>
> Thanks in 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+unsubscribe@**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
> .
>
>
>


-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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: 'url' template tag throws and error after upgrading to 1.4

2013-03-28 Thread Pankaj Singh
You may try

{% load url from future %}



But wrapping first argument to url in quotes was introduced in 1.5. Your
original code should work.

Please wait for someone else to answer.

On Thu, Mar 28, 2013 at 9:27 PM, Bastian  wrote:

> Hi,
>
> I am trying to upgrade an existing project from 1.3 to 1.4.5. I have it
> almost done but when I try to load the home page, in the base.html I have
> this line:
>
> 
>
> and it throws an error: No module named views.
>
> When I replace the tag with the real url (/jsi18n/) then the error
> disappears but it reappears a little further with another 'url' template
> tag. So I believe something is wrong with this
> specific template tag. I have no idea how to debug it. Is there something
> obvious that I missed when upgrading to 1.4?
>
> Here is the traceback:
>
> Traceback:
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   136. response = response.render()
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/response.py"
> in render
>   104. self._set_content(self.rendered_content)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   81. content = template.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in
> render
>   140. return self._render(context)
> File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py"
> in instrumented_test_render
>   62. return self.nodelist.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in
> render
>   823. bit = self.render_node(node, context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in
> render_node
>   74. return node.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   123. return compiled_parent._render(context)
> File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py"
> in instrumented_test_render
>   62. return self.nodelist.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in
> render
>   823. bit = self.render_node(node, context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in
> render_node
>   74. return node.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   123. return compiled_parent._render(context)
> File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py"
> in instrumented_test_render
>   62. return self.nodelist.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/base.py" in
> render
>   823. bit = self.render_node(node, context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in
> render_node
>   74. return node.render(context)
> File
> "/home/env/project/lib/python2.7/site-packages/django/template/defaulttags.py"
> in render
>   411. url = reverse(view_name, args=args, kwargs=kwargs,
> current_app=context.current_app)
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in reverse
>   476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
> *args, **kwargs))
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in _reverse_with_prefix
>   363. possibilities = self.reverse_dict.getlist(lookup_view)
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in reverse_dict
>   276. self._populate()
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in _populate
>   265. lookups.appendlist(pattern.callback, (bits,
> p_pattern, pattern.default_args))
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in callback
>   216. self._callback = get_callable(self._callback_str)
> File
> "/home/env/project/lib/python2.7/site-packages/django/utils/functional.py"
> in wrapper
>   27. result = func(*args)
> File
> "/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py"
> in get_callable
>   92. lookup_view = getattr(import_module(mod_name),
> func_name)
> File
> "/home/env/project/lib/python2.7/site-packages/django/utils/importlib.py"
> in import_module
>   35. __import__(name)
>
> Exception Type: ImportError at /
> Exception Value: No module named views
>
> --
> 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 

Re: showing an Integerfield as checkbox in form with defaulted as "check"

2013-03-28 Thread Pankaj Singh
Hey Abhishek,

In your form, you need to specify a form field to use
django.forms.widgets.CheckboxInput (
https://docs.djangoproject.com/en/dev/ref/forms/widgets/#checkboxinput) for
this.

Here is an example

from django import formsfrom django.form.widgets import
CheckboxInputfrom django.forms.fields import IntegerField
def my_check_test(some_integer):
"""
A custom check test used by CheckboxInput.
"""
return some_integer%2 == 0
class SimpleForm(forms.Form):
my_field = IntegerField(widget=CheckboxInput(check_test=my_check_test))


On Thu, Mar 28, 2013 at 5:57 PM, Abhishek Kumar 
wrote:
> I am trying to show an integer field as check box and wanted to show it as
> default check.
> Does anyone know how to do this.
>
> thanks
> ak
>
> --
> 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.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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: Integrity Error: column username is not unique

2013-03-28 Thread Jaimin Patel
If the user is marked as deleted and we want to do soft delete.What can we 
do to have the username available again for use.

Can we just mask the deleted usernames with some random string so that the 
actual username can be used?

On Sunday, June 24, 2012 10:36:02 AM UTC-4, Dhivya wrote:
>
> Hi,
> username field in django.contrib.auth.User model  is unique. 
> Probably, the username you are trying to save already exists. 
> In your view, you might want to check,
> try:
> username = User.objects.get(username=form.cleaned_data['username'])
> except ObjectDoesNotExist:
>   #create user new object here
>
> -Dhivya
> On Sunday, June 24, 2012 9:36:48 AM UTC-4, Nikhil Verma wrote:
>>
>>
>> Hi 
>>
>> I got this error when i was making a post after filling the details from 
>> the user.
>>
>> Can somebody throw a light in this where i am going wrong.
>>
>> models.py
>>
>> class UserProfile(models.Model):
>> user = models.ForeignKey(User, blank=True, null=True, unique=True)
>> first_name = models.CharField(max_length=30, blank=True)
>> last_name = models.CharField(max_length=30, blank=True)
>> gender = models.CharField(max_length=1, choices=GENDER_CHOICES, 
>> blank=True)
>> birth_date = models.DateField(auto_now_add=True)
>> street = models.CharField(max_length=75, blank=True)
>> state = models.CharField(max_length=30, blank=True)
>> zip_code = models.IntegerField(max_length=7, blank=True, null=True)
>> country = models.CharField(max_length=30, blank=True)
>> mobile = models.CharField(max_length=15, blank=True)
>> home_phone = models.CharField(max_length=15, blank=True)
>> primary_email = models.EmailField(max_length=60, blank=True)
>> institution_name = 
>> models.CharField(max_length=100,blank=True,null=True)
>> institution_website = 
>> models.CharField(max_length=100,blank=True,null=True)
>>
>>
>> forms.py
>>
>> class UserProfileForm(forms.Form):
>> 
>> username = forms.CharField(label='Username', max_length=20)
>> first_name = forms.CharField(label="First Name", max_length=40, 
>> required=True)
>> last_name = forms.CharField(label="Last Name", max_length=40, 
>> required=True)
>> gender = forms.CharField(max_length=1, 
>> widget=Select(choices=GENDER_CHOICES), required=True)
>> date_of_birth = CustomDateField(label='Date of Birth', required=False)
>> telephone = forms.CharField(label='Mobile Phone', max_length=40, 
>> required=False) 
>> institution_name = forms.CharField(label='Institute Name', 
>> max_length=80, required=False)
>> street = forms.CharField(label='Street', max_length=100, 
>> required=False)
>> zip_code = forms.CharField(label='Zip Code', max_length=40, 
>> required=False)
>> state = forms.CharField(label='State', max_length=80, required=False)
>> country = forms.CharField(label='Country', max_length=80, 
>> required=False)
>> institue_name = forms.CharField(label='Institute Name', 
>> max_length=80, required=False)
>> institue_website = forms.URLField(label='Institute Website', 
>> max_length=80, required=False)
>>
>>
>> views.py
>> def createprofile(request):
>> """
>> Creating Profile
>> """
>> 
>> if request.method == "POST":
>> form = UserProfileForm(request.POST)
>> if form.is_valid():
>> user = User(
>> username = form.cleaned_data['username'],
>> first_name = form.cleaned_data['first_name'],
>> last_name = form.cleaned_data['last_name'],
>> )
>> user.save()
>> userprofile_obj = UserProfile(
>> user = 
>> user.username,  
>> first_name = user.first_name,
>> last_name = user.last_name,
>> gender = form.cleaned_data['gender'],
>> birth_date = form.cleaned_data['date_of_birth'],
>> mobile = form.cleaned_data['telephone'],
>> institution_name = form.cleaned_data['institution_name'],
>> street = form.cleaned_data['street'],
>> zip_code = form.cleaned_data['zip_code'],
>> state = form.cleaned_data['state'],
>> country = form.cleaned_data['country'],
>> )
>> userprofile_obj.save()
>>
>>
>> Any help how can i solve this problem ?
>>
>>
>> -- 
>> Regards
>> Nikhil Verma
>> +91-958-273-3156
>>
>>

-- 
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: Redirects working locally but not in live server

2013-03-28 Thread Bill Freeman
Are you sure that you restarted after making redirection changes in
production?  Unlike runserver, most deployment schemes do not automatically
restart when a .py file is changed, so changes to them are not picked up.
You would have restarted when you switched DEBUG on and off, and other
changes would have been picked up at that time.

But it could be cacheing, and that is somewhat outside Django's scope.
While you can arrange particular cache control headers to control which
pages are cacheable and for how long, proxy caches (e.g.; varnish on your
server, others in the great wide world), and even browsers, may have their
own ideas.  If you are running a proxy cache on your server, you should
look up the commands required to purge it, assuming your hosting provider
allows that.  (But only purge it if you seem to be having cacheing
problems, particularly if it is shared.)

On Thu, Mar 28, 2013 at 11:21 AM, angelika wrote:

> Hm, well, I've solved it myself, I guess. It must have been a caching
> problem. I changed Debug to True in settings.py to look for errors, and
> then it started working. Something must have reloaded, cuz it still works
> when I change it back.
>
> For future reference, does anyone know how I can get this type of
> reload/empty cache of the server without having to edit my settings.py?
>
> /Angelika
>
>
> On Thursday, March 28, 2013 4:10:24 PM UTC+1, angelika wrote:
>>
>> Hi,
>>
>> I'm using the django redirects app: https://docs.**
>> djangoproject.com/en/1.4/ref/**contrib/redirects/
>>
>> I've created a couple of redirect objects in the admin interface and when
>> I run it locally it works fine, but when I do the same thing on my live
>> server it has no effect. The regular 404 page is showing in stead. The
>> installation is very simple, just a couple of settings and a db table and
>> nothing went wrong there as far as I can see. What am I missing? Locally I
>> run the site with runserver, my liveserver is running nginx and gunicorn.
>> I've restarted both, but it makes no difference.
>>
>> Thoughts? Guesses?
>>
>> /Angelika
>>
>  --
> 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.
>
>
>

-- 
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: Getting the selected value on a Django forms.ChoiceField

2013-03-28 Thread Martin J. Laubach


Continent = form.cleaned_data['Continent']Continent = 
dict(form.fields['Continent'])[Continent]

  The obvious confusion stemming from the upper case variable aside, the 
second line is total nonsense. Drop it and you'll be golden.

  Cheers,

mjl

-- 
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: Getting the selected value on a Django forms.ChoiceField

2013-03-28 Thread Tom Evans
On Thu, Mar 28, 2013 at 3:10 PM, amine antri  wrote:
> i'm working on Djnago and i need to know how can i get selected value in
> forms.ChoiceField
>
> class FilterForm(forms.Form):
> Continent = forms.ChoiceField(choices=continents())
>
> i tried with :
>
> def affiche_all(request, currency):
> if request.method == 'POST':
> form = FilterForm(request.POST)
> if form.is_valid() :
> Continent = form.cleaned_data['Continent']

At this point, 'Continent' (variables should have lower case names,
see PEP 8) should have the chosen value from the choices.

> Continent = dict(form.fields['Continent'])[Continent]

I have no idea what this is attempting to do.


Cheers

Tom

-- 
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.




'url' template tag throws and error after upgrading to 1.4

2013-03-28 Thread Bastian
Hi,

I am trying to upgrade an existing project from 1.3 to 1.4.5. I have it 
almost done but when I try to load the home page, in the base.html I have 
this line:



and it throws an error: No module named views.

When I replace the tag with the real url (/jsi18n/) then the error 
disappears but it reappears a little further with another 'url' template 
tag. So I believe something is wrong with this
specific template tag. I have no idea how to debug it. Is there something 
obvious that I missed when upgrading to 1.4?

Here is the traceback:

Traceback:
File 
"/home/env/project/lib/python2.7/site-packages/django/core/handlers/base.py" 
in get_response
  136. response = response.render()
File 
"/home/env/project/lib/python2.7/site-packages/django/template/response.py" 
in render
  104. self._set_content(self.rendered_content)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/response.py" 
in rendered_content
  81. content = template.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/base.py" in 
render
  140. return self._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" 
in instrumented_test_render
  62. return self.nodelist.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/base.py" in 
render
  823. bit = self.render_node(node, context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in 
render_node
  74. return node.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py" 
in render
  123. return compiled_parent._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" 
in instrumented_test_render
  62. return self.nodelist.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/base.py" in 
render
  823. bit = self.render_node(node, context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in 
render_node
  74. return node.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/loader_tags.py" 
in render
  123. return compiled_parent._render(context)
File "/home/env/project/lib/python2.7/site-packages/django/test/utils.py" 
in instrumented_test_render
  62. return self.nodelist.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/base.py" in 
render
  823. bit = self.render_node(node, context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/debug.py" in 
render_node
  74. return node.render(context)
File 
"/home/env/project/lib/python2.7/site-packages/django/template/defaulttags.py" 
in render
  411. url = reverse(view_name, args=args, kwargs=kwargs, 
current_app=context.current_app)
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in reverse
  476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs))
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in _reverse_with_prefix
  363. possibilities = self.reverse_dict.getlist(lookup_view)
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in reverse_dict
  276. self._populate()
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in _populate
  265. lookups.appendlist(pattern.callback, (bits, 
p_pattern, pattern.default_args))
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in callback
  216. self._callback = get_callable(self._callback_str)
File 
"/home/env/project/lib/python2.7/site-packages/django/utils/functional.py" 
in wrapper
  27. result = func(*args)
File 
"/home/env/project/lib/python2.7/site-packages/django/core/urlresolvers.py" 
in get_callable
  92. lookup_view = getattr(import_module(mod_name), 
func_name)
File 
"/home/env/project/lib/python2.7/site-packages/django/utils/importlib.py" 
in import_module
  35. __import__(name)

Exception Type: ImportError at /
Exception Value: No module named views

-- 
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: Redirects working locally but not in live server

2013-03-28 Thread angelika
Hm, well, I've solved it myself, I guess. It must have been a caching 
problem. I changed Debug to True in settings.py to look for errors, and 
then it started working. Something must have reloaded, cuz it still works 
when I change it back. 

For future reference, does anyone know how I can get this type of 
reload/empty cache of the server without having to edit my settings.py?

/Angelika

On Thursday, March 28, 2013 4:10:24 PM UTC+1, angelika wrote:
>
> Hi,
>
> I'm using the django redirects app: 
> https://docs.djangoproject.com/en/1.4/ref/contrib/redirects/ 
> I've created a couple of redirect objects in the admin interface and when 
> I run it locally it works fine, but when I do the same thing on my live 
> server it has no effect. The regular 404 page is showing in stead. The 
> installation is very simple, just a couple of settings and a db table and 
> nothing went wrong there as far as I can see. What am I missing? Locally I 
> run the site with runserver, my liveserver is running nginx and gunicorn. 
> I've restarted both, but it makes no difference. 
>
> Thoughts? Guesses?
>
> /Angelika
>

-- 
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.




Getting the selected value on a Django forms.ChoiceField

2013-03-28 Thread amine antri



**

i'm working on Djnago and i need to know how can i get selected value in 
forms.ChoiceField

class FilterForm(forms.Form):
Continent = forms.ChoiceField(choices=continents())

i tried with :

def affiche_all(request, currency):
if request.method == 'POST':

 
form = FilterForm(request.POST) 

   
if form.is_valid() : 
Continent = form.cleaned_data['Continent']
Continent = dict(form.fields['Continent'])[Continent]
url = reverse('affiche_all', args=(),   kwargs={'continent': 
Continent})
return HttpResponseRedirect(url)

but Continent always return the last value in ChoiceField and what i need 
is the selected one any suggestions?

-- 
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.




Redirects working locally but not in live server

2013-03-28 Thread angelika
Hi,

I'm using the django redirects 
app: https://docs.djangoproject.com/en/1.4/ref/contrib/redirects/ 
I've created a couple of redirect objects in the admin interface and when I 
run it locally it works fine, but when I do the same thing on my live 
server it has no effect. The regular 404 page is showing in stead. The 
installation is very simple, just a couple of settings and a db table and 
nothing went wrong there as far as I can see. What am I missing? Locally I 
run the site with runserver, my liveserver is running nginx and gunicorn. 
I've restarted both, but it makes no difference. 

Thoughts? Guesses?

/Angelika

-- 
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-03-28 Thread Rija RABETOKOTANY RAOBIVELO
Hello,
Thank you for your response.
I found the issue. The include statement inside the root project URLS.py
was not reaching the specified app urls.py  it should reference.
I then find a workaround, I put an import statement inside the root project
URLS.py instead of calling the include directly

Regards!

2013/3/26 Bill Freeman 

> You haven't shown us the call to reverse of use of the url template tag
> that evokes this issue.  A stack trace might be helpful too, in jogging
> someone's memory.
>
> But I seem to recall problems when I named my url patter the same as the
> name of my view function.  It's not that it can't work that way, just that
> it was surprising, and required specifying things strangely in the reverse
> or url call.  But I could be remembering a nightmare instead of reality.
>
> There's always good old pdb.
>
> Bill
>
> On Tue, Mar 26, 2013 at 6:37 AM, rainikotobary 
> wrote:
>
>> Hello,
>>
>> I dont have the $ sign like you but I'm still getting this error.
>> Please, is there any workaround, what are the issues ? I really about to
>> give up
>>
>> Le lundi 4 février 2013 21:48:37 UTC+3, frocco a écrit :
>>>
>>> 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.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/kYPM88rv0rs/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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.
>
>
>

-- 
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.




management commands in namespaced apps

2013-03-28 Thread Alexis Roda

Hi all,
I'm having a hard time making management commands defined in a 
namespaced app available to "manage.py".


I have a namespace python package "dja.skel.core" that provides some 
functionality and a namespace app "dja.skel.django_skel" which defines 
functionality specific to django, a management command named "skel".


"dja.skel.django_skel" is in INSTALLED_APPS but when I run "python 
manage.py help" the "skel" management command is not listed.


Tracking down the problem it seems to be caused by the 
"imp.find_module()" function in 
"django.core.management.find_management_module()".


When calling imp.find_module("dja", None) it returns 
'/home/alex/prog/dja_skel/dja.skel.core/dja' for the path, so locating 
"dja.skel.django_skel.management" will fail as it is being searched for 
in "dja.skel.core".


So my question is if is this a bug or namespace apps are no supported by 
django in the way I'm trying to use them?




Thanks in 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




re: Displaying And Selecting Tags in Admin Site

2013-03-28 Thread Jonathan Harris
Hi All

New to Django and coding in general, so sorry if this has been covered - I
did search the group postings, have read the documentation, trawled the net
etc, but couldn't find anything directly relevant

I have been following various tutorials (django homepage, youtube etc) for
how to start creating a blog site

What I would like to do seems really simple, but I cannot find a solution

Django 1.5 on Ubuntu Server 12.04LTS

It uses Taggable Manager, so in models.py we see

#models.py

from taggit.managers import TaggableManager

class Post(models.Model):
title = models.CharField(max_length=100)

tags = TaggableManager()

#admin.py

from blog.models import Post

class PostAdmin(admin.ModelAdmin):
fieldsets = [
('Title',  {'fields': ['title']}),
..
('Tags', {'fields': ['tags'], 'classes': ['collapse']}),
]

admin.site.register(Post, PostAdmin)



This works fine

What I would like to do is change the way that tags can be viewed and
selected in the admin site

Currently, it is as a comma separated list

I would like to pre-create the tags, then see them in a drop down, or
table, or similar, so that one or more may be selected
The view I am looking to achieve would be as if 'filter_horizontal =
['tags']' had been applied

However, I cannot find a way to do it

I have tried to give the tags a separate class, with a ManyToManyField link
into Post, but any tags that are created are not displayed - and this is
probably really not the right approach

So is it possible to change the way that tags from TaggableManager is
displayed? Can it be as a selection box, or check boxes or anything else?
Or are we stuck with the list approach?

Any advice would be gratefully received

Many Thanks

Jon

-- 
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.




showing an Integerfield as checkbox in form with defaulted as "check"

2013-03-28 Thread Abhishek Kumar
I am trying to show an integer field as check box and wanted to show it as 
default check. 
Does anyone know how to do this.

thanks
ak

-- 
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: manytomany field and intermediary table from a legacy database

2013-03-28 Thread Pankaj Singh
Hey Vittorio,

ManyToManyField has one optional argument for specifying
db_table(http://bit.ly/10ciWdu).

Since, you have different column names, you should create a new model.
and specify that model as `through` argument(http://bit.ly/10cjdgz).
And set `db_table` in `Meta` class of this model.

In this new `through` model, specify all fields and for each field you
can set `db_column` (http://bit.ly/10cjjEU).

Example code

class Person(models.Model):
name = models.CharField(max_length=128)

def __unicode__(self):
return self.name

class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Membership')

def __unicode__(self):
return self.name

class Membership(models.Model):
person = models.ForeignKey(Person, db_column="person_column_name")
group = models.ForeignKey(Group, db_column="group_column_name")
date_joined = models.DateField(db_column="date_joined_column_name")
invite_reason = models.CharField(max_length=64,
db_column="invite_reason_column_name")

class Meta:
db_table = "membership_table_name"

On Wed, Mar 27, 2013 at 11:28 PM, Vittorio  wrote:
> I know that when I define a manytomany field automagically "behind the scene
> Django creates an intermediary join table to represent the many-to-many
> relationship".
> Now I have a legacy MySQL db, feeded by an existing procedure built in
> Filemaker  via ODBC, which I would like to use with django too. In this
> legacy db the "intermediary join table" already exists but with a different
> name and with different name fields.
> How can I tell Django to use that table without creating a new one?
> An example would be very useful.
> Bye from Rome
> Vittorio
>
> --
> 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.
>
>



-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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: South Error in migration:

2013-03-28 Thread Tim Cook
On Thu, Mar 28, 2013 at 6:50 AM, Tom Evans  wrote:

> This should be many migrations, not one migration.
>
> 1) Schema migration: Add nullable foreign key to Project to CCD.
> 2) Data migration: Create Project objects as needed from 'RMversion' links
> 3) Data migration: Update CCD objects to point at projects
> 4) Schema migration: Drop RMversion foreign key from CCD
> 5) Schema migration: Make CCD->Project foreign key not null
>
> Splitting it into multiple migration steps stops this from blowing up
> in your face and preserves your data.
>

Thanks Tom & Juan.

I don't think I did the initial conversion correctly either according to this:
http://south.readthedocs.org/en/latest/convertinganapp.html#converting-an-app

So if I revert my models changes, delete the existing migrations
folder, follow those instructions about converting an app, then break
it up into the steps you laid out.  All will be well.  Correct?

Thanks,
Tim




Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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: models.DecimalField causing weird Attribute/Type errors

2013-03-28 Thread Tomas Pelka
Resolved, the __unicode__ did not returned unicode object.

Dne pátek, 22. března 2013 10:50:08 UTC+1 Tomas Pelka napsal(a):
>
> Hi all
>
> I'm trying to make one of my first apps running but always getting weird 
> errors Attribute/Type for models.DecimalField as well as for DateField.
>
> In case I want to store anything into sqlitedb I always get:
>
> TypeError: 'datetime.datetime' object is unsubscriptable, same for 
> Decimal/int
>
> For the case I already have any records in db and just want to display 
> them in admin interface:
>
> Request Method: GET  Request URL: http://127.0.0.1:8000/admin/energie/el/  
> Django 
> Version: 1.5  Exception Type: AttributeError  Exception Value: 
>
> 'Decimal' object has no attribute 'encode'
>
>  Exception Location: 
> /usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg/django/db/models/base.py
>  
> in __str__, line 433  Python Executable: /usr/bin/python  Python Version: 
> 2.6.6  Python Path: 
>
> ['/home/tpelka/workspace/energie/wsgi/energie',
>  '/usr/lib/python2.6/site-packages/ropemode-0.2-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/rope-0.9.4-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/ropevim-0.4-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/mozmill-1.5.20-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/ManifestDestiny-0.2.2-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/mozrunner-2.5.14-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/jsbridge-2.4.16-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg',
>  '/usr/share/qa-tools/python-modules',
>  '/usr/lib64/python26.zip',
>  '/usr/lib64/python2.6',
>  '/usr/lib64/python2.6/plat-linux2',
>  '/usr/lib64/python2.6/lib-tk',
>  '/usr/lib64/python2.6/lib-old',
>  '/usr/lib64/python2.6/lib-dynload',
>  '/usr/lib64/python2.6/site-packages',
>  '/usr/lib64/python2.6/site-packages/Numeric',
>  '/usr/lib64/python2.6/site-packages/gst-0.10',
>  '/usr/lib64/python2.6/site-packages/gtk-2.0',
>  '/usr/lib64/python2.6/site-packages/webkit-1.0',
>  '/usr/lib/python2.6/site-packages',
>  '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
>
>
> Attaching models,py, admin.py and settings.py
>

Dne pátek, 22. března 2013 10:50:08 UTC+1 Tomas Pelka napsal(a):
>
> Hi all
>
> I'm trying to make one of my first apps running but always getting weird 
> errors Attribute/Type for models.DecimalField as well as for DateField.
>
> In case I want to store anything into sqlitedb I always get:
>
> TypeError: 'datetime.datetime' object is unsubscriptable, same for 
> Decimal/int
>
> For the case I already have any records in db and just want to display 
> them in admin interface:
>
> Request Method: GET  Request URL: http://127.0.0.1:8000/admin/energie/el/  
> Django 
> Version: 1.5  Exception Type: AttributeError  Exception Value: 
>
> 'Decimal' object has no attribute 'encode'
>
>  Exception Location: 
> /usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg/django/db/models/base.py
>  
> in __str__, line 433  Python Executable: /usr/bin/python  Python Version: 
> 2.6.6  Python Path: 
>
> ['/home/tpelka/workspace/energie/wsgi/energie',
>  '/usr/lib/python2.6/site-packages/ropemode-0.2-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/rope-0.9.4-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/ropevim-0.4-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/mozmill-1.5.20-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/ManifestDestiny-0.2.2-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/mozrunner-2.5.14-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/jsbridge-2.4.16-py2.6.egg',
>  '/usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg',
>  '/usr/share/qa-tools/python-modules',
>  '/usr/lib64/python26.zip',
>  '/usr/lib64/python2.6',
>  '/usr/lib64/python2.6/plat-linux2',
>  '/usr/lib64/python2.6/lib-tk',
>  '/usr/lib64/python2.6/lib-old',
>  '/usr/lib64/python2.6/lib-dynload',
>  '/usr/lib64/python2.6/site-packages',
>  '/usr/lib64/python2.6/site-packages/Numeric',
>  '/usr/lib64/python2.6/site-packages/gst-0.10',
>  '/usr/lib64/python2.6/site-packages/gtk-2.0',
>  '/usr/lib64/python2.6/site-packages/webkit-1.0',
>  '/usr/lib/python2.6/site-packages',
>  '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']
>
>
> Attaching models,py, admin.py and settings.py
>

Dne pátek, 22. března 2013 10:50:08 UTC+1 Tomas Pelka napsal(a):
>
> Hi all
>
> I'm trying to make one of my first apps running but always getting weird 
> errors Attribute/Type for models.DecimalField as well as for DateField.
>
> In case I want to store anything into sqlitedb I always get:
>
> TypeError: 'datetime.datetime' object is unsubscriptable, same for 
> Decimal/int
>
> For the case I already have any records in db and just want to display 
> them in admin interface:
>
> Request Method: GET  Request URL: http://127.0.0.1:8000/admin/energie/el/  
> Django 
> Version: 1.5  Exception Type: AttributeError  Exception Value: 
>
> 'Decimal' object has no attribute 'encode'
>
>  Exception Location: 
> 

Re: South Error in migration:

2013-03-28 Thread Tom Evans
On Wed, Mar 27, 2013 at 11:49 PM, Tim Cook  wrote:
> I can't find a similar scenario in the list archives, so .
>
> I had run the initial migration, etc and all seemed fine.
>
> I modified one model from this:
> class CCD(models.Model):
> rm_version = models.ForeignKey(RMversion, 
> related_name='%(class)s_related+')
> ...
>
> to this:
> class CCD(models.Model):
> prj_name = models.ForeignKey(Project, verbose_name="Project Name")
> ...
>
> The new ForeignKey in CCD, points to this, which already has the
> RMversion relation.
>
> class Project(models.Model):
> prj_name = models.CharField("project name", max_length=110, unique=True)
> rm_version = models.ForeignKey(RMversion, 
> related_name='%(class)s_related+')
> owner_group = models.CharField(max_length=110) #must be a member
> of this group to edit this project
>
> During the migration, here are the prompts and my responses:
>

This should be many migrations, not one migration.

1) Schema migration: Add nullable foreign key to Project to CCD.
2) Data migration: Create Project objects as needed from 'RMversion' links
3) Data migration: Update CCD objects to point at projects
4) Schema migration: Drop RMversion foreign key from CCD
5) Schema migration: Make CCD->Project foreign key not null

Splitting it into multiple migration steps stops this from blowing up
in your face and preserves your data.

Cheers

Tom

-- 
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.




[ANN] 'django-smarter' app for declarative style generic views in Django

2013-03-28 Thread Alexey Kinyov
Hello, everyone!

I've released 1.0 beta of the app:
https://github.com/05bit/django-smarter

It helps with adding generic views. Actually, I've build this app for
one of my projects, which is 80% based on generic views, and it seemed
very useful for that particular case :)

As my project evolved and became more complicated, I've got another
look on what an API for library should like, so today I've published
completely renewed version of the app and migrated my project to it.

My approach is to have all generic views in a single class, like
GenericViews class has 'add', 'index', 'edit', 'remove' and 'details'
methods. And to include generic views for some model in a simplest
case you should just write something like this:

import smarter
from myapp.models import Page

site = smarter.Site()
site.register(smarter.GenericViews, Page)

urlpatterns = patterns('',
url(r'^', include(site.urls)),
# other urls ...
)

And for more custom generic views you may subclass from GenericViews
and define options:

class PageViews(smarter.GenericViews):
model = Page
options = {
'add': {
'form': NewPageForm,
'decorators': (login_required,)
},
'edit': {
'form': EditPageForm,
'decorators': (login_required,)
},
'remove': {
'decorators': (login_required,)
}
}

Wide range of options are available, so I hope you'll find it useful
for some cases :)


Regards,
Alex
///

-- 
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: Testing with a custom user model as a ForeignKey in Django 1.5

2013-03-28 Thread Felipe Coelho
2013/3/18 Felipe Coelho 

>  1) Using tests that need the models, but don't actually touch the
>> database. This means you can put the model definition inline in the test
>> code, so AUTH_USER_MODEL has the right value when the code is run. This
>> lets us test validation conditions, etc, but not hit the database. You
>> *might* be able to get away with manually running syncdb in the middle of
>> the test -- Django's swappable_model test contains an example of doing
>> this, but only for the purposes of recreating permissions, not tables.
>
>
> The issue is that I'm trying to port an application with a whole test
> suite to work with custom user models, so I've got many tests which make
> use of classes like ModelWithForeign already.
>
>
>>  2) Define 2 "ModelWIthForeign" classes, and use the "right" one
>> depending on what the User model is at the time of test. This works fine
>> for Django's purposes because "ModelWithForeign" is a test-only model, so
>> it doesn't matter if you have a few of them. This approach won't be
>> successful if you're actually shipping ModelWithForeign as a core part of
>> your system.
>>
>>  3) Use test decorators to skip the test if a non-default user model is
>> in use.
>>
>
> The issue really is that I'm using ModelWithForeign in here, but the real
> app has one class with a ForeignKey to the user model as well. I can
> certainly skip the tests which use that model or which touch the database,
> but since this is a user registration app, being able to test it with other
> user types is quite a requirement for me.
>
>
>> Any suggestions on how to improve Django's testing infrastructure to
>> handle custom User models would be gratefully accepted (especially if they
>> come with patches). It's still new code, so reports of problems like yours
>> are helpful in shaping what features we've missed during initial
>> development.
>>
>
> I don't have any knowledge on the inside of Django, but if I figure out
> something, I'll certainly share it and try to create a patch for it.
>
> Currently I'm running the test suite using a runtests.py file like this
> one , and I'm thinking of
> two possible "solutions":
>
>- Making the runtests.py configure the system with different
>AUTH_USER_MODEL values each time, in a way that would run the tests
>multiple times, each time with a different database layout. The test suite
>would be in charge of creating the database each time, but since I can't
>call settings.configure multiple times, I somehow have to "unload" it
>before moving on to the next test group. This also has the disadvantage
>that, if built into my runtests.py, running the test suite when the app is
>installed in a larger project, only the tests running on the
>project-specified value for AUTH_USER_MODEL would run.
>- Maybe I could use multiple databases. In each one, the ForeignKey
>would be attached to a different user model, and then different databases
>could be selected depending on the currently defined user model. I don't
>know if that is possible, though.
>
> Hi, just a follow up. I had this on StackOverflow as well but didn't get
any answers there, so I just posted the method I'm currently using.
Essentially, I'm launching a different process for each user model, in a
way that I don't have to deal with user model changes, I just accept them
as they are and continue testing. More details:
http://stackoverflow.com/questions/15369987/testing-with-a-custom-user-model-as-a-foreignkey-in-django-1-5/15675119#15675119

-- 
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.