Re: To Django or not to Django

2013-11-24 Thread Nick Santos
I'd say the answer depends on your personal capabilities and objectives.
"Best" tends to always be relative to what you know and your personal
requirements as much as to you specific design requirements. Nothing you've
said here sounds like it couldn't be done with a CMS and some plugins, and
if you're not a proficient programmer, or you want this set up very
quickly, I'd suggest you look there first. If you have a goal of learning
new technologies, or you need specific extension points that a CMS can't
provide, or if you want the experience to be more tightly integrated than a
CMS, then django could be a good option for you.

-Nick 


On Sun, Nov 24, 2013 at 10:37 AM,  wrote:

> Hi,
> I'm looking to build a contest website where there would be a challenge
> every so often where people need to post a video or a picture.  Then all
> users can vote on them, and I can announce a winner.   I would prefer maybe
> if people not actually upload to my site, but provide a link to youtube,
> instragram, etc.
>
> My website building experience is limited, but I am a techie, so I could
> spend some time learning stuff, but my question is, what is the best
> solution for such site?  Do I need a CMS site, maybe use django CMS, or
> just django and use many of the available plugins.   Or is there a host
> that can provide a configurable solution like some have with e-commerce
> sites?
>
>
>
> Help is appreciated.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e64f41f1-3c3a-4237-b9d5-ec61345b74dc%40googlegroups.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM1S3vB70Zp0JcRPCMPw_t%3DbbikXdc4ZrvF6%2BDP0%2Bb2E3OQMFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to use modpython in django version 1.5

2013-11-24 Thread Russell Keith-Magee
On Mon, Nov 25, 2013 at 1:39 PM, nobody  wrote:

> Hi,
>
> After version 1.5, django has disabled mod_python. Can we still use the
> modpython instead of mod_wsgi? If so, how can we install the mod_python,
> doesn't seem a package is available in Debian squeeze or wheezy.
>

No, you can't. The reason Django removed support for mod_python is because
mod_python is an unmaintained project - and that's coming direct from the
maintainers of mod_python. That means it isn't getting bug fixes, nobody is
looking after security issues, or memory leaks, or fixing any of the myriad
problems that mod_python had (including, but not limited to, a lack of
support for Python 3).

This isn't a recent change, either. The Apache project moved mod_python
into the "attic" on 16 Jun 2010. That's 3.5 years ago.

Seriously - there's no reason to be using mod_python these days. You should
be using a container based on WSGI -- mod_wsgi if you want to stick with
Apache, or any of the other excellent WSGI containers (e.g., gunicorn).

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq8485qfPrn336VV-LhGjc4UnSZ4kKHSR38rii3n%3DpHi7qbg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


How to use modpython in django version 1.5

2013-11-24 Thread nobody
Hi,

After version 1.5, django has disabled mod_python. Can we still use the 
modpython instead of mod_wsgi? If so, how can we install the mod_python, 
doesn't seem a package is available in Debian squeeze or wheezy.

Thank you.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a634841-6b6c-4e60-a9c9-2a7f7dd94e39%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Render User Selected Communities (as Checkboxes) in Multiple Choice Form

2013-11-24 Thread JJ Zolper







I was so focused on posting the code I forgot to attach the pictures, now 
I'm putting them in.

