Re: IPAddressField inserted as empty string although null=True

2010-09-21 Thread rihad
Incidentally this has been mentioned in the trac for 3 years by a few,
but no milestone has been set yet.
http://code.djangoproject.com/ticket/5622
Unfortunately I'm not yet knowledgeable enough in Django's inner
workings to propose a patch myself.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: REST XML + HTML API suggestions

2010-09-21 Thread vikalp sahni
Hi,

You might want to have a look at django-piston.

http://bitbucket.org/jespern/django-piston/wiki/Home

Its a nice project to give rest full interface to your models.

And for some specific logic also you can tweak the handlers to get desired
results.

Regards,
//Vikalp

On Tue, Sep 21, 2010 at 11:09 AM, Brendon  wrote:

> Hi all,
>
> I want to use DJango to implement an XML based RESTful API and a
> website together using DJango. I am wondering if anyone here is aware
> of any tutorials on ways of achieving this in DJango without
> duplicating too much code?
>
>
> Basically what I want to achieve is to use the same core logic for
> both the website and the API and just have different presentation
> layers for the two systems. I have not seen any tutorials or the like
> on doing this sort of thing and was wondering if people here have
> suggestions on best approaches or tutorials that might show good ways
> to structure this.
>
> The idea is that all interaction using the API uses XML. The POST data
> sent to the server and responses from the server are all using an XML
> schema that we have designed for our application. All interaction with
> the website is the same but uses normal web forms etc for the
> interface of the presentation layer.
>
> Example API:
> * GET   : https://mywebsite/api/rooms/ : List available rooms, returns
> XML with a list of Room ID's
> * POST : https://mywebsite/api/room/  : Create a new room, raw POST
> data is XML with the parameters required to create a room, on success
> returns a Room ID
> * GET   : https://mywebsite/api/room// : Retrieves details
> about an existing room
> * POST : https://mywebsite/api/room// : Modifies details for
> an existing room
> * DELETE : https://mywebsite/api/room// : Delete a room
>
> Now, on the website side of things I want to do exactly the same but
> as part of a a nice HTML site (with menus for navigation, nice graphs
> to display relevant data etc).
>
> Example Web:
> * GET   : https://mywebsite/web/rooms/ : Displays a page with a list
> of links to available Rooms.
> * GET   : https://mywebsite/web/room/   : Displays a page with a form
> requesting input of all necessary data to create a new room.
> * POST : https://mywebsite/web/room/   : Create a new room. POST data
> comes from form displayed previously (on error redisplays form). On
> success redirects the user to the details page for that room.
> * GET   : https://mywebsite/web/room// : Displays details
> about an existing room and provides it in a form that can be used to
> change the data with a POST
> * POST : https://mywebsite/web/room// : Modifies details for
> an existing room
> * DELETE : https://mywebsite/web/room// : Delete a room
>
>
> Thanks,
> Brendon.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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 1.2 and keyless many to many on legacy databases

2010-09-21 Thread Xavier Ordoquy
Hi,

I'd like to know whether someone managed to get a many to many relationship 
with a keyless joint table.
I got a legacy database which uses that and although I can get it working on 
read mode, I have issues with writing.

I'm using this snippet (works fine with django 1.1):
http://djangosnippets.org/snippets/962/
but got no luck in patching it so that it could work with django 1.2 (and I 
need the later for permission management and multi database support).

Also I can't see how I could do it with a through table since django doesn't 
support composite keys.

Regards,
Xavier.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: REST XML + HTML API suggestions

2010-09-21 Thread Alexandre González
I'm using django-piston in my app, and it's incredible.

You can use XML in your RESTful API, but if you like to user another emitter
as JSON, Pickle... you can do at-the-moment! Incredible!

On Tue, Sep 21, 2010 at 11:11, vikalp sahni  wrote:

> Hi,
>
> You might want to have a look at django-piston.
>
> http://bitbucket.org/jespern/django-piston/wiki/Home
>
> Its a nice project to give rest full interface to your models.
>
> And for some specific logic also you can tweak the handlers to get desired
> results.
>
> Regards,
> //Vikalp
>
>
> On Tue, Sep 21, 2010 at 11:09 AM, Brendon wrote:
>
>> Hi all,
>>
>> I want to use DJango to implement an XML based RESTful API and a
>> website together using DJango. I am wondering if anyone here is aware
>> of any tutorials on ways of achieving this in DJango without
>> duplicating too much code?
>>
>>
>> Basically what I want to achieve is to use the same core logic for
>> both the website and the API and just have different presentation
>> layers for the two systems. I have not seen any tutorials or the like
>> on doing this sort of thing and was wondering if people here have
>> suggestions on best approaches or tutorials that might show good ways
>> to structure this.
>>
>> The idea is that all interaction using the API uses XML. The POST data
>> sent to the server and responses from the server are all using an XML
>> schema that we have designed for our application. All interaction with
>> the website is the same but uses normal web forms etc for the
>> interface of the presentation layer.
>>
>> Example API:
>> * GET   : https://mywebsite/api/rooms/ : List available rooms, returns
>> XML with a list of Room ID's
>> * POST : https://mywebsite/api/room/  : Create a new room, raw POST
>> data is XML with the parameters required to create a room, on success
>> returns a Room ID
>> * GET   : https://mywebsite/api/room// : Retrieves details
>> about an existing room
>> * POST : https://mywebsite/api/room// : Modifies details for
>> an existing room
>> * DELETE : https://mywebsite/api/room// : Delete a room
>>
>> Now, on the website side of things I want to do exactly the same but
>> as part of a a nice HTML site (with menus for navigation, nice graphs
>> to display relevant data etc).
>>
>> Example Web:
>> * GET   : https://mywebsite/web/rooms/ : Displays a page with a list
>> of links to available Rooms.
>> * GET   : https://mywebsite/web/room/   : Displays a page with a form
>> requesting input of all necessary data to create a new room.
>> * POST : https://mywebsite/web/room/   : Create a new room. POST data
>> comes from form displayed previously (on error redisplays form). On
>> success redirects the user to the details page for that room.
>> * GET   : https://mywebsite/web/room// : Displays details
>> about an existing room and provides it in a form that can be used to
>> change the data with a POST
>> * POST : https://mywebsite/web/room// : Modifies details for
>> an existing room
>> * DELETE : https://mywebsite/web/room// : Delete a room
>>
>>
>> Thanks,
>> Brendon.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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-us...@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.
>



-- 
@agonzalezro 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-mailer truncate my log file

2010-09-21 Thread ferran
Thanks to Rolando for he's answer
http://groups.google.com/group/django-es/browse_thread/thread/c2107f2b172eb0c0/6f5ffb8235326e56?show_docid=6f5ffb8235326e56


On Sep 17, 11:35 am, ferran  wrote:
> hello,
> I don't understand because django-mailer truncate my log file every
> time run cronjob for send email, this is my config in settings.py
> import logging
>
> LOGFILE = "site.log"
> logging.basicConfig(level=logging.DEBUG,
>                     format='%(asctime)s %(name)-12s %(levelname)-8s %
> (lineno)d %(message)s',
>                     datefmt='%a, %d %b %Y %H:%M:%S',
>                     filename=os.path.join(PROJECT_PATH, LOGFILE),
>                     filemode='w')
>
> and in models or view i use:
> import logging
> log = logging.getLogger("order.views")
> log.debug("hello")
>
> , any idea?
> thanks in advanced

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Making admin callables to display foreignkey relations (nested)

2010-09-21 Thread N8
No one responds to questions regarding nested inlines in the admin,
there must be a reason for that :)

But Im a django novice, and am having troubles customizing the admin
to make it intuitive for the client.  Can someone give me an example
of one of the following:

- nesting inlines of foreignkey relations (Model A - fk Model B = fk
Model C):  known not be possible in django admin by default
- or making a direct link to an admin view of Model B within Model A,
which would give a similar result ... sufficient at least
- generally how to add functions to admin actions (i need to trigger
an xml file write when the administrator saves a model instance for
example)

Any other useful links to documentations for making the admin more
customizable would be great, I havent had much success with the
documentation on this.

Cheers, thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Automatically creating fields

