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




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.




Models at one place vs. separate places

2013-05-08 Thread Parin Porecha
Hi,

I am developing a to-do task manager using Django 1.5 .
It will have tasks, tags, different forms of input etc.

I read on stackoverflow that creating separate apps with separate and
limited functionalities is a good practice. So, should I create different
apps for Task backend, Tag backend, and the frontend views ?

If yes, then I am thinking of having only the Task model in the Task app,
Tag model in Tag app, User profile model in it's own app, and import them
wherever necessary. Now, is this good also, or should I keep all my models
in one place ?
Regarding views, should I follow the same convention ( i.e. - only the
views related to tasks should be in the Task app, and the views relating to
tags should be in the Tag app ) ?

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.




Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
Hi,

This is my model -

class Tag(models.Model):
user = models.ForeignKey(get_user_model())
name = models.CharField(max_length = 300)
color = models.CharField(max_length = 10)
icon = models.CharField(max_length = 50)

class Meta:
unique_together = ("user", "name")

def __unicode__(self, ):
return self.name

The problem I am facing is -
I made 2 Tag objects =
1) Tag(user = jon, name = 'man')
2) Tag(user = jon, name = 'Man')

The first gets saved, but while saving the second, I am getting the error -
IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")

I deleted the database, created it again and ran 'syncdb'. Still, I am
getting the same error. Is this because of unique_together ?
How can I bypass this ?

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: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
UPDATE:

On changing the user, it gets saved successfully.
So, the problem is with the object.name

I want to save both the objects. How can I do so ?


On Sat, May 11, 2013 at 12:48 PM, Parin Porecha wrote:

> Hi,
>
> This is my model -
>
> class Tag(models.Model):
> user = models.ForeignKey(get_user_model())
> name = models.CharField(max_length = 300)
> color = models.CharField(max_length = 10)
> icon = models.CharField(max_length = 50)
>
> class Meta:
> unique_together = ("user", "name")
>
> def __unicode__(self, ):
> return self.name
>
> The problem I am facing is -
> I made 2 Tag objects =
>  1) Tag(user = jon, name = 'man')
> 2) Tag(user = jon, name = 'Man')
>
> The first gets saved, but while saving the second, I am getting the error -
> IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")
>
> I deleted the database, created it again and ran 'syncdb'. Still, I am
> getting the same error. Is this because of unique_together ?
> How can I bypass this ?
>
> 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: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
Yes, I forgot to mention
I am running Django 1.5, with database MySQL

So, how can I change the COLLATE pattern through Django's model fields ?
If not via Django, can you show me how to change it manually ?


On Sat, May 11, 2013 at 1:19 PM, Joey Chang  wrote:

> What's your database engine?
> As i know, if your  database engine was  mysql, and the database's COLLATE
> pattern name ends with "_ci" which means case-insensitive. you should got
> that result.
> You can change the COLLATE pattern to the name which ends with "_cs" or
> "_bin".
> Wish it's useful to you
>
>
>
> 2013/5/11 Parin Porecha 
>
>>  UPDATE:
>>
>> On changing the user, it gets saved successfully.
>> So, the problem is with the object.name
>>
>> I want to save both the objects. How can I do so ?
>>
>>
>> On Sat, May 11, 2013 at 12:48 PM, Parin Porecha 
>> wrote:
>>
>>> Hi,
>>>
>>> This is my model -
>>>
>>> class Tag(models.Model):
>>> user = models.ForeignKey(get_user_model())
>>> name = models.CharField(max_length = 300)
>>> color = models.CharField(max_length = 10)
>>> icon = models.CharField(max_length = 50)
>>>
>>> class Meta:
>>> unique_together = ("user", "name")
>>>
>>> def __unicode__(self, ):
>>> return self.name
>>>
>>> The problem I am facing is -
>>> I made 2 Tag objects =
>>>  1) Tag(user = jon, name = 'man')
>>> 2) Tag(user = jon, name = 'Man')
>>>
>>> The first gets saved, but while saving the second, I am getting the
>>> error -
>>> IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")
>>>
>>> I deleted the database, created it again and ran 'syncdb'. Still, I am
>>> getting the same error. Is this because of unique_together ?
>>> How can I bypass this ?
>>>
>>> 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: Is unique_together case-insensitive ?

2013-05-11 Thread Parin Porecha
Got it
Thanks!


On Sat, May 11, 2013 at 1:42 PM, Joey Chang  wrote:

