Re: My "Contributors" page Conundrum

2012-09-18 Thread JJ Zolper
Melyvn,

Thanks for the tip but I'm still having trouble understand how to make this 
work.

If you see the post I sent to Nick that should explain my problem in enough 
detail.

Maybe you can give some advice or any example of some sort?

Thanks,

JJ

On Tuesday, August 28, 2012 2:24:03 AM UTC-4, Melvyn Sopacua wrote:
>
> On 28-8-2012 6:58, JJ Zolper wrote: 
>
> > My problem is that I want each contributor to have their own separate 
> page. 
> > So if the first guys name for some example is Mike Smith then if you 
> were 
> > to click his name for example you would be sent to 
> > /about/contributor/mikesmith and so on. 
>
> <
> https://docs.djangoproject.com/en/1.4/ref/models/instances/#django.db.models.Model.get_absolute_url>
>  
>
> and make sure you read the permalink bit. 
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/DKB3lEvJuLcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: My "Contributors" page Conundrum

2012-09-18 Thread JJ Zolper
Nick,

Sorry my other very long posted vanished so I'm going to keep it shorter 
this time.

So I was able to implement what you said. Thanks a lot!

Only tricky part is I had to change my name in the database to "JJZolper" 
instead of "JJ Zolper" so that it could find me.

So now if you do:

http://www.madtrak.com/about/contributors/JJZolper

It works!

However, that's not very practical so I could use some help still. I'm 
wondering if I should come up with some other field in my contributor 
database like "id" or something and see if I could make it so it takes the 
name "JJ Zolper" and creates an id of "jjzolper" and thus when 

http://www.madtrak.com/about/contributors/jjzolper

is called everything is happy because the same code you showed me would go 
through the database and work fine! Is this a good practice or is there a 
better way?

Also, even though I've made progress on requesting the page with the name 
and all that I still have another problem.

On this page:

http://www.madtrak.com/about/contributors

If you click a name to hopefully go to the page of that contributor it 
breaks. Here is the code:


{% for Contributor in Contributors_List %}
{{ Contributor.name 
}}

Title: {{ Contributor.title }}

{% endfor %}


So bascially it pulls the contributor name which is messed up now cause I 
changed my name to JJZolper but this seems to work.

I was trying to go after what Melvyn said about permalink and get absolute 
url to try to solve the problem of making these two pages actually connect 
up but I still haven't made it work. Any ideas there?

I could use some help basically depending on the object handling the 
absolute url function and then sending it off to the respective url and 
then the file. I mean those are the right steps I think?

Thanks so much,

JJ

PS. I'm making sure to copy this so hopefully it won't just crap out on me 
before I post it. Oh the joys of spending time on something and it getting 
destroyed. The internet is fun, eh? haha

On Tuesday, August 28, 2012 1:50:09 AM UTC-4, Nick Santos wrote:
>
> Hi JJ,
>
> You're absolutely right that there is a better way to do this that doesn't 
> involve repetition. To start with, check out the docs under example on the 
> page for the URL dispatcher: 
> https://docs.djangoproject.com/en/dev/topics/http/urls/ - I'll walk you 
> through part of it though.
>
> First, let's take a look at how capture groups work. Capture groups allow 
> you to pass a variable portion of the url to a view, which is what you'll 
> need to do in order to have one definition that lets you have a generic 
> view that looks up the contributor. So, you can assign a view to a URL 
> where only part of it is known at the time of the definition, and pass the 
> unknown parts into the view. In your case, your url definition would look 
> like:
>
> urlpatterns = patterns('',
>  your other patterns...
> (r'^about/contributor/(?P[a-zA-Z]+)/$', 'your.view.name
> '),
> possibly more patterns 
> )
>
> So, what that (?P[a-zA-Z]+) says, in parts is that we want to 
> capture a value - designated by the parenthesis - to be passed to 
> your.view.name as a named parameter called contribname - this is defined 
> by the ?P. That value looks like text with at least one 
> character. The text definition is [a-zA-Z] (careful, this doesn't include 
> spaces right now)and the at least one is +, and comes between two slashes. 
> If you want to learn more about writing things like that, look into regular 
> expressions.
>
> Then, in your view, you can take that parameter and look up the relevant 
> contributor and make the view generic to something like:
>
> def contributor_page(request, contribname):
> contrib_object = Contributor.objects.filter(name=contribname)
> return render_to_response('contributor.html', {'Contributor': 
> contrib_object}, context_instance = RequestContext(request))
>
> Then, in outputting your links, you can put the relevant name in the url, 
> etc.
>
> I hope that helps. Let me know if anything is unclear. Good luck
>
>
> On Mon, Aug 27, 2012 at 9:58 PM, JJ Zolper  > wrote:
>
>> Hello,
>>
>> I'm trying to develop a simple hyperlink between two pages. It sounds 
>> simple but it's a little bit more complex then that.
>>
>> Here is the template code that proceeds through the database of 
>> contributors:
>>
>> Contributors
>>
>> 
>>  {% for Contributor in Contributors_List %}
>> http://www.madtrak.com/about/contributors/;>{{ 
>> Contributor.name }}
>>  
>> Title: {{ Contributor.title }}
>> 
>>  {% endfor %}
>> 
>>
>> and spits out the contributors name in a link form and the title of that 
>> person.
>>
>> My problem is that I want each contributor to have their own separate 
>> page. So if the first guys name for some example is Mike Smith then if you 
>> were to click his name for example you would be sent to 
>> /about/contributor/mikesmith 

Re: Hello World with Django

2012-09-18 Thread Stephen Anto
Hi,

It is very simple to say hello world through Django projects, Only 7 steps
ahead to say... 

Pls visit http://www.f2finterview.com/web/Django/17/ its clearly guide you
step by step to say hello world via django.

Thank you for visiting  For more Django visit:
http://www.f2finterview.com/web/Django

On Mon, Sep 17, 2012 at 2:54 AM,  wrote:

>
> Hi,
>
> Can someone help me in this question?
>
>
> http://stackoverflow.com/questions/12399318/why-do-i-need-django-for-a-simple-hello-world
>
> As you can see, the Flask solution is only "half answer" and the Django
> solution in my web hosting service
> doesn't work and, as you can imagine, I don't have access to
> http://127.0.0.1/ because
> this is the "localhost" of my computer and I am accessing a remote server.
>
> Thank you in advance
>
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/JpWu0xcrY1MJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards
Stephen S