2010-09-21 Thread tsmets
I think, one of the question is also ...
What are these fields for ... ?
If they are derived values like : is_firstname_filled or
is_age_above_18
you should then just implement a method ... but bottom line, it looks
much simpler / efficienter / safer to implement it (as an attribute or
a method) instead of trying to generate it

\T,

On Sep 20, 6:27 pm, pixelcowboy  wrote:
> Hi, for every field in a model that I have created, I want to create a
> releated boolean field. Is there any way to do this automatically?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: REST XML + HTML API suggestions

2010-09-21 Thread Brian Bouterse
I typically check the content type and have the response match the content
type of the incoming request.  I also typically have this be the only
decision that lives within views.py, and in turn calls out to code in other
modules to handle xml and/or html presentation respectively.  Also, I would
recommend using an xml processing/generating library.

Brian

On Tue, Sep 21, 2010 at 1:39 AM, Brendon  wrote:

> Hi all,
>
> I want to use DJango to implement an XML based RESTful API and a
> website together using DJango. I am wondering if anyone here is aware
> of any tutorials on ways of achieving this in DJango without
> duplicating too much code?
>
>
> Basically what I want to achieve is to use the same core logic for
> both the website and the API and just have different presentation
> layers for the two systems. I have not seen any tutorials or the like
> on doing this sort of thing and was wondering if people here have
> suggestions on best approaches or tutorials that might show good ways
> to structure this.
>
> The idea is that all interaction using the API uses XML. The POST data
> sent to the server and responses from the server are all using an XML
> schema that we have designed for our application. All interaction with
> the website is the same but uses normal web forms etc for the
> interface of the presentation layer.
>
> Example API:
> * GET   : https://mywebsite/api/rooms/ : List available rooms, returns
> XML with a list of Room ID's
> * POST : https://mywebsite/api/room/  : Create a new room, raw POST
> data is XML with the parameters required to create a room, on success
> returns a Room ID
> * GET   : https://mywebsite/api/room// : Retrieves details
> about an existing room
> * POST : https://mywebsite/api/room// : Modifies details for
> an existing room
> * DELETE : https://mywebsite/api/room// : Delete a room
>
> Now, on the website side of things I want to do exactly the same but
> as part of a a nice HTML site (with menus for navigation, nice graphs
> to display relevant data etc).
>
> Example Web:
> * GET   : https://mywebsite/web/rooms/ : Displays a page with a list
> of links to available Rooms.
> * GET   : https://mywebsite/web/room/   : Displays a page with a form
> requesting input of all necessary data to create a new room.
> * POST : https://mywebsite/web/room/   : Create a new room. POST data
> comes from form displayed previously (on error redisplays form). On
> success redirects the user to the details page for that room.
> * GET   : https://mywebsite/web/room// : Displays details
> about an existing room and provides it in a form that can be used to
> change the data with a POST
> * POST : https://mywebsite/web/room// : Modifies details for
> an existing room
> * DELETE : https://mywebsite/web/room// : Delete a room
>
>
> Thanks,
> Brendon.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Brian Bouterse
ITng Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 servers one database

2010-09-21 Thread Tim Arnold
Hi Steve,
That would definitely be the easiest and simplest answer.
Unfortunately I only have power over these two machines. What I'm
trying to do is create a site that if one machine dies/hangs, the
system will continue to work on the alternate server. I just read
about the master-master mysql server setup and though that seems a
little complicated, I suppose my desires are more difficult than I
thought at first.

Any other ideas out there? Is SQLite a possibility or is master-master
the way to go?

thanks,
--Tim

On Sep 20, 9:22 pm, Steve Holden  wrote:
> On 9/20/2010 11:11 AM, Tim Arnold wrote:> hi, I have two machines for a 
> Django-powered site and they are  setup
> > to be duplicates to provide redundancy. Each one runs its own apache
> > instance and accesses the same Django apps on a shared disk.
>
> > The problem I have is that I need a single database. The users should
> > not need to know which machine they're actually connecting to. As I
> > understand it, I can't do that with MySQL. I can make one a master and
> > one a slave, but that's not duplication of machines. I tried making a
> > symlink from /usr/local/mysql/var to a shared disk location for both
> > MySQL servers, but that is a Bad Idea (from what I read this weekend).
>
> > So finally, my question is how to solve the problem and maybe whether
> > SQLite would be a better database since AIUI, it is simply file-based.
>
> If the two web servers are sharing a disk they are presumably fairly
> local to each other. Why not just a single database server with each
> Django server connecting to it over a LAN? You may need to think more
> deeply abut transaction isolation. Just an idea ...
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 forms

2010-09-21 Thread ashy
Hi All,

I want to create dynamic fields on the form, for instance I want the
city and state fields
to appear only when these properties are blank for the user. Can I
create such a form in
django? Any ideas?

thanks
ashy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: What's the best way to develop an app that is similar the django admin?

2010-09-21 Thread Alex Robbins
I think you'll definitely want to use ModelForms.
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

Alex

On Sep 20, 8:13 am, Federico Capoano  wrote:
> Hi all,
>
> I try to explain it clearly.
>
> I have to develop an application that will implement similar
> functionality and look of the django admin, but in the frontend.
>
> So this application will have files management, clients management,
> and much more similar stuff, with add new, edit, delete, file upload
> and so on.
>
> Is there a way you would advice to do this?
>
> Thanks a lot.
> Federico

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread Anton Danilchenko
Hi all!

Please, help me undestand, how to solve next task.

I am show for user form with two fields: user name and text field,
where user input list of phones, separated by comma. User sholud enter
one or more phones separated by comma. If user enter not valid number
- we show error message like this "Phone 12345 is not valid. Please,
enter valid phone numbers separated by comma".

I have next two models:

class Phone(models.Model):
  number = models.CharField(max_length=20)

class UserInfo(models.Model):
  name = models.CharField(max_length=70)
  phones = models.ManyToManyField(Phone)

User should enter numbers in CharField in format 0XX XXX . But, I
need save phone in database in format 0XX (only number without
spaces and other non-numbers digits).

Please, can you help me in this. I am new in Django, and I am read
more articles and not found solution. I think that I need create
custom fields for form and model.

P.S. Also, in admin section I should see CharField instead of
ManyToManyField.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 forms

2010-09-21 Thread Shawn Milochik
Of course. You can dynamically add to self.fields in the __init__ of your form 
instance.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Problems to render a tree in Json - __init__() got an unexpected keyword argument 'use_decimal'

2010-09-21 Thread Rogério Carrasqueira
Hello!

I'm new on this list and a newbie in Django. I'm recurring to this list
because I'm having a problem to implement a Json Tree using Django. I saw an
article at
http://www.elfsternberg.com/2009/05/20/fixing-an-omission-from-djangos-simplejson-iterators-generators-functors-and-closures/and
there it has a good implementation to render a tree in Json, so I
implemented my code as follow:

on utils/json.py

from django.utils import simplejson
from django.utils.simplejson.encoder import JSONEncoder

class TreeToJson:

def __init__(self, roots):
self.roots = roots

def _index(self, nodes):
def _item(node):
t = { 'id': node.id,
  'name': node.name }
  #'top': node.is_root()}
if not node.is_leaf():
t.update({'children': self._index(node.get_children())})
return t

return [_item(node) for node in nodes]

def __call__(self):
return self._index(self.roots)

def json(s,**kw):

kw.update({'cls': ExtJsonEncoder})
return simplejson.dumps(s,**kw)

At myapp/views.py

def jsonSiteList(request):

data = json(TreeToJson(Site.get_root_nodes()))
return HttpResponse(data, mimetype='text/javascript;')

But I don't know why this error is appearing when calling at browser:

*__init__() got an unexpected keyword argument 'use_decimal'*


Sorry for my so novice phase, but I'm dont know all the things on django, so
rest to me a only way: ask to the others :)

Can anyone help me with this issue?

Thanks so much!

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread nick.l...@gmail.com
First I don't think you should be using the admin for such fine grained
control of your data formats.
BUT if you do want to do that you would want to do your validation in custom
admin forms. (created in your admin.py to do cleans on the data that's being
submitted)

Second I wouldn't do a manytomany with this, I would instead create an
inline on your userinfo model linking to phones. Then your Phone will have a
FK relationship to your UserInfo.

in models.py
class Phone(model.Models):
number = models.CharField(max_lenth=25)

