Re: Doubt the split()

2013-06-21 Thread Tomas Neme
a regex?

something like re.match("\[http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django DEBUG=False made all css loss

2013-06-11 Thread Tomas Neme
https://docs.djangoproject.com/en/1.5/howto/static-files/

On Tue, Jun 11, 2013 at 8:32 AM,   wrote:
> I am build my application using Python 2.7 and Django 1.3.7.All it is
> working perfectly and most of the part are over so we planed to move it to
> live.While checking with DEBUG = False in settings.py made unhappy.
>
> Problem i am facing is the css what ever i used is not applied in the
> application.Totally my page is like a mixing of every thing if i set DEBUG =
> False.
>
> What might be the problem.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Looking for a Django mentor

2013-06-10 Thread Tomas Neme
> Trying to learn the platform and work on the project at the same time.
>
> Thanks, Feyzi

first of all, do the tutorial, don't try to go further until you're
somewhat comfortable with the concepts there. You'll get the feel of
the most basic and powerful django tools are: models, forms, and the
admin site. I don't remember if it's been updated to use class-based
views, but you should take a look at them too, it'll be easier for you
to navigate 3rd party code, and it's becoming the standard, plus
generic views are another of the time-saving goodies.

Then go to #django in irc.freenode.net, there's lot of very patient
and helpful people there

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Admin for proxy model for custom User

2013-06-02 Thread Tomas Neme
The docs say this has changed to get_queryset in dev version, 1.5 uses
get_query_set

isn't this a rather.. radical change? Is backwards compatibility
maintained somehow?

On Sun, Jun 2, 2013 at 12:40 PM, Tomas Neme <lacrymol...@gmail.com> wrote:
> django.db.models.manager, L118
>
> it seems to be "get_query_set" not "get_queryset"



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Admin for proxy model for custom User

2013-06-02 Thread Tomas Neme
django.db.models.manager, L118

it seems to be "get_query_set" not "get_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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin for proxy model for custom User

2013-05-28 Thread Tomas Neme
Silly, but aren't you missing

class Patient()
save(self):
self.kind = 'p'
super(Patient, self).save()

or some such thing and something similar for Doctor? I guess it might be in
the forms, but since it's nowhere in the code you showed...

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




Re: password encryption

2013-03-01 Thread Tomas Neme
> We haven't used SHA-based or MD5-based hashing for some time.

oh, I was convinced sha2 was being used.

I probably just read the code a while ago and didn't notice it in the changelogs


--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Tomas Neme
your view class is.. well, that, just a class.

Every time you use it in an urlpattern, calling .as_view() a new
instance object of that class is created. So the "per instance" should
be pretty much self explanatory

On Thu, Feb 28, 2013 at 5:04 PM, Ivo Brodien <i...@brodien.de> wrote:
> Thanks Tomas,
>
> now I got it! Still the original usage of "per" and "every" sounds strange to 
> me.. it should be more like "per instance within a URL pattern", but I am not 
> a native in English, so nevermind.
>
> Thanks!
>
> On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:
>
>>> This approach applies the decorator on a per-instance basis. If you want
>>> every instance of a view to be decorated, you need to take a different
>>> approach.
>>
>> This means that with "this approach" you have to apply the decorator
>> in every instance you want modified, that is, every time you have this
>>
>> url(, YourView.as_view(),...)
>>
>> and want it decorated, you need to wrap it, individually, like
>>
>> url(, decorator(YourView.as_view()), )
>>
>> and if you want to define the entire view as decorated, so you don't
>> need to decorate it every time you use it in an urlpattern, because it
>> ALWAYS needs, e.g., to be login_required, you'll need to take a
>> different approach.
>>
>> With function views, this was the normal case, because you did
>>
>> @decorator
>> def my_view(request, *args, **kwargs):
>> ..
>>
>> and you didn't need to add anything in the urls, with class-based
>> views, you need to do this:
>> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
>>
>>
>> --
>> "The whole of Japan is pure invention. There is no such country, there
>> are no such people" --Oscar Wilde
>>
>> |_|0|_|
>> |_|_|0|
>> |0|0|0|
>>
>> (\__/)
>> (='.'=)This is Bunny. Copy and paste bunny
>> (")_(") to help him gain world domination.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Tomas Neme
> This approach applies the decorator on a per-instance basis. If you want
> every instance of a view to be decorated, you need to take a different
> approach.

This means that with "this approach" you have to apply the decorator
in every instance you want modified, that is, every time you have this

url(, YourView.as_view(),...)

and want it decorated, you need to wrap it, individually, like

url(, decorator(YourView.as_view()), )

and if you want to define the entire view as decorated, so you don't
need to decorate it every time you use it in an urlpattern, because it
ALWAYS needs, e.g., to be login_required, you'll need to take a
different approach.

With function views, this was the normal case, because you did

@decorator
def my_view(request, *args, **kwargs):
..

and you didn't need to add anything in the urls, with class-based
views, you need to do this:
https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class


--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: password encryption

2013-02-27 Thread Tomas Neme
and here it presses an even stronger case about NOT using bcrypt but
something even slower

http://www.unlimitednovelty.com/2012/03/dont-use-bcrypt.html

On Wed, Feb 27, 2013 at 12:33 PM, Tomas Neme <lacrymol...@gmail.com> wrote:
> I just ran into this. It presses a pretty strong case...
>
> http://codahale.com/how-to-safely-store-a-password/
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.



--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




password encryption

2013-02-27 Thread Tomas Neme
I just ran into this. It presses a pretty strong case...

http://codahale.com/how-to-safely-store-a-password/

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Object composition in django

2013-02-17 Thread Tomas Neme
There's a way to do what you want to do, but I don't remember out of
the top of my head. I can check it out on the week, but you'll need to
customize some things on the Producer's ModelAdmin, not just set the
list of inlines, because, as it was said, inlines are for "children"
objects (i.e. other objects that have a FK pointing to self, not the
other way around).

I don't remember exactly, but IIRC it went about making a single-form
inline_formset and possibly some modifying of the model-specific admin
template. Or maybe making a custom ModelForm in the ModelAdmin's
get_form method

On Sun, Feb 17, 2013 at 3:14 PM, Peter of the Norse
 wrote:
> Have you tried using unique_together? You could add unique_together = ( 
> ('type', 'producer',), ) to your Address model. There really isn't any way 
> for the default admin to edit a second table at the same time.
>
> https://docs.djangoproject.com/en/1.4/ref/models/options/#unique-together
>
> On Feb 14, 2013, at 8:42 AM, Ray Hatfield wrote:
>
>> Thanks, but I've omitted related_name and I've used distinct related_names 
>> and gotten the same errors. I don't want to reuse addresses. The one-to-one 
>> relationship you describe is precisely what I'm trying to do.
>>
>> On Feb 14, 2013, at 1:32 AM, Jani Tiainen  wrote:
>>
>>> Hi,
>>>
>>> You're trying to setup one-to-one relationship.
>>>
>>> It means that producer.mailing_address does have exactly one unique Address 
>>> entity. Same goes for physical_address.
>>>
>>> What you want is really ForeignKey to address which means that you reuse 
>>> addresses to multiple producer.mailing_address.
>>>
>>> Then you can omit related names, or like someone suggested use different 
>>> related names for both fields.
>>>
>>> 13.2.2013 21:25, Ray Hatfield kirjoitti:
 Hi,

 I have a model which requires two addresses: a mailing address and a
 physical address. From an OO perspective it makes sense to have an
 Address class and the Producer to have Address instances as properties,
 but I can't seem to achieve this in django while still being able to
 edit the addresses inline as part of the Producer admin.

 I've tried this sort of thing:

 class Address( models.Model ):
street = models.CharField( ... )
# city state zip, etc.

 class Producer( models.Model ):
mailing_address = models.OneToOneField( Address, related_name='+' )
physical_address = models.OneToOneField( Address, related_name='+' )

 but when I attempt to inline the addresses in the django admin I run
 into trouble. I get errors like:

  has no ForeignKey to >>> 'producers.models.Producer'>

 (This error is true, of course. But I was under the apparently erroneous
 impression that including related_name='+' would prevent django from
 setting up the reverse relationship.)

 I realize I could add a foreign key to Address to associate it with a
 specific Producer but this feels backwards to me. An Address shouldn't
 need to know whether it's for a Producer or some other object. It's just
 an address.

 I've been banging my head on this for far too long. Advice?

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


>>>
>>>
>>> --
>>> Jani Tiainen
>>>
>>> - Well planned is half done and a half done has been sufficient before...
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> Peter of the Norse
> rahmc...@radio1190.org
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving 

Re: 2 projects, 2 apps, bad templates ...

2013-01-24 Thread Tomas Neme
just to clarify:

somewhere else, not a subdir of any of your projects/
   |
   ---FOOAPP/
|
---templates/
  |
  ---fooapp/
   |
   --mytemplate.html

projectA/
  |
  --settings.py
  |
  --urls.py
  |
  --templates/
  |
  --base.html
  --fooapp/
  |
  --mytemplate.html # this has ProjectA specific template

projectB/ # this project can use FOOAPP's templates out of the box
  |
  --settings.py
  |
  --urls.py
  |
  --templates/
  |
  -- base.html
  --- otherstuff.html
  -- no fooapp/ directory here!



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: 2 projects, 2 apps, bad templates ...

2013-01-24 Thread Tomas Neme
> > Use virtualenvs. That's basic for any serious python development
> > you'll want to do.
>
> Totally agree. Setting up virtualenv's are our long term goal.

really, it should be your SHORT term goal.

As for your problem, you can't expect to install FOOAPP in two
different directories on the same environment (system global, in this
case) and expect that to work OK.

You're supposed to install that just once, and USE it from different
projects, if that's what you want to do. Also, if you're installing in
the global system python installation, you should not put them under
any single project's directory, but rather somewhere outside them,
because otherwise you'll end up with modules that can be reached from
two different paths (FOOAPP and ProjectA.FOOAPP) and that's bad.

Doing that will probably end you up with the templates problem in BOTH
projects, but at least you'll have consistent behaviour.

Now for the templates. If you're making a reusable app and providing
templates with it, you should do your best to make the templates
reusable as well. The standard procedure is to have them under an
 directory like this:

AppDir/templates/appname/TemplateFiles.html

so the idea is that if you need special modifications for a project,
you can put your special templates in your project's
templates/appname/ directory, and the template loader will find your
local templates before it falls back to the app's directory.

I hope that's clear enough.

Also, make sure your app has a MANIFEST for setup.py to be able to
install non-python files (e.g.: your templates) when you install it
without the -e option. Look at the distutils docs for more details

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 2 projects, 2 apps, bad templates ...

2013-01-24 Thread Tomas Neme
Use virtualenvs. That's basic for any serious python development
you'll want to do.

Besides that, you might add DjangoProjectA to sys.path on ProjectA
(and add DjangoProjectB to sys.path on ProjectB) in their respective
manage.py files.

On the other hand, why does pip install -e install it under ProjectA's
directories? that shouldn't happen, you should end up with a SINGLE
FOOAPP package, probably in /usr/local/lib or something. Try removing
(or renaming so it's not there under that name, anyways)
ProjectA/FOOAPP and see if adding FOOAPP to INSTALLED_APPS uses the
global version (the one you installed with `sudo pip`)

On Thu, Jan 24, 2013 at 10:58 PM, Micky Hulse  wrote:
> Noob alert! :D
>
> I work on a server where we have multiple Django projects that all
> share one Django installation.
>
> Each project has it's own subdomain.
>
> At this time, we aren't using virtual envs.
>
> Situation:
>
> 1. I built a basic application (let's call it FOOAPP) inside of
> DjangoProjectA; after using it for a while, I decided to put the app
> on GitHub.
>
> 2. One of my co-workers wanted to use the same app, but he needed it
> on DjangoProjectB; I installed FOOAPP using PIP from GitHub:
>
> $ sudo pip install -e git+https://github.com/user/FOOAPP.git#egg=FOOAPP
>
> ... which put it in a "src" folder at the root level of the
> DjangoProjectB project directory.
>
> 3. DjangoProjectB's FOOAPP now works great.
>
> 4. DjangoProjectA's FOOAPP templates all broke.
>
> From what we could tell, FOOAPP from DjangoProjectA was looking at the
> template folder from DjangoProjectB.
>
> We fixed the problem by being more explicit in DjangoProjectA's
> settings.py file. In other words, we changed this:
>
> INSTALLED_APPS = (
> # ...
> 'FOOAPP',
> # ...
> )
>
> ... to this:
>
> INSTALLED_APPS = (
> # ...
> 'DjangoProjectA.FOOAPP',
> # ...
> )
>
> And all of our templates came back to life.
>
> Other than setting up virtual environments, is there a better way to
> fix the problem? Being more explicit for this one particular app is
> fine, bu I think it kinda feels like a dirty patch.
>
> What did we do wrong? Why would Django look in a different project's
> app for templates before looking in its own? Tips on how to avoid this
> in the future?
>
> Thanks!
> M
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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




Re: Can I set a "global" variable after user login, to use in my view?

2013-01-23 Thread Tomas Neme
> I don`t understand that.. in my form, I don't have the request, or I have?
>
> I know I have request in my view, but I need to pass UserProfile to my form, 
> but inlineformset_factory doesn't accept to pass vUserProfile as parameter, 
> even I modified __init__ to get this parameter.

OK, so you were asking the wrong question, or incompletely. So you
want to know how to pass a parameter to your form via the formset.

Why don't you show us your code? The view and the form, mainly. The
models too, if your final objective is to modify a model object

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
vUserProfile=request.user.profile
or
vUserProfile=request.user.get_profile()
to be more flexible



On Tue, Jan 22, 2013 at 5:01 PM, Fellipe Henrique <felli...@gmail.com>wrote:

> The problem is, I need to pass this request.user to one form, using a
> inlineformset_factory..in these code:
>
> class PedidoItensForm(ModelForm):
> class Meta:
> model = ItensPedido
>
> def __init__(self, *args, **kwargs):
> profile = kwargs.pop('vUserProfile', None)
> super(PedidoItensForm, self).__init__(*args, **kwargs)
> self.fields["idproduto"].queryset =
> Produto.objects.filter(idempresa=profile.idempresa)
>
> I need to pass UserProfile to my form, to get works my filter.
>
> If I use inlineformset_factory, how can I pass the vUserProfile ?
>
>
> Thanks
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> *"Quemadmodum gladius neminem occidit, occidentis telum est."* (Epistulae
> morales ad 
> Lucilium<http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>,
> Lucius Annaeus Seneca)
>
> *"Any intelligent fool can make things bigger, more complex, and more
> violent. It takes a touch of genius -- and a lot of courage -- to move in
> the opposite direction."*
> Albert Einstein (March 14th 1879 – April 18th 1955)
>
>
> 2013/1/22 Tomas Neme <lacrymol...@gmail.com>
>
>>
>>
>> what mengu says is good for templates, but not so for views.
>>
>> But lo! your request should have a .user property that points to the
>> currently logged user, so try
>>
>> request.user
>>
>> in your view
>>
>>
>> On Tue, Jan 22, 2013 at 4:49 PM, Mengu <whalb...@gmail.com> wrote:
>>
>>> hi fellipe,
>>>
>>> if you enable auth context processors and pass in RequestContext to
>>> render_to_response you can always access the user in your templates
>>> which also means you can access the associated profile as user.profile
>>> (assuming your model is named profile)
>>>
>>> please read more at
>>> https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-data-in-templates
>>>
>>>
>>>
>>> On Jan 22, 8:34 pm, Fellipe Henrique <felli...@gmail.com> wrote:
>>> > Hello,
>>> >
>>> > It's possible, when the user make a login, I set one "global"
>>> variable, and
>>> > get this value in my view?
>>> >
>>> > My question is because I have a inlineformset_factory, and I need to
>>> pass a
>>> > user profile do my view.. but it`s doesn't work.
>>> >
>>> > Regards,
>>> >
>>> > T.·.F.·.A.·. S+F
>>> > *Fellipe Henrique P. Soares*
>>> >
>>> > *"Quemadmodum gladius neminem occidit, occidentis telum est."*
>>> (Epistulae
>>> > morales ad Lucilium<
>>> http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>,
>>> > Lucius Annaeus Seneca)
>>> >
>>> > *"Any intelligent fool can make things bigger, more complex, and more
>>> > violent. It takes a touch of genius -- and a lot of courage -- to move
>>> in
>>> > the opposite direction."*
>>> > Albert Einstein (March 14th 1879 – April 18th 1955)
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> "The whole of Japan is pure invention. There is no such country, there
>> are no such people" --Oscar Wilde
>>
>> |_|0|_|
>> |_|_|0|
>> |0|0|0|
>>
>> (\__/)
>> (='.'=)This is Bunny. Copy and paste bunny
>> (")_(") to help him gain world domination.
>>
>> --
>> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Can I set a "global" variable after user login, to use in my view?

2013-01-22 Thread Tomas Neme
what mengu says is good for templates, but not so for views.

But lo! your request should have a .user property that points to the
currently logged user, so try

request.user

in your view


On Tue, Jan 22, 2013 at 4:49 PM, Mengu  wrote:

> hi fellipe,
>
> if you enable auth context processors and pass in RequestContext to
> render_to_response you can always access the user in your templates
> which also means you can access the associated profile as user.profile
> (assuming your model is named profile)
>
> please read more at
> https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-data-in-templates
>
>
>
> On Jan 22, 8:34 pm, Fellipe Henrique  wrote:
> > Hello,
> >
> > It's possible, when the user make a login, I set one "global" variable,
> and
> > get this value in my view?
> >
> > My question is because I have a inlineformset_factory, and I need to
> pass a
> > user profile do my view.. but it`s doesn't work.
> >
> > Regards,
> >
> > T.·.F.·.A.·. S+F
> > *Fellipe Henrique P. Soares*
> >
> > *"Quemadmodum gladius neminem occidit, occidentis telum est."* (Epistulae
> > morales ad Lucilium<
> http://en.wikipedia.org/wiki/Epistulae_morales_ad_Lucilium>,
> > Lucius Annaeus Seneca)
> >
> > *"Any intelligent fool can make things bigger, more complex, and more
> > violent. It takes a touch of genius -- and a lot of courage -- to move in
> > the opposite direction."*
> > Albert Einstein (March 14th 1879 – April 18th 1955)
>
> --
> 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.
>
>


-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: l10n not loaded from base.html template

2012-12-31 Thread Tomas Neme
each template needs to {% load %} every templatetag library it uses, this
is normal behavior


On Mon, Dec 31, 2012 at 8:31 AM, bikeridercz  wrote:

> Dears,
>
> strange thing happens to me, {% load l10n %} is not loaded in my base.html
> template, all other things like css works well.
>
> Thus I'm forced to {% load l10n %} in every template. I'm using formating
> numbers  usings{% localize on %} and {% endlocalize %} tags.
>
> Can You help to solve this small but annoying issue ?
>
> 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/-/N4uIBo_UnjkJ.
> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How to make django-registration use Chinese as username?

2012-12-10 Thread Tomas Neme
I *think* it should work OK, data-wise. Try changing the
login/registration forms so chinese characters pass the verification
process. You can start by trying with a simple CharField with no
verification and see if it works.

On Sun, Dec 9, 2012 at 7:49 AM, Scarl  wrote:
> I am a chinese user. I want to use django-registration to make a
> user-registration application.
> But I find django-registration only support english username. And its
> help_text are also english.
> I need to use Chinese as username.
> What should I do?
>
> --
> 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/-/sM6wldu7pvwJ.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Reason for not allowing spaces in usernames?

2012-11-17 Thread Tomas Neme
> I'm puzzled with this too. Did anyone manage to find a solution to resolving
> spaces in usernames.
>
> Generally a user, these days logs in with their email - that's predominately
> how I've setup all my django projects. People don't remember usernames. It

Well, I can't really agree, but whatever, it shouldn't be hard to do..
just override the forms... at the worse of cases, the User model...

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: 1.5: syntax of AUTH_USER_MODEL

2012-10-29 Thread Tomas Neme
> Thanks, yup! I just figured it out too. I didn't realize all the "apps" are
> in the path as well.

the apps aren't NECESSARILY in the path. Django has a concept of app
label, which is the name of the directory where the models module
exists.

For example, django-cms has plugins, which in order to use, you need
to add to INSTALLED_APPS:

'cms.plugins.text',
'cms.plugins.picture'

but the app label of these plugins are just 'text' and 'picture'
respectively, and the "app model" path to their models are just
'text.TextPlugin', and 'picture.PicturePlugin'.

This is, IMO, the biggest and most stupid problem in django core
design, because it stops you from having an otherwise completely legal
configurations, like having a 'cms.plugins.picture' app alongside a
'myproject.custom.picture' one which might do something completely
different. I.E.: you can't have apps with repeated app labels even if
there's no python path conflict between them.

I don't know what the reason behind this is. I know it allows you to
make a model part of any given app regardless of where it's located
(via Meta.app_label), but this could very easily be extended (in a
backwards-incompatible way, I'm afraid) to require to be the fully
qualified name of the app package

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Modernizing the Tutorial

2012-10-25 Thread Tomas Neme
> However, there is also scope for a focussed tutorial about class-based views
> in general. IMHO one of the biggest uptake problems around class-based

This is what I meant. Something that brings in, easy and clearly, the
concept of mixins, the different mixins,something that, for example,
take two mixins that alter the context, and combines them, stuff like
that, simple, but useful, and that gives you a glimpse of "real world"
usage and customization.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Modernizing the Tutorial

2012-10-25 Thread Tomas Neme
Now that function-based views are being deprecated, or at least that
class-based views are being favored, there should be a tutorial with
them in the docs, shouldn't it?

I don't mean replacing the current one, because that'd raise the entry
point a lot, but cloning the original tutorial, but implementing it
with class-based views, possibly placing a link to it in the generic
views docs page, would go a long way towards generating "good" habits
amongst new users, I think.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: implement of view

2012-10-25 Thread Tomas Neme
>>> How can i create 2 views on one page?
>>> def sql(request): and def portal(request):

You can't. A View *is* a page. Do the tutorial.

You could use class-based views and have a view that inherits from
both, and combines the contexts (this is _not_ in the tuto)

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread Tomas Neme
Just by the way, I'm looking at django-picklefield code and README
https://github.com/gintas/django-picklefield and it says NOTHING about
a widget, or an admin representation, so.. maybe it's not DESIGNED to
be shown on the admin? it'd make sense, too, since it's.. well, it can
be ANYTHING

On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme <lacrymol...@gmail.com> wrote:
> maybe restate the problem, give some more code, show your models, and
> your admin files, and someone may be able to help a little
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Displaying a custom field (PickledObjectField) in the admin

2012-10-24 Thread Tomas Neme
maybe restate the problem, give some more code, show your models, and
your admin files, and someone may be able to help a little

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: implement of view

2012-10-24 Thread Tomas Neme
>> Thank you for your answer. i have chapter 1-4 of
>> http://www.djangobook.com/en/2.0/index.html done, but not much time to go
>> throught the hole book atm. i will try it with your code. :)

the django book is somewhat outdated, and long.

https://docs.djangoproject.com/en/dev/intro/tutorial01/

do that tutorial, it's quite short, you can get through it in a couple of hours.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: implement of view

2012-10-24 Thread Tomas Neme
>
> how can i implements now these "def sql(request):" into my html code? pls
> help me...
>

you're saying next to nothing, but I *guess* you could do something like

return render_to_response("sql.html", { 'row': row })

at the bottom of your sql view, and write an sql.html template that
shows it the way you want...

Also, you'll better go on and learn that pyodbc library and how to
pass parameters into your queries, which will protect you against SQL
injection attacks.. and you should probably learn SOME python if
you're going to be coding in it.

And you shuold *really* at least run through the django tutorial at
least once, in order to get a grip on some of the basic django
concepts, like forms and models, which will help you a lot

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Facebook like button in django

2012-10-12 Thread Tomas Neme
> I want to create a website facebook like, but real simple and I want to have
> a button that I can give to blogger to add them on their blog entries.  It
> have nothing to do with facebook.

Ah! so you want your own "facebook button"!

It'll be mostly a javascript task, rather than django-specific. In
order to protect your users' identities, you won't be giving the
client (blog) an actual HTML form, but rather (like the FB button) a
link to a JS library, and some markup that the library will use to
create an iframe to your website where you'll send the actual rendered
markup

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Facebook like button in django

2012-10-11 Thread Tomas Neme
You should probably start by reading this:

http://developers.facebook.com/docs/reference/plugins/like/

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Making form label a href

2012-09-30 Thread Tomas Neme
> Is there some way to have the form label be a href?

you'll have to change the forms templates to something like

{% for field in form %}

  {{
field.label }}
  {{ field }}

{% endfor %}


-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: language in field description in forms won't change

2012-09-22 Thread Tomas Neme
you probably are using ugettext and should be using ugettext_lazy

On Sat, Sep 22, 2012 at 8:44 PM, Patrick  wrote:
> When I change language on my Django-powered site, everything works fine
> except the translation of the field descriptions in the forms. The
> description is still displayed in the old language. Only the forms already
> visited that session are affected.
>
> It seems like some sort of caching problem, but I don't use any caching (as
> far as I know) and all other parts of the site behave as expected (templates
> and random text using django.utils.translaction.ugettext work just fine).
>
> Summarized:
>
> When I open the site and change language, and then visit a form: everything
> works as expected. All text is translated.
> When I visit a form, change language and return to the form: everything is
> translated, but the form stays in the old language.
> Restarting the web server forces the language to change: then Django behaves
> as in (1) for the current session. Until the language is changed again.
>
> Help is appreciated!
>
> Kind regards, Patrick
>
> --
> 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/-/P3sRNFd-aaAJ.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: OR together multiple extra clauses

2012-09-14 Thread Tomas Neme
I haven't done this, so I might be wrong, but...

> queryset.extra(
> where=['unaccent("table_name"."column_name"::text) LIKE
> unaccent(%s)'],
> params=['%%%s%%' % value]
> )

first, wouldn't just setting params=[value] work? furthermore, isn't
that the whole point of the params thing? maybe unaccent(%%%s%%)'
params=[value].

secondly.. wouldn't chaining .extra() methods work?

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: Django-admin (was: tastypie - some feedback / comments)

2012-09-12 Thread Tomas Neme
The admin templates and views themselves are convoluted enough (the
price of having them work with anything), and full of enough magic
that it's not really feasible to build on top of them to add the
required capabilities. Maybe adding new admin views would be a
posibility, but what happens when you want an admin page that does not
exactly correspond to a given model? You can usually twist things
around to make it so, but the fact stands that the admin is in the end
just a way of managing the database, and that the user must *really*
know what they're doing to avoid screwing up big time. Maybe careful
permission handling and/or different admin site instances are a
(partial) solution to this, but I haven't played with those myself.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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-admin (was: tastypie - some feedback / comments)

2012-09-12 Thread Tomas Neme
Since this came up, are there any more-or-less packaged alternatives
to django-admin? More than twice I've had to give up in something as
simple as rendering two-level FK indirections, lest I wanted to
override most of the ModelAdmin classes.

The thing is that I don't trust myself to be throughout enough with
security and the such when rolling my own.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: To Use or Not to Use the admin backend

2012-09-04 Thread Tomas Neme
> Anyway, to the question. Once the models, the intermediate models and
> the interactions between all of them start getting sufficiently
> complex, you will need to put new forms on front. Theoretically, you

I've a question about this. I tried to do something like this, but
using the main capabilities and hacking on the ModelAdmin classes,
changing the formsets and the like, and reusing as much as possible,
including of course the admin templates.

Of course, it wasn't possible. I was trying to do something as simple
as a double-indirection inline, a second-level foreign key, and ended
up just showing a link to the other model's admin page, creating,
indeed, a complex workflow where none was needed.

To what extent and how particularly would one need override a specific
admin page to do this kind of thing? Is reusing the templates at all
possible if you've customized things? Maybe the templates yes, but the
ModelAdmin views are impossible, I was in a hurry so I wasn't able to
do a good diagnosis of what would have been needed to do this.

Tomas

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Hard time debugging an strange problem

2012-08-31 Thread Tomas Neme
I'd like to see some of your management commands' code.

It smells somewhat like you're running a shell subprocess and not
waiting for it to be done before going on to the next thing

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Full auth solution

2012-08-17 Thread Tomas Neme
> http://www.django-userena.org/
++

I've successfully combined it with django-social-auth to have
facebook/twitter/google/openId login

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: [old question]NoReverseMatch.. I am sorry.

2012-08-17 Thread Tomas Neme
> But I am confused.
> For example,
> the following code needs to add single quote.
>
> {% block content %}
> Add Todo items

https://docs.djangoproject.com/en/dev/releases/1.3/#changes-to-url-and-ssi

also, that won't work with double quotes either, unless you import
future, and a bunch of other things.

Just import url from future, since this will be the default behavior
in the near future

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: [old question]NoReverseMatch.. I am sorry.

2012-08-17 Thread Tomas Neme
either remove the quotes from {% url 'blog.views.add_comment' %} (so it's
{% url blog.views.add_comment %}) or {% load url from future %}

Loading from future is the better option, I think.

and for future reference:


Reverse for ''blog.views.add_comment'' with arguments '(1L,)' and
keyword arguments '{}' not found.

notice how there's two single quotes there, not a double quote? that's your
clue, right there

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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 makemessages doesn't recognize trans in templates

2012-08-17 Thread Tomas Neme
> For example for this link
>
> {% trans "contacts" %}
>
> I have the msgstr="Contactos". I expect to see "Contactos" in the browser,
> but I still see "contacts". Any suggestion?

1) case-sensitive. Are you sure you haven't translated "Contacts"
instead of "contacts"?
2) fuzzy-mark. I've noticed that if a translation is marked as
"fuzzy", sometimes gettext doesn't use it

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How to create a formset that contains forms with a dropdown? (Crucial)

2012-08-16 Thread Tomas Neme
DropDownMultiple widget

http://djangosnippets.org/snippets/747/

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How well does South work in a team?

2012-08-16 Thread Tomas Neme
>>> Well, if you push without pulling, this might happen,
>>
>> *Implicit git usage* :D
>
> Implicit VCS usage, whichever you choose.
>
> If you don't, you shouldn't be doing team work

ah, I see now. CVS wouldn't complain in that scenario...

neither would git/hg when you pull, for that case.. yes , you need to
be careful, but it's better than the alternative

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How well does South work in a team?

2012-08-16 Thread Tomas Neme
>> Well, if you push without pulling, this might happen,
>
> *Implicit git usage* :D

Implicit VCS usage, whichever you choose.

If you don't, you shouldn't be doing team work

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How well does South work in a team?

2012-08-16 Thread Tomas Neme
Well, if you push without pulling, this might happen, if you always
pull before pushing, then you'd have to manually merge both migrations
(which would probably mean letting the other migration as 001, and
changing yours so it adds your wanted changes on top of THAT

And as an answer: using south is always better than NOT using it
(unless you want to roll out your own migrations system)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: New to dj: relational limitations

2012-08-15 Thread Tomas Neme
> On Tue, Aug 14, 2012 at 8:49 PM, Russell Keith-Magee 
>  wrote:

I'm just glad I didn't come back with a half-assed response


--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Hot to use widgets with generic views

2012-08-14 Thread Tomas Neme
well, for starters, you won't magically get "on keyup" behavior by
adding something on your backend, you'll need to use ajax for this,
and, depending on your expected number of elements, it might be better
to send everything and do any filtering on the client side (if you're
handling, say, up to a few thousands of records, and not up to tens of
thousands or more).

In any way, you'll need to give your view some parameter to do the
filtering. For this, I'd recommend passing a ?q=keywords GET argument
to your view, and with that in mind, I link you here:
https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/#dynamic-filtering

Just do something like that, but instead of using self.args or
self.kwargs, use self.request.GET for the filtering

--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: multiple profile

2012-08-14 Thread Tomas Neme
Well, it depends on what you want to do exactly, you could create something
like this:

class UserProfile(models.Model):
common_data

class ClientProfile(UserProfile):
specific_data

class StudentProfile(UserProfile):
specific_data

class TeacherProfile(UserProfile):
specific_data

...

AUTH_PROFILE_MODULE = 'appname.UserProfile'

This would ensure that 3rd party apps that don't know about your
3-user-types system work in your site, but whether you do this, or ignore
AUTH_PROFILE_MODULE, you'll have to set up a specific way of creating the
profiles on user creation. Save signals are your friend here, probably,
and/or the views you use to create the different types of user.

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How to override an attribute?

2012-08-05 Thread Tomas Neme
I don't mean to say you shouldn't need to ask questions, I just say
that using or not "proxy" is not a "let's see what happens" choice,
and having the docs read and halfway understood will help you ask *the
right* questions

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How to override an attribute?

2012-08-05 Thread Tomas Neme
> There is a class (let's call it Foo) which is a subclass of User.
> Foo has the following line in its Meta:
> proxy = True

if you don't provide full minimal data, it's hard for us to help. If I
had known you were using a proxy model, I'd have proposed something
different.

In general, unless you got a good reason, I'd recommend against
subclassing User, use a profile instead. If you *really* need to
subclass or override it, first go read the docs about overriding the
User class, *and* all the documentation about models and model
inheritance.

Things should be pretty clear, whether you want a proxy model or not,
where in the inheritance tree it should be, and how to set it up.
THEN, if you have some issue with your class schema, you'll be able to
realize what you need, and be sure whether you really need to do what
django is complaining about, or if there's a better way of doing it.

For the time being, I suggest you drop all the Foos and Bars, post
some real code, and explain why do you feel the need to subclass the
User model

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: DRYing up my forms.py

2012-08-04 Thread Tomas Neme
But if you subclass the widget, then you'll need to override every
form's widget with

{
  forms.DateField: MyDateWidget
}

so overriding and using your own MyDateField would be less verbose and
repetitive

On Sat, Aug 4, 2012 at 6:17 PM, Melvyn Sopacua  wrote:
> On 3-8-2012 18:23, Lee Hinde wrote:
>>
>> On Aug 3, 2012, at 9:01 AM, Melvyn Sopacua  wrote:
>>
>>> On 3-8-2012 17:37, Lee Hinde wrote:
>>>
 self.fields['photo_response'].widget.attrs["class"] = 'date-field 
 input-small'
 self.fields['photo_response'].widget.format = '%m-%d-%Y'
>
>> Thanks, that got me looking in the right place. I think I need to
>> sublcass the widget, since I'm concerned with the display of the data,
>> not how it's saved/stored?
>
> Yes, if the data doesn't need special handling you can stick to
> subclassing the widget.
>
> --
> Melvyn Sopacua
>
> --
> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



showing a second level of indirection in an admin change_form page

2012-08-03 Thread Tomas Neme
Anyone knows of any trick that will let me show a second-level
indirection inline

via a one2one, so ModelA <-FK- ModelB <-one2one- ModelC, and show A,
B-C-B-C-B-C kind of thing?

Maybe I can override the get_formsets in the admin?

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Noob question

2012-08-02 Thread Tomas Neme
as Kurtis says, drop the explicit Primary Keys, and drop the hungarian
notation as well (don't declare the variable type on it's name): I
don't need to be reminded that the name of a project will be a string,
it's pretty obvious. Also, python standards talk against using
underscore in class names, so standard naming would be HeaderEnrich
instead of Header_Enrich. Underscores for field names are good. I'd
also use less abbreviations.

also, I'd name the FK on that model just "projeto", since what you'll
get when you do `headerenrichobject.projeto` will be a Projeto object,
not it's ID

Try to forget the underlying database, the ORM is there to abstract you from it.

But all these are style things, the syntax looks good, so it's all
your call, but getting used to standardized style will make your life
easier, as well as the life of people who try to help you in mailing
lists and IRC channels

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: returning a zip file for download

2012-08-01 Thread Tomas Neme
OK, I got it working, I'm not sure what the problem was, but calling the
loop variable 'file' was overriding the python default file object class

now I'm doing this:

response = HttpResponse(File(file(tmp[1])),
mimetype="application/zip")
response['Content-disposition'] = ('attachment; '

 'filename="{}"').format(os.path.basename(tmp[1]))
return response

and I'm wondering, what happens with that File object after the response is
sent? when does it get closed? isn't there some cleanup code missing?

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



returning a zip file for download

2012-07-31 Thread Tomas Neme
Down here's the code in which I'm creating a zip file with a bunch of pdf
labels, and returning it on the HttpResponse for the user to DL it.

The weird thing is that I'm getting just a pdf file (ok, I'm testing with a
single file, so I don't know if that's the problem) and I can't set the
downloaded filename to anything (it's always "download")

Can someone see what I'm doing wrong?

files = []
for detail in queryset:
for parcel in
detail.parceldescription_set.select_related().all():
shipment = parcel.shipment
if not shipment.label:
try:
shipment.download_label(args['username'],
args['password'])
except Shipment.Wait:
self.message_user(_("Failed downloading label for "
"shipment {id} because the "
"Canada Post server is busy, "
"please wait a couple of
minutes "
"and try again").format(
id=shipment.id))
files.append(shipment.label.file)

tmp = tempfile.mkstemp(suffix=".zip")
tf = zipfile.ZipFile(tmp[1], mode="w")
for file in files:
filename = os.path.basename(file.name)
tf.write(file.name, filename)
tf.close()

return HttpResponse(open(tmp[1]), mimetype="application/zip")


-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Dynamic forms

2012-07-30 Thread Tomas Neme
Just to be clear, sandeep, jQuery is not java, javascript is not java.
Get yourself clear on that, because it can become a big confusion.

Besides that, yes, without javascript, the only way you've got to do
that, is having the user submit a form where he selects the options,
and then return another form with the appropriate options rendered.
Maybe you can use a form wizard for this

--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: access the state of a Model object prior to it's modification ?

2012-07-30 Thread Tomas Neme
uhm, if you register a listener to the pre_save signal, then you can do
this:


if instance.published:
  # the instance about to be saved has the published flag on
  dbojb = MyModel.objects.get(id=instance.id)

  # did it have it on the database?
  if not dbobj.published:
do_stuff()

you probably need to check the "created" argument on the listener that
tells you if the object is a new one, or a modification

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Variable # of fields in a form

2012-07-30 Thread Tomas Neme
maybe this will help?
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup

On Mon, Jul 30, 2012 at 5:06 AM, Alex Strickland  wrote:
> On 2012/07/25 12:41 PM, Daniel Roseman wrote:
>
>> You could probably subclass the CheckboxSelectMultiple widget and
>> override the `render` method to get what you want.
>>
>> See the original code here:
>> https://github.com/django/django/blob/master/django/forms/widgets.py#L749
>> unfortunately you'll need to copy-and-paste most of that code but that
>> should give you the output you need while still leaving Django to do the
>> "messy data handling" .
>
>
> Thanks Daniel. I am looking at that code distributed with 1.4, amazing how
> different it is in the head version already.
>
> I think I'll try and do something similar to Select() which caters for
> , and if I can make that work then I'll override the
> render method to suit my layout purposes (try, being the operative word).
>
> If I can make it work nicely it might be nice to upgrade it to the same
> style as the head version and offer it back as a snippet - that looks a long
> way off though!
>
> --
> Regards
> Alex
>
>
> --
> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Is there a way to use 'request.user' in a custom template tag without an inclusion tag?

2012-07-29 Thread Tomas Neme
>
> class EditableNode(template.Node):
>  def __init__(self, location_name):
>  self.location_name = location_name.encode('utf-8').strip("'")
>  def render(self, context):
> obj = Placeholder.objects.filter(location=self.location_name)
>  if request.user.is_authenticated():
> for x in obj:
> return "%sedit" % (x, self.location_name)
>  else:
> for x in obj:
> return x
>
>
>
>
that `request` variable isn't declared anywhere, that's what that "global
name `` does not exist" error mean.

I *think* you've got to use context['user'], try that. Else, try
context['request'].user

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: REMOVE ME

2012-07-29 Thread Tomas Neme
I'm very sorry. I got completely out of line.

It's just something that irritates me a lot, and I'm not a native
english speaker, and it may be I don't know the actual "value" of the
word, I felt it was more funny than insulting. And I hadn't read your
first reply.

It won't happen again.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Can i use django book

2012-07-28 Thread Tomas Neme
While the things on the djangobook are probably still compatible,
they're far of being best practices nowadays, and will lead you down
old and abandoned roads, more times than not.

As it's been said, I'd rather stay by the official docs, they're very
clear and pretty helpful, not purely technical  at all.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: ignore field during form validation

2012-07-26 Thread Tomas Neme
> class Form(forms.Form):
>
> check = forms.BooleanField(
> required=False,
> )
> # take into account only when 'check' is True
> len = forms.IntegerField(
> min_value=3,
> max_value=5,
> required=True,
> )
>
>
> What I want is to validate the 'len' field only when 'check' is True.
> I could define the clean method of the form and validate the required,
> min_value and max_value stuff only when 'check' is True but the case when
> someone types a non integer value into the input is still there. How could I
> skip that? That check is done by the IntegerField.

well, you could override clean_len() and not do anything in it, and
then override clean() and do your check there.

The only problem is that you won't be able to raise the issue as a
field-specific error

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: 'QuerySet' object has no attribute '_meta' ... but I'm not using a QuerySet!

2012-07-26 Thread Tomas Neme
The ArtworkForm AND the full view code would be helpful, yes

also, maybe you'll want to install django-extensions, werkzeug, and
run your devserver with runserver_plus, that'll give you full
debugging capabilities on your browser, and will be able to see what's
each object (that instace object, specifically)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: ManyToMany relationship with intermediate model and admin list display with each realtion with value as diferent column

2012-07-24 Thread Tomas Neme
> as shown in the picture, this i could do by add a method in the model
> getTienda1 and return the stock and do it for each store, but i want it to
> be created dinamically because the user could create a new store and it
will
> not be there.
>
> so this is my cuestion: can i do that?

Interesting question. You COULD try the following:

in the ProductAdmin ModelAdmin's class' __init__ you can define
list_display like

from store.models import Tienda
for store in Tienda.objects.all():
self.list_display.append('stock_tienda_{id}'.format(id=store.id))

this would give you the list of existing stores at server init time.
and then you could define your Product model's __getattr__ method something
like this:

def __getattr__(self, attr):
 base = 'stock_tienda_'
 if attr[:len(base)] == base:
 return
Product.objects.filter(tienda=Tienda.objects.get(id=attr[len(base):]))
 return super(Product, self).__getattr__(self, attr)

this should make the ModelAdmin's hack work

finally, you need a way to add new columns for newly created stores, so
maybe a post_save signal on Tienda objects

@receiver(post_save, sender=Tienda)
def add_to_product_list_display(sender, instance, new, **kwargs):
  if new:
  # I don't know how to get the ModelAdmin's instance for a given
class,
  #  but it must be something in django.contrib.admin.site
  product_admin.list_display.append('stock_tienda_{id}'.format(id=
instance.id))

you probably need another listener before .delete of stores, and I'm not
certain the __getattr__ hack will work, but this sounds interesting.

Please try on those lines, and let me know if this worked, I'm most
interested

--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How To Display Non-Modal Popup From Resulting Asynchronous Javascript Request

2012-07-24 Thread Tomas Neme
> The current URL, mediahelp/comphelp/mediaHelpPopup.html, didn't match any of
> these.
>
> The code from the comphelp url view is very basic and looks like this:
> def component_help(request):
> view = "component_help"
> dctnry = {}
> reqGET = request.GET.copy()
> if reqGET.has_key('fieldId'):
> field_value = reqGET['fieldId']
> else:
> field_value = "NONE FOUND"
> message = "This is a test message!...FIELD-ID="+field_value
> dctnry['helpdata'] = message
> return HttpResponse(message)

then why are you calling /mediahelp/comphelp/mediaHelpPopup.html?

what exactly do you think that html filename in the end does to your call?

And.. no, I could make a lot of questions trying to lead you slowly to
the answer, but what I really think is that you need to do the
tutorial again, and understand urlconfs, views and templates.
https://docs.djangoproject.com/en/dev/intro/tutorial01/

I'll give you the short of it because I'm not your teacher: what you
actually want to do is call '/mediahelp/comphelp/' and from the view
you'll want to `return render_to_response('mediaHelpPopup.html',
dctnry)`

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How To Display Non-Modal Popup From Resulting Asynchronous Javascript Request

2012-07-23 Thread Tomas Neme
your error's got nothing to do with AJAX. As the very helpful error
message you're getting, there's no URL that matches your requested
path:

> Request URL:
>
> http://127.0.0.1:8000/mediahelp/mediaHelpPopup.html
>
>  Using the URLconf defined in streamingmedia.urls, Django tried these URL
> patterns, in this order:
> 1.^mymedia/
> 2.^mediaadmin/
> 3.^mediahelp/ ^$
> 4.^mediahelp/ ^comphelp/$
> 5.^admin/

I don't know where did you get the 'mediaHelpPopup.html' part of your
URL, but it's quite clear it doesn't match any of those urls you've
got set up.

So if you give us some more details on your idea for this popup, where
does the data come from, and why do you feel the need to make a call
to some phantom html file
(https://docs.djangoproject.com/en/1.4/topics/http/urls/, and
especially http://www.w3.org/Provider/Style/URI).

Basically, you need to have a view that renders your popup's HTML, and
that view needs to be linked to an URL.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: How is the label_tag's attrs parameter supposed to specified?

2012-07-20 Thread Tomas Neme
{% for field in form %}
{{ field.label
}}{{ field }}
{% endfor %}

although I think the custom form class is not such a bad solution



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Boolean always returns False?

2012-07-20 Thread Tomas Neme
why do you have your own User model? Are you sure you're logging in
the right user and loading the right user instance?

On Fri, Jul 20, 2012 at 12:37 PM, Sithembewena Lloyd Dube
 wrote:
> Hi everyone,
>
> I have a user model in which i have a newsletter boolean field. When the
> user subscribes to a newsletter, this is checked.
> I am then instantiating that user and checking the property, so that if it
> is False (i.e. unchecked) = I can display a subscription box.
>
> In the model:
> newsletter = models.BooleanField(verbose_name=u'Sign up to the newsletter',
> default=False)
>
> .. and in the view:
> print registered_user.newsletter
>
> The print outputs False even though this same user's 'newsletter' field
> appears checked in the admin. What am I missing?
>
> Thanks.
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Can a method call inside save() display its return on template?

2012-07-20 Thread Tomas Neme
You can still do self.something = foobar even if "something" is not a
database Field.

What I mean is, doing self.vdr_code = get_vdr_code() will save it for
THIS INSTANCE and then you can use it in your template.

If you really need this to be only at .save() (instead of, say, at
__init__, because it feels like once the object's been saved this
could be get in object initialization), you just have to make sure
this is the same instance you pass to the template context.

Something like:

myobject.save()
.
render_to_response(template, { 'object': myobject })

then in your template you can do {{ object.vdr_code }}

Although all in all, I *really* hope you have a good reason to use db
backend-specific SQL instead of making a django model of those
DirectionDescr whatever they are

---
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Query with 3 models

2012-07-19 Thread Tomas Neme
> Thanks, the first example is exactly that i want. I try it in the Django
> Shell and it works, but; How I show the results in the template?
>
> Maybe I'm wrong, but I try to pass like  { 'empresas':
> Empresa.objects.all().select_related() } ,and only can show the 'Empresa'
> attributes on the loop.
>
> I  do something like this
>
> {% for a in empresa%}
>   a.slogan
>   a.descripcion
>   a.platillo.fotografia
> {% endfor %}


as I said, you need to do a loop like the one I showed in python, but
in the template

say, for example

{% for empresa in empresas %} {# keeping your plurals straight is good
practice! #}
{% for sucursal in empresa.sucursal_set.all %}
{% for platillo in empresa.platillo_set.all %}
{% for horario in empresa.horario_set.all %}

   empresa.slogan
   empresa.descripcion
   platillo.fotografia
   horario.foobar
   
   {% endfor %}
   {% endfor %}
   {% endfor %}
{% endfor %}

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Can a method call inside save() display its return on template?

2012-07-19 Thread Tomas Neme
> In my models.py I override the save method like this:
>
> def save(self, *args, **kwargs):
> self.directiondb = get_direction_db(self.nod_id1.id,
> self.nod_id2.id)
> get_direction_descr(self.nod_id1.id, self.nod_id2.id)
> get_vrd_code(self.nod_id1.id, self.nod_id2.id)
> self.vrd_id = get_vrd_id(self.nod_id1.id, self.nod_id2.id)
> super(Webrequests, self).save(*args, **kwargs)
>
> and it works fine.
> Is it now possible what get_direction_descr() and get_vrd_code() return to

well, what does get_vrd_code do? why aren't you saving the value
anywhere? same question with get_direction_descr.

The easy answer will be:
 self.vrd_code = get_vrd_code(self.nod_id1.id, self.nod_id2.id)

and then use that on the template, but that save() method seems
awfully redundant, so.. can you explain what your model does better?

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Query with 3 models

2012-07-19 Thread Tomas Neme
> {Empresa1, Sucursal1, Platillo1, Horario1},
> {Empresa1, Sucursal1, Platillo2, Horario1},
> {Empresa2, Sucursal1, Platillo1, Horario1}...

I'm guessing the Sucursal1 in the first and third lines are not the same? I
mean, each Sucursal points to only one Empresa, so I'm guessing you want
only the related objects

if this is the case, you can do something like this:

[(empresa, sucursal, platillo, horario) for empresa in
Empresa.objects.all().select_related()
for sucursal in
empresa.sucursal_set.all()
for platillo in
empresa.platillo_set.all()
for horario in
empresa.horario_set.all()]

that if what you want is a list. If you want just to loop through those,
you can do

for empresa in Empresa.objects.all().select_related():
for sucursal in empresa.sucursal_set.all():
for platillo in empresa.platillo_set.all():
for horario in empresa.horario_set.all():
do_something(empresa, sucursal, platillo, horario)

and about the same thing if you want to cycle through them in a template,
in which case you can just pass { 'empresas':
Empresa.objects.all().select_related() } and then loop like above on the
template side

-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: one field of modelForm doesn't being displayed

2012-07-18 Thread Tomas Neme
> You could override your ModelForm's save() method to save some data to that 
> field. And then modify the same ModelForm to exclude that field. For example,

or maybe, just maybe, he might show us his model, form, and rendered
html so we can actually help him identify and possibly fix his
problem! ;)

I mean, perhaps he wants to be able to fill that field as well?

But unless we know the type and the output, we won't be able to help you

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Prepopulating a contact form

2012-07-18 Thread Tomas Neme
user = request.user
initial = {}
if user.is_authenticated:
initial.update({ 'name': user.name, 'email_address': user.email_address
})
form = MyContactForm(initial=initial)

On Wed, Jul 18, 2012 at 11:23 AM, Sithembewena Lloyd Dube 
wrote:
> Hi everyone,
>
> I have a contact form in my app and would like to prepopulate it with user
> details where a user is logged in. Basically, I do the following:
>
> reg_user = get_registered_user(request)
> # get my form object
>
>
> I would like to do something like:
> if reg_user:
> my_form.name = reg_user.name
> my_form.email_address = reg_user.email_address
> # and so on ...
>
> Any ideas? Thanks ...
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Tutorial question

2012-07-17 Thread Tomas Neme
> Do these just get stuck onto the end of my class Poll(models.Model):?  like
> this...

Yes, that's right

perhaps you should start here:
http://docs.python.org/tutorial/classes.html

you should probably at least be comfortable enough with python to know
how to define classes before diving into django

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Directory indexes are not allowed here. for Grappilli

2012-07-17 Thread Tomas Neme
On Mon, Jul 16, 2012 at 2:56 PM, Dott. Tegagni Alessandro
 wrote:
>
> write the urls.py code and var. static in settings.py, please.

do as he says.

Also you could try asking the grapelli user group, if there is one,
this seems to be specific

--
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: satchmo and django-admin-tools

2012-07-16 Thread Tomas Neme
> thanks for sharing, I'll try to understand it.
>
> where should I put this file? inside localsite?
>
> what admin template are you talking about? the admin tools or the plain
> admin?

dashboard's (it's part of admin_tools) admin/index template.

> I thought of using the admin tools templates and building from that, but all
> I got was noReverseMatch erros, looks like the INSTALLED_APPS order is
> significative and I don't understand it well.

well, I should probably just point you to this:
http://django-admin-tools.readthedocs.org/en/latest/index.html

and specifically this:
http://django-admin-tools.readthedocs.org/en/latest/quickstart.html

You probably didn't add dashboard to INSTALLED_APPS and you're
probably missing the urls as well.

> how can I configure it to ignore the satchmo admin templates?

and some of django's documentation as well..
https://docs.djangoproject.com/en/dev/ref/templates/api/#loading-templates

The short version is, usually, you put under
yourproject/templates/admin/index.html whatever template you want to
be used, but do go and read those docs

> btw, could I make all this work with grappelli? it seems I could enjoy some
> of the image uploading and wysiwyg editor

you can most probably make everything work with everything, I don't
know what grappelli is, bear in mind you might need to dig deep in the
admin templates to make javascript (specially jquery) play nice with
every app you use

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: satchmo and django-admin-tools

2012-07-16 Thread Tomas Neme
> I thought they extended the templates instead of trying to replace
> everything

they don't replace everything. But the admin site's index template is
called 'admin/index.html', so it's not easy to extend them. They DO
extend admin/base.html.


This is my dashboard.py file, where I create a module that emulates
satchmo's template additions.

https://gist.github.com/3124534

There's a couple of things that are MY PREFERENCES, so it might not
all be to your liking, please do try to read, understand, and modify
as you like.

with this, I just use dashboards' admin/index.html template

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Is Tutorial / Part 4 wrong? (or is it me?)

2012-07-16 Thread Tomas Neme
It's the second time this issue appears in the list in two weeks, maybe
it's time to recheck the tutorial?

There's no "polls" in your results' url, doesn't the tutorial say you
should have two urls file? one in project/urls.py and another one in
polls/urls.py ?

the polls-specific urls shouldn't start with "^polls/" and be in
polls/urls.py, and in project/urls.py there should be a line with

url(r'^polls/', include('polls.urls')),

On Mon, Jul 16, 2012 at 1:59 PM, Bill Torcaso  wrote:

>
> Django is great, and the tutorial is great.  I'm having a problem at the
> very end of tutorial-4.
>
> I try to use generic views, and I get an error when I Redirect from the
> POST request in vote() to the Results page.  Details below.
>
> The tutorial code says to put this in my urls.py:
>
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model=Poll,
> template_name='polls/results.html')
> ,name="poll_results"
> ),
>
> And this in my views.py:
>
>  from django.shortcuts import get_object_or_404, render_to_response
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>
>
> def vote(request, poll_id):
> p = get_object_or_404(Poll, pk=poll_id)
> try:
> selected_choice = p.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> # Redisplay the poll voting form.
> return render_to_response('polls/detail.html', {
> 'poll': p,
> 'error_message': "You didn't select a choice.",
> }, context_instance=RequestContext(request))
> else:
> selected_choice.votes += 1
> selected_choice.save()
> # Always return an HttpResponseRedirect after successfully dealing
> # with POST data. This prevents data from being posted twice if a
> # user hits the Back button.
>
>
>
> return HttpResponseRedirect(reverse('polls_results', args=(p.id
> ,)))
> ### OKAY:return HttpResponseRedirect("/polls/%i/results" %
> p.id)
> ### OKAY:return render_to_response("polls/results.html",
> {"poll": p})
> ### BAD:   return
> HttpResponseRedirect(reverse('polls.views.results', args=(p.id,)))
>
>
>
> NoReverseMatch at /polls/4/vote/
>
> Reverse for 'polls_results' with arguments '(4,)' and keyword arguments
> '{}' not found.
>
> *Request Method:*
>
> POST
>
> *Request URL:*
>
> http://127.0.0.1:8000/polls/4/vote/
>
> *Django Version:*
>
> 1.4
>
> *Exception Type:*
>
> NoReverseMatch
>
> *Exception Value:*
>
> Reverse for 'polls_results' with arguments '(4,)' and keyword arguments
> '{}' not found.
>
> *Exception Location:*
>
> /Library/Python/2.7/site-packages/django/core/urlresolvers.py in
> _reverse_with_prefix, line 407
>
> *Python Executable:*
>
> /usr/bin/python
>
> *Python Version:*
>
> 2.7.1
>
> *Python Path:*
>
> ['/Users/s3/Desktop/CODE/APPSS3/EdAssistant/experiments/djtest',
>
>
>  
> '/Library/Python/2.7/site-packages/mercurial-2.0.2-py2.7-macosx-10.7-intel.egg',
>
>
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>
>
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>
>
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
>
>  '/Library/Python/2.7/site-packages']
>
> *Server time:*
>
> Mon, 16 Jul 2012 11:53:21 -0500
>
>  --
> 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/-/f-sjN1OtNuwJ.
> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.

Re: satchmo and django-admin-tools

2012-07-16 Thread Tomas Neme
Yes, you'll need to get your hands dirty, and merge the two admin
templates, since both apps redefine templates/admin/index.html and
some other templates.

The best approach, I think, is just use django-admin-tools' templates
and create custom dashboard/modules to duplicate satchmo's templates'
behavior

On Sun, Jul 15, 2012 at 7:12 PM, אברהם סרור  wrote:
> Hi,
>
> I'm trying to use django admin tools with satchmo, I installed satchmo in my
> dev machine and made a store with clonesatchmo.py
> after that the store seemed to be running fine, so I installed
> django-admin-tools using the instructions on their website
>
> but I didn't manage to make it work, I spent about a week googling, I think
> I must be doing some obvious mistake
>
> anyone had success using both together? where can I see an example
> settings.py?
>
> Also I have in mind grappelli, can the three work together?
>
> any help is appreciated
> 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/-/PyVTP5tNkqMJ.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: ajax loading html

2012-07-14 Thread Tomas Neme
On Sat, Jul 14, 2012 at 2:11 PM, ledzgio  wrote:
> If I use the TemplateViews method, should I have to set anything on the
> views.py? and how can I point that file from template?

the TemplateView is a view, it's already been written for you, so you
can use it without adding anything new. If you want to add some custom
behavior to it, you can subclass it, or skip it completely and make a
new view, either out of mixin classes, or function-based (though that
method's being deprecated in the future). That you'd usually do in
your views.py file (bearing in mind that it's not mandatory that it's
called that, it's just a convention), but for this case (at least as
far as you've described it) I don't think you need any specific
behavior.

And how can you point what file from which template?

That being said: My real recommendation would be go do the tutorial
and understand the concepts. Then go read about Class-based views, and
understand all that on a conceptual level, as well.

I.. don't mean to sound harsh, but all your questions and the place
they seem to point to give out a feeling that you're not really
understanding django and it's underlying concepts, it'll be very hard
for you to ask the right questions unless you figure it out first, and
even harder for us to answer them.

A template is just some text that can be mixed with some programming
structures (loops, ifs, and other template tags and filters) and
variables. The HTML you actually send the client could be (and usually
is) built from a mixture of a number of different templates, so you
should get yourself rid of that concept of "HTML page" = "template
file" you seem to be carrying.

At this point, I think the best thing you could do is be a little more
explicit, tell us what you're trying to do, possibly paste some models
and urls files

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: ajax loading html

2012-07-14 Thread Tomas Neme
an "html page" can't be located within the templates directory, an
HTML file might, but what is it you want to do, exactly? you want to
render a static file? does it make sense going through django for
this?

URLs point to views, not templates, the views are which decide what
templates to use (the same view could use different templates in case
there's errors, or depending on whether the user is logged in or not,
for example).

In any case, you should set up an URL to make your ajax call to, if
you want to go through django for this, something like

url(r'path/to/tip/$',
TemplateView.as_view(template="path/to/template.html"),
name="ajax_tooltip")

docs on the matter of TemplateViews:
https://docs.djangoproject.com/en/dev/ref/class-based-views/base/#django.views.generic.base.TemplateView

If you don't want to write an url for this, then you don't want to
handle it through django. If that's the case, as someone explained,
you can just put the html file somewhere OFF your templates directory,
and have your webserver (apache, or nginx, or whatever you're using)
serve that url by itself (you'll still have to set up the URL in the
webserver's config files)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Tasking? A fluid user experience with Uploading Media.

2012-07-14 Thread Tomas Neme
Well, first of all, you're gonna have to set up quite a big amount of
parallel connections for this to work,

> A new user could be uploading media/music files or something at the same
> time as uploading a video of themselves. I want it to be efficient and fast
> to the point where it all gets updated but the user can leave this task
> going and leave the page that is updating the file and just check back in

Well, this whole part, I don't see happening, because you need to have
some application on the client side sending the data, this is usually
the browser, which unless it stays on the sending page, will close all
outstanding connections to your server. You'd need a client-side
application for something like this to work, like Picasa and Dropbox
do. I also would recommend against letting users upload more than one
file at any given time, because multiple files per client means
multiple connections. Of course, you could add a "send file" link that
actually only adds stuff to a queue, but again, this will always
depend on the browser page not being closed, or changed, not even
refreshed, I've seen this worked-around with popups (have the popup
window handle the connection, so the user can keep browsing on his
main window, but he cannot close the popup, in that case).

As for the actual solution tools for your problem, I don't know them,
but I do know enough to just mark that thing up there

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



Re: django-admin.py makemessages issue

2012-07-12 Thread Tomas Neme
"django-admin.py makemessages -l de"
"django-admin.py makemessages -l es"

On Thu, Jul 12, 2012 at 2:59 PM, Phil  wrote:
> Hi,
>
> (django version 1.3.1, Python2.7)
>
> (at the end of my settings file)
> 
> # translation support
> ugettext = lambda s: s
>
> LANGUAGES = (
> ('en', ugettext('English')),
> ('es', ugettext('Spanish')),
> ('de', ugettext('German')),
> )
>
> LOCALE_PATHS = (
> '/home/phil/project/locale',
> )
> 
>
> I am implementing languages into my django website. It's working fine but
> when I run "django-admin.py makemessages" on the command line it gives the
> following error
>
> "Error: This script should be run from the Django SVN tree or your project
> or app tree. If you did indeed run it from the SVN checkout or your project
> or application, maybe you are just missing the conf/locale (in the django
> tree) or locale (for project and application) directory? It is not created
> automatically, you have to create it by hand if you want to enable i18n for
> your project or application."
>
> So like it says, I create the "locale" folder manually then(it's in the root
> of my project directory) run makemessages again but I just get another error
> saying...
>
> "Error: Type 'django-admin.py help makemessages' for usage information."
>
> Any idea's where I could be going wrong?
>
> --
> 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/-/IukJjVtKua4J.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Error in blog

2012-07-12 Thread Tomas Neme
Have you done the django tutorial, first? it covers named urls

On Thu, Jul 12, 2012 at 11:06 AM, luthur  wrote:
> why not post your example? It's too abstract.
>
> --
> luthur
>
> On Thursday, July 12, 2012 at 9:56 PM, jun wrote:
>
>
>
> On Thursday, July 12, 2012 7:40:46 PM UTC+8, lawgon wrote:
>
> On Wed, 2012-07-11 at 23:29 -0700, jun wrote:
>> I was trying out the blog example in Django by Example but ran into
>> this error:
>> Reverse for 'blog_post_add' with arguments '()' and keyword arguments '{}'
>> not found.
>>
>> I think it has something to do with the urlpatterns since there is
>> no /blog/post/add configuration there, and tried a few variations but
>> nothing worked.
>>
>> What should I do next? Any django docs I can refer to, as in how to
>> link the blog_post_add with the main url?
>
> what version of django are you using - is it the same version that is
> being used in the example?
> --
> regards
> Kenneth Gonsalves
>
> Hi I'm using Django 1.4 now. Understand that the example is using 1.2. Would
> this have an effect?
>
> Regards,
> jun
>
> --
> 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/-/Ox4KIBiwce8J.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: getting variable from __init__ into clean_xxx function

2012-07-11 Thread Tomas Neme
also this:
http://docs.python.org/tutorial/classes.html

On Wed, Jul 11, 2012 at 12:58 PM, Nikolas Stevenson-Molnar
 wrote:
> Change nbi_patch to self.nbi_patch, and you should be set. I.e:
>
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> self.nbi_patch = kwargs.pop('nbi_patch', None)
> ...
>
> def clean_release_number(self):
> self.nbi_patch #use however you want here
>
> _Nik
>
>
> On 7/11/2012 8:06 AM, Leandro Alves wrote:
>
> Hi,
>
> I'm sending a variable from my views.py and getting it in my forms.py.
>
> My form looks like this now:
>
> class PatchForm1(forms.Form):
> def __init__(self, *args, **kwargs):
> nbi_patch = kwargs.pop('nbi_patch', None)
> super(PatchForm1, self).__init__(*args, **kwargs)
>
> release_number = forms.CharField(label='Release number:')
>
> def clean_release_number(self):
> #nbi_patch = I want to use the nbi_patch var from __init__ here
> release_number = self.cleaned_data.get("release_number")
> path = os.path.join(nbi_patch, release_number)
> if not os.path.exists(path):
> raise forms.ValidationError("Hmm... it looks like %s does not
> exist in nbi-patch." % release_number )
> return release_number
>
> I want to use my var nbi_patch from __init__ inside my
> clean_release_number() function. Is that possible?
>
> I tried pass it as a parameter but it didn't work...
>
> Thanks!!!
>
> Leandro
> --
> 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/-/90_l6B36fHsJ.
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: rendering modelForms

2012-07-10 Thread Tomas Neme
There's a way, but you'll need to touch the form on the python side
quite a lot, changing the default widgets adding them the css classes
you want.

You can take a look at https://github.com/earle/django-bootstrap and
https://github.com/dyve/django-bootstrap-toolkit/ they provide some
shortcuts for this


-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: masking only a small part of a template

2012-07-09 Thread Tomas Neme
http://djangosnippets.org/snippets/1376/

this is what you want, I'm using it and it works like a charm

you override in templates/path/to/template.html and do

{% extends "app:path/to/template.html" %}, and this loader searches in
`app`'s template dir by default

On Mon, Jul 9, 2012 at 3:06 AM, tWoolie  wrote:
> Sorry, I should have been clearer. What I have is an external project that
> is included "as-is". It has it's templates and it's views are hardcoded
> against the template names.
> I want to know if it's possible to create a template called, say,
> "app/dashboard.html" in the global template dir that then extends
> "app/dashboard.html" in the app's template directory, thereby allowing me to
> change ONLY the block I need to change, without requiring me to copy-paste
> the entire template and re-edit every time I update that app.
>
> --
> 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/-/G2ExbPmO4e0J.
>
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Adding a custom validation to Django's auth_user in admin

2012-07-08 Thread Tomas Neme
> Ah. I think the method is overriding the edit page. In other words, you have
> click on the editpage to see the effect of my fail code. So it doesn't
> trigger if you are on the list view page. Does anyone know what to do with
> the editable submission?
> It should use the same clean_ method, shouldn't it??

if you want this validation everywhere you should probably do
something in the model's .save() method, or even better (to avoid
monkey patching) register into the pre_save signal

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Model for ListView needed?

2012-07-08 Thread Tomas Neme
Oh, and setting up a queryset in a DetailView means that it won't work
for instances that are not inside the queryset, if we did

url(r'/books/shakespeare/(P\d+)/$',
queryset=Book.objects.filter(author='shakespeare')), then
/books/shakespeare/1/ would work if the book with pk=1 was Romeo and
Juliet, but it wouldn't if it was Crime and Punishment (Fedor
Dostoievsky)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Model for ListView needed?

2012-07-08 Thread Tomas Neme
> A queryset returns a /list/ of model instances. Thus you should queryset
> when you want more then one instance of the model displayed.

well, slightly wrong, let's clarify. While it's true a queryset
represents a list of model instances (it's not EXACTLY that, it's,
more like, a partially set up query that only gets ran when you
actually request the objects), in GenericViews the difference between
setting up a model and a queryset is that setting up model=Post is the
same as setting up queryset=Post.objects.all(). So if you want your
view to act upon ALL Post instances, and you don't care about
ordering, then you can do model=Post and save yourself some typing.

If, however, you want your view to act upon only a SUBSET of objects,
you can use queryset. If, for example, you are making a list of books
made by a specific author, you can do this:

url(r'^books/shakespeare/$',
ListView.as_view(queryset=Book.objects.filter(author='shakespeare')),...

(of course, this isn't the best example, since it'd be much smarter to
make a more specific view that filters authors by a parameter,
something like (r'books/(P\w+)/$')), but it serves as
example)

In the docs' example, the queryset= parameter is used, because they
want the view to show only the latest 5 Polls, hence the
queryset=Poll.objects.order_by('-pub_date')[:5]. If you wanted ALL,
but ordered by -pub_date (and this wasn't the default ordering for the
model), you would use the same queryset, but leaving out the [:5]
part.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: urlpatterns

2012-07-08 Thread Tomas Neme
Django isn't able to guess you want your polls urls under a /poll/ path.

To achieve this, you do url inclusion

you define something like polls/urls.py like you did and then do

url(r'^polls/', include('polls.urls'))

then your defined urls will work when prepended with a polls/ path.
You can change that polls to foo, and then the same views will work
under 'foo/' path (localhost:8000/foo/1/results will show the results
for poll#1 and so on)

On Sun, Jul 8, 2012 at 3:21 PM, Seyfullah Tıkıç  wrote:
> Yes, in tutorial it is said to be done so. I expect it works as follows,
> after the commented lines.
> urlpatterns = patterns('',
> url(r'^$',
> ListView.as_view(
> queryset=Poll.objects.order_by('-pub_date')[:5],
> context_object_name='latest_poll_list',
> template_name='polls/index.html')),
> url(r'^(?P\d+)/$',
> DetailView.as_view(
> model=Poll,
> template_name='polls/detail.html')),
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model=Poll,
> template_name='polls/results.html'),
> name='poll_results'),
> url(r'^(?P\d+)/vote/$', 'polls.views.vote'),
> )
> urlpatterns += patterns('',
> url(r'^admin/', include(admin.site.urls)),
>
> 2012/7/8 Mario Gudelj 
>>
>> But you've commented out all your URLs that start with /polls/, like
>> url(r'^polls/$', 'index')... r'^polls/$' will resolve to
>> http://127.0.0.1:8000/polls/, for example.
>>
>> -m
>>
>>
>> On 8 July 2012 23:01, Seyfullah Tıkıç  wrote:
>>>
>>> http://127.0.0.1:8000/polls/34/
>>> http://127.0.0.1:8000/polls/
>>> http://127.0.0.1:8000/polls/34/results/
>>> 2012/7/8 Mario Gudelj 

 Which url are you trying to access when you get that 404?

 On Jul 8, 2012 5:36 PM, "Seyfullah Tıkıç"  wrote:

 --
 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.
>>>
>>>
>>>
>>>
>>> --
>>> SEYFULLAH TIKIÇ
>>>
>>> --
>>> 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.
>
>
>
>
> --
> SEYFULLAH TIKIÇ
>
> --
> 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.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Problem with DetailView

2012-07-08 Thread Tomas Neme
Man...

> (r'^sets/(?P\d+)/$', SetDetailView.as_view(
> model=Set,
> context_object_name="set_details",
> template_name='data/set_details.html',
> )),
>
> But the site is empty. Here's my extremely simple template:
>
> {% block title %}{{ set.text_name }}{% endblock %}
>
> {% block content %}
> Set:
>
> {{ set.theme }} - {{ set.subtheme }}
> {% endblock %}

and where, pray, would that 'set' variable be populated when you very
explicitly told the DetailView you wanted your context object named
'set_details'?

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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

2012-07-08 Thread Tomas Neme
> No, I'm not. I didn't think I need to...

the only things that are automatically included are your settings
file, your site urls file, and your apps' models file, everything else
depends on you (or them) to include them. For example, if you don't
call admin.autodiscover() sometime soon (your site's urls file is
about the soonest it makes sense to do this, and where it's usually
done), your ModelAdmins won't get registered. Likewise, unless you
include the call to signal.register() (or in your case the @listener
decorator), then your listener never gets registered in the signal.

The signal itself is working because you included it from your models
file in order to .send() it

I don't know exactly why is it working from the shell, I'm guessing
you included something more when you were fiddling in it, that got it
included.

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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

2012-07-08 Thread Tomas Neme
Are you importing your listeners.py from anywhere?

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Problem with DetailView

2012-07-08 Thread Tomas Neme
> Turns out that's the problem. I wanted to use a field from my Car model:
> car_id, so the link on the website would look like:
> www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the
> car_id is not the same as . Can I achieve something like that with class

what's car_id and why isn't it your PK?

you should post your full models when asking for help, in general.

As a general rule, having a car_id field in a Car model is
unnecessary. Models come with ids of their own by default, you don't
need to define them. If you have IDs of your own that you want to
reflect in your database, first of all, I'd call it just "id", so you
can do my_car.id, my_car.car_id sounds a little bit redundant to my
taste, and secondly, you can define it as id =
models.IntegerField(primary_key=True). If you do that, your pk will be
the ID you defined (you can do this with a CharField as well, I think)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: migration via south for inheritance change -> please help

2012-07-07 Thread Tomas Neme
> and I do
> for fruit in Fruits.objects.all(): fruit.rott()
>
> will anything happen at all? I know in C++ this would work... ;-)
>
> on database-level I know how to do it, I just don't know if the django
> abstraction handles this automalically.

I.. don't know. I'd think yes, at least I wonder otherwise how does
the DB keep coherent if you do
BaseModel.objects.filter(foo=bar).delete(). "CASCADE" would deal with
it in PG, but mysql sometimes lacks that, and sqlite doesn't handle
foreign keys at all.

but you probably need to make some tests to make sure. It'd be quite
easy to do it from the shell

> Seems I have too little faith in the capabilities of python ;-)

Yah, and about that.. what you said WOULD work for any Objects of a
subclassed class in python, as it would in C. Actually, since you
don't declare types in python, you don't really know the class of your
parameters unless you ask, it is the concept of duck-typing that gets
used strongliest in python (you ask the parameter to respond to a
certain interface, you don't care what type it is).

The question is not whether python is able to know what the real class
of an object is, but rather whether django knows the real model of an
object it got from a supermodel's table.

my_fruit.apple returns the corresponding Apple instance, and
my_fruit.orange returns the corresponding Orange instance, but if you
call my_fruit.orange on an object that actually represents an Apple,
you'll get an Orange.DoesNotExist exception raised. But this behavior
is lazy (the Orange table doesn't get hit in the database until you do
.orange).

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: migration via south for inheritance change -> please help

2012-07-07 Thread Tomas Neme
> The big difference is, -as I see it- I will not get real polymorphism,
> as the base class would need to do the join on all it's child classes.
> Is that true?

with abstract models you won't get polymorphism at all, in the
database level (this is, you WON'T be able to do Fruit.objects).
You'll mostly just be sharing structure and behavior, saving yourself
some repetition.

With multi table inheritane (MTI) you get three tables, one for Fruits
one for Oranges and one for Apples, Fruits have a row for every Orange
and every Apple, so you can do Fruit.objects.all(). Knowing whether
this is an orange or an apple is trickier, but not too much

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Returning nothing from a view

2012-07-06 Thread Tomas Neme
Just return an empty response, with a 200 OK code:

return HttpResponse("")

I'm not sure whether you can omit the ""

On Fri, Jul 6, 2012 at 5:44 PM, Larry Martell  wrote:
> I have a situation where I'm sending an ajax request to a function
> that updates a row in database. I then want to return control to the
> browser, with no changes to the page that was up. I am not returning
> anything from the function, and it's working the way I want, however I
> get an error in the browser's console:
>
> Failed to load resource: the server responded with a status of 500
> (INTERNAL SERVER ERROR)
>
>
> Is there some was to avoid this error?
>
> --
> 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.
>



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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



  1   2   >