On Monday, November 25, 2013 12:13:57 AM UTC-5, JJ Zolper wrote:
>
> Hello,
>
> Hopefully it becomes clear as well from my code but, here is what is going 
> on. There is an Athlete registration form which has a long list of choices 
> or communities in the form of a multiple choices that the user can select 
> to then become a part of the communities they select. Then what I'm trying 
> to do is in my EditProfile view basically render this long list of multiple 
> choices again but obviously it would make sense to show the user what ones 
> they have selected/are already in, be able to deselect from this group to 
> remove themselves from the ones they selected on registration, or to select 
> new ones to then be added to those communities.
>
> My EditProfile view:
>
> # AU Athlete Edit Profile
>
> def EditProfile(request):
>
> if request.user.is_authenticated():
>
> contexterror = {}
>
> context = {}
>
> contexterror = {'Error': 'Error'}
>
> # Since it is the generic view know we know if the user in the 
> request is a specific group this way
>
> if request.user.groups.filter(name='Athletes').exists():
>
> # Since it is the generic view know we know if the user in 
> the request is in 'Athletes' / member of of the 'Athletes' Group
>
> if request.method == 'POST':
>
> userprofile = UserProfileUpdateForm(request.POST, 
> instance=request.user)
>
> athleteprofile = AthleteProfileUpdateForm(request.POST, 
> instance=request.user.profile)
>
> # Need to make it so it checks the forms properly and 
> saves the info if its correct
>
> if userprofile.is_valid() and athleteprofile.is_valid():
>
> # Do something with the user selected athlete groups 
> below
>
> athletegroupsids = request.POST.getlist(
> 'athletecommunities')
>
> # Iterate though all the athlete group names and 
> collect the objects which we can use to add the request.user to those 
> athlete groups
>
> for athletegroupLOWERCASEname in athletegroupsids:
>
> # Filter through all the communities and take the 
> check box selection id which is lowercase and compare it to the 
> communityurl which is the lowercase name
>
> AthleteCommunities = Community.objects.get(url = 
> athletegroupLOWERCASEname)
>
> # Check to make sure we have one athlete 
> community that we want to add the athlete to
>
> # Get the name of the athlete community
>
> AthleteCommunityName = AthleteCommunities.name
>
> # By taking the desired athlete community name 
> and filtering down the Athlete Group name be then add the user to the group
>
> AddAthleteToGroup = 
> Group.objects.get(name=AthleteCommunityName)
>
> 
> AddAthleteToGroup.user_set.add(request.user.athlete.athleteuser)
>
> # Now the user has been added to all the groups they 
> selected and notifications will go when a post is made in each respective 
> group
>
> # Save the two forms to the database
>
> userprofile.save() and athleteprofile.save()
>
> return HttpResponseRedirect('/profile/')
>
> else:
>
> user = request.user
>
> profile = user.profile
>
> userprofile = UserProfileUpdateForm(instance = user)
>
> athleteprofile = AthleteProfileUpdateForm(instance = 
> profile)
>
> context = {'AthleteProfileUpdateForm': athleteprofile, 
> 'UserProfileUpdateForm': userprofile}
>
> return render_to_response('editprofile.html', context, 
> context_instance = RequestContext(request))
>
> return render_to_response('editprofile.html', contexterror, 
> context_instance = RequestContext(request))
>
> return HttpResponseRedirect('/login/')
>
>
>
> My forms.py:
>
>
> from django import forms
>
> from django.forms import ModelForm
>
> from django.contrib.auth.models import User
>
> from athletesunited.athletes.models import Athlete
>
>
> # Athlete Community Choices
>
> ATHLETECOMMUNITIESCHOICES = (('archery', 'Archery',), ('mensbasketball', 
> 'Men\'s 
> Basketball',), ('womensbasketball', 'Women\'s Basketball',), ('baseball', 
> 'Baseball',), ('cardio', 'Cardio',), ('cheerleading', 'Cheerleading',), (
> 

Render User Selected Communities (as Checkboxes) in Multiple Choice Form

2013-11-24 Thread JJ Zolper
Hello,

Hopefully it becomes clear as well from my code but, here is what is going 
on. There is an Athlete registration form which has a long list of choices 
or communities in the form of a multiple choices that the user can select 
to then become a part of the communities they select. Then what I'm trying 
to do is in my EditProfile view basically render this long list of multiple 
choices again but obviously it would make sense to show the user what ones 
they have selected/are already in, be able to deselect from this group to 
remove themselves from the ones they selected on registration, or to select 
new ones to then be added to those communities.

My EditProfile view:

# AU Athlete Edit Profile

def EditProfile(request):

if request.user.is_authenticated():

contexterror = {}

context = {}

contexterror = {'Error': 'Error'}

# Since it is the generic view know we know if the user in the 
request is a specific group this way

if request.user.groups.filter(name='Athletes').exists():

# Since it is the generic view know we know if the user in the 
request is in 'Athletes' / member of of the 'Athletes' Group

if request.method == 'POST':

userprofile = UserProfileUpdateForm(request.POST, 
instance=request.user)

athleteprofile = AthleteProfileUpdateForm(request.POST, 
instance=request.user.profile)

# Need to make it so it checks the forms properly and saves 
the info if its correct

if userprofile.is_valid() and athleteprofile.is_valid():

# Do something with the user selected athlete groups 
below

athletegroupsids = request.POST.getlist(
'athletecommunities')

# Iterate though all the athlete group names and 
collect the objects which we can use to add the request.user to those 
athlete groups

for athletegroupLOWERCASEname in athletegroupsids:

# Filter through all the communities and take the 
check box selection id which is lowercase and compare it to the 
communityurl which is the lowercase name

AthleteCommunities = Community.objects.get(url = 
athletegroupLOWERCASEname)

# Check to make sure we have one athlete community 
that we want to add the athlete to

# Get the name of the athlete community

AthleteCommunityName = AthleteCommunities.name

# By taking the desired athlete community name and 
filtering down the Athlete Group name be then add the user to the group

AddAthleteToGroup = 
Group.objects.get(name=AthleteCommunityName)


AddAthleteToGroup.user_set.add(request.user.athlete.athleteuser)

# Now the user has been added to all the groups they 
selected and notifications will go when a post is made in each respective 
group

# Save the two forms to the database

userprofile.save() and athleteprofile.save()

return HttpResponseRedirect('/profile/')

else:

user = request.user

profile = user.profile

userprofile = UserProfileUpdateForm(instance = user)

athleteprofile = AthleteProfileUpdateForm(instance = 
profile)

context = {'AthleteProfileUpdateForm': athleteprofile, 
'UserProfileUpdateForm': userprofile}

return render_to_response('editprofile.html', context, 
context_instance = RequestContext(request))

return render_to_response('editprofile.html', contexterror, 
context_instance = RequestContext(request))

return HttpResponseRedirect('/login/')



My forms.py:


from django import forms

from django.forms import ModelForm

from django.contrib.auth.models import User

from athletesunited.athletes.models import Athlete


# Athlete Community Choices

ATHLETECOMMUNITIESCHOICES = (('archery', 'Archery',), ('mensbasketball', 
'Men\'s 
Basketball',), ('womensbasketball', 'Women\'s Basketball',), ('baseball', 
'Baseball',), ('cardio', 'Cardio',), ('cheerleading', 'Cheerleading',), (
'crochet', 'Crochet',), ('dieting', 'Dieting',), ('football', 'Football',), 
('golf', 'Golf',), ('gymnastics', 'Gymnastics',), ('hockey', 'Hockey',), (
'injuryrecovery', 'Injury Recovery',), ('lacrosse', 'Lacrosse',), ('lifting', 
'Lifting',), ('rugby', 'Rugby',), ('racing', 'Racing',), ('swimming', 
'Swimming',), ('soccer', 'Soccer',), ('skateboarding', 'Skateboarding',), (
'tennis', 'Tennis',),  ('wrestling', 'Wrestling',))


# Athlete Update Profile Form

class AthleteProfileUpdateForm(ModelForm):

athletebirthday = forms.CharField(label=(u'Athlete Birthday:'))

athleteurl = forms.CharField(label=(u'Athlete Url:'))

#athletecommunities = forms.MultipleChoiceField(label=(u'Athlete 
Communities:'), 

Re: Editing html templates from front end

2013-11-24 Thread Mario Gudelj
In this case you need to store templates in db which means you need to have
a custom loader for your templates. I think that this app does what you
need https://pypi.python.org/pypi/django-dbtemplates

Cheers,

M
On 25/11/2013 1:39 AM, "Harjot Mann"  wrote:

> In django Is there any way through which we can edit the html
> templates from front end and those changes should also be updated in
> database like an edit button on the page?
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB0GQhB9hkwPke219aHyawYYN8ZjGUFWPc1hoxh_K_H3%3DAoXHg%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbj%3DWc9ZigLk-py%2BARDP63vNobxd5qHRfpbagULjzoQz8MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


To Django or not to Django

2013-11-24 Thread zaptor999
Hi,
I'm looking to build a contest website where there would be a challenge 
every so often where people need to post a video or a picture.  Then all 
users can vote on them, and I can announce a winner.   I would prefer maybe 
if people not actually upload to my site, but provide a link to youtube, 
instragram, etc.

My website building experience is limited, but I am a techie, so I could 
spend some time learning stuff, but my question is, what is the best 
solution for such site?  Do I need a CMS site, maybe use django CMS, or 
just django and use many of the available plugins.   Or is there a host 
that can provide a configurable solution like some have with e-commerce 
sites?



Help is appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e64f41f1-3c3a-4237-b9d5-ec61345b74dc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: how to get at the manytomany fields in for

2013-11-24 Thread Daniel Roseman
No, that is incorrect. `dir_list` is a queryset of AdviceLevel objects, and 
`specialism` is a field defined directly on that model. You only need to add 
`_set` for a reverse relationship, which this isn't.
-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/723be118-c10d-4bdf-8c60-58da710c3d3f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman  wrote:
> Hmm, I tried to post an answer to your original question earlier but it never 
> appeared.
>

Thanks Daniel.  Your help is very much appreciated.

> The reason why adding the values to `cleaned_data` doesn't work is that those 
> fields aren't in the `fields` list for the form in the first place, so it 
> doesn't know to do anything with them. Adding them to the uncommitted model 
> instance is the correct solution.
> --

I guess I was thinking that cleaned_data is a dictionary sent to the
ORM for commit?

Now, what is confusing is why saving the 'form' instance to another
(in this case 'f') instance without a commit and adding the values to
the new instance makes a difference.  Isn't 'f' just a copy of 'form'?

Any clarification?

Thanks,
Tim



> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d0ad9a93-ffbf-4439-a06a-270c965cfb6a%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XpKaumgVELGac%3DL4xoOTJFM%3DyN0ruk7V4A1jdfwTPVCA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form cleaned_data

2013-11-24 Thread Daniel Roseman
Hmm, I tried to post an answer to your original question earlier but it never 
appeared.

The reason why adding the values to `cleaned_data` doesn't work is that those 
fields aren't in the `fields` list for the form in the first place, so it 
doesn't know to do anything with them. Adding them to the uncommitted model 
instance is the correct solution.
-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0ad9a93-ffbf-4439-a06a-270c965cfb6a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
SOLVED:  (I think)

Though I do not understand the how/why.  From an example on
StackOverflow I tried changing the post method to this:

def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)

if form.is_valid():
# 
paper = get_object_or_404(Paper,pk=kwargs['pk'])
reviewer =
Reviewer.objects.filter(user=self.request.user).filter(prj_name=paper.project)
f = form.save(commit=False)
f.reviewer = reviewer[0]
f.paper = paper
f.stage = paper.current_stage
f.save()
return HttpResponseRedirect('#')

return render(request, self.template_name, {'form': form})


and it works.  Now to study more about saving the form to a new object
and then adding the additional data before saving with a commit.  Very
confusing ...


On Sun, Nov 24, 2013 at 11:46 AM, Timothy W. Cook  wrote:
> I have an issue with save data from a form.
>
> The actual form has one required and two optional fields.
> The model has three additional fields that I want to assign based on
> the context, two of those are ForeignKey related.
>
> The post method in the view:
> def post(self, request, *args, **kwargs):
> form = self.form_class(request.POST)
>
> if form.is_valid():
> # 
> paper = get_object_or_404(Paper,pk=kwargs['pk'])
> reviewer =
> Reviewer.objects.filter(user=self.request.user).filter(prj_name=paper.project)
> form.cleaned_data['reviewer'] = reviewer[0]
> form.cleaned_data['paper'] = paper
> form.cleaned_data['stage'] = paper.current_stage
> print(form.cleaned_data)
> form.save()
> return HttpResponseRedirect('#')
> return render(request, self.template_name, {'form': form})
>
> The form:
> class ReviewTitleCreateForm(ModelForm):
> class Meta:
> model = Review
> fields = ['include','exclusion_choice','exclusion_text',]
>
>
> The model:
> class Review(models.Model):
> """
> A review at a specific stage of one paper.
> """
> INCLUDE_CHOICES = [(True,'Include'),(False,'Exclude')]
> STAGES = [('Selection by Title','Selection by Title'),('Selection
> by Abstract','Selection by Abstract'),
>   ('Selection by Full Text','Selection by Full Text')]
>
> reviewer = models.ForeignKey(Reviewer, verbose_name=_('Reviewer'),
> related_name="%(app_label)s_%(class)s_related", null=False,
> blank=False, help_text=_("The reviewer of this paper, at this
> stage."))
> paper = models.ForeignKey(Paper, verbose_name=_('Paper'),
> related_name="%(app_label)s_%(class)s_related", null=False,
> blank=False, help_text=_("The reviewed paper."))
> review_stage = models.CharField("Review Stage",max_length=30,
> choices=STAGES, help_text="The stage for review of this paper.")
> include = models.NullBooleanField("Choice",
> choices=INCLUDE_CHOICES, default=True, null=False, blank=False,
> help_text="Select Include or Exclude for this stage of review.")
> exclusion_choice = models.ForeignKey(Exclusion, null=True,
> blank=True, related_name="%(app_label)s_%(class)s_related")
> exclusion_text = models.TextField(null=True, blank=True)
>
>
> When I output the cleaned_data from the print at the bottom of the
> post method (see above), I get this:
> {'reviewer': , 'include': True, 'paper':  Assessing the quality of clinical data in a computer-based record for
> calculating the pneumonia severity index.>, 'exclusion_text': '',
> 'stage': 'Selection by Title', 'exclusion_choice': None}
>
>
> Which looks correct, to me.  However I am getting an error as if there
> is no Reviewer assigned:
> IntegrityError at /papers/review_title/3
> null value in column "reviewer_id" violates not-null constraint
> Request Method:POST
>
> Any ideas?
>
> Thanks,
> Tim
>
>
>
>
>
>
>
>
>
> --
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> 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



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

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 

Re: Translation from templates doesn't work.

2013-11-24 Thread Ramiro Morales
On Sun, Nov 24, 2013 at 4:21 AM, Shahar Or  wrote:
> String in my template don't translate. They stay English even though they do
> pop up in the po files using `makemessages`.

Do you comvert these -po files to .mo files using the compilemessages
Django command or the msgfmt GNU gettext utility?

Otherwise the translations wont be picked up.


-- 
Ramiro Morales
@ramiromorales

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO7PdF_eh5Qr_d_KbgaoaC2YCuu-q1M-qcAvQUTeLO59opohvA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Generate a random directory for files to be uploaded

2013-11-24 Thread Michael Manfre
There are two things that you'll need to do. Set the random directory name 
on the UpFile instance in the view and define a function to use with 
upload_to that uses the random directory name on the instance to define the 
file's target path.

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to

Regards,
Michael Manfre

On Saturday, November 23, 2013 10:33:59 AM UTC-5, Matt Lind wrote:
>
> So I am trying to modify django-jfu ( a multi uploader) to send files to a 
> unique directory for every unique upload session performed.  This is just 
> due to my application's requirements and to prevent file collisions during 
> the operations later down the road in my app.
>
> Anyway, here is views.py (I think the most relevant portion anyway, I 
> could be wrong)
>
> def upload( request ):
>
> # The assumption here is that jQuery File Upload
> # has been configured to send files one at a time.
> # If multiple files can be uploaded simulatenously,
> # 'file' may be a list of files.
> #Create the file object
> file = upload_receive( request )
>
> #Create an instance of our Uploader Class and pass it the file object
> instance = UpFile ( file = file )
> #Save the file object
> instance.save() 
>
> And the "UpFile" class in models.py:
>
> class UpFile(models.Model):
> file = models.FileField( upload_to = 
> MEDIA_ROOT+'/'+"".join([random.choice(string.ascii_letters) for n in 
> xrange(12)]))
>
> The problem I am having is that it appears that the "random" section at 
> the tail end of the "upload_to" option in models,py is processed only once 
> when the server is started (or restarted).
>
> This won't work for my particular application, as I need the "top level" 
> for any uploaded of a set of files to be unique.
>
> For example if I have the following "upload sessions"
>
> Session 1:  User only uploaded a single file.  A new random/unique 
> directory should be generated under MEDIA_ROOT, and the file should be 
> placed in that directory.
> Session 2:  User uploaded 2 files.  A new random/unique directory should 
> be generated under MEDIA_ROOT, and BOTH files should be uploaded to that 
> directory (NOT a different directory per file)
> Session 3:  User uploaded 100 files.  Like session 2 above, a new 
> random/unique directory should be generated under MEDIA_ROOT and all 100 
> files should be placed underneath.
>
> Later on I plan on cleaning house, but for now simply getting that logic 
> down will get me moving again...
>
> Thanks for any help you can provide.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/50e14318-214e-4560-a27e-03325e250998%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Editing html templates from front end

2013-11-24 Thread Harjot Mann
In django Is there any way through which we can edit the html
templates from front end and those changes should also be updated in
database like an edit button on the page?
-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB0GQhB9hkwPke219aHyawYYN8ZjGUFWPc1hoxh_K_H3%3DAoXHg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Translation from templates doesn't work.

2013-11-24 Thread gilberto dos santos alves
please could you post url or some more details!

Em domingo, 24 de novembro de 2013 07h21min12s UTC, Shahar Or escreveu:
>
> String in my template don't translate. They stay English even though they 
> do pop up in the po files using `makemessages`.
>
> To make sure that the current `lang` is indeed what I expect it to be, I 
> use `{{ lang }}` in the template somewhere.
>
> I have `{% load i18n %}` in the template somewhere near the top. Does the 
> order matter?
>
> I have `USE_I18N = True` and
> ```
> TEMPLATE_CONTEXT_PROCESSORS = (
> 'django.contrib.auth.context_processors.auth',
> 'django.core.context_processors.i18n',
> 'django.core.context_processors.request',
> 'django.core.context_processors.media',
> 'django.core.context_processors.static',
> 'cms.context_processors.media',
> 'sekizai.context_processors.sekizai',
> 'bidiutils.context_processors.bidi',
> )
> ```
>
> I restart the server and still I get no translation.
>
> I don't know whether translation from code such as views works because I 
> didn't code any views. i'm only using `django-cms` and in it's scope 
> translation does seem to work because it's interface gets translated and I 
> do get the pages in the language that I expect.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6f83c68-ee92-4319-bae4-15b74de0916d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Form cleaned_data

2013-11-24 Thread Timothy W. Cook
I have an issue with save data from a form.

The actual form has one required and two optional fields.
The model has three additional fields that I want to assign based on
the context, two of those are ForeignKey related.

The post method in the view:
def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)

if form.is_valid():
# 
paper = get_object_or_404(Paper,pk=kwargs['pk'])
reviewer =
Reviewer.objects.filter(user=self.request.user).filter(prj_name=paper.project)
form.cleaned_data['reviewer'] = reviewer[0]
form.cleaned_data['paper'] = paper
form.cleaned_data['stage'] = paper.current_stage
print(form.cleaned_data)
form.save()
return HttpResponseRedirect('#')
return render(request, self.template_name, {'form': form})

The form:
class ReviewTitleCreateForm(ModelForm):
class Meta:
model = Review
fields = ['include','exclusion_choice','exclusion_text',]


The model:
class Review(models.Model):
"""
A review at a specific stage of one paper.
"""
INCLUDE_CHOICES = [(True,'Include'),(False,'Exclude')]
STAGES = [('Selection by Title','Selection by Title'),('Selection
by Abstract','Selection by Abstract'),
  ('Selection by Full Text','Selection by Full Text')]

reviewer = models.ForeignKey(Reviewer, verbose_name=_('Reviewer'),
related_name="%(app_label)s_%(class)s_related", null=False,
blank=False, help_text=_("The reviewer of this paper, at this
stage."))
paper = models.ForeignKey(Paper, verbose_name=_('Paper'),
related_name="%(app_label)s_%(class)s_related", null=False,
blank=False, help_text=_("The reviewed paper."))
review_stage = models.CharField("Review Stage",max_length=30,
choices=STAGES, help_text="The stage for review of this paper.")
include = models.NullBooleanField("Choice",
choices=INCLUDE_CHOICES, default=True, null=False, blank=False,
help_text="Select Include or Exclude for this stage of review.")
exclusion_choice = models.ForeignKey(Exclusion, null=True,
blank=True, related_name="%(app_label)s_%(class)s_related")
exclusion_text = models.TextField(null=True, blank=True)


When I output the cleaned_data from the print at the bottom of the
post method (see above), I get this:
{'reviewer': , 'include': True, 'paper': , 'exclusion_text': '',
'stage': 'Selection by Title', 'exclusion_choice': None}


Which looks correct, to me.  However I am getting an error as if there
is no Reviewer assigned:
IntegrityError at /papers/review_title/3
null value in column "reviewer_id" violates not-null constraint
Request Method:POST

Any ideas?

Thanks,
Tim









-- 
MLHIM VIP Signup: http://goo.gl/22B0U

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3V8m%3DjJms2Zyt0h6-dRE2qmwieAHgYPVyDRsth095oesA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to fix URL link redirecting from login?

2013-11-24 Thread Vibhu Rishi
Its the @login_required decorator.
https://docs.djangoproject.com/en/1.2/topics/auth/#the-login-required-decorator

V.


On Sun, Nov 24, 2013 at 3:46 PM, Timothy W. Cook  wrote:

> Check in the docs for the instructions on decorating your views to
> restrict to authenticated users.  This also talks about redirecting to
> a page instructing them to login.  Sorry, I don't have the link
> available right now.
>
>
> On Sat, Nov 23, 2013 at 10:40 PM, nobody  wrote:
> > Hi,
> >
> > I made an URL link in an email, if I have logged into the web site, then
> I
> > can click the link, it would bring to a valid web page. But if I haven't
> > logged log in, to click the link would result an error "page not found".
> How
> > can I fix it to check if a user has not logged in, it opens a log page to
> > ask the user to log in rather than an error page, after the user loges
> in,
> > it would redirect to the link URL page?
> >
> > Thank you.
> >
> > Kind regards.
> >
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/ff130970-c4d4-4a96-8748-d386217b9cf5%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WJCAEwgGzvgnH1bH%3DpxtQ%3DWEGO%3DZcJHaWKXz%2BT2863Tw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPiONwno25Gf0KyKoFZWVD%2ByHF8m7%2Biw8KQLOTx8TPDUUrxxbA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I use mathematical calculations on my forloop Article/Publication list?

2013-11-24 Thread Pepsodent Cola
Thanks airstrike I will check out your suggestions and study it.


Also, is there a reason why you're not using class based views?

Well as a newbie programmer I started out following the Django polls 
tutorial writing my views using CBVs.  But then when I had trouble doing 
things with my database and sending my database data through the Views and 
to the Template pages, since I'm not very familiar with MVC coding.
Explaining my MVC problems was very difficult and it took months before I 
could get any helpful hints, and when I did get help the CBV related help 
was too complicated for me to understand and study.

So after 6 months of trying to work with MVC, I signed up for a local 
Django Meetup.com meeting in real life.  There I grabbed a person who has 
worked with Django professionally most of their life and showed him my 
Django polls code project.

Explaining my problems was very difficult because CBVs confuse me so much.  
I find it hard to see what is going on under the hood.
Then when I saw how this Django professional had a hard time untangling my 
View code.  Also he said using CBVs is the preferred way but writing 
function based Views is simpler to follow.

I then decided to get rid of all my CBVs and write function based Views 
only.  Suddenly the time it takes for me to explain my MVC problems and get 
help went down from months to only days. :)

On an academic level I realize using CBVs is the most efficient way but 
being a total Framework beginner I'm having trouble seeing the real 
practical advantage of using CBVs compared to simple function based Views.  
The function based Views looks more cleaner and lighter to my eyes compared 
to CBV code and I find it easier to follow what is going on, less magic 
going on under the hood.






On Wednesday, November 20, 2013 10:29:24 PM UTC+1, Pepsodent Cola wrote:
>
> 1.)
> How do I use mathematical calculations on my forloop Article/Publication 
> list?
>
> * I have attached a screenshot with the table field that I'm working on 
> *"Publicists 
> coverage (%)"*.
> * Admin user/pass = joe/joe
> * I have also attached my project files so that you can see things for 
> yourselves.
>
>
> 2.)
> Is the solution I'm working with in "Index View page" the correct practice 
> to do my mathematical calculations?
>
>
> #___
>
> def index(request):
> publications = Publication.objects.all()
>
>
> # sum_publications = Publication.objects.filter(article__pk=1).count()
> articles = 
> Article.objects.all().annotate(num_publications=Count('publications'))
> *#articles_int = int(articles)*
>
> *sum_publicists = Publication.objects.all().count()*
>
> *#publicists_coverage = articles/sum_publicists*
>
>
> #context = {'publications':publications, 
> 'sum_publicists':sum_publicists,
> #   'publicists_coverage':publicists_coverage, 
> 'articles':articles}
> context = {'publications':publications, 
> 'sum_publicists':sum_publicists,
>'articles':articles}
> return render(request, 'magazine/index.html', context)
>
> #___
>
> 
> How many Publications was each Article in?
>
> {% if articles %}
> 
> 
> Article id
> Article
> Publication
> *Publicists coverage (%)*
> 
> {% for row in articles %}
> 
> {{ 
> row.id}}
> {{ row.headline }}
> {{ row.num_publications }}
> (*{{ row.num_publications }} / {{ sum_publicists }}*) = x 
> %
> 
> {% endfor %}
> 
> {% else %}
> No Articles are available.
> {% endif %}
>
> 
> 
>
>
> #___
>
>
> 3.)
> When I try to convert articles object into int it doesn't work.  Am I 
> going the wrong direction when thinking about solving things like this?
>
>
> Exception Type: TypeError
> Exception Value: *int() argument must be a string or a number, not 
> 'QuerySet'*
> Exception Location: /home/linux/Django/ManyToMany/magazine/views.py in 
> index, line 17
>
>
> >>> articles = 
> Article.objects.all().annotate(num_publications=Count('publications'))
> >>> type(articles)
> 
> >>> 
> >>> *articles_int = int(articles)*
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: int() argument must be a string or a number, not 'QuerySet'
> >>> 
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 

Re: How to fix URL link redirecting from login?

2013-11-24 Thread Timothy W. Cook
Check in the docs for the instructions on decorating your views to
restrict to authenticated users.  This also talks about redirecting to
a page instructing them to login.  Sorry, I don't have the link
available right now.


On Sat, Nov 23, 2013 at 10:40 PM, nobody  wrote:
> Hi,
>
> I made an URL link in an email, if I have logged into the web site, then I
> can click the link, it would bring to a valid web page. But if I haven't
> logged log in, to click the link would result an error "page not found". How
> can I fix it to check if a user has not logged in, it opens a log page to
> ask the user to log in rather than an error page, after the user loges in,
> it would redirect to the link URL page?
>
> Thank you.
>
> Kind regards.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ff130970-c4d4-4a96-8748-d386217b9cf5%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WJCAEwgGzvgnH1bH%3DpxtQ%3DWEGO%3DZcJHaWKXz%2BT2863Tw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.