class UserInfo(model.Models):
name = models.CharField(max_length=50)

in admin.py

from myproject.myapp.models import Phone, User
class PhoneInline(models.TabularInline):
   model = Phone

class UserAdmin(models.ModelAdmin):
inlines = [PhoneInline, ]

admin.site.register(User, UserAdmin)


What you get with that is the ability for a user to dynamically add as many
phone numbers to a user as they want. Also you get the charfield (instead of
the select box, which is what you get from the M2M field)

n


On Tue, Sep 21, 2010 at 9:14 AM, Anton Danilchenko <
anton.danilche...@gmail.com> wrote:

> Hi all!
>
> Please, help me undestand, how to solve next task.
>
> I am show for user form with two fields: user name and text field,
> where user input list of phones, separated by comma. User sholud enter
> one or more phones separated by comma. If user enter not valid number
> - we show error message like this "Phone 12345 is not valid. Please,
> enter valid phone numbers separated by comma".
>
> I have next two models:
>
> class Phone(models.Model):
>  number = models.CharField(max_length=20)
>
> class UserInfo(models.Model):
>  name = models.CharField(max_length=70)
>  phones = models.ManyToManyField(Phone)
>
> User should enter numbers in CharField in format 0XX XXX . But, I
> need save phone in database in format 0XX (only number without
> spaces and other non-numbers digits).
>
> Please, can you help me in this. I am new in Django, and I am read
> more articles and not found solution. I think that I need create
> custom fields for form and model.
>
> P.S. Also, in admin section I should see CharField instead of
> ManyToManyField.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread nick.l...@gmail.com
Let me rephrase my first statement...You can use the admin for fine grained
control of your data formats and characters. But don't use the Database to
control the characters and formats. Use the database as a storage and make
sure that anything you store gets cleaned.

n

On Tue, Sep 21, 2010 at 9:37 AM, nick.l...@gmail.com wrote:

> First I don't think you should be using the admin for such fine grained
> control of your data formats.
> BUT if you do want to do that you would want to do your validation in
> custom admin forms. (created in your admin.py to do cleans on the data
> that's being submitted)
>
> Second I wouldn't do a manytomany with this, I would instead create an
> inline on your userinfo model linking to phones. Then your Phone will have a
> FK relationship to your UserInfo.
>
> in models.py
> class Phone(model.Models):
> number = models.CharField(max_lenth=25)
>
> class UserInfo(model.Models):
> name = models.CharField(max_length=50)
>
> in admin.py
>
> from myproject.myapp.models import Phone, User
> class PhoneInline(models.TabularInline):
>model = Phone
>
> class UserAdmin(models.ModelAdmin):
> inlines = [PhoneInline, ]
>
> admin.site.register(User, UserAdmin)
>
>
> What you get with that is the ability for a user to dynamically add as many
> phone numbers to a user as they want. Also you get the charfield (instead of
> the select box, which is what you get from the M2M field)
>
> n
>
>
> On Tue, Sep 21, 2010 at 9:14 AM, Anton Danilchenko <
> anton.danilche...@gmail.com> wrote:
>
>> Hi all!
>>
>> Please, help me undestand, how to solve next task.
>>
>> I am show for user form with two fields: user name and text field,
>> where user input list of phones, separated by comma. User sholud enter
>> one or more phones separated by comma. If user enter not valid number
>> - we show error message like this "Phone 12345 is not valid. Please,
>> enter valid phone numbers separated by comma".
>>
>> I have next two models:
>>
>> class Phone(models.Model):
>>  number = models.CharField(max_length=20)
>>
>> class UserInfo(models.Model):
>>  name = models.CharField(max_length=70)
>>  phones = models.ManyToManyField(Phone)
>>
>> User should enter numbers in CharField in format 0XX XXX . But, I
>> need save phone in database in format 0XX (only number without
>> spaces and other non-numbers digits).
>>
>> Please, can you help me in this. I am new in Django, and I am read
>> more articles and not found solution. I think that I need create
>> custom fields for form and model.
>>
>> P.S. Also, in admin section I should see CharField instead of
>> ManyToManyField.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>
>
> --
> Guadajuko! Vamos a correr!
>  -"Cool! we are going to run!"
>



-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread Anton Danilchenko
In my case, I have Users with equal phone numbers. And I need only
ManyToMany relationship.

I need create custom field for get information from CharFiels,
validate this data, clean and save to datastore in separate model. If
this phone already exists - we get ID of this phone. And, if this is a
new phone number - we insert this phone to separate model and get new
ID.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread nick.l...@gmail.com
Maybe I don't understand your problem.

It sounds to me like your trying to make this way more difficult than it
needs to be.

Also it sounds to me like your trying to assign the same phone number to
multiple people. (which is fine) But doesn't make a lot of sense to me in a
practical application.

n



On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
anton.danilche...@gmail.com> wrote:

> In my case, I have Users with equal phone numbers. And I need only
> ManyToMany relationship.
>
> I need create custom field for get information from CharFiels,
> validate this data, clean and save to datastore in separate model. If
> this phone already exists - we get ID of this phone. And, if this is a
> new phone number - we insert this phone to separate model and get new
> ID.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 1.2.1. admin WYSIWYG editor

2010-09-21 Thread Sithembewena Lloyd Dube
Hi,

Has anybody intergrated a WYSIWYG editor in the admin of a Django 1.2.1.
site? I have tried django-wysiwyg and TinyMCE to no avail. I need something
with concise, up-to-date documentation.

If anybody has done this, please recommend and also point to the docs?

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 1.2.1. admin WYSIWYG editor

2010-09-21 Thread bagheera
Dnia 21-09-2010 o 17:41:26 Sithembewena Lloyd Dube   
napisał(a):



Hi,

Has anybody intergrated a WYSIWYG editor in the admin of a Django 1.2.1.
site? I have tried django-wysiwyg and TinyMCE to no avail. I need  
something

with concise, up-to-date documentation.

If anybody has done this, please recommend and also point to the docs?

Thanks.



I just downloaded newest tinyMCE and placed it in 'js' directory, then i  
made proper cfg


in modelAdmin:


class Media:
js = ('js/tiny_mce/tiny_mce.js', 'js/tiny_mce/tiny_mce_config.js',)

and the config in tiny_mce_config.js file:


tinyMCE.init({
mode : "textareas",
width : "800",
height : "500",
theme : "advanced",
language : 'pl',
content_css : "../../css/style.css",
theme_advanced_toolbar_location : "top",
plugins : 'preview, searchreplace, paste, table, insertdatetime, media',
theme_advanced_buttons1 :  
'preview,undo,redo,visualaid,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,image,cleanup,help,code',
theme_advanced_buttons2 :  
'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',
theme_advanced_buttons3 :  
'forecolor,backcolor,|,sub,sup,|,charmap,insertdate,inserttime,media,|,tablecontrols'

});

and it works fine in admin panel with textareas

--
Linux user

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.



Synching samba users to django users?

2010-09-21 Thread MrMuffin
Hi,

I need to sync samba users ( and generally manage samba users, samba
shares and start/restart the samba service ) from within django. I've
googled for hours and emailed some people on the samba site, but
haven`t gotten any answers.

I want to create a reusable app that can handle samba management and
especially manage samba user accounts, synching samba users and their
passwords to the user profiles defined in django.

Any hint or clue would be highly appreciated. My project will run on
ubuntu, I`ll use any library available to achieve this goal as long as
it has python bindings. The project will be released as free software.

Thanks! :-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Synching samba users to django users?

2010-09-21 Thread Rogério Carrasqueira
Did you thought to use a third party solution creating a LDAP server and
syncs the Samba and Django system with the LDAP?

http://www.google.com.br/search?hl=&q=LDAP+django&sourceid=navclient-ff&rlz=1B7GGLL_enBR394BR394&ie=UTF-8

Cheers

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074



2010/9/21 MrMuffin 

> Hi,
>
> I need to sync samba users ( and generally manage samba users, samba
> shares and start/restart the samba service ) from within django. I've
> googled for hours and emailed some people on the samba site, but
> haven`t gotten any answers.
>
> I want to create a reusable app that can handle samba management and
> especially manage samba user accounts, synching samba users and their
> passwords to the user profiles defined in django.
>
> Any hint or clue would be highly appreciated. My project will run on
> ubuntu, I`ll use any library available to achieve this goal as long as
> it has python bindings. The project will be released as free software.
>
> Thanks! :-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Synching samba users to django users?

2010-09-21 Thread MrMuffin
Yes, that`s one option I`ve looked at, but I also need to manage
shares and restart the samba service when the config has been updated
so it would be better to have a library that managed samba directly.
But if I cannot find any other alternative, LDAP might be the best
solution for my problem.

Thanks for your input :-)