Website: www.f2finterview.com
Blog:  blog.f2finterview.com
Tutorial:  tutorial.f2finterview.com
Group:www.charvigroups.com

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



Re: date display problem?

2012-09-18 Thread Lachlan Musicman
 On Wed, Sep 19, 2012 at 3:51 PM, Navnath Gadakh
 wrote:
> model
>class Offer(models.Model):
> effective_date = models.DateField()
> expiration_date = models.DateField()

Nothing wrong here

> view.py
> HTML = HTML + ""
> HTML = HTML + "Offer Description :
> "+offer.description+""
> HTML = HTML + "Coupon Number :
> "+coupon_no.coupon_detail+""
> HTML = HTML + "Effective Date :
> "+str(offer.effective_date)+""
> HTML = HTML + "Expiration Date :
> "+str(offer.expiration_date)+""
> HTML = HTML + ""
> HTML = HTML + ""
>
> at the time of create offer i print variable for expiration and effective
> date in view it worked fine.
> but in temlate it did't other fields displays.
> effective date and expiration date not displaying on browser..


My django isn't good enough to quiet understand your view, but since
you have the offer object there in the view, why don't you pass it to
the template via

render_to_response('/path/to/template.html',{'offer':offer})

And then in your template path/to/template.html

you just need to use the variable

{{ offer.effective_date }}

for instance?

cheers
L.

-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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



problem with html select box values

2012-09-18 Thread Navnath Gadakh
i have project for online shoping in that i use product category and and 
product names.
   i have taken product name in select dropdown box.
 now i want to create offer for any perticular product whatever i selected .

but at the time of product name comparison in view it takes only first 
string (i.e for ex. product name = sony ericsson , it takes only sony )
plz do needful...


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/TzXgpObSiK0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: date display problem?

2012-09-18 Thread Navnath Gadakh
model
   class Offer(models.Model):
product_id = models.ForeignKey(Product)
merchant_id = models.ForeignKey(Merchant)
offer_id = models.AutoField(primary_key=True)
description = models.CharField(max_length=100,null=False)#Not NULL
effective_date = models.DateField()
expiration_date = models.DateField()




view.py 
HTML = HTML + ""
HTML = HTML + "Offer Description : 
"+offer.description+""
HTML = HTML + "Coupon Number :  
"+coupon_no.coupon_detail+"" 
HTML = HTML + "Effective Date : 
"+str(offer.effective_date)+""
HTML = HTML + "Expiration Date : 
"+str(offer.expiration_date)+""
HTML = HTML + ""
HTML = HTML + ""

at the time of create offer i print variable for expiration and effective 
date in view it worked fine.
but in temlate it did't other fields displays.
effective date and expiration date not displaying on browser..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/cTFKSlnEUEsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Confused by BooleanField

2012-09-18 Thread Lachlan Musicman
Ignore - I've found the documentation. PATH/ref/forms/fields.html#booleanfield

required=False

cheers
L.

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



Re: date display problem?

2012-09-18 Thread Lachlan Musicman
On Wed, Sep 19, 2012 at 2:34 PM, Navnath Gadakh  wrote:
> i have post date variable to view? but when i retrieve date from database .
> not displaying on browser

We need more information than that - do you mean it's not displaying
in a form, in a regular template or in the admin pages?

And how are you referencing it? Send us the relevant code to look at?

Cheers
L.

>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/t7LK3gY0Ib0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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



Confused by BooleanField

2012-09-18 Thread Lachlan Musicman
Hola,

I've written a form that has two BooleanFields on it.

They render as text boxes on the page, which is great.

All my initial testing included checking the boxes for the two
BooleanFields as this is the major use case.

I just did a test in which I didn't check the boxes, and I'm getting
"This field is required" errors.

I'm confused. I understand the whole Blank=True, null=True concepts,
but these two fields aren't within models - they are used for
decision/flow control within the saving of a model...

Finally, if it's a BooleanField, it should be able to represent on/off
- so *not* ticking the box would indicate off, wouldn't it?

What am I doing wrong here?

cheers
L.

-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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



date display problem?

2012-09-18 Thread Navnath Gadakh
i have post date variable to view? but when i retrieve date from database . 
not displaying on browser 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/t7LK3gY0Ib0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Alternatives to CBVs (class based views)

2012-09-18 Thread Russell Keith-Magee
On Tue, Sep 18, 2012 at 7:24 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Russell,
>
> On a separate note, I am curious about these 'copy-on-call' leaks, and I
> have not seen this behaviour documented anywhere else.
>
> "The abstraction of the copy-on-call can leak in surprising ways. Some users
> will try to set up state using an __init__ method (common practice). If any
> of the state they attach to self in __init__ is mutable (list, dict, object,
> etc) and they mutate it in the view, this will fail (but not immediately, or
> in obvious ways)."
>
> Could you elaborate further on this, possibly with a rough example?
>
> Not arguing that CBV approach should be changed, but this copy-on-call
> behaviour is quite unexpected, no?

The issue is the shallow copy.

You create a view that sets up state in the __init__ method. Part of
your view's state is held in a mutable object (e.g., a dict, list or
object). The __call__ creates a shallow copy of the view object. A
shallow copy of a mutable object copies the container, but the new
container points to the old content.

So, if your view logic modifies something held by the mutable object
(which will be a fairly common occurrence), the modification will be
shared by all instances of your view. Hilarity ensues :-)

You could work around this by using a deep copy, but then you're into
territory where accessing a view could be an incredibly expensive
operation, which is something we want to avoid. It also means anything
you attach to a view must be deep-copyable, which won't always be
true.

Yours,
Russ Magee %-)

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



Django + mod_wsgi url rewriting issue

2012-09-18 Thread Sebastiaan Snoeckx

Hello list

I used mod_wsgi to setup my site to rewrite urls according to
 but now my app doesn't seem to follow
its urlconf anymore. Every single request to the wsgi application just
returns my default (index) view. example.com/, example.com/a/,
example.com/foo/bar... it's all my default view, no other views work...