> You can'n change it via django directly.
> https://docs.djangoproject.com/en/1.5/ref/databases/#collation-settings
> this link is django collation-settings notes.
> and
> http://dev.mysql.com/doc/refman/5.0/en/charset-column.html
>  this shows how to change the collation in mysql.
>
>
>
> 2013/5/11 Parin Porecha 
>
>> Yes, I forgot to mention
>> I am running Django 1.5, with database MySQL
>>
>> So, how can I change the COLLATE pattern through Django's model fields ?
>> If not via Django, can you show me how to change it manually ?
>>
>>
>> On Sat, May 11, 2013 at 1:19 PM, Joey Chang wrote:
>>
>>> What's your database engine?
>>> As i know, if your  database engine was  mysql, and the database's
>>> COLLATE pattern name ends with "_ci" which means case-insensitive. you
>>> should got that result.
>>> You can change the COLLATE pattern to the name which ends with "_cs" or
>>> "_bin".
>>> Wish it's useful to you
>>>
>>>
>>>
>>> 2013/5/11 Parin Porecha 
>>>
>>>>  UPDATE:
>>>>
>>>> On changing the user, it gets saved successfully.
>>>> So, the problem is with the object.name
>>>>
>>>> I want to save both the objects. How can I do so ?
>>>>
>>>>
>>>> On Sat, May 11, 2013 at 12:48 PM, Parin Porecha >>> > wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> This is my model -
>>>>>
>>>>> class Tag(models.Model):
>>>>> user = models.ForeignKey(get_user_model())
>>>>> name = models.CharField(max_length = 300)
>>>>> color = models.CharField(max_length = 10)
>>>>> icon = models.CharField(max_length = 50)
>>>>>
>>>>> class Meta:
>>>>> unique_together = ("user", "name")
>>>>>
>>>>> def __unicode__(self, ):
>>>>> return self.name
>>>>>
>>>>> The problem I am facing is -
>>>>> I made 2 Tag objects =
>>>>>  1) Tag(user = jon, name = 'man')
>>>>> 2) Tag(user = jon, name = 'Man')
>>>>>
>>>>> The first gets saved, but while saving the second, I am getting the
>>>>> error -
>>>>> IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")
>>>>>
>>>>> I deleted the database, created it again and ran 'syncdb'. Still, I am
>>>>> getting the same error. Is this because of unique_together ?
>>>>> How can I bypass this ?
>>>>>
>>>>> 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.
>>
>>
>>
>
>  --
> 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.




Pinax Django User Accounts vs. Django Registration

2013-05-13 Thread Parin Porecha
Hi,

I want to implement 2-step registration in my Django application.
I am using Django 1.5 and MySQL.
So, I have decided to use either 'django-user-accounts' by Pinax or
'django-registration' by James Reynolds.
I am confused which app to use.
User Accounts takes care of all the aspects regarding a user (
registration, password change, reset and settings )
whereas Django Registration only deals with signing up a user, but has been
developed originally by James Bennett.

So, please can anyone suggest which choice is better ?

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.




Template Inheritance doubt

2013-05-18 Thread Parin Porecha
Hi,

I have just started to learn Django's template inheritance and I am stuck
due to this problem -
In my application's 'base.html', I have defined two blocks -
{% block topbar %}{% endblock topbar %}
and
{% block sidebar %}{% endblock sidebar %}

I have 2 templates - 'sidebar.html' which extends {% block sidebar %}
and 'topbar.html' which extends {% block topbar %}

The 'sidebar.html' is also divided into further blocks which are extended
by other templates.

Now, my question is -
in 'views.py', i have a view which is supposed to render the whole homepage
( i.e.- including the sidebar, topbar and content ). So, which template
should I load in the view, so that both sidebar and topbar plus the content
defined in other templates gets shown ?
because 'base.html' contains many children, I'm confused which one to load

Thanks to mattmc who tried to help me with this in IRC. Sorry, didn't get
it completely :)

-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/> and look forward to 17.09.13 !

-- 
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: Template Inheritance doubt

2013-05-18 Thread Parin Porecha
Dow,
I am trying to have multiple children of the same parent. And thats why I'm
not able to decide which child to load. Anyways, the sidebar and topbar are
more or less static, so I guess there isn't much need to have separate
files for them. I want to have them different so that developing that
section of the website would be easier. In the end, I want to merge all
those different sections into one file and load that in my view. Can you
please help me with this ?

Artem,
Yes, I get it :) Thanks!


On Sat, May 18, 2013 at 9:56 PM, Artem Zinoviev wrote:

> if you have base.html and sidebar.html, base.html file just declare {%
> block sidebar %} section and sidebar.html make implementation of it, if
> you have SidebarView, then you load sidebar.html and this file take all
> from {% extends base.html %}. And if you try load base.html from
> SidebarView - you get it :-), but {% block sidebar %} section be blank...
>
> суббота, 18 мая 2013 г., 12:14:37 UTC+3 пользователь Parin Porecha написал:
>
>> Hi,
>>
>> I have just started to learn Django's template inheritance and I am stuck
>> due to this problem -
>> In my application's 'base.html', I have defined two blocks -
>> {% block topbar %}{% endblock topbar %}
>> and
>> {% block sidebar %}{% endblock sidebar %}
>>
>> I have 2 templates - 'sidebar.html' which extends {% block sidebar %}
>> and 'topbar.html' which extends {% block topbar %}
>>
>> The 'sidebar.html' is also divided into further blocks which are extended
>> by other templates.
>>
>> Now, my question is -
>> in 'views.py', i have a view which is supposed to render the whole
>> homepage ( i.e.- including the sidebar, topbar and content ). So, which
>> template should I load in the view, so that both sidebar and topbar plus
>> the content defined in other templates gets shown ?
>> because 'base.html' contains many children, I'm confused which one to load
>>
>> Thanks to mattmc who tried to help me with this in IRC. Sorry, didn't get
>> it completely :)
>>
>> --
>> Regards,
>> Parin Porecha
>>
>> say Kifflom! <http://www.epsilonprogram.com/> and look forward to
>> 17.09.13 !
>>
>  --
> 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.
>
>
>



-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/> and look forward to 17.09.13 !

-- 
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: [Bulk] Re: Template Inheritance doubt

2013-05-20 Thread Parin Porecha
Dow,
I am using the chained approach which you suggested ( base -> topbar ->
sidebar -> view1 ). It works perfectly as i wanted :)

Thanks!


On Sun, May 19, 2013 at 10:50 PM, Dow Street  wrote:

> Hi.  I'm not sure, but we may be using the terms 'parent' and 'child'
> differently (i.e. what you're calling a child I'm calling a parent?).  I
> have only used django template inheritance where a given template file has
> at most one {% extends %} tag in it - that is what I am referring to when I
> say 'has at most one parent'.  However, the base.html template (the parent)
> is extended by many different child templates (e.g. view1.html).  Is this
> what you are thinking as well?
>
> If you want a template to inherit from multiple parents - e.g. include
> multiple {% extends %} tags - well, that is not something I have done
> previously (and I can't say whether that model is supported).  However, you
> can achieve comparable functionality (I think) by adding a layer in the
> inheritance hierarchy - for example:
>
> base.html - has empty blocks for topbar and sidebar
> topbar.html - extends base.html and contains the code for the topbar
> sidebar.html - extends topbar.html and contains the code for the sidebar
> view1.html - extends sidebar.html and contains the code specific to that
> page
>
> If you load the view1.html template in your view function all those {%
> extends %} tags will cause the django template engine to walk the
> hierarchy, starting from base -> topbar -> sidebar -> view1, leaving you
> with a single 'merged' html file.  At each step, if a child template has a
> block with the same name as one of the parents, the child block will
> overwrite the contents of the parent block.  Does this make sense?
>
> (and I should note that I am by no means an expert in the django template
> processor - this is just my understanding).
>
> R,
> Dow
>
>
> On May 18, 2013, at 11:12 PM, Parin Porecha 
> wrote:
>
> > Dow,
> > I am trying to have multiple children of the same parent. And thats why
> I'm not able to decide which child to load. Anyways, the sidebar and topbar
> are more or less static, so I guess there isn't much need to have separate
> files for them. I want to have them different so that developing that
> section of the website would be easier. In the end, I want to merge all
> those different sections into one file and load that in my view. Can you
> please help me with this ?
> >
> > Artem,
> > Yes, I get it :) Thanks!
> >
> >
> > On Sat, May 18, 2013 at 9:56 PM, Artem Zinoviev 
> wrote:
> > if you have base.html and sidebar.html, base.html file just declare {%
> block sidebar %} section and sidebar.html make implementation of it, if you
> have SidebarView, then you load sidebar.html and this file take all from {%
> extends base.html %}. And if you try load base.html from SidebarView - you
> get it :-), but {% block sidebar %} section be blank...
> >
> > суббота, 18 мая 2013 г., 12:14:37 UTC+3 пользователь Parin Porecha
> написал:
> > Hi,
> >
> > I have just started to learn Django's template inheritance and I am
> stuck due to this problem -
> > In my application's 'base.html', I have defined two blocks -
> > {% block topbar %}{% endblock topbar %}
> > and
> > {% block sidebar %}{% endblock sidebar %}
> >
> > I have 2 templates - 'sidebar.html' which extends {% block sidebar %}
> > and 'topbar.html' which extends {% block topbar %}
> >
> > The 'sidebar.html' is also divided into further blocks which are
> extended by other templates.
> >
> > Now, my question is -
> > in 'views.py', i have a view which is supposed to render the whole
> homepage ( i.e.- including the sidebar, topbar and content ). So, which
> template should I load in the view, so that both sidebar and topbar plus
> the content defined in other templates gets shown ?
> > because 'base.html' contains many children, I'm confused which one to
> load
> >
> > Thanks to mattmc who tried to help me with this in IRC. Sorry, didn't
> get it completely :)
> >
> > --
> > Regards,
> > Parin Porecha
> >
> > say Kifflom! and look forward to 17.09.13 !
> >
> > --
> > 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