Thomas

On Sep 21, 7:06 pm, Rogério Carrasqueira
 wrote:
> Did you thought to use a third party solution creating a LDAP server and
> syncs the Samba and Django system with the LDAP?
>
> http://www.google.com.br/search?hl=&q=LDAP+django&sourceid=navclient-...
>
> Cheers
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.: (11) 7805-0074
>
> 2010/9/21 MrMuffin 
>
> > Hi,
>
> > I need to sync samba users ( and generally manage samba users, samba
> > shares and start/restart the samba service ) from within django. I've
> > googled for hours and emailed some people on the samba site, but
> > haven`t gotten any answers.
>
> > I want to create a reusable app that can handle samba management and
> > especially manage samba user accounts, synching samba users and their
> > passwords to the user profiles defined in django.
>
> > Any hint or clue would be highly appreciated. My project will run on
> > ubuntu, I`ll use any library available to achieve this goal as long as
> > it has python bindings. The project will be released as free software.
>
> > Thanks! :-)
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread Anton Danilchenko
I describe my task more reallistical.

This is application for rent an apartment. User can create new message
with information about apartment, and also add one or more contact
phone numbers. One user, without registration, can create more that
one message on the site. For one message can add one phone number, for
other message add two phones.

I need to save only one copy of phone number in database in format
. For each phone I can set if this phone in black list or not
(model Phone have property "blocked" by default setted to False).

I want to save phone numbers in model Phone, and messages in model
Message. But, people can see input text field (CharField) where enter
one or more phone numbers separated by comma.

class Phone(models.Model):
  number = models.CharField(max_length=20)
  blocked = models.BooleanField(default=False)

class Message(models.Model):
  # ... information about count of rooms, floor, cost, etc ...
  phones = models.ManyToManyField(Phone)


Nick, thank you for you help. You are really very good people!


On 21 сен, 18:12, "nick.l...@gmail.com"  wrote:
> Maybe I don't understand your problem.
>
> It sounds to me like your trying to make this way more difficult than it
> needs to be.
>
> Also it sounds to me like your trying to assign the same phone number to
> multiple people. (which is fine) But doesn't make a lot of sense to me in a
> practical application.
>
> n
>
> On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
>
>
>
>
>
> anton.danilche...@gmail.com> wrote:
> > In my case, I have Users with equal phone numbers. And I need only
> > ManyToMany relationship.
>
> > I need create custom field for get information from CharFiels,
> > validate this data, clean and save to datastore in separate model. If
> > this phone already exists - we get ID of this phone. And, if this is a
> > new phone number - we insert this phone to separate model and get new
> > ID.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Guadajuko! Vamos a correr!
>  -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



filepath (system file system path) field

2010-09-21 Thread pixelcowboy
Hi, I have seen this asked before here (without answers), but I wanted
to know how to go on about creating a field that stores filepath names
from the client filesystem, so I wanted to check if someone could
recommend the best apporach: Creating a custom field perhaps? Or
perhaps extending the filefield? Or maybe just use a charfiled and do
it all in validation? What do you guys think?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Header being removed or overwritten

2010-09-21 Thread TheIvIaxx
Hello, I have recently switched over to nginx as my front end server.
All is well.  However i have a view that sets the Cache-Control header
to no-cache.  But when going to this view, it looks like nginx is
either overwriting the header value or removing/ignoring it all
together.

I'm not 100% i have the server set up correctly, but it is working:

apache/mod_wsgi running on port 8080

nginx:

location ~* {
proxy_pass http://X:8080;
break;
}

Any ideas on this?  Is my setup incorrect?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread Anton Danilchenko
Also I need get list of all phones as with many-to-many relationship:

m = Message.objects.get(1)
for phone in m.phones:
  ptint phone


On 21 сен, 20:15, Anton Danilchenko 
wrote:
> I describe my task more reallistical.
>
> This is application for rent an apartment. User can create new message
> with information about apartment, and also add one or more contact
> phone numbers. One user, without registration, can create more that
> one message on the site. For one message can add one phone number, for
> other message add two phones.
>
> I need to save only one copy of phone number in database in format
> . For each phone I can set if this phone in black list or not
> (model Phone have property "blocked" by default setted to False).
>
> I want to save phone numbers in model Phone, and messages in model
> Message. But, people can see input text field (CharField) where enter
> one or more phone numbers separated by comma.
>
> class Phone(models.Model):
>   number = models.CharField(max_length=20)
>   blocked = models.BooleanField(default=False)
>
> class Message(models.Model):
>   # ... information about count of rooms, floor, cost, etc ...
>   phones = models.ManyToManyField(Phone)
>
> Nick, thank you for you help. You are really very good people!
>
> On 21 сен, 18:12, "nick.l...@gmail.com"  wrote:
>
>
>
> > Maybe I don't understand your problem.
>
> > It sounds to me like your trying to make this way more difficult than it
> > needs to be.
>
> > Also it sounds to me like your trying to assign the same phone number to
> > multiple people. (which is fine) But doesn't make a lot of sense to me in a
> > practical application.
>
> > n
>
> > On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
>
> > anton.danilche...@gmail.com> wrote:
> > > In my case, I have Users with equal phone numbers. And I need only
> > > ManyToMany relationship.
>
> > > I need create custom field for get information from CharFiels,
> > > validate this data, clean and save to datastore in separate model. If
> > > this phone already exists - we get ID of this phone. And, if this is a
> > > new phone number - we insert this phone to separate model and get new
> > > ID.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com > >  groups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Guadajuko! Vamos a correr!
> >  -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Synching samba users to django users?

2010-09-21 Thread Doug
You could create a secondary python script running as root that polls
a queue or config file generated by your django app.  Have that script
perform the requested actions by running the same executables as a sub
process and checking the exit codes.  If you need immediate responses,
it could run like a daemon/service sleeping between poll intervals...
or via a cron job if you can deal with the delayed actions.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



select_template but return only template name?

2010-09-21 Thread ringemup
I've set up a theming system that relies on using select_template to
find the correct template for each view, searching first the skin's
template directory, then the theme's template directory, then the
master template directory.  (A "skin" in this case being mostly a
stylesheet that applies a color scheme to a "theme", which determines
the markup.)

However, I'm tripping up badly on built-in views such as the
contrib.auth views, many of which can take a template name as an
argument, but not an actual template.  Being able to do the equivalent
of select_template and returning only the template name rather than
the actual template object would be a big help.

Any tips?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread nick.l...@gmail.com
PersonallyI don't like the idea of adding multiple phone numbers as
comma separated values.  What happens when a user's trying to add more phone
numbers than your charField's max_length?

So let me see if I understand what's going on here...

You have a problem where exists apartments for rent. People who want to rent
these apartments will send messages to the owner of said apartment (through
your website). This message will have associated to it, a User and Multiple
Phone Numbers.

This message is then checked to see if the phone numbers associated to it
have been black listed...
And then finally deliver the message?

n


On Tue, Sep 21, 2010 at 12:15 PM, Anton Danilchenko <
anton.danilche...@gmail.com> wrote:

> I describe my task more reallistical.
>
> This is application for rent an apartment. User can create new message
> with information about apartment, and also add one or more contact
> phone numbers. One user, without registration, can create more that
> one message on the site. For one message can add one phone number, for
> other message add two phones.
>
> I need to save only one copy of phone number in database in format
> . For each phone I can set if this phone in black list or not
> (model Phone have property "blocked" by default setted to False).
>
> I want to save phone numbers in model Phone, and messages in model
> Message. But, people can see input text field (CharField) where enter
> one or more phone numbers separated by comma.
>
> class Phone(models.Model):
>  number = models.CharField(max_length=20)
>   blocked = models.BooleanField(default=False)
>
> class Message(models.Model):
>  # ... information about count of rooms, floor, cost, etc ...
>  phones = models.ManyToManyField(Phone)
>
>
> Nick, thank you for you help. You are really very good people!
>
>
> On 21 сен, 18:12, "nick.l...@gmail.com"  wrote:
> > Maybe I don't understand your problem.
> >
> > It sounds to me like your trying to make this way more difficult than it
> > needs to be.
> >
> > Also it sounds to me like your trying to assign the same phone number to
> > multiple people. (which is fine) But doesn't make a lot of sense to me in
> a
> > practical application.
> >
> > n
> >
> > On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
> >
> >
> >
> >
> >
> > anton.danilche...@gmail.com> wrote:
> > > In my case, I have Users with equal phone numbers. And I need only
> > > ManyToMany relationship.
> >
> > > I need create custom field for get information from CharFiels,
> > > validate this data, clean and save to datastore in separate model. If
> > > this phone already exists - we get ID of this phone. And, if this is a
> > > new phone number - we insert this phone to separate model and get new
> > > ID.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@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.
> >
> > --
> > Guadajuko! Vamos a correr!
> >  -"Cool! we are going to run!"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread Anton Danilchenko
Message - this is a rental proposition (rooms, floor, cost, area,
country, cirty and contact phones).

Visitors can create new messages (message - this is a rent
proposition) and enter list of own phones (one or more phones). My
application store this phones not in char field, but save each phone
number to separate Phone morel - one phone in one model). If phone
already exists - message attached to this phone. If phone not exists -
we create new phone and attach message to this phone number.

In future, I tell to people - and see that this people not a good
man :-). I go to my application and mark this phone number to black
list. All future messages from this people to be marked as bad
messages.

Now I need to create own Form field called MultiPhoneField based on
CharField widget, but implenet logic of ManyToManyField. I need show
for user CharField where user enter comma separated phone numbers. I
check this numbers and if all numbers correct - store this numbers in
database in Phone model (each phone in separate record) and associate
message with list of this phones.

Can you please help me in this. I not understand how to create my own
Field based on ManyToManyField.

Thanks!

On 21 сен, 21:16, "nick.l...@gmail.com"  wrote:
> PersonallyI don't like the idea of adding multiple phone numbers as
> comma separated values.  What happens when a user's trying to add more phone
> numbers than your charField's max_length?
>
> So let me see if I understand what's going on here...
>
> You have a problem where exists apartments for rent. People who want to rent
> these apartments will send messages to the owner of said apartment (through
> your website). This message will have associated to it, a User and Multiple
> Phone Numbers.
>
> This message is then checked to see if the phone numbers associated to it
> have been black listed...
> And then finally deliver the message?
>
> n
>
> On Tue, Sep 21, 2010 at 12:15 PM, Anton Danilchenko <
>
>
>
>
>
> anton.danilche...@gmail.com> wrote:
> > I describe my task more reallistical.
>
> > This is application for rent an apartment. User can create new message
> > with information about apartment, and also add one or more contact
> > phone numbers. One user, without registration, can create more that
> > one message on the site. For one message can add one phone number, for
> > other message add two phones.
>
> > I need to save only one copy of phone number in database in format
> > . For each phone I can set if this phone in black list or not
> > (model Phone have property "blocked" by default setted to False).
>
> > I want to save phone numbers in model Phone, and messages in model
> > Message. But, people can see input text field (CharField) where enter
> > one or more phone numbers separated by comma.
>
> > class Phone(models.Model):
> >  number = models.CharField(max_length=20)
> >   blocked = models.BooleanField(default=False)
>
> > class Message(models.Model):
> >  # ... information about count of rooms, floor, cost, etc ...
> >  phones = models.ManyToManyField(Phone)
>
> > Nick, thank you for you help. You are really very good people!
>
> > On 21 сен, 18:12, "nick.l...@gmail.com"  wrote:
> > > Maybe I don't understand your problem.
>
> > > It sounds to me like your trying to make this way more difficult than it
> > > needs to be.
>
> > > Also it sounds to me like your trying to assign the same phone number to
> > > multiple people. (which is fine) But doesn't make a lot of sense to me in
> > a
> > > practical application.
>
> > > n
>
> > > On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
>
> > > anton.danilche...@gmail.com> wrote:
> > > > In my case, I have Users with equal phone numbers. And I need only
> > > > ManyToMany relationship.
>
> > > > I need create custom field for get information from CharFiels,
> > > > validate this data, clean and save to datastore in separate model. If
> > > > this phone already exists - we get ID of this phone. And, if this is a
> > > > new phone number - we insert this phone to separate model and get new
> > > > ID.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com > > >  groups.com>
> > 
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > Guadajuko! Vamos a correr!
> > >  -"Cool! we are going to run!"
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?

Localization time formatting

2010-09-21 Thread tsuraan
What do you have to do to get the localized datetime formats to work
in Django?  I started a new project, set LANGUAGE_CODE to 'en-GB',
enabled LocaleMiddleware (doesn't matter for this test though), and
ran "django manage.py shell".  In the shell, I had the following
session:

>>> from django.conf import settings
>>> settings.LANGUAGE_CODE
'en-GB'
>>> settings.DATE_FORMAT
'N j, Y'
>>> settings.SHORT_DATE_FORMAT
'm/d/Y'

So, obviously setting the LANGUAGE_CODE doesn't seem to affect the
locale that django uses when getting the date/time format strings.
What variable does do this?  I can see that in
django/conf/locale/en_GB/formats.py there are formats for date and
time, but I can't figure out what function I have to call to activate
them instead of the american formats.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: ManyToManyField to Phones model for enter phones manually (not select from list)

2010-09-21 Thread nick.l...@gmail.com
read this here I think this'll explain what you're wanting.

http://docs.djangoproject.com/en/dev/ref/forms/validation/

On Tue, Sep 21, 2010 at 1:50 PM, Anton Danilchenko <
anton.danilche...@gmail.com> wrote:

> Message - this is a rental proposition (rooms, floor, cost, area,
> country, cirty and contact phones).
>
> Visitors can create new messages (message - this is a rent
> proposition) and enter list of own phones (one or more phones). My
> application store this phones not in char field, but save each phone
> number to separate Phone morel - one phone in one model). If phone
> already exists - message attached to this phone. If phone not exists -
> we create new phone and attach message to this phone number.
>
> In future, I tell to people - and see that this people not a good
> man :-). I go to my application and mark this phone number to black
> list. All future messages from this people to be marked as bad
> messages.
>
> Now I need to create own Form field called MultiPhoneField based on
> CharField widget, but implenet logic of ManyToManyField. I need show
> for user CharField where user enter comma separated phone numbers. I
> check this numbers and if all numbers correct - store this numbers in
> database in Phone model (each phone in separate record) and associate
> message with list of this phones.
>
> Can you please help me in this. I not understand how to create my own
> Field based on ManyToManyField.
>
> Thanks!
>
> On 21 сен, 21:16, "nick.l...@gmail.com"  wrote:
> > PersonallyI don't like the idea of adding multiple phone numbers as
> > comma separated values.  What happens when a user's trying to add more
> phone
> > numbers than your charField's max_length?
> >
> > So let me see if I understand what's going on here...
> >
> > You have a problem where exists apartments for rent. People who want to
> rent
> > these apartments will send messages to the owner of said apartment
> (through
> > your website). This message will have associated to it, a User and
> Multiple
> > Phone Numbers.
> >
> > This message is then checked to see if the phone numbers associated to it
> > have been black listed...
> > And then finally deliver the message?
> >
> > n
> >
> > On Tue, Sep 21, 2010 at 12:15 PM, Anton Danilchenko <
> >
> >
> >
> >
> >
> > anton.danilche...@gmail.com> wrote:
> > > I describe my task more reallistical.
> >
> > > This is application for rent an apartment. User can create new message
> > > with information about apartment, and also add one or more contact
> > > phone numbers. One user, without registration, can create more that
> > > one message on the site. For one message can add one phone number, for
> > > other message add two phones.
> >
> > > I need to save only one copy of phone number in database in format
> > > . For each phone I can set if this phone in black list or not
> > > (model Phone have property "blocked" by default setted to False).
> >
> > > I want to save phone numbers in model Phone, and messages in model
> > > Message. But, people can see input text field (CharField) where enter
> > > one or more phone numbers separated by comma.
> >
> > > class Phone(models.Model):
> > >  number = models.CharField(max_length=20)
> > >   blocked = models.BooleanField(default=False)
> >
> > > class Message(models.Model):
> > >  # ... information about count of rooms, floor, cost, etc ...
> > >  phones = models.ManyToManyField(Phone)
> >
> > > Nick, thank you for you help. You are really very good people!
> >
> > > On 21 сен, 18:12, "nick.l...@gmail.com"  wrote:
> > > > Maybe I don't understand your problem.
> >
> > > > It sounds to me like your trying to make this way more difficult than
> it
> > > > needs to be.
> >
> > > > Also it sounds to me like your trying to assign the same phone number
> to
> > > > multiple people. (which is fine) But doesn't make a lot of sense to
> me in
> > > a
> > > > practical application.
> >
> > > > n
> >
> > > > On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko <
> >
> > > > anton.danilche...@gmail.com> wrote:
> > > > > In my case, I have Users with equal phone numbers. And I need only
> > > > > ManyToMany relationship.
> >
> > > > > I need create custom field for get information from CharFiels,
> > > > > validate this data, clean and save to datastore in separate model.
> If
> > > > > this phone already exists - we get ID of this phone. And, if this
> is a
> > > > > new phone number - we insert this phone to separate model and get
> new
> > > > > ID.
> >
> > > > > --
> > > > > 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.
> >
> > > > --
> > > > Guadajuk

