django+virtualenv+git(hub)

2013-03-30 Thread John
Hi list,

I'm a Django newbie and have been reading of usefulness of using it with
virtualenv+git. I'm not clear however how to set it up in terms of
structure/hierarchy.

Say I've got my ~/projects/django-projects where I want to create my
projects so I'd initialise git inside ~/projects/django-projects. Then
I'd create separate virtual environments inside that adjusting
.gitignore to ignore things like:

*.pyc
.*swp

# Django files
include
lib
local
man
share
Scripts
.Python
*.pyc
*~
*.db


# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
 
# Installer logs
 pip-log.txt



Is that a recommended setup/logic?

Thank you

John

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




Re: django+virtualenv+git(hub)

2013-03-30 Thread Pankaj Singh
Hey,

I would recommend using virtualenvwrapper to manage virtual
environments for different projects.
[http://virtualenvwrapper.readthedocs.org/en/latest/]

Once you have virtualenvwrapper installed, you can create virtualenv
for new projects using

$ mkvirtualenv 

.. and you can activate this virtualenv in future using

$ workon 

For using git,

1. initialize git when you create the project
2. Copy content of required .gitignore files from
https://github.com/github/gitignore in .gitignore file for your
project

You should read `Two Scoops of Django` book
(https://django.2scoops.org/). It has dedicated chapters on optimal
django environment setup , project layouts, app design and much more.
It's worth reading.

You can find project layout explained in book at
https://github.com/twoscoops/django-twoscoops-project

On Sat, Mar 30, 2013 at 1:26 PM, John  wrote:
> Hi list,
>
> I'm a Django newbie and have been reading of usefulness of using it with
> virtualenv+git. I'm not clear however how to set it up in terms of
> structure/hierarchy.
>
> Say I've got my ~/projects/django-projects where I want to create my
> projects so I'd initialise git inside ~/projects/django-projects. Then
> I'd create separate virtual environments inside that adjusting
> .gitignore to ignore things like:
>
> *.pyc
> .*swp
>
> # Django files
> include
> lib
> local
> man
> share
> Scripts
> .Python
> *.pyc
> *~
> *.db
>
>
> # Packages
> *.egg
> *.egg-info
> dist
> build
> eggs
> parts
> bin
> var
> sdist
> develop-eggs
> .installed.cfg
>
> # Installer logs
>  pip-log.txt
>
>
>
> Is that a recommended setup/logic?
>
> Thank you
>
> John
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

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

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




Re: django+virtualenv+git(hub)

2013-03-30 Thread Andrey Yanov
1. You included pyc twice.

2. I don't see a need to add all subfolders. I've used to name virtual 
env's the same for each project, so you just add the it's name to gitignore.
Since my virtual env folder lives inside project folder they are not mixed 
up.

This way you don't make your .gitignore file messed up.

суббота, 30 марта 2013 г., 11:56:37 UTC+4 пользователь Martin написал:
>
> Hi list, 
>
> I'm a Django newbie and have been reading of usefulness of using it with 
> virtualenv+git. I'm not clear however how to set it up in terms of 
> structure/hierarchy. 
>
> Say I've got my ~/projects/django-projects where I want to create my 
> projects so I'd initialise git inside ~/projects/django-projects. Then 
> I'd create separate virtual environments inside that adjusting 
> .gitignore to ignore things like: 
>
> *.pyc 
> .*swp 
>
> # Django files 
> include 
> lib 
> local 
> man 
> share 
> Scripts 
> .Python 
> *.pyc 
> *~ 
> *.db 
>
>
> # Packages 
> *.egg 
> *.egg-info 
> dist 
> build 
> eggs 
> parts 
> bin 
> var 
> sdist 
> develop-eggs 
> .installed.cfg 
>   
> # Installer logs 
>  pip-log.txt 
>
>
>
> Is that a recommended setup/logic? 
>
> Thank you 
>
> John 
>

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




PyScripter and Django with MySQL in wamp

2013-03-30 Thread Sanjay Maurya
Hello Everyone,

I new to Django. I'm using portable PyScripter 2.4.1.0 (Python 3.2.1) for 
learning Python. Recently I downloaded Django 1.5. With help of tutorials, 
I could install Django on this portable PyScripter.

Currently I'm able to create projects and apps in the Django. However I'm 
not able to set MySQL of Wamp to Django project settings. Below are 
locations of each:

Python.exe: E:\Python\App\python.exe
Django Projects: E:\Projects

I have one project (FirstBlog) and one app (testblog) created in 
E:\projects directory. The name of database is firstblog. The settings in 
setting.py for this project are:

'ENGINE': 'django.db.backends.mysql',
'NAME': 'firstblog',
'USER': 'root',
'PASSWORD': '',
'HOST': '',
'PORT': '',

When I Django ran server, I got error that no MySQLdb was found. From MySQL 
website I downloaded "MySQL Connector/Python" to interface MySQL and 
Python. I didn't create/make changes to anything after "MySQL 
Connector/Python" installed. But this did not help me.

Could anyone please let me know what exact procedures for connecting MySQL 
of wamp to Django projects with tools (PyScripter, Django 1.5, Wamp)?

Thanks

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




Doubt regarding JSON/SQL in Django

2013-03-30 Thread Parin Porecha
Hi,

I have just started using Django. I want to create a to-do task
manager application. Users would register, login and can work with
their tasks. So, instead of creating a table in the database for each
user, I want to create a JSON file for each user which will store all
his tasks.

Is there any way I can do this in Django ?
I mean, use the database only for authentication, and use JSON to
store data instead of storing it in the database.

Thanks,
Parin

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Shawn Milochik
Django is just Python, so yes. Just use the json module in the standard
library.
On Mar 30, 2013 9:23 AM, "Parin Porecha"  wrote:

> Hi,
>
> I have just started using Django. I want to create a to-do task
> manager application. Users would register, login and can work with
> their tasks. So, instead of creating a table in the database for each
> user, I want to create a JSON file for each user which will store all
> his tasks.
>
> Is there any way I can do this in Django ?
> I mean, use the database only for authentication, and use JSON to
> store data instead of storing it in the database.
>
> Thanks,
> Parin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Parin Porecha
Also, would it be beneficial performance wise ?

One more doubt -
is it better to convert query results ( obtained from sql tables ) to
JSON, and send it as an http response to the client and use it to show
data, or to simply send the query result to the client and show it via
task.name, task.start_date etc. ?

On Sat, Mar 30, 2013 at 7:01 PM, Shawn Milochik  wrote:
> Django is just Python, so yes. Just use the json module in the standard
> library.
>
> On Mar 30, 2013 9:23 AM, "Parin Porecha"  wrote:
>>
>> Hi,
>>
>> I have just started using Django. I want to create a to-do task
>> manager application. Users would register, login and can work with
>> their tasks. So, instead of creating a table in the database for each
>> user, I want to create a JSON file for each user which will store all
>> his tasks.
>>
>> Is there any way I can do this in Django ?
>> I mean, use the database only for authentication, and use JSON to
>> store data instead of storing it in the database.
>>
>> Thanks,
>> Parin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Alexis Roda

Al 30/03/13 14:14, En/na Parin Porecha ha escrit:

Hi,

I have just started using Django. I want to create a to-do task
manager application. Users would register, login and can work with
their tasks. So, instead of creating a table in the database for each
user, I want to create a JSON file for each user which will store all
his tasks.

Is there any way I can do this in Django ?
I mean, use the database only for authentication, and use JSON to
store data instead of storing it in the database.


Yes, just import json and work with it, but be aware that you'll loose 
most of the functionality that makes django so productive: no 
ModelForms, no ORM/Querysets, no admin for tasks, ...




Regards

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Shawn Milochik
On Sat, Mar 30, 2013 at 9:42 AM, Alexis Roda
 wrote:
> Yes, just import json and work with it, but be aware that you'll loose most
> of the functionality that makes django so productive: no ModelForms, no
> ORM/Querysets, no admin for tasks, ...
>

That's true. Without the ORM and Forms/ModelForms, you may as well
just use any one of the many tiny Python frameworks.

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Alexis Roda

Al 30/03/13 14:37, En/na Parin Porecha ha escrit:

Also, would it be beneficial performance wise ?


It depends on how you implement it:

* on a "traditional" client/server application I think that 
loading/parsing/processing/encoding/saving the json file on each request 
will be very expensive compared to database access.


* if all the processing logic is in the client side and django acts as 
an storage service it may be ok.



One more doubt -
is it better to convert query results ( obtained from sql tables ) to
JSON, and send it as an http response to the client and use it to show
data, or to simply send the query result to the client and show it via
task.name, task.start_date etc. ?


IIUC you can't return the query (as a python object) to the client. You 
must convert the data on it to some format (json, xml, ...) that the 
client understands. That will depend on the libraries that you use in 
the client side.




Regards

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Alan Johnson
You almost certainly don't want to use JSON as your storage method. This is 
a database problem, and the Django ORM really shines at letting you solve 
it without having to think super hard about database modeling. You wouldn't 
create a table for each user's task list. You would create a model called 
Task, which is has a foreign key to your user model. The ORM then defines 
one table for all tasks for all users, and it's easy to get the tasks for a 
single user using the reverse relationship on the foreign key. You should 
really check out the Django project docs to sort through how this works.

The alternative NoSQL approach would be to make the task list for each 
users a schemaless document in a system like MongoDB, but to my mind, a 
simple task list is a good problem for straightforward, relational Django.

On Saturday, March 30, 2013 9:14:20 AM UTC-4, Parin Porecha wrote:
>
> Hi, 
>
> I have just started using Django. I want to create a to-do task 
> manager application. Users would register, login and can work with 
> their tasks. So, instead of creating a table in the database for each 
> user, I want to create a JSON file for each user which will store all 
> his tasks. 
>
> Is there any way I can do this in Django ? 
> I mean, use the database only for authentication, and use JSON to 
> store data instead of storing it in the database. 
>
> Thanks, 
> Parin 
>

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




Re: Displaying And Selecting Tags in Admin Site

2013-03-30 Thread JonH
HI Pankaj

Sincerest thanks for the link.
It could be exactly what I'm looking for!
Will have a proper look this weekend

Bests

Jon

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

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Parin Porecha
Thank you all for your prompt replies :)

> IIUC you can't return the query (as a python object) to the client. You must 
> convert the data on it to some format (json, xml, ...) that the client 
> understands. That will depend on the libraries that you use in the client 
> side.

So, if I don't use JSON as storage and only as a format to send data
to client ( All the parsing will be done client side ), is it better
than using {{ task.name }}, {{ task.start_date }} ? ( Sorry to ask
this again, but i haven't got it )

> You almost certainly don't want to use JSON as your storage method.

What if all of my logic is on the client side, and I just send an
encoded JSON file to the server only for storage ? Your single model
option is looking better than this, but won't query time take longer
as the no. of users increase ? ( Sorry if this is abstract, but my
MySQL level is basic )


On Sat, Mar 30, 2013 at 7:37 PM, Alan Johnson  wrote:
> You almost certainly don't want to use JSON as your storage method. This is
> a database problem, and the Django ORM really shines at letting you solve it
> without having to think super hard about database modeling. You wouldn't
> create a table for each user's task list. You would create a model called
> Task, which is has a foreign key to your user model. The ORM then defines
> one table for all tasks for all users, and it's easy to get the tasks for a
> single user using the reverse relationship on the foreign key. You should
> really check out the Django project docs to sort through how this works.
>
> The alternative NoSQL approach would be to make the task list for each users
> a schemaless document in a system like MongoDB, but to my mind, a simple
> task list is a good problem for straightforward, relational Django.
>
>
> On Saturday, March 30, 2013 9:14:20 AM UTC-4, Parin Porecha wrote:
>>
>> Hi,
>>
>> I have just started using Django. I want to create a to-do task
>> manager application. Users would register, login and can work with
>> their tasks. So, instead of creating a table in the database for each
>> user, I want to create a JSON file for each user which will store all
>> his tasks.
>>
>> Is there any way I can do this in Django ?
>> I mean, use the database only for authentication, and use JSON to
>> store data instead of storing it in the database.
>>
>> Thanks,
>> Parin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread scottanderso...@gmail.com
Remember: Premature optimization is the root of all evil.

Use a database for its intended purpose: storing data.

If you use individual files then you need to implement your own locking, 
writing to disk, caching, and so forth. 

Not only is the database more functional, but it will likely be more 
performant as well. People have spent decades making databases efficient 
means of storing data; you aren't likely to improve on that in a few days. 
:-)

And if some point you want to put the data on one machine and the app 
server on another, you'll have to deal with remote files as well.

Now, let's talk about this comment: "instead of creating a table in the 
database for each user" If you have to do that, you're doing it wrong. :-)

Put django.contrib.auth in your INSTALLED_APPS and create this model:

todo/models.py:

class Task(models.Model):
user = models.ForeignKey(django.contrib.auth.get_user_model())
description = models.CharField(max_length=200)
priority = models.PositiveIntegerField(choices=PRIORITY_CHOICES)

and so on. Done. That's really all you need to do to create a task 
management system with the built-in Django auth. You'll have one table, 
todo_task, with one row for each Task created by a user.

In a view, you can then do this:

new_task = Task(user=request.user, description=request.POST.description, 
priority=SOME_PRIORITY).save()

To get all of the tasks for a user:

tasks = Task.objects.filter(user=request.user)

Regards,
-scott

On Saturday, March 30, 2013 9:14:20 AM UTC-4, Parin Porecha wrote:
>
> Hi, 
>
> I have just started using Django. I want to create a to-do task 
> manager application. Users would register, login and can work with 
> their tasks. So, instead of creating a table in the database for each 
> user, I want to create a JSON file for each user which will store all 
> his tasks. 
>
> Is there any way I can do this in Django ? 
> I mean, use the database only for authentication, and use JSON to 
> store data instead of storing it in the database. 
>
> Thanks, 
> Parin 
>

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Parin Porecha
Thanks !

Okay, so i am dropping the idea of using JSON for storage.

So, if I use JSON only as a format to send data
to client ( All the parsing will be done client side ), is it better
than using {{ task.name }}, {{ task.start_date }} ? ( Sorry to ask
this again, but i haven't got it )

On Sat, Mar 30, 2013 at 8:08 PM, scottanderso...@gmail.com
 wrote:
> Remember: Premature optimization is the root of all evil.
>
> Use a database for its intended purpose: storing data.
>
> If you use individual files then you need to implement your own locking,
> writing to disk, caching, and so forth.
>
> Not only is the database more functional, but it will likely be more
> performant as well. People have spent decades making databases efficient
> means of storing data; you aren't likely to improve on that in a few days.
> :-)
>
> And if some point you want to put the data on one machine and the app server
> on another, you'll have to deal with remote files as well.
>
> Now, let's talk about this comment: "instead of creating a table in the
> database for each user" If you have to do that, you're doing it wrong. :-)
>
> Put django.contrib.auth in your INSTALLED_APPS and create this model:
>
> todo/models.py:
>
> class Task(models.Model):
> user = models.ForeignKey(django.contrib.auth.get_user_model())
> description = models.CharField(max_length=200)
> priority = models.PositiveIntegerField(choices=PRIORITY_CHOICES)
>
> and so on. Done. That's really all you need to do to create a task
> management system with the built-in Django auth. You'll have one table,
> todo_task, with one row for each Task created by a user.
>
> In a view, you can then do this:
>
> new_task = Task(user=request.user, description=request.POST.description,
> priority=SOME_PRIORITY).save()
>
> To get all of the tasks for a user:
>
> tasks = Task.objects.filter(user=request.user)
>
> Regards,
> -scott
>
>
> On Saturday, March 30, 2013 9:14:20 AM UTC-4, Parin Porecha wrote:
>>
>> Hi,
>>
>> I have just started using Django. I want to create a to-do task
>> manager application. Users would register, login and can work with
>> their tasks. So, instead of creating a table in the database for each
>> user, I want to create a JSON file for each user which will store all
>> his tasks.
>>
>> Is there any way I can do this in Django ?
>> I mean, use the database only for authentication, and use JSON to
>> store data instead of storing it in the database.
>>
>> Thanks,
>> Parin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Help, ckeditor not rendering in form

2013-03-30 Thread frocco
Hello,

My form is not based on a model, form.value is not showing the editor.

Thanks for the help.

class RebateForm(forms.Form):
item = forms.CharField(max_length=50, required=True)
category = forms.ModelChoiceField(queryset=Category.objects.all())
value = forms.CharField(widget=CKEditorWidget())

def save(self):
return do_rebate(self)




{{ form.errors }}

{% csrf_token %}


Item to find
{{ form.item }}


Category to find
{{ form.category }}


Value to show user
{{ form.value }}







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




Filtering M2M in Admin Interface

2013-03-30 Thread Tim Cook
Hi All,

I have a scenario setup very much like the Polls example in the tutorial.

class Terminology(models.Model):
name = models.CharField(max_length=110)
abbreviation = models.CharField(max_length=20)
version = models.CharField(max_length=30)

def __unicode__(self):
return self.name + " : " + self.version

class Codes(models.Model):
terminology = models.ForeignKey(Terminology)
code_string = models.CharField(max_length=110)
code = models.CharField(max_length=20)
url = models.URLField(verbose_name="Reference", help_text="An
optional reference to the description for the code.", blank=True)

def __unicode__(self):
return self.code + " : " + self.code_string


Now to extend this a bit.

class DvCodedString(DvString):
terminology = models.ForeignKey(Terminology, null=True, blank=True)
codes = models.ManyToManyField(Codes, null=True, blank=True)
...


My admin models:
class CodesInline(admin.TabularInline):
model = Codes
extra = 5

class TerminologyAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'classes':('wide',),
   'fields':('abbreviation','version','name',)}),
)
inlines = [CodesInline]
admin.site.register(Terminology, TerminologyAdmin)


class DvCodedStringAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'classes':('wide',),
   'fields':('published','prj_name','data_name',)}),
("Basic", {'classes':('collapse',),
   'fields':('terminology','codes',),
   'description':'When all codes come from one
terminology (and one version of it).'}),

...

Currently all codes will be shown in the select box.
But of course what I really want is the Terminology Choice to filter
the available codes displayed.

So, my question is:
Where can I find the relevant documentation on doing this in the admin
interface?
Or can it be done in the admin interface?

Thanks,
Tim





-- 

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

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


<>

Re: Help, ckeditor not rendering in form

2013-03-30 Thread frocco
I figured it out.
In my index.html file, I had to add {{ form.media }}

On Saturday, March 30, 2013 12:21:52 PM UTC-4, frocco wrote:
>
> Hello,
>
> My form is not based on a model, form.value is not showing the editor.
>
> Thanks for the help.
>
> class RebateForm(forms.Form):
> item = forms.CharField(max_length=50, required=True)
> category = forms.ModelChoiceField(queryset=Category.objects.all())
> value = forms.CharField(widget=CKEditorWidget())
>
> def save(self):
> return do_rebate(self)
>
>
>
> 
> {{ form.errors }}
> 
> {% csrf_token %}
> 
> 
> Item to find
> {{ form.item }}
> 
> 
> Category to find
> {{ form.category }}
> 
> 
> Value to show user
> {{ form.value }}
> 
>
> 
> 
> 
> 
>

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




FileField delete and update handling

2013-03-30 Thread temp4746
Hi,

As it seems Django doesn't handle the update and delete of files from a 
FileField by itself leaving you them pretty hard to use by default.

I tried search around but couldn't find a proper answer as to the correct 
way of handling this.

I'm looking for the case where when the file is updated to a new name or 
deleted, it will be deleted properly from the file system, preferably not 
leaving empty directories too.

Not having this done at the model level means all the generic views and 
admin pages are useless and require customization to delete and update the 
file name in them.

The other option is a script that is going to iterate the entire directory 
and look for files not listed in the db, which is a really expensive and 
slow operation.

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




ORM Char/TextField substring

2013-03-30 Thread temp4746
Does Django provide a way to only get part of a text string at the ORM 
level?

That means using SQL functions as to only download a substring.

As in the substr,left sql functions?

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Alexis Roda

Al 30/03/13 16:41, En/na Parin Porecha ha escrit:

Thanks !

Okay, so i am dropping the idea of using JSON for storage.

So, if I use JSON only as a format to send data
to client ( All the parsing will be done client side ), is it better
than using {{ task.name }}, {{ task.start_date }} ? ( Sorry to ask
this again, but i haven't got it )


Sorry, but I still don't get the point on your question. Do you mean "is 
better to manage presentation on the client (json response + javascript) 
or in the server (django templates)"?




Regards

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




Re: FileField delete and update handling

2013-03-30 Thread Shawn Milochik
You could remember the old path by saving it as a variable in your
model's __init__ function.

Something like this:

self._old_file_path = self.file_path

Then in your save():

#only if there was a non-blank path to begin with, and it changed
if self._old_file_path and ( self._old_file_path != self.file_path):

os.remove(self._old_file_path

I don't know if this is the best possible solution, but it would
guarantee that this would happen automatically from the admin and your
ModelForms without any extra code.

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Parin Porecha
Yes, I meant the former ( managing presentation on the client ).

Also, considering that a user might have as many as 100 - 200 tasks in
one JSON file ( their description, dates, tags and all ),
is it better performance wise ?

On Sat, Mar 30, 2013 at 11:46 PM, Alexis Roda
 wrote:
> Al 30/03/13 16:41, En/na Parin Porecha ha escrit:
>
>> Thanks !
>>
>> Okay, so i am dropping the idea of using JSON for storage.
>>
>> So, if I use JSON only as a format to send data
>> to client ( All the parsing will be done client side ), is it better
>> than using {{ task.name }}, {{ task.start_date }} ? ( Sorry to ask
>> this again, but i haven't got it )
>
>
> Sorry, but I still don't get the point on your question. Do you mean "is
> better to manage presentation on the client (json response + javascript) or
> in the server (django templates)"?
>
>
>
> Regards
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Kurtis Mullins
If you don't use the ORM, Forms, and even the templating system you're
losing quite a bit with Django. In my opinion, it's not worth using Django
for those sorts of projects.

While not a Python project, I found NodeJS & node-restify a good candidate
for these types of applications. That's not a conclusive alternative as I
honestly didn't put a *lot* of time into looking at Python alternatives
since this one merged so seamlessly into our technologies (Backbone.js,
MongoDB, Web-Service)

Also, there's some Django Rest Modules which can help automate some
Object->JSON (RESTful) functionality


On Sat, Mar 30, 2013 at 2:16 PM, Alexis Roda <
alexis.roda.villalo...@gmail.com> wrote:

> Al 30/03/13 16:41, En/na Parin Porecha ha escrit:
>
>  Thanks !
>>
>> Okay, so i am dropping the idea of using JSON for storage.
>>
>> So, if I use JSON only as a format to send data
>> to client ( All the parsing will be done client side ), is it better
>> than using {{ task.name }}, {{ task.start_date }} ? ( Sorry to ask
>> this again, but i haven't got it )
>>
>
> Sorry, but I still don't get the point on your question. Do you mean "is
> better to manage presentation on the client (json response + javascript) or
> in the server (django templates)"?
>
>
>
> Regards
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> django-users+unsubscribe@**googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users?hl=en
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

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




Re: FileField delete and update handling

2013-03-30 Thread Pankaj Singh
Please have a look at following code.

pre_save and post_delete signal handlers are used here to
automatically delete unused files.

Signal handlers are generic in nature as the use isinstance(field,
models.FileField) to identify file fields.

Source - 
https://github.com/un1t/django-cleanup/blob/master/django_cleanup/models.py.

import os
from django.db import models
from django.db.models.signals import pre_save, post_delete
from django.db.models.loading import cache


def find_models_with_filefield():
result = []
for app in cache.get_apps():
model_list = cache.get_models(app)
for model in model_list:
for field in model._meta.fields:
if isinstance(field, models.FileField):
result.append(model)
break
return result

def remove_old_files(sender, instance, **kwargs):
if not instance.id:
return

try:
old_instance = instance.__class__.objects.get(id=instance.id)
except instance.DoesNotExist:
return

for field in instance._meta.fields:
if not isinstance(field, models.FileField):
continue
old_file = getattr(old_instance, field.name)
new_file = getattr(instance, field.name)
if old_file and old_file != new_file and os.path.exists(old_file.path):
try:
os.remove(old_file.path)
except OSError:
pass

def remove_files(sender, instance, **kwargs):
for field in instance._meta.fields:
if not isinstance(field, models.FileField):
continue
file = getattr(instance, field.name)
if file and os.path.exists(file.path):
try:
os.remove(file.path)
except OSError:
pass


for model in find_models_with_filefield():
pre_save.connect(remove_old_files, sender=model)
post_delete.connect(remove_files, sender=model)

On Sat, Mar 30, 2013 at 9:57 PM,   wrote:
> Hi,
>
> As it seems Django doesn't handle the update and delete of files from a
> FileField by itself leaving you them pretty hard to use by default.
>
> I tried search around but couldn't find a proper answer as to the correct
> way of handling this.
>
> I'm looking for the case where when the file is updated to a new name or
> deleted, it will be deleted properly from the file system, preferably not
> leaving empty directories too.
>
> Not having this done at the model level means all the generic views and
> admin pages are useless and require customization to delete and update the
> file name in them.
>
> The other option is a script that is going to iterate the entire directory
> and look for files not listed in the db, which is a really expensive and
> slow operation.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

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

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




Re: Doubt regarding JSON/SQL in Django

2013-03-30 Thread Alexis Roda

Al 30/03/13 19:25, En/na Parin Porecha ha escrit:

Yes, I meant the former ( managing presentation on the client ).

Also, considering that a user might have as many as 100 - 200 tasks in
one JSON file ( their description, dates, tags and all ),
is it better performance wise ?


The responsiveness of the application will be better. By the way, you're 
not required to load all the tasks at a time, you can paginate the query 
result and request chunks of data from the server as the user scrolls 
down the list.




Regards

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




Re: Displaying And Selecting Tags in Admin Site

2013-03-30 Thread JonH
Hi again

Have tried out this app and it is exactly what I was looking for!
I strongly recommend it for anyone who wants an easy way to manage 
attaching and removing tags in the admin site
Thanks again for your help : )

Jon

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

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




Re: Question about documentauion under Managers>Adding extra Manager methods

2013-03-30 Thread James Durham
In this instance, what I'm asking is about the documentation.
In other words does anyone recognize the dialect.
It would just help in understanding docs.
Though, thanks for indicating that it is backend dependent.

On Friday, March 29, 2013 8:40:09 PM UTC-5, Russell Keith-Magee wrote:
>
>
>
> On Sat, Mar 30, 2013 at 6:20 AM, James Durham 
> 
> > wrote:
>
>> In the example:
>>
>> class PollManager(models.Manager):
>> def with_counts(self):
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute("""SELECT p.id, p.question, p.poll_date, 
>> COUNT(*)FROM polls_opinionpoll p, polls_response r
>> WHERE p.id = r.poll_idGROUP BY 1, 2, 3ORDER BY 3 
>> DESC""")
>> result_list = []
>> for row in cursor.fetchall():
>> p = self.model(id=row[0], question=row[1], poll_date=row[2])
>> p.num_responses = row[3]
>> result_list.append(p)
>> return result_list
>> class OpinionPoll(models.Model):
>> question = models.CharField(max_length=200)
>> poll_date = models.DateField()
>> objects = PollManager()
>> class Response(models.Model):
>> poll = models.ForeignKey(OpinionPoll)
>> person_name = models.CharField(max_length=50)
>> response = models.TextField()
>>
>> What is the sql dialect that is used.
>>
>> In this case you're opening a cursor, so you use whatever dialect your 
> database uses. If you're using PostgreSQL, use PostgreSQL syntax; if you're 
> using MySQL, use MySQL syntax. 
>
> Django's ORM hides syntax differences from you; but once you start dealing 
> with database cursors or raw() queries, you're coding right to the metal, 
> so your deployment environment matters.
>
> Yours,
> Russ Magee %-)
>
>

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