Is there some setting (I heard something about a faulty SCRIPT_NAME? but
I'm unsure about that) I'm missing or how does Django find out the
original request from the rewritten URI?

Maybe I'm not very clear, so feel free to ask for more information.

Thanks in advance






smime.p7s
Description: S/MIME Cryptographic Signature


Re: creating a button using dgango

2012-09-18 Thread Nikolas Stevenson-Molnar
Does this get at what you want to accomplish?
https://docs.djangoproject.com/en/1.1/ref/contrib/formtools/form-wizard/

_Nik

On 9/18/2012 1:00 PM, Ndlovu wrote:
> How do I add a simple button, that does  fuction loading another
> *.html page. Basically a basic next button.
>
> My forms class looks like:
>
> forms.py:
>
> # -*- coding: utf-8 -*-
> from django import forms
>
> class ButtonForm(forms.Form):
>  
>  #what do put here as for the button
> )
>
>
> The views class:
>
> views.py:
>
> # -*- coding: utf-8 -*-
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from django.core.urlresolvers import reverse
>
> from myproject.myapp.forms import ButtonForm
>
> def list(request):
>
> #This is where I need to implement the button action. 
>
> where I add the button on the *.html file:
>
> 
> {% csrf_token %}
>
> 
> 
>
> thanks.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/6VXaVdPZnvIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: SyntaxError Creating New Project

2012-09-18 Thread Bestrafung
I restarted from the beginning using the previously mentioned guide but 
also a very helpful post on the cpanel.net forums and there were some 
missed steps and minor misconfigurations. Everthing seems to be working on 
the webserver side but now have some strange permissions issues that'll go 
into another post. I hope this helps anyone else interested in setting up 
Django on a CentOS 5.x cPanel system.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GukGIRK-mpwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



creating a button using dgango

2012-09-18 Thread Ndlovu
How do I add a simple button, that does  fuction loading another *.html 
page. Basically a basic next button. 

My forms class looks like:

forms.py:

# -*- coding: utf-8 -*-
from django import forms

class ButtonForm(forms.Form):
  
 #what do put here as for the button
)


The views class:

views.py:

# -*- coding: utf-8 -*-
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

from myproject.myapp.forms import ButtonForm

def list(request):

#This is where I need to implement the button action.  

where I add the button on the *.html file:


{% csrf_token %}




thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6VXaVdPZnvIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django confirm email. Change value from false to true

2012-09-18 Thread enemybass
This is my model:

from django.db import models

class Meeting(models.Model):
name = models.CharField(max_length=255)
time = models.DateTimeField()
confirmed = models.BooleanField(default=False)

This is my form:

from django import forms

class MeetingForm(forms.Form):
name = forms.CharField(max_length=100)
time = forms.DateTimeField()
user_name = forms.CharField(max_length=100)
user_email = forms.EmailField()

How to create a view that send a mail to user with link and when user 
clicks on this link confrimed field will change value to true?

Link is my biggest problem.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/01tWYQEuJ9IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: tree.io installation with django

2012-09-18 Thread Fabian Weiss
YES! I got this error: http://snipurl.com/251cbjb
After doing your MySQL Code it WORKS!! :)
THX alot!


Am Dienstag, 18. September 2012 19:54:17 UTC+2 schrieb Nick Apostolakis:
>
> On 18/09/2012 08:47 πμ, Fabian Weiss wrote: 
> > Just I cannot login! :-D 
> > admin/admin doesn't work.. :/ 
> > Does it has something to do with settings.py? 
> > 
> > ADMINS = ( 
> >  # ('Your Name', 'your_...@domain.com '), 
> > ) 
> > 
> > Should I done this before I start installation?? 
> > 
> > 
> during my installation it failed to install the initial mysql data 
> so i have done a manual import of mysql initial data using this command 
>
> mysql -u treeiouser -p< sql/mysql-treeio-current.sql treeio 
>
> maybe your problem is the same 
>
> -- 
>   -- 
> Nick Apostolakis 
>e-mail: nick...@oncrete.gr  
>   Web Site: http://nick.oncrete.gr 
>   -- 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ppO6ktJEiuEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: EncryptedField

2012-09-18 Thread lingrlongr
It looks like I solved it by doing this:

def __set__(self, instance, value):
instance.__dict__[self.field.name] = value
if value != getattr(instance, self.field.attname):
setattr(instance, self.field.attname, self.field.encrypt(value))

I figured I should be checking somewhere if I already encrypted, but 
couldn't figure out where.  Not sure if this is the best way though...


On Tuesday, September 18, 2012 9:51:23 AM UTC-4, lingrlongr wrote:
>
> I'm trying to make an encrypted field.  I'm using some of the code from 
> the book Pro Django.  Generally speaking, it works, but it fails when using 
> Django's admin interface.  Here's the code:
>
> class EncryptedTextFieldDescriptor(property):
> def __init__(self, field):
> self.field = field
>
> def __get__(self, instance, owner):
> if instance is None:
> return self
> if self.field.name not in instance.__dict__:
> raw_data = getattr(instance, self.field.attname)
> instance.__dict__[self.field.name] = 
> self.field.decrypt(raw_data)
> return instance.__dict__[self.field.name]
>
> def __set__(self, instance, value):
> instance.__dict__[self.field.name] = value
> setattr(instance, self.field.attname, self.field.encrypt(value))
>
> class EncryptedTextField(models.TextField):
> def encrypt(self, data):
> return binascii.b2a_hex(_magic.encrypt(data))
>
> def decrypt(self, data):
> return _magic.decrypt(binascii.a2b_hex(data))
>
> def get_attname(self):
> return '%s_encrypted' % self.name
>
> def get_db_prep_lookup(self, lookup_type, value):
> raise ValueError("Can't make comparisons against encrypted data.")
>
> def contribute_to_class(self, cls, name):
> super(EncryptedTextField, self).contribute_to_class(cls, name)
> setattr(cls, name,  EncryptedTextFieldDescriptor (self))
>
> When using a python shell:
>
> >>> obj.enc_field = 'test'
> >>> print obj.enc_field
> 'test'
> >>> print obj.enc_field_encrypted
>
> '4441f5378dbb0be1c5a84e32c8616295b739c0ca82e68sb8f230f0aab2c40c0561d2223c7534a563da727578852db7ac3dd1f9d289ffac34d5492d1c1cefeed771f97b45ad862166e67f2170856fd4bd'
> >>> obj.save()
>
> This all works fine.  When this object is loaded in the admin, the value 
> for the enc_field will be the encrypted version, not the decrypted version. 
>  So, if I were to save the object, the encrypted text gets encrypted again, 
> then saved.
>
> How can I stop this behavior?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/G9238VJeRKUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: tree.io installation with django

2012-09-18 Thread Nick Apostolakis

On 18/09/2012 08:47 πμ, Fabian Weiss wrote:

Just I cannot login! :-D
admin/admin doesn't work.. :/
Does it has something to do with settings.py?

ADMINS = (
 # ('Your Name', 'your_em...@domain.com'),
)

Should I done this before I start installation??

   

during my installation it failed to install the initial mysql data
so i have done a manual import of mysql initial data using this command

mysql -u treeiouser -p< sql/mysql-treeio-current.sql treeio

maybe your problem is the same

--
 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


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



Django Unobtrusive Ajax

2012-09-18 Thread Faraz Masood Khan
I think it is the easiest way to do Ajax in 
Djangovia 
attributes: 
http://codestand.feedbook.org/2012/09/django-unobtrusive-ajax.html 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WdC2dM6xOXIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



GeoDjango : external WMS request problem

2012-09-18 Thread arnojc
Hi,

In a Django's template I realize a getFeatureInfo request with OpenLayers 
to an external WMS... and I can't get the result, the response is empty.
If I use the same code in a standard html page I can display the result 
received in text/html format.
The problem is that Firebug does not signal error (just put the request in 
red). Idem for Django in debug mode.
Where is the problem ?

To explain, I have an existing PostGis database with 3 SCHEMA but GeoDjango 
does not support natively multi SCHEMA so...
instead I want to use WMS requests to get info on the PostGis database 
features but I realize that I can not get the results for the time being :-(

Thanks for your help
Arno


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EAT_KyWBRNQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



EncryptedField

2012-09-18 Thread lingrlongr
I'm trying to make an encrypted field.  I'm using some of the code from the 
book Pro Django.  Generally speaking, it works, but it fails when using 
Django's admin interface.  Here's the code:

class EncryptedTextFieldDescriptor(property):
def __init__(self, field):
self.field = field

def __get__(self, instance, owner):
if instance is None:
return self
if self.field.name not in instance.__dict__:
raw_data = getattr(instance, self.field.attname)
instance.__dict__[self.field.name] = 
self.field.decrypt(raw_data)
return instance.__dict__[self.field.name]

def __set__(self, instance, value):
instance.__dict__[self.field.name] = value
setattr(instance, self.field.attname, self.field.encrypt(value))

class EncryptedTextField(models.TextField):
def encrypt(self, data):
return binascii.b2a_hex(_magic.encrypt(data))

def decrypt(self, data):
return _magic.decrypt(binascii.a2b_hex(data))

def get_attname(self):
return '%s_encrypted' % self.name

def get_db_prep_lookup(self, lookup_type, value):
raise ValueError("Can't make comparisons against encrypted data.")

def contribute_to_class(self, cls, name):
super(EncryptedTextField, self).contribute_to_class(cls, name)
setattr(cls, name,  EncryptedTextFieldDescriptor (self))

When using a python shell:

>>> obj.enc_field = 'test'
>>> print obj.enc_field
'test'
>>> print obj.enc_field_encrypted
'4441f5378dbb0be1c5a84e32c8616295b739c0ca82e68sb8f230f0aab2c40c0561d2223c7534a563da727578852db7ac3dd1f9d289ffac34d5492d1c1cefeed771f97b45ad862166e67f2170856fd4bd'
>>> obj.save()

This all works fine.  When this object is loaded in the admin, the value 
for the enc_field will be the encrypted version, not the decrypted version. 
 So, if I were to save the object, the encrypted text gets encrypted again, 
then saved.

How can I stop this behavior?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/iXAJVIw90o0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[RESOLVED]: Re: Search/Lookup of raw_id_field in inline

2012-09-18 Thread Axel Rau

Am 18.09.2012 um 12:19 schrieb Axel Rau:

> I have this inline:
> ---
> class LocallistentryInline(TabularInline):
>model = Locallistentry
>extra = 1
>raw_id_fields = ('relaynetfk', 'relayhostfk', 'mailrelationfk', 
> 'senderdomainfk')
>exclude = ('remarks', )
> 
> class LocallistAdmin(ModelAdmin):
>inlines = [LocallistentryInline, ]
> site.register(Locallist, LocallistAdmin)
> ---
> The raw_id_fields are FKs of type int and I can select such a related model 
> by entering its PK in the raw id field.
> This works fine for changing or adding rows.
> However when I click the little magnifier glass, I come to the change list of 
> the related table where I can select a row (mark its check box) but have no 
> action or other widget, which says "return selected to the inline".
> 
> How is this supposed to work?
This was a browser issue.
Adjusting the browser to open a new tab instead a new window (which is my usual 
adjustment), makes these check boxes and the action selector box appear.

Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

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



GeoDjango : external WMS request problem

2012-09-18 Thread arnojc
Hi,

I use, in a Django's template, a getFeatureInfo request with OpenLayers to 
an external WMS and I can't get the response...
If I use the same code in a standard html page it works fine, it displays 
the result as I wish.  
The problem is that I have no error message in Firebug except the request 
in red and no error message from Django with debug option.
What is the issue ?

To explain, I have to use requests on external WMS because I have an 
existing Postgis DataBase with 3 SCHEMA (no choice) and GeoDjango does not 
accept multi SCHEMA.
So I can't interrogate the features with GeoDjango but with WMS requests.

Thanks in advance for the help
Arnojc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/S52WFn8d5RkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Browser get closed when clicked on others links

2012-09-18 Thread m1chael
are you using internet explorer?

On Tue, Sep 18, 2012 at 7:50 AM, Pervez Mulla  wrote:

> Hi,
>
> I have developed simple website with Django framework.
>
> When i want to switch to other page, the browser getting closed..:(
>
> What the problem for this ?
>
> Thank You
> Pervez
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Issues with validation of multiple forms

2012-09-18 Thread neeraj dhiman
I am using two models in my app and different form for each model, when I 
tried to validate these two forms , one model is validated but other is not.

model.py

from django.db import models
from django.contrib.auth.models import User

class Customer(models.Model):
user=models.OneToOneField(User)
birthday=models.DateField()
website=models.CharField(max_length=50)
store=models.CharField(max_length=50)
welcomemail=models.CharField(max_length=50)






def __unicode__(self):
 return self.user

class Customer_check_attributes(models.Model):
user=models.ManyToManyField(User)
billing_add=models.CharField(max_length=50)
shipping_add=models.CharField(max_length=50)
payment_method=models.CharField(max_length=50)
shipping_method=models.CharField(max_length=50)
reward_points=models.CharField(max_length=50)


form for first model **Customer**

class Registration_Form(ModelForm):
   first_name  = forms.CharField(label=(u'First Name'))
   last_name   = forms.CharField(label=(u'Last Name'))  
   username   = forms.CharField(label=(u'User Name'))
   email  = forms.EmailField(label=(u'Email Address'))
   password   = forms.CharField(label=(u'Password'), 
widget=forms.PasswordInput(render_value=False))

:   
   class Meta:
  model=Customer 
  
  exclude=('user',)

form for 2nd model **Customer_check_attributes**

In template I am using this 
**for 1st model Customer** and it is validating the field first name


{% if form.first_name.errors %}{{ 
form.first_name.errors }}{% endif %}
Firstname:
{{ form.first_name }}


**for 2nd model Customer_check_attributes** and it is not validating the 
field billing add


{% if check.billing_add.errors %}{{ 
check.billing_add.errors }}{% endif %}
Billing Address:
{{ check.billing_add }}


here I am using **check** instead of form because I am storing the form in 
this and return it in context 


view.py


from django.contrib.auth.models import User
from customer_reg.models import Customer,Customer_check_attributes
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from customer_reg.forms import Registration_Form, Check_Attribute_Form, 
LoginForm
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required


def CustomerRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = Registration_Form(request.POST)
if form.is_valid():

user=User.objects.create_user(username=form.cleaned_data['username'], 
email=form.cleaned_data['email'], password = form.cleaned_data['password'])
user.first_name = form.cleaned_data['first_name']
user.last_name = form.cleaned_data['last_name']
user.save()

#customer=user.get_profile()
#customer.birthday=form.cleaned_data['birthday']
#customer.website=form.cleaned_data['website']
#customer.store=form.cleaned_data['store']
#customer.welcomemail=form.cleaned_data['welcomemail']
#customer.save()

customer=Customer(user=user, 
website=form.cleaned_data['website'], 
birthday=form.cleaned_data['birthday'], store=form.cleaned_data['store'], 
welcomemail=form.cleaned_data['welcomemail'])  
customer.save()

  return HttpResponseRedirect('/profile/')
else:
check_form=Check_Attribute_Form()
context={'form':form, 'check':check_form}
return 
render_to_response('customer_register.html',context , 
context_instance=RequestContext(request)) 
else:
''' user is not submitting the form, show them a blank 
registration form '''

form = Registration_Form()
check_form = Check_Attribute_Form()
 context={'form':form,'check':check_form}
 return render_to_response('customer_register.html',context 
, context_instance=RequestContext(request))


#PROFILE##

@login_required
def Profile(request):
 if not request.user.is_authenticated():
 return HttpResponseRedirect('/login/')
  #select = select * from auth_users
 #reg_users = User.objects.all()
 customer 

Issues with validation

2012-09-18 Thread neeraj dhiman
I am using two models in my app and different form for each model, when I 
tried to validate these two forms , one model is validated but other is not.

model.py

from django.db import models
from django.contrib.auth.models import User

class Customer(models.Model):
user=models.OneToOneField(User)
birthday=models.DateField()
website=models.CharField(max_length=50)
store=models.CharField(max_length=50)
welcomemail=models.CharField(max_length=50)






def __unicode__(self):
 return self.user

class Customer_check_attributes(models.Model):
user=models.ManyToManyField(User)
billing_add=models.CharField(max_length=50)
shipping_add=models.CharField(max_length=50)
payment_method=models.CharField(max_length=50)
shipping_method=models.CharField(max_length=50)
reward_points=models.CharField(max_length=50)


form for first model **Customer**

class Registration_Form(ModelForm):
   first_name  = forms.CharField(label=(u'First Name'))
   last_name   = forms.CharField(label=(u'Last Name'))  
   username   = forms.CharField(label=(u'User Name'))
   email  = forms.EmailField(label=(u'Email Address'))
   password   = forms.CharField(label=(u'Password'), 
widget=forms.PasswordInput(render_value=False))

:   
   class Meta:
  model=Customer 
  
  exclude=('user',)

form for 2nd model **Customer_check_attributes**

In template I am using this 
**for 1st model Customer** and it is validating the field first name


{% if form.first_name.errors %}{{ 
form.first_name.errors }}{% endif %}
Firstname:
{{ form.first_name }}


**for 2nd model Customer_check_attributes** and it is not validating the 
field billing add


{% if check.billing_add.errors %}{{ 
check.billing_add.errors }}{% endif %}
Billing Address:
{{ check.billing_add }}


here I am using **check** instead of form because I am storing the form in 
this and return it in context 


view.py


from django.contrib.auth.models import User
from customer_reg.models import Customer,Customer_check_attributes
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from customer_reg.forms import Registration_Form, Check_Attribute_Form, 
LoginForm
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required


def CustomerRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = Registration_Form(request.POST)
if form.is_valid():

user=User.objects.create_user(username=form.cleaned_data['username'], 
email=form.cleaned_data['email'], password = form.cleaned_data['password'])
user.first_name = form.cleaned_data['first_name']
user.last_name = form.cleaned_data['last_name']
user.save()

#customer=user.get_profile()
#customer.birthday=form.cleaned_data['birthday']
#customer.website=form.cleaned_data['website']
#customer.store=form.cleaned_data['store']
#customer.welcomemail=form.cleaned_data['welcomemail']
#customer.save()

customer=Customer(user=user, 
website=form.cleaned_data['website'], 
birthday=form.cleaned_data['birthday'], store=form.cleaned_data['store'], 
welcomemail=form.cleaned_data['welcomemail'])  
customer.save()

  return HttpResponseRedirect('/profile/')
else:
check_form=Check_Attribute_Form()
context={'form':form, 'check':check_form}
return 
render_to_response('customer_register.html',context , 
context_instance=RequestContext(request)) 
else:
''' user is not submitting the form, show them a blank 
registration form '''

form = Registration_Form()
check_form = Check_Attribute_Form()
 context={'form':form,'check':check_form}
 return render_to_response('customer_register.html',context 
, context_instance=RequestContext(request))


#PROFILE##

@login_required
def Profile(request):
 if not request.user.is_authenticated():
 return HttpResponseRedirect('/login/')
  #select = select * from auth_users
 #reg_users = User.objects.all()
 customer 

Re: duplicate key value violates unique constraint "django_admin_log_pkey"

2012-09-18 Thread MohamadReza Rezaei
what Groups Google Don't access to my accout for Creating New Groups by Name 
"AmolMap" and tell this name created by i, but show this Groups?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/udCxIaihp3MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Browser get closed when clicked on others links

2012-09-18 Thread Pervez Mulla
Hi,

I have developed simple website with Django framework.

When i want to switch to other page, the browser getting closed..:(

What the problem for this ?

Thank You
Pervez

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



Re: Alternatives to CBVs (class based views)

2012-09-18 Thread Cal Leeming [Simplicity Media Ltd]
Russell,

On a separate note, I am curious about these 'copy-on-call' leaks, and I
have not seen this behaviour documented anywhere else.

"The abstraction of the copy-on-call can leak in surprising ways. Some
users will try to set up state using an __init__ method (common practice).
If any of the state they attach to self in __init__ is mutable (list, dict,
object, etc) and they mutate it in the view, this will fail (but not
immediately, or in obvious ways)."

Could you elaborate further on this, possibly with a rough example?

Not arguing that CBV approach should be changed, but this
copy-on-call behaviour is quite unexpected, no?

Cal

On Fri, Sep 14, 2012 at 10:16 AM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
>
> On Fri, Sep 14, 2012 at 12:12 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>> On Thu, Sep 13, 2012 at 12:58 AM, Cal Leeming [Simplicity Media Ltd]
>>  wrote:
>> > Hi all,
>> >
>> > There is a lot of debate on whether there is a real future for the
>> Django
>> > CBVs (class based views).
>>
>> Sigh.
>
>
> Thank you for the detailed response on this - hopefully this thread will
> serve as a reference point for people in the future
>
>
>>
>> No - there isn't *any* debate about the future of CBVs. There *are* a
>> lot of people who apparently don't like them who keep making a lot of
>> noise. Every single time I've spoken with one of those people at
>> length, the problem has reduced to either:
>>
>>  1) I don't like classes/OO. There's no winning these people over.
>
>
> Well that's certainly not the reason I dislike them - OO makes views
> tidier, simple.
>
>
>>  2) CBV's aren't documented well. You won't get any argument from me
>> on (2). I'll take the hit for that -- the initial documentation for
>> CBVs was my doing, and it has lots of room for improvement.
>
>
> +1
>
>
>
>
>> I'm not aware of anyone in the core that has advocated removing
>> class-based views from Django.
>
>
>> > Personally, I find them tedious, and just wanted a
>> > way to keep my views clean.
>> >
>> > So, here is a really minimalistic way of having class based views,
>> without
>> > the fuss.
>> >
>> > http://djangosnippets.org/snippets/2814/
>> >
>> > This is a fork from:
>> >
>> > http://stackoverflow.com/questions/742/class-views-in-django
>> > http://djangosnippets.org/snippets/2041/
>> >
>> > My thanks to eallik for his initial post on stackoverflow for this.
>> >
>> > Personally I think Django's CBVs should offer a really minimalistic base
>> > like this, as well as the existing CBV stuff already in the core - so
>> as to
>> > not force people into needing to learn an entirely new way of doing
>> things,
>> > but at the same time allowing them to reap some of the benefits of using
>> > callable classes as views.
>> >
>> > Any thoughts?
>>
>> What you've described -- a single entry point class-based view base
>> class -- *does* exist. It's called django.views.generic.View. Override
>> the "dispatch" method, or write a "get/post/put/etc" method, and
>> you've got a class-based view.
>>
>
> I noticed this yesterday whilst trawling through the documentation again,
> so I will look at this again.
>
>
>>
>> I also think you should read the discussions that led to the current
>> form of Class-based views. The pattern you've proposed from Stack
>> Overflow was one of many suggestions that were made, and were rejected
>> because of inherent problems with the approach. The discussions are
>> summarised in the wiki:
>>
>> https://code.djangoproject.com/wiki/ClassBasedViews
>
>
> Thanks for sending this link through, looks very detailed, I will spend an
> hour or two reading through it all and put some thoughts back.
>
>
>>
>>
>> Yours,
>> Russ Magee %-)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: Extending templates