Why Django Apps Suck

2010-09-21 Thread klaasvanschel...@gmail.com
Ok here it goes: I don't have a proper platform for my observations /
rants so I figured I'd try my luck here. Django has been my favorite
framework for developing web applications for about a year and a half,
so it comes from a position of love when I say that the Django app
really sucks as a level of abstraction. And I'm really looking for a
way out so any suggestions are much appreciated. A tl;dr is provided
below.

Others have complained before me. Two particular ones worth mentioning
are:
http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it
which claims that "Apps which provide models are inflexible" and
http://www.mutualinformation.org/2010/03/why-i-switched-to-pylons-after-using-django-for-six-months/
Both claim that the Django app provides the wrong level of
abstraction, neither goes in too much detail exactly why that is the
case. That's the question I'll attempt to answer.

Before we can answer the question we must first set some reasonable
expectations for an "app". I'd say an app is a small package of
closely related features as they are presented to the user (in the
context of a web project) that can be easily modified/extended for any
given project.

Examples of apps (in my own particular context):
* Dealing with customer information (a mini CRM). Adding, editing,
useful overviews.
* A small news app (Add, edit, overviews)
* Our own particular UserProfile app (editing, viewing others,
birthday calendars etc.)
* A small budgetting tool (creating budgets, see how much money has
been used)
* Logging time lines (for worked hours), searching them.

I choose this definition for "app" because it is a very useful one in
the context of web projects. At least in my context it works like
this: we have a lot of customers with similar intranets and extranets.
Each one of them might want a particular subset of the various apps we
have "on the shelf".

By the way: there's other things that can already be reused quite
well. Anything pure python for example. Or extensions to Django (extra
fields, extra context managers, middleware etc etc.) This is not my
concern, mainly because it already works well.

One thing that deserves extra stress is that apss should be easily
extendable. Exactly the fact that every customer want something that
is slightly different from the next is how we're able to provide
value. (This is also the reason I like Django in the first place:
making stuff "your own way" is very easy). So: if no one want exactly
the same, extensibility is a major prerequisite for reusability.

What are some typical things we want to do when extending (modifying)
an app for the context of a particular project?
* Deal with authorization in the context of the particular django
project
* Styling for the project
* Turn a subset of the functionality on or off for a given project (no
docs, no 'advanced features')
* Add one or more fields to one or more models and possibly related
edit pages, view pages forms etc

Given this control flow let's try to do some of the typical
modifications mentioned above:
Authorization:
Django has a beautiful mechanism for authorization, which is using
decorators (@may_do_a_b_or_c) directly in the views.py.
Tempting, but will not be modifyable in any way once you lift the app.
(because the decorator will become tied to the view function). Other
mechanisms are not presented (in a standardized way). If anyone has
ideas about this I'd love to discuss them.

Styling:
This actually works well, by providing sufficient amount of hooks in
the templates and extending.

Turning functionality on and off:
This could be made to work by working with a 'url_parts.py' in the
reusable app, that provides different url_patterns for the various
subsets. So one for the CRUD, one for the docs, one for the simple
features and one for the advanced features. Our project's urls.py
would then simply include the right subset from this url_parts.py. I'm
not sure it's very pretty though.

Extending models
This is the big one, for two reasons.
1. You almost always want to do this (for any change to the app that
is reflected in the underlying data)
2. It's pretty much impossible.

Why is it impossible?
Firstly, /app/models.py is always discovered, so unless we make all
Models abstract, or we do not include "app" in settings.py, models are
created for syncdb and any related commands.

Secondly, let's take a look at Django's control flow:
* urls.py matches and calls,
* possibly via a decorator
* a view in views.py, that may use any number of
  * models,
  * forms and
  * templates
The "official" way to modify a reusable app for your particular app is
by making it available as a kwarg with proper default in the view, and
then customizing it from urls.py.
However, if you simply want to add one field to a much used object,
this solution implies passing around the object class (factory)
through your whole app. That's not very elegant.
The same goes for any other changes at a lower level. Say I want

Re: Why Django Apps Suck

2010-09-21 Thread Shawn Milochik
Just FYI, the videos from DjangoCon 2010 are already up on blip.tv.

The Python AV team was awesome.

Here's that talk:
http://blip.tv/file/4112452/

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Why Django Apps Suck

2010-09-21 Thread Ramdas S
On Wed, Sep 22, 2010 at 1:56 AM, klaasvanschel...@gmail.com <
klaasvanschel...@gmail.com> wrote:

> Ok here it goes: I don't have a proper platform for my observations /
> rants so I figured I'd try my luck here. Django has been my favorite
> framework for developing web applications for about a year and a half,
> so it comes from a position of love when I say that the Django app
> really sucks as a level of abstraction. And I'm really looking for a
> way out so any suggestions are much appreciated. A tl;dr is provided
> below.
>
> Others have complained before me. Two particular ones worth mentioning
> are:
> http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it
> which claims that "Apps which provide models are inflexible" and
>
> http://www.mutualinformation.org/2010/03/why-i-switched-to-pylons-after-using-django-for-six-months/
> Both claim that the Django app provides the wrong level of
> abstraction, neither goes in too much detail exactly why that is the
> case. That's the question I'll attempt to answer.
>
> Before we can answer the question we must first set some reasonable
> expectations for an "app". I'd say an app is a small package of
> closely related features as they are presented to the user (in the
> context of a web project) that can be easily modified/extended for any
> given project.
>
> Examples of apps (in my own particular context):
> * Dealing with customer information (a mini CRM). Adding, editing,
> useful overviews.
> * A small news app (Add, edit, overviews)
> * Our own particular UserProfile app (editing, viewing others,
> birthday calendars etc.)
> * A small budgetting tool (creating budgets, see how much money has
> been used)
> * Logging time lines (for worked hours), searching them.
>


Wow! I guess your definition of an app  and expectation of re-usuability
from an app written by someone else
is fairly high!

We have built serveral news sites based on Django, and a lot of code gets
rewritten everytime, because customer requirements are very different. We
reuse 90% of code in every project, but 10% gets rewritten or gets writtenf
fresh.

I know there's a number of apps out there including ones written by people
like me, which are grossly unusable. I guess that's primarily because its
written by developers for a specific work, and when they threw it back into
the wild, they did not pay enought attention tomake it really re-usuable.
However there are quite a few exceptions,

I completely agree with your views that with the way you write code with {%
url in templates, and decorators, reusing the code is a pain. I had to scrap
a project based on Pinax for the same reason, and then rewrite a mini scoial
framework, because pinax is not customizable beyond a point.

However my personal experience is that it's true for most platforms. There
are always trade-offs and trade-ins when you use a platform.



> I choose this definition for "app" because it is a very useful one in
> the context of web projects. At least in my context it works like
> this: we have a lot of customers with similar intranets and extranets.
> Each one of them might want a particular subset of the various apps we
> have "on the shelf".
>
> By the way: there's other things that can already be reused quite
> well. Anything pure python for example. Or extensions to Django (extra
> fields, extra context managers, middleware etc etc.) This is not my
> concern, mainly because it already works well.
>
> One thing that deserves extra stress is that apss should be easily
> extendable. Exactly the fact that every customer want something that
> is slightly different from the next is how we're able to provide
> value. (This is also the reason I like Django in the first place:
> making stuff "your own way" is very easy). So: if no one want exactly
> the same, extensibility is a major prerequisite for reusability.
>
> What are some typical things we want to do when extending (modifying)
> an app for the context of a particular project?
> * Deal with authorization in the context of the particular django
> project
> * Styling for the project
> * Turn a subset of the functionality on or off for a given project (no
> docs, no 'advanced features')
> * Add one or more fields to one or more models and possibly related
> edit pages, view pages forms etc
>
> Given this control flow let's try to do some of the typical
> modifications mentioned above:
> Authorization:
> Django has a beautiful mechanism for authorization, which is using
> decorators (@may_do_a_b_or_c) directly in the views.py.
> Tempting, but will not be modifyable in any way once you lift the app.
> (because the decorator will become tied to the view function). Other
> mechanisms are not presented (in a standardized way). If anyone has
> ideas about this I'd love to discuss them.
>
> Styling:
> This actually works well, by providing sufficient amount of hooks in
> the templates and extending.
>
> Turning functionality on and off:
> This could be mad

Customizing and Suppressing "Select a valid choice. That choice is not one of ..." error?

2010-09-21 Thread ydjango
How to customizing and suppressing "Select a valid choice. That choice
is not one of ..."  error?

I have two requirements:

1) for some select drop downs, I want to customize the message
 "Select a valid choice. That choice is not one of ..."
to

 "Select a valid choice for field ABC. 12 choice is not one of ..."

is there a way I can do it in form. Like I can specify my own message
for 'Required'

2) Some cases, I want to add the user input as a new data to the db.
In that case I do not this validation error to be raised. How do I
suppress it .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



help setting 'apps' folder Error: No module named registration

2010-09-21 Thread justin jools
I have setup 'apps' folder with __init__.py inside and
'registration' app inside 'apps'

I then refer to it with:
'apps.registration' in installed_apps/settings.py

When I run syncdb it gives error:

Error: No module named registration

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Why Django Apps Suck

2010-09-21 Thread Klaas van Schelven
Shawn: thanks
Just started watching the video and I'm noticing my complaints are not
unique.

> Wow! I guess your definition of an app  and expectation of re-usuability
> from an app written by someone else
> is fairly high!

Actually, a big part of the problem is reusing my own apps. Mostly
since all of them provide models, and every use case either needs
changes to those.

>
> We have built serveral news sites based on Django, and a lot of code gets
> rewritten everytime, because customer requirements are very different. We
> reuse 90% of code in every project, but 10% gets rewritten or gets writtenf
> fresh.
>
That's interesting.
Do you adapt models across your apps?
Do you deal with (some kind of advanced) authorization that differs
over projects?
I'd like to know how.

> I know there's a number of apps out there including ones written by people
> like me, which are grossly unusable. I guess that's primarily because its
> written by developers for a specific work, and when they threw it back into
> the wild, they did not pay enought attention tomake it really re-usuable.
> However there are quite a few exceptions,
>
> I completely agree with your views that with the way you write code with {%
> url in templates, and decorators, reusing the code is a pain. I had to scrap
> a project based on Pinax for the same reason, and then rewrite a mini scoial
> framework, because pinax is not customizable beyond a point.

Yeah I looked at Pinax too (because it is presented as a "reusable
app") but I was a bit disappointed. (not so much in the app, as in how
it is an example of reusability).

Problem is "{% url %}" is presented as a Good Thing (DRY) while it
makes reuse in some ways harder
What's your alternative, i.e. how do you provide links that are
project independent?

> However my personal experience is that it's true for most platforms. There
> are always trade-offs and trade-ins when you use a platform.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



ChoiceField -suppressing "Select a valid choice. That choice is not one of ..." error?

2010-09-21 Thread ydjango
How to suppress invalid_choice validation error for choicefield
-"Select a valid choice. That choice
is not one of ..."  ?

I am using a client side combo box where user can either select from
the choices or add a new value. For new value Django - ChoiceField
give invalid_choice validation error.

I do not want this validation error to be raised. How do I suppress
it ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Why Django Apps Suck

2010-09-21 Thread Mike Dewhirst
Also at pycon-au http://glamkit.org/ where the talk focused on 
reusability of apps.



On 22/09/2010 6:26am, klaasvanschel...@gmail.com wrote:

Ok here it goes: I don't have a proper platform for my observations /
rants so I figured I'd try my luck here. Django has been my favorite
framework for developing web applications for about a year and a half,
so it comes from a position of love when I say that the Django app
really sucks as a level of abstraction. And I'm really looking for a
way out so any suggestions are much appreciated. A tl;dr is provided
below.

Others have complained before me. Two particular ones worth mentioning
are:
http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it
which claims that "Apps which provide models are inflexible" and
http://www.mutualinformation.org/2010/03/why-i-switched-to-pylons-after-using-django-for-six-months/
Both claim that the Django app provides the wrong level of
abstraction, neither goes in too much detail exactly why that is the
case. That's the question I'll attempt to answer.

Before we can answer the question we must first set some reasonable
expectations for an "app". I'd say an app is a small package of
closely related features as they are presented to the user (in the
context of a web project) that can be easily modified/extended for any
given project.

Examples of apps (in my own particular context):
* Dealing with customer information (a mini CRM). Adding, editing,
useful overviews.
* A small news app (Add, edit, overviews)
* Our own particular UserProfile app (editing, viewing others,
birthday calendars etc.)
* A small budgetting tool (creating budgets, see how much money has
been used)
* Logging time lines (for worked hours), searching them.

I choose this definition for "app" because it is a very useful one in
the context of web projects. At least in my context it works like
this: we have a lot of customers with similar intranets and extranets.
Each one of them might want a particular subset of the various apps we
have "on the shelf".

By the way: there's other things that can already be reused quite
well. Anything pure python for example. Or extensions to Django (extra
fields, extra context managers, middleware etc etc.) This is not my
concern, mainly because it already works well.

One thing that deserves extra stress is that apss should be easily
extendable. Exactly the fact that every customer want something that
is slightly different from the next is how we're able to provide
value. (This is also the reason I like Django in the first place:
making stuff "your own way" is very easy). So: if no one want exactly
the same, extensibility is a major prerequisite for reusability.

What are some typical things we want to do when extending (modifying)
an app for the context of a particular project?
* Deal with authorization in the context of the particular django
project
* Styling for the project
* Turn a subset of the functionality on or off for a given project (no
docs, no 'advanced features')
* Add one or more fields to one or more models and possibly related
edit pages, view pages forms etc

Given this control flow let's try to do some of the typical
modifications mentioned above:
Authorization:
Django has a beautiful mechanism for authorization, which is using
decorators (@may_do_a_b_or_c) directly in the views.py.
Tempting, but will not be modifyable in any way once you lift the app.
(because the decorator will become tied to the view function). Other
mechanisms are not presented (in a standardized way). If anyone has
ideas about this I'd love to discuss them.

Styling:
This actually works well, by providing sufficient amount of hooks in
the templates and extending.

Turning functionality on and off:
This could be made to work by working with a 'url_parts.py' in the
reusable app, that provides different url_patterns for the various
subsets. So one for the CRUD, one for the docs, one for the simple
features and one for the advanced features. Our project's urls.py
would then simply include the right subset from this url_parts.py. I'm
not sure it's very pretty though.

Extending models
This is the big one, for two reasons.
1. You almost always want to do this (for any change to the app that
is reflected in the underlying data)
2. It's pretty much impossible.

Why is it impossible?
Firstly, /app/models.py is always discovered, so unless we make all
Models abstract, or we do not include "app" in settings.py, models are
created for syncdb and any related commands.

Secondly, let's take a look at Django's control flow:
* urls.py matches and calls,
* possibly via a decorator
* a view in views.py, that may use any number of
   * models,
   * forms and
   * templates
The "official" way to modify a reusable app for your particular app is
by making it available as a kwarg with proper default in the view, and
then customizing it from urls.py.
However, if you simply want to add one field to a much used object,
this solution implies passing

Re: Django 1.2.1. admin WYSIWYG editor

2010-09-21 Thread felix

I got sick of TinyMCE and switched to jQuery wysiwyg

sorry this is just posted raw like this, but here it is.
I should wrap it up on github.

requires http://code.google.com/p/jwysiwyg/

and the 3 files stated below to be in your compress stack or on your
page



from django import forms
from django.utils.safestring import mark_safe
import simplejson as json


# requires
# 'shared/js/jquery.wysiwyg.js',
# 'shared/css/jquery.wysiwyg.css',
# 'shared/css/jquery.wysiwyg.modal.css',



class JWYSIWYGFormField(forms.fields.Field):

def __init__(self, cols=80,rows=10,params=None,*args, **kwargs):
self.widget =
JWYSIWYGWidget(cols=cols,rows=rows,params=params)
super(JWYSIWYGFormField, self).__init__(*args, **kwargs)


class JWYSIWYGWidget(forms.TextInput):

def __init__(self, cols,rows,params=None,attrs=None):
final_attrs = {'cols':cols,'rows':rows}
if attrs:
final_attrs.update(attrs)
self.params = params

super(JWYSIWYGWidget,self).__init__(attrs=final_attrs)

def render(self, name, value, attrs=None):

# attrs is for the form field
subs = {}
subs['id'] = "id_" + name
subs['name'] = name
if value is not None:
subs['value'] = value
else:
subs['value'] = ""

subs['cols'] = attrs.get('cols',self.attrs['cols'])
subs['rows'] = attrs.get('rows',self.attrs['rows'])

# no separators yet
# button_rows = [BUTTON_PALETTE[group] for group in
self.attrs['button_groups']]
params = {}
defaults = dict(
  strikeThrough= True,
  underline= True,

  separator00= False,

  justifyLeft  = True,
  justifyCenter= True,
  justifyRight = False,
  justifyFull  = False,

  separator01= False,

  indent = True,
  outdent= True,

  separator02= False,

  subscript  = False,
  superscript= False,

  separator03= False,

  undo= False,
  redo= False,

  separator04= False,
  resizeOptions = {},
  insertOrderedList   = False,
  insertUnorderedList = True,
  insertHorizontalRule= False,
  h1 = False,
  h2 = False,
  h3 = True,
  table = False,

  separator07= False,

  cut  = False,
  copy = False,
  paste= False)