Re: [Bulk] Re: Template Inheritance doubt

2013-05-21 Thread Parin Porecha
Yes, this approach is also good. Besides, I have no problem in letting the
html tags remain in header and footer.
Thanks :)


On Tue, May 21, 2013 at 3:58 AM, Sam Solomon  wrote:

> If you are mainly using this for splitting stuff into multiple files, here
> is what we do to accomplish the same thing but keep it so that templates
> always inherit base.html instead of sidebar.html:
>
> base.html:
> {% extends 'header.html' %}
>
> {% block main %}
> 
> {% endblock main %}
>
> header.html:
> {% extends base_footer_template|default:"includes/footer.html" %}
>
> {% block base_everything %}
> 
>  overridable blocks for navigation etc>
> {% block main %}{% endblock main %}
> {% endblock base_everything %}
>
> footer.html:
> {% block base_everything %}{% endblock %}
> 
> 
>
>
> So it's a little weird that the html tags are in header.html and
> footer.html but it does allow the code to be logically separated otherwise.
>
> Also, because of the |default filter, you can render header.html without
> the footer if you need to (we did this for a while when we were playing
> around with "sharing" the overall layout with a wordpress install. (We'd
> have the django server render the header and footer separately and the
> wordpress server would cache the result and use the header and footer in
> it's main template (would only show the logged out versions of the
> header/footer).)
>
> On Monday, May 20, 2013 1:52:15 AM UTC-7, Parin Porecha wrote:
>
>> Dow,
>> I am using the chained approach which you suggested ( base -> topbar ->
>> sidebar -> view1 ). It works perfectly as i wanted :)
>>
>> Thanks!
>>
>>
>> On Sun, May 19, 2013 at 10:50 PM, Dow Street  wrote:
>>
>>>  Hi.  I'm not sure, but we may be using the terms 'parent' and 'child'
>>> differently (i.e. what you're calling a child I'm calling a parent?).  I
>>> have only used django template inheritance where a given template file has
>>> at most one {% extends %} tag in it - that is what I am referring to when I
>>> say 'has at most one parent'.  However, the base.html template (the parent)
>>> is extended by many different child templates (e.g. view1.html).  Is this
>>> what you are thinking as well?
>>>
>>> If you want a template to inherit from multiple parents - e.g. include
>>> multiple {% extends %} tags - well, that is not something I have done
>>> previously (and I can't say whether that model is supported).  However, you
>>> can achieve comparable functionality (I think) by adding a layer in the
>>> inheritance hierarchy - for example:
>>>
>>> base.html - has empty blocks for topbar and sidebar
>>> topbar.html - extends base.html and contains the code for the topbar
>>> sidebar.html - extends topbar.html and contains the code for the sidebar
>>> view1.html - extends sidebar.html and contains the code specific to that
>>> page
>>>
>>> If you load the view1.html template in your view function all those {%
>>> extends %} tags will cause the django template engine to walk the
>>> hierarchy, starting from base -> topbar -> sidebar -> view1, leaving you
>>> with a single 'merged' html file.  At each step, if a child template has a
>>> block with the same name as one of the parents, the child block will
>>> overwrite the contents of the parent block.  Does this make sense?
>>>
>>> (and I should note that I am by no means an expert in the django
>>> template processor - this is just my understanding).
>>>
>>> R,
>>> Dow
>>>
>>>
>>> On May 18, 2013, at 11:12 PM, Parin Porecha  wrote:
>>>
>>> > Dow,
>>> > I am trying to have multiple children of the same parent. And thats
>>> why I'm not able to decide which child to load. Anyways, the sidebar and
>>> topbar are more or less static, so I guess there isn't much need to have
>>> separate files for them. I want to have them different so that developing
>>> that section of the website would be easier. In the end, I want to merge
>>> all those different sections into one file and load that in my view. Can
>>> you please help me with this ?
>>> >
>>> > Artem,
>>> > Yes, I get it :) Thanks!
>>> >
>>> >
>>> > On Sat, May 18, 2013 at 9:56 PM, Artem Zinoviev 
>>> wrote:
>>> > if you have base.html and sidebar.html, base