2012-09-18 Thread Satinderpal Singh
On Tue, Sep 18, 2012 at 3:45 PM, Tom Evans  wrote:
> On Mon, Sep 17, 2012 at 8:14 AM, Satinderpal Singh
>  wrote:
>> I want to extend a template file into the other file. I get fine
>> results when done simply but whenever I use the template containing
>> 'for' tag into the other, it does not show any results.
>> My code for template which is to be extended is here :
>>
>> #template file to be extended into the other
>> 
>> 
>> {% block header %}
>>
>> {% for organisations in organisation %}
>
> Is this just a logic fail?
No, it is not the logic failure as the output is listed when file is
not extended for other file.

> Is 'organization' a list of organizations?
> Or should this be 'for organization in organizations'?
>
No.
The 'organization' is an object which calls the values from the database.

-- 
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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



Re: Extending templates

2012-09-18 Thread Satinderpal Singh
> With template 'inheritance', when you extend another template, what
> happens is that the named blocks in the parent template are replaced
> with the equivalently named blocks in the derived template.
>
> This means that in the derived template, everything outside of a named
> block is ignored. You have lots of content outside the named blocks,
> so this is probably causing you some grief.
>
But I have used different block names for both the files. So I don't
think there is any chance of overriding  of data.

-- 
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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