defaults.update(self.params or {})
for p,v in defaults.iteritems():
if type(v) == bool:
params[p] = { 'visible': v }
else:
params[p] = v

subs['params'] = json.dumps({'controls':params})
subs['button'] = "" % subs['id']
subs['button_code'] = """$('#edit_html_%
(id)s').click(function(){$(this).hide();$('#%(id)s').slideDown();});
$('#%(id)s').blur(function(){$(this).wysiwyg('setContent',$
(this).val())});
""" % {'id':subs['id']}

template = u"""%(value)s$(function(){  $('#%(id)s').wysiwyg(%(params)s);%
(button_code)s});%(button)s"""

return mark_safe(template % subs)



On Sep 21, 5:41 pm, Sithembewena Lloyd Dube  wrote:
> Hi,
>
> Has anybody intergrated a WYSIWYG editor in the admin of a Django 1.2.1.
> site? I have tried django-wysiwyg and TinyMCE to no avail. I need something
> with concise, up-to-date documentation.
>
> If anybody has done this, please recommend and also point to the docs?
>
> Thanks.
>
> --
> Regards,
> Sithembewena Lloyd Dubehttp://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Installing python 2.6 / 2.7, Django, mysql on Windows

2010-09-21 Thread m.bouzahir
good tutoriel about Installing python 2.6 / 2.7, Django, mysql on
Windows
http://web-eng-help.blogspot.com/2010/09/installing-django-on-windows.html

Good luck

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 1.2.1. admin WYSIWYG editor

2010-09-21 Thread Kenneth Gonsalves
On Tue, 2010-09-21 at 17:41 +0200, Sithembewena Lloyd Dube wrote:
> Has anybody intergrated a WYSIWYG editor in the admin of a Django
> 1.2.1.
> site? I have tried django-wysiwyg and TinyMCE to no avail. I need
> something
> with concise, up-to-date documentation. 

a snippet from my admin.py:

class ArticleAdmin(admin.ModelAdmin):
class Media:
js = ('/sitemedia/js/tiny_mce/jscripts/tiny_mce/tiny_mce.js',
  '/sitemedia/js/tiny_mce/jscripts/tiny_mce/textareas.js',)

admin.site.register(Article, ArticleAdmin)
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Why Django Apps Suck

2010-09-21 Thread Ramdas S
On Wed, Sep 22, 2010 at 2:48 AM, Klaas van Schelven <
klaasvanschel...@gmail.com> wrote:

> Shawn: thanks
> Just started watching the video and I'm noticing my complaints are not
> unique.
>
> > Wow! I guess your definition of an app  and expectation of re-usuability
> > from an app written by someone else
> > is fairly high!
>
> Actually, a big part of the problem is reusing my own apps. Mostly
> since all of them provide models, and every use case either needs
> changes to those.
>
> >
> > We have built serveral news sites based on Django, and a lot of code gets
> > rewritten everytime, because customer requirements are very different. We
> > reuse 90% of code in every project, but 10% gets rewritten or gets
> writtenf
> > fresh.
> >
> That's interesting.
> Do you adapt models across your apps?
> Do you deal with (some kind of advanced) authorization that differs
> over projects?
>

We don't do anything that's extra-ordinary. Tried it and it failed. While I
have not quite experimented in depth with Pylons, the problem what you are
describing about reusability exists in some way or other with every
platform. We've been through almost all major frameworks from Java based
ones to CakePHP to Rails.

I'm sorry to disappoint, but all I do is move code between projects and then
customize models, views and urls according to the needs.
Even an app which is pretty well written like django-registration, I had to
customize it number of times to suite specific needs of some of my
customers, that my versions are impossible to reuse.

> I'd like to know how.
>
> > I know there's a number of apps out there including ones written by
> people
> > like me, which are grossly unusable. I guess that's primarily because its
> > written by developers for a specific work, and when they threw it back
> into
> > the wild, they did not pay enought attention tomake it really re-usuable.
> > However there are quite a few exceptions,
> >
> > I completely agree with your views that with the way you write code with
> {%
> > url in templates, and decorators, reusing the code is a pain. I had to
> scrap
> > a project based on Pinax for the same reason, and then rewrite a mini
> scoial
> > framework, because pinax is not customizable beyond a point.
>
> Yeah I looked at Pinax too (because it is presented as a "reusable
> app") but I was a bit disappointed. (not so much in the app, as in how
> it is an example of reusability).
>
> Problem is "{% url %}" is presented as a Good Thing (DRY) while it
> makes reuse in some ways harder
> What's your alternative, i.e. how do you provide links that are
> project independent?
>

Pinax was a bad experience for me. I am going to give glamkit a try now...

> > However my personal experience is that it's true for most platforms.
> There
> > are always trade-offs and trade-ins when you use a platform.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Ramdas S
+91 9342 583 065

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



Problem with ForeignKey()

2010-09-21 Thread Yo-Yo Ma
I have a model with:

parent = ForeignKey('self', blank=True, null=True)

In that model I've overridden clean() to contain:

if self.parent:
# Do some stuff

It raises an attribute error saying that parent.pk doesn't exist. How
can I get around this. Note that my foreign key is recursive.

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



How to use the given snippet..?

2010-09-21 Thread girish shabadimath
hi all,
how to make use of this snippets

http://djangosnippets.org/snippets/963/


i have a view function

 def demand(request, id, template = 'hello.html'):
 
 

i want to test dis using the above snippets,,

i copied  the snippet in my localmachine

when i use django shell to check wat the request method (defined in snippet)
returns, it gives the following message...:

>>> from xxx.xxx import RequestFactory
>>> req = RequestFactory.request
>>> req


plz help me to knw how to use the snippet given in the above link...
-- 
Girish M S

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.