Change template block via AJAX

2013-06-29 Thread Parin Porecha
Hi,

I have an application containing a topbar and rest is content area.

In my 'base.html', I've defined two blocks -


  {% block topbar %}{% endblock topbar %}
  {% block page_content %}
{% block sidebar %}
{% endblock sidebar %}

{% block main %}
{% endblock main %}
{% endblock page_content %}


These two blocks are then overridden by child templates.
The topbar contains a search input. The search query is sent via AJAX, and
the results are loaded in respective child blocks through client-side
templating.

Now, I want that whenever user enters a search query for a user via a radio
button instead of default, The block 'page_content' should get overridden
by another template 'user_results.html'. ( I'll know it client-side itself )
This can be done by redirecting to a path like '/search/user/', but that
would involve reloading of the page.
Is this possible via an AJAX request, and then the server would load
another template which will replace the 'page_content' block without page
refresh ?

-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/kifflom.htm> and look forward
to 17.09.13 !

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




File Log vs. Database Log

2013-07-20 Thread Parin Porecha
Hi,

I have a to-do list app ( using Django 1.5 and MySQL ) in which a task can
be shared with another user. Thus, a user can have personal tasks and
shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
tasks of a user )

For shared tasks, I want to keep a log so that users connected to the task
can know who has done which changes.
For this, I'm thinking of keeping a log file for every shared task.
Whenever any user makes a change, it'll be appended to that file.

My question is - *Should I do it via file storage, or should I save it in
database ?*

Please note these points -
- Log will not be accessed frequently ( A file's log may be read 5-10 times
max in an hour. )
- In an hour, there may be total >500 writes ( but for different files. So
for a file there may be 10-50 max writes in an hour. So, concurrency is not
a major issue. )
- I won't need to search or modify the data anyway after reading it.

Thanks in advance !

-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/kifflom.htm> and look forward
to 17.09.13 !

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: File Log vs. Database Log

2013-07-20 Thread Parin Porecha
django-logtailer looks a great app, but the last commit was 2 years ago.
Also, it's focused on admins.
Maybe the term 'logs' is confusing. So, I'll change it to 'audit-data' (
stackoverflow suggestion ).
I need audit data not system logs.

Thanks Valder


On Sat, Jul 20, 2013 at 9:02 PM, Valder Gallo  wrote:

> Do you know django-logtailer ?
> https://github.com/fireantology/django-logtailer
>
> If you don't need search or modify the data.
>
> +1 for file storage
>
> :D
>
>
> On Sat, Jul 20, 2013 at 11:52 AM, Parin Porecha wrote:
>
>> Hi,
>>
>> I have a to-do list app ( using Django 1.5 and MySQL ) in which a task
>> can be shared with another user. Thus, a user can have personal tasks and
>> shared tasks. Shared tasks will be a fraction ( i guess around 30% of total
>> tasks of a user )
>>
>> For shared tasks, I want to keep a log so that users connected to the
>> task can know who has done which changes.
>> For this, I'm thinking of keeping a log file for every shared task.
>> Whenever any user makes a change, it'll be appended to that file.
>>
>> My question is - *Should I do it via file storage, or should I save it
>> in database ?*
>>
>> Please note these points -
>> - Log will not be accessed frequently ( A file's log may be read 5-10
>> times max in an hour. )
>> - In an hour, there may be total >500 writes ( but for different files.
>> So for a file there may be 10-50 max writes in an hour. So, concurrency is
>> not a major issue. )
>> - I won't need to search or modify the data anyway after reading it.
>>
>> Thanks in advance !
>>
>> --
>> Regards,
>> Parin Porecha
>>
>> say Kifflom! <http://www.epsilonprogram.com/kifflom.htm> and look
>> forward to 17.09.13 !
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Valder Gallo
> +55 11 9949 2911
> +55 11 2532 2911
> Skype: valdergallo
> @valdergallo
> www.valdergallo.com.br
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/kifflom.htm> and look forward
to 17.09.13 !

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.