Re: Button action to delete files from server

2012-09-18 Thread xactive
Sebastian

I'm not sure if I've done something wrong, but this does not seem to work.

What happens now is that the content of the page redirects immediately when 
it renders, before anything is clicked.

Hope you have a solution?

Thanks

Adam

On Monday, September 17, 2012 1:57:48 PM UTC+1, Sebastian Henschel wrote:
>
> hey xactive... 
>
> a simple solution, without bells & whistles could be this (assuming 
> File.file_obj is defined as a Django FileField): 
>
> On 09/17/2012 01:15 PM, xactive wrote: 
> > I have little experience with Django/Python but have a problem that I 
> > need to solve. 
> > 
> > Currently I have a button action that allows users of a website to 
> > download files from a displayed list. I want to add a button to allow 
> > users to delete the files if required. 
> > 
> > The current download button is set up as follows on the page itself: 
> > Download 
>
> add to your template: 
>
> Delete 
>
> > And as far as I can see there is a file called views.py which contains 
> > code as follows: 
> > @login_required(login_url='/portal/login/', redirect_field_name=None) 
> > def file_view(request, id, template_name='portal/file_view.html'): 
> > try: 
> > f = File.objects.get(pk=id) 
> > except File.DoesNotExist: 
> > raise Http404 
> > if request.user not in f.recipients.all() and request.user != 
> f.owner: 
> > return HttpResponseForbidden() 
>
> if request.GET.has_key('action'): 
>action = request.GET['action'] 
>if action == 'download': 
>  filename = f.file_obj.name.rsplit('/', 1)[1] 
>  response = HttpResponse() 
>  response['Content-Disposition'] = 'attachment; filename=%s' % 
> filename 
>  response['Content-Length']  = '' 
>  response['X-Accel-Redirect']= '/%s' % f.file_obj.name 
>  return response 
>elif action == 'delete': 
>  f.file_obj.delete() 
>  # read https://docs.djangoproject.com/en/dev/ref/models/fields/ 
>
>  return render_to_response('portal/file_deleted.html', {}, 
>context_instance=RequestContext(request)) 
>
>return render_to_response(template_name, { 
>  'file': f 
>}, context_instance=RequestContext(request)) 
>
>
>
> you still have to create the template file 'portal/file_deleted.html'. 
> or you do a redirect to another URL instead... 
>
> > 
> > Can somebody please help me to create an action to delete files? 
> > 
>
>
> hth, 
>   Sebastian 
>
> -- 
> Sebastian Henschel, Python Developer Web 
> txtr GmbH | Rosenthaler Str. 13 | 10119 Berlin | Germany 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rmt9k1bLvHAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Search/Lookup of raw_id_field in inline

2012-09-18 Thread Axel Rau
I have this inline:
---
class LocallistentryInline(TabularInline):
model = Locallistentry
extra = 1
raw_id_fields = ('relaynetfk', 'relayhostfk', 'mailrelationfk', 
'senderdomainfk')
exclude = ('remarks', )

class LocallistAdmin(ModelAdmin):
inlines = [LocallistentryInline, ]
site.register(Locallist, LocallistAdmin)
---
The raw_id_fields are FKs of type int and I can select such a related model by 
entering its PK in the raw id field.
This works fine for changing or adding rows.
However when I click the little magnifier glass, I come to the change list of 
the related table where I can select a row (mark its check box) but have no 
action or other widget, which says "return selected to the inline".

How is this supposed to work?

Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

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



Re: Django newbie with issues

2012-09-18 Thread Morrti
Hi,

Thought I'd update you all and bring this thread to a close.

The issue was down to a typo on my part. This was corrected and symlink 
recreated, things seem to be ok now.
Thanks for the help/advice.  

Thanx,
Tim

On Saturday, September 15, 2012 12:48:09 PM UTC+1, Karen Tracey wrote:
>
> On Wed, Sep 12, 2012 at 5:46 AM, Morrti  > wrote:
>
>> Thanks for your comments on version numbers, but moving to 1.4 isn't a 
>> quick option for me/us so I'm stuck on 1.1 for a while.
>>
>> Trying to run the app and instead of getting the "welcome" page I get the 
>> following, see below.
>>
>> Not withstanding my version issue, anyone got any ideas on this.
>>
>> [snip]
>>
>> Traceback (most recent call last):
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/servers/basehttp.py",
>>  line 279, in run
>> self.result = application(self.environ, self.start_response)
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/servers/basehttp.py",
>>  line 651, in __call__
>> return self.application(environ, start_response)
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/handlers/wsgi.py", 
>> line 230, in __call__
>> self.load_middleware()
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/handlers/base.py", 
>> line 42, in load_middleware
>> raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: 
>> "%s"' % (mw_module, e)
>>
>> ImproperlyConfigured: Error importing middleware django.middleware.common: 
>> "cannot import name force_text"
>>
>>
>>
> force_text did not exist in 1.1, but it exists in current master. Getting 
> an error referring to it rather implies that you're running a mutant 
> version with some leftover py/pyc files form when you were running current 
> master (which appears to be what you were running for the first traceback 
> posted -- the " __init__() keywords must be strings" error there is what 
> you get today on master if you run with Python earlier than 2.6.5).
>
> I'd start over with a completely new install, in a completely new 
> directory tree. (I also would not include "django-trunk" in the name of 
> that tree, if it was actually intended to hold 1.1.something.)
>
> Karen
> -- 
> http://tracey.org/kmt/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1ad1NQJLDDoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Extending templates

2012-09-18 Thread Tom Evans
On Mon, Sep 17, 2012 at 8:14 AM, Satinderpal Singh
 wrote:
> I want to extend a template file into the other file. I get fine
> results when done simply but whenever I use the template containing
> 'for' tag into the other, it does not show any results.
> My code for template which is to be extended is here :
>
> #template file to be extended into the other
> 
> 
> {% block header %}
>
> {% for organisations in organisation %}

Is this just a logic fail? Is 'organization' a list of organizations?
Or should this be 'for organization in organizations'?

Cheers

Tom

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



Re: Extending templates

2012-09-18 Thread Tom Evans
On Mon, Sep 17, 2012 at 5:58 PM, Satinderpal Singh
 wrote:
> On Mon, Sep 17, 2012 at 7:31 PM, jondykeman  wrote:
>> Can you put the code of the template you are extending this one with?
> Here is the file that is extending:
>
> {% extends "report/report_header.html" %}
> {% load i18n %}
> 
> 
> {% block content %}
> 
> 

With template 'inheritance', when you extend another template, what
happens is that the named blocks in the parent template are replaced
with the equivalently named blocks in the derived template.

This means that in the derived template, everything outside of a named
block is ignored. You have lots of content outside the named blocks,
so this is probably causing you some grief.

Hope that helps

Tom

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



Re: Django newbie with issues

2012-09-18 Thread Morrti
Hi,

Thought I'd update you all and bring this thread to a close.

The issue was down to a typo on my part. This was correct and symlink 
recreated, things seem to be ok now.
Thanks for the help/advice.  

Thanx,
Tim

On Saturday, September 15, 2012 12:48:09 PM UTC+1, Karen Tracey wrote:
>
> On Wed, Sep 12, 2012 at 5:46 AM, Morrti  > wrote:
>
>> Thanks for your comments on version numbers, but moving to 1.4 isn't a 
>> quick option for me/us so I'm stuck on 1.1 for a while.
>>
>> Trying to run the app and instead of getting the "welcome" page I get the 
>> following, see below.
>>
>> Not withstanding my version issue, anyone got any ideas on this.
>>
>> [snip]
>>
>> Traceback (most recent call last):
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/servers/basehttp.py",
>>  line 279, in run
>> self.result = application(self.environ, self.start_response)
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/servers/basehttp.py",
>>  line 651, in __call__
>> return self.application(environ, start_response)
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/handlers/wsgi.py", 
>> line 230, in __call__
>> self.load_middleware()
>>
>>   File 
>> "/Users/timmorris/Sites/django/django-trunk/django/core/handlers/base.py", 
>> line 42, in load_middleware
>> raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: 
>> "%s"' % (mw_module, e)
>>
>> ImproperlyConfigured: Error importing middleware django.middleware.common: 
>> "cannot import name force_text"
>>
>>
>>
> force_text did not exist in 1.1, but it exists in current master. Getting 
> an error referring to it rather implies that you're running a mutant 
> version with some leftover py/pyc files form when you were running current 
> master (which appears to be what you were running for the first traceback 
> posted -- the " __init__() keywords must be strings" error there is what 
> you get today on master if you run with Python earlier than 2.6.5).
>
> I'd start over with a completely new install, in a completely new 
> directory tree. (I also would not include "django-trunk" in the name of 
> that tree, if it was actually intended to hold 1.1.something.)
>
> Karen
> -- 
> http://tracey.org/kmt/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/t0LUNkYk2F4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Markers on a map in geodjango project

2012-09-18 Thread Coulson Thabo Kgathi
i have be able to follow a tutorial on the link below

http://invisibleroads.com/tutorials/geodjango-googlemaps-build.html
you can download the code at the link above u dnt have to do everythin.

and i have been able to plot a maker, bt i dont want to have the marker 
appear only when i click on the link of the marker cos it appearrs only 
when i do so.
I tried just using javascript to add a marker the way i learnt in google 
maps api v3, but its no showing using the code below on my template called 
index.html the one whre my map has been initialised

i used codinates that i wanted though

  var myLatlng = new google.maps.LatLng(-25.363882,131.044922);


 var marker = new google.maps.Marker({
  position: myLatlng,
  map: map,
  title:"Hello World!"
  });



thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VGdrTLzBYMwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: duplicate key value violates unique constraint "django_admin_log_pkey"

2012-09-18 Thread Christoph Pingel
Thanks, this helped me too 2 years later.. :-)

On Thursday, October 14, 2010 6:23:37 PM UTC+2, reduxionist wrote:
>
> On 14 ต.ค. 2010, at 22:24, glob...@iamsandiego.com  wrote:
>
> > Hi Folks,
> > 
> > After updating a postgres db for my django app Iam getting this error
> > when I try and save new data to the db:
> > 
> > Request Method:  POST
> > Request URL: http://10.50.253.200/admin/survey/gps/add/
> > Django Version: 1.2 beta 1
> > Exception Type: IntegrityError
> > Exception Value:
> > 
> > duplicate key value violates unique constraint "django_admin_log_pkey"
> > 
> > Is there any way to correct this?
>
> Sounds to me like your DB update has reset the sequence 
> "django_admin_log_id_seq" used by postgres to get the next  value for the 
> "auto-increment"-type id field used by django_admin_log. 
>
> I would manually reset the sequence via the following:
>
> First get the id value of the last admin entry:
>
> select id from "django_admin_log" order by id desc limit 1;
>
> Then set the next value of the ID sequence to that + 1 via:
>
> select setval('django_admin_log_id_seq', LASTID+1);
>
> (replacing LASTID+1 with the result of the first query +1 obviously...)
>
> The other option would be to "delete * from 'django_admin_log';" so that 
> the old ids are gone and you can start over from 1 - but then you lose your 
> whole admin history which seems sub-optimal.
>
> Haven't run into the problem myself though, so this is just a guess, and 
> from a Django newbie so...
>
> Hope it helps!
> Jonathan
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/29-tT_F6SlMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customizing the Django Admin Interface

2012-09-18 Thread Derek
The text  I am referring to is the one that appears as a title on all the 
change list pages; I cannot, however, find it in the change_list template. 
 But if you have not needed to change that, then you would not be able to 
help.

(PS I was not asking to see the result of your changes, but where in the 
source code you had made them...)

On Monday, 17 September 2012 23:00:21 UTC+2, JJ Zolper wrote:
>
> Derek,
>
> You can see the custom changes I made here:
>
> http://www.madtrak.com/admin 
>
> That is the extent of what I have done in relation to the default. Nothing 
> more then some colors in the CSS and text color. Additionally I changed the 
> actual wording for the  to  Log in | MadTrak Django 
> Admin other then that text change and the colors I'm not sure what 
> you are asking?
>
> What is:
>
> I cannot seem to find the source text, for example, for "Select ... to 
> change"
> and would appreciate seeing/knowing how you did it.
>
> referring to?
>
> JJ
>
> On Monday, September 17, 2012 3:09:26 AM UTC-4, Derek wrote:
>>
>> Hi JJ
>>
>> I'd like to know how you changed the wording... I cannot seem to find the 
>> source text, for example, for "Select ... to change"
>> and would appreciate seeing/knowing how you did it.
>>
>> There are examples on various blogs, but Django has changed how it is 
>> works since they were written.
>>
>> Thanks
>> Derek
>>
>> On Sunday, 16 September 2012 08:25:18 UTC+2, JJ Zolper wrote:
>>>
>>> Hello,
>>>
>>> I was able to locate the Django files for the admin under contrib in the 
>>> source. I was curious if I could get some tips about customizing the 
>>> interface.
>>>
>>> One website I read said I shouldn't change any of the Django source but 
>>> if I want to set up a slightly different login page for example, to put the 
>>> admin files in my local directories that I'm working with.
>>>
>>> The real question is that I was able to edit some template files to 
>>> change some of the wording displayed but when I tried to edit the CSS files 
>>> to get a different design I did not see any changes when I restarted my 
>>> server. Is there some sort of collectstatic command that needs to be run? 
>>> Any input on how to propagate these CSS files through would be great.
>>>
>>> Thanks,
>>>
>>> JJ Zolper
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7_yIZ12jL8sJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Multi-tenant open-source e-commerce solution?

2012-09-18 Thread Alec Taylor
Are there any open-source multi-tenant e-commerce solutions built with Django?

I.e.: where you can have multiple shops on the one site, and a
shop-create form on the frontend to add more shops.

If there aren't any, I'd be willing to start such a project.

Thanks for all suggestions,

Alec Taylor

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