Re: how to design URL pattern to get the field value using request.query_params.get in the view

2016-09-05 Thread Siddharth Ghumre
If I understand it correctly, for this view your url must correspond to

http://www.mysite.com/xyz?year=2015

Here as per standard url protocol, anything you pass after the "?"
(question mark) is passed as a request.query_params to the views.

Hope this helps.
Sid


On Sun, Sep 4, 2016 at 10:03 PM, Afiz S  wrote:

> Hi All,
>
> I have very new to Django. Can anyone tell me how to the data from URL to
> view.
>
> in this below example I am trying to get year param from the URL.
>
> def get_queryset(self):
> queryset = Battles.objects.all()
> year = self.request.query_params.get('year',None)
> if year is not None:
> queryset = queryset.filter(year__exact=year)
> return queryset
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/693bbae5-0ffc-4737-86be-a9cee202e68e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp6n%2Bj5Gar-XVcEU%3DhRooy8nOCW_iMBBDCE_BM%2BnOkuDyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to add logo to django header

2016-07-28 Thread Siddharth Ghumre
Hi,

Please follow the documentation on
https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#overriding-vs-replacing-an-admin-template

The file you are looking for is base_site.html which you need to override
to change the default 'Django Administrator' heading to your company logo.

Hope this helps.

-Sid

On Thu, Jul 28, 2016 at 2:04 PM, Gauri Shirsath <
gauri.shirs...@inspiritvision.com> wrote:

> Hi,
>
> I want to show company logo instead of 'Django Administrator' heading.
> Can someone please guide me.
>
> Regards,
> Gauri
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/991a1cf4-8a32-4941-ae43-e7a3f46916af%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp5R9XcYcNBYKWwB%2BT%3DjrGr-O2aBdjHqEO%2Bgw0FFfe-bJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: It is possible to somehow fill the database data as soon as all applications will be loaded?

2016-07-26 Thread Siddharth Ghumre
For Django version 1.7 and above use migrations to load initial data as
South is inbuilt included in these versions. Prior to version Django 1.7
(1.6 and below) use fixtures to load initial data.

https://docs.djangoproject.com/en/1.8/howto/initial-data/

Hope this helps.

-Sid

On Tue, Jul 26, 2016 at 4:17 PM, Jani Tiainen  wrote:

> Hi,
>
> Sounds like you're in need of data migrations to insert initial data while
> building up your database schema.
>
>
> On 26.07.2016 11:14, Seti Volkylany wrote:
>
> It is possible to somehow fill the database data as soon as all
> applications will be loaded.
> I explain the problem. It is necessary that the default database was an
> urgent data for the entire project, in my case, tags, level of accounts and
> professions.
> To resolve this problem, I created the necessary commands. For example,
> for tags that command is "create_tags" (called so ./manage.py create_tags).
> It creates all the necessary tags for all other objects: articles,
> questions, answers, snippets and so.
>
> The question is next, how to run it once as soon as Django will be able to
> fill these databases.
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/4884ce55-8862-4c0f-967e-710ea36b9175%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/57971C8F.1030508%40gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp7ErBZLxrm52rAjem2rVEd-1F13CQtt6MLg0dPuDR_ShA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installation de Django dans un environnement virtuel.

2016-07-25 Thread Siddharth Ghumre
I think "*sudo* pip install django" is the problem here as when you so sudo
it installs it in the host machine not in virtualenv so the thumb rule says
-  dont use sudo when you are working in vitrual env.

I guess pip install Django==1.X.X would solve the problem.

Suggestion - use pip freeze to list all the installed packages in the
virtual env.

Hope this helps.

*Bonne Chance*

-Sid

On Mon, Jul 25, 2016 at 2:20 AM, ludovic coues  wrote:

> Est-ce que l'erreur survient aussi si la commande est lancé sans sudo ?
> Dans un virtualenv, sudo ne devrait pas etre utilisé, on travail avec
> des fichiers que l'on a crée, dans notre dossier personnel.
>
> 2016-07-24 16:17 GMT+02:00  :
> > Can You, please, in English describe what a problem You have? I
> understand
> > just that this is some with virtualenv.
> >
> >
> > --
> > 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 https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/36fed426-aa40-4ab0-bf7a-430de2888240%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEuG%2BTbrZv5TMYSkqbX54dhnrgZ%2Bj1mqqTBN6ah0CMRbctdjqQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp4ewKKdV-jKhLa%3D-CqLxpLgv0H%3DV5ojsz2ZyuFeXfO2Hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin on Microsoft Visual Studio Problem

2016-07-25 Thread Siddharth Ghumre
To access Django's admin site, your admin url should look like url(
r'^admin/', include(admin.site.urls)) which says whenever u hit rather
http://127.0.0.1:8000/admin would include admin urls from "admin.site.urls"
rather than "polls.views" unless you have all the admin login there in
"polls.views".

Hope this helps.
Also Visual studio has nothing to do with this error as its just an editor.

-Sid

On Mon, Jul 25, 2016 at 3:01 AM, James Schneider 
wrote:

> On Jul 23, 2016 6:39 PM, "Jose"  wrote:
> >
> > Hi all,
> >
> > After I built my classes on Django how can I access the admin site when
> running it on the local server online. I was reading the django
> documentations and they only say  http://127.0.0.1:8000/admin/ and that
> forwards them to the admin site without having to make an url. I get an URL
> error since I never specified an URL on urls.py. I then tried to make an
> url and used the code on the documentation for making the polls app on an
> admin.py file under polls. This also did not work. Could someone tell me
> how I could access that admin page using Visual Studio. These are pictures
> of the code.
> >
>
> Accessing the admin site is separate from Visual Studio. Are you running
> the Django development server? What errors are you getting when you try to
> access the site?
>
> -James
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVEGp_GuybQvYexwCYsc3RtVq27vmhy%3DBVTRRDUnvmaUA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANtEdp582TZdqzejrBB7_xbHP7%2B_xNTmjHSR926Kt2Z_JD62Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - Query

2013-05-05 Thread Siddharth Ghumre
Hi,

get the length of object by using len(movieObject)
if len(movieObject)==1:
   #you can get along with get query
if len(movieObject)>1:
   #use filter query and access each element by using for loop
   for i in movieObject:
  


-Siddharth


On Mon, May 6, 2013 at 1:54 AM, Shawn Milochik  wrote:

> On Sun, May 5, 2013 at 3:29 PM, Hélio Miranda  wrote:
>
>> How do I get the two?
>>
>> --
>>
>> Use .filter() instead of .get().
>
>
>
> --
> 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: Modifying a field in another model

2013-05-01 Thread Siddharth Ghumre
Hi,

Though its not the perfect solution for your query, please refer the link
for ModelAdmin to include conditional formatting in admin interface.

https://docs.djangoproject.com/en/dev/ref/contrib/admin/

-Siddharth


On Mon, Apr 22, 2013 at 10:35 PM, Vittorio  wrote:

> My (newbye) problem is as follows:
>
> Suppose
>
> class Person(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30)
>
> address = models.CharField(max_length=100)
>
> 
>
>
> class Lent_Book(models.Model):
> title = models.CharField(max_length=100)
> to_whom = models.ForeignKey(Person)
>
> last_known_address= HERE I WOULD LIKE TO SHOW AND, IF NECESSARY, 
> MODIFY Person.address
>
>
> In a nutshell, my problem is: when I run admin and open Lent_book I would
> like to have a changeable field 'last-know_address' that  modifies
> Person.address in one shot (without having to open Person).
>
> Is that possible and how?
>
> An example would be highly appreciated.
>
> Ciao from Rome
> Vittorio
>
>
> --
> 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: How to create a temporary table in Django use ORM

2013-05-01 Thread Siddharth Ghumre
Hi

If you are interested in using multiple order by in django's ORM then use

TABLE.objects.order_by('column_A','column_B')


On Tue, Apr 23, 2013 at 11:18 AM, teddy wang wrote:

> CREATE TEMPORARY TABLE TEMP (SELECT * FROM TABLE ORDER BY COLUMN_A);
> SELECT * FROM TEMP ORDER BY COLUMN_B;
> I want to implement this selection in Django use ORM,,,still have no
> idea,,,
> anybody help?
> 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.
>
>
>

-- 
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: ManyToMany relationship and raw sql queries

2013-05-01 Thread Siddharth Ghumre
Hi ,

Did you try python psycopg2.
A simple deomostration.
Ex:-
import psycopg2
conn=psycopg2.connect("dbname='xxx' user='xxx' host='localhost'
password='xxx'")
cur = conn.cursor()

query="""SELECT * FROM bookmarkmanager_bookmark b '
 'LEFT JOIN bookmarkmanager_bookmark_tags bt ON (b.id =
 bt.bookmark_id) '
 'LEFT JOIN bookmarkmanager_tag t ON (bt.tag_id = t.id
);"""


cur.execute(query)
result=cur.fetchall()


you can iterate over result list for data-processing and getting the
requires resultset.

-Siddharth





On Sun, Apr 28, 2013 at 4:06 AM, Marc R  wrote:

> did you use Bookmark.objetcs.all().select_related() ?
>
> As this will create a join query... at least for your model you show in
> the message I have found that for very complex joins, you need to use
> raw query and not a Model.
>
> On Thursday, April 25, 2013 10:44:28 AM UTC-4, Matthieu Bouron wrote:
>>
>> On Thursday, April 11, 2013 5:39:57 PM UTC+2, Tom Evans wrote:
>>>
>>> On Thu, Apr 11, 2013 at 3:42 PM, Matthieu Bouron
>>>  wrote:
>>> > Hello,
>>> >
>>> > Is there a way to handle many-to-many relationship with raw sql
>>> queries ?
>>> > I have the following model:
>>> >
>>> > from django.db import models
>>> >
>>> > class Tag(models.Model):
>>> > name = models.CharField(max_length=**512, unique=True)
>>> >
>>> > class Bookmark(models.Model):
>>> > link = models.CharField(max_length=**512)
>>> > title = models.CharField(max_length=**512)
>>> > tags = models.ManyToManyField(Tag)
>>> > added_at = models.DateField()
>>> >
>>> > Using Bookmark.objetcs.all() will result in a subquery for each row of
>>> the
>>> > bookmark table which is not acceptable for performance reasons.
>>> > First question is there a way to fetch all the content with a single
>>> query ?
>>> > Second question is it possible to use raw sql queries. I tried the
>>> > following:
>>> >
>>> > bookmarks = Bookmark.objects.raw(
>>> > 'SELECT * FROM bookmarkmanager_bookmark b '
>>> > 'LEFT JOIN bookmarkmanager_bookmark_tags bt ON (
>>> b.id =
>>> > bt.bookmark_id) '
>>> > 'LEFT JOIN bookmarkmanager_tag t ON (bt.tag_id =
>>> t.id)'
>>> > )
>>> >
>>> > But when i tried to access the tags attribute on a bookmark i get the
>>> > following exception:
>>> >
>>> > ValueError: "" needs to have a value for
>>> field
>>> > "bookmark" before this many-to-many relationship can be used.
>>> >
>>> > Thanks in advance,
>>> > Matthieu
>>> >
>>>
>>> Are you tied to raw SQL queries? Django itself supports traversing M2M
>>> relationships in a sane manner if you tell it to do so:
>>>
>>> https://docs.djangoproject.**com/en/1.5/ref/models/**
>>> querysets/#prefetch-related
>>>
>>
>> Thanks.
>> Another problem remains ... performances are horrible even if i use
>> values().
>> I have 1000 rows in base, executing from a script (db sqlite):
>>   - 800ms to fetch all the objects (traversing m2m with prefetch_related).
>>   - 200ms to fetch all the row from bookmark table without traversing the
>> m2m relationship).
>>
>> Are my results expected ?
>> Are there any plan on improving django orm performance ?
>>
>> Matthieu
>>
>  --
> 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: Admin shows all users as staff and super user

2013-05-01 Thread Siddharth Ghumre
Hi,

I could not replicate your error here. I am also adding users via admin
interface and the "Staff status" and "Superuser status" are unchecked by
default.
I am running django 1.4 on ubuntu 12.04 with postgresql.
Can you just try switching to postgresql and see.

-Siddharth


On Wed, May 1, 2013 at 2:22 PM, Thomas De Reyck <
thomas%dereyck...@gtempaccount.com> wrote:

> Hi Siddharth,
>
> Thanks for your reply. I only create/delete/manage users via the admin
> itself, so there is no code to show you I guess.
> Furthermore, the auth table displays the correct values when queried
> directly.
>
> Kind regards,
> Thomas
>
> Op woensdag 1 mei 2013 10:48:10 UTC+2 schreef siddharth56660 het volgende:
>>
>> Hi Thomas,
>>
>> Can you paste the code snippet where you add the user in your auth table
>> (not the admin).
>> It might help in understanding the problem.
>>
>> -Siddharth
>>
>>
>> On Tue, Apr 30, 2013 at 11:45 PM, Thomas De Reyck > gtempaccount.com> wrote:
>>
>>> Hi everyone,
>>>
>>> My very first question here. I hope anyone can help me out with this...
>>>
>>> I have created a Django powered site for my company. Everything works
>>> perfectly, except in our production environment,
>>> where I have one bug in the admin that is quite annoying:
>>>
>>> When I click a user to edit it, the "Staff" and "SuperUser" checkboxes
>>> are always checked for every user, even when they
>>> shouldn't be. The database however does record these properties
>>> properly, and they work correctly in the application. Only
>>> the admin is displaying them incorrectly in the "edit" page for a user.
>>> When looking at the user overview in the admin, the
>>> "staff" property is correctly displayed.
>>>
>>> Because of this error we need to be extra cautious when editing users,
>>> because we don't accidentally want to make anyone
>>> a staff or superuser.
>>>
>>> Does anyone know how I can attempt to debug this? Where should I start?
>>>
>>> I am running:
>>> Django 1.5.1 on Ubuntu 12.04 with SQL Server 2008R2 as my database (via
>>> pyodbc->UnixODBC->FreeTDS).
>>>
>>> Thanks in advance for any hints you can provide!
>>>
>>> Kind regards,
>>> Thomas
>>>
>>>  --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@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: Admin shows all users as staff and super user

2013-05-01 Thread Siddharth Ghumre
Hi Thomas,

Can you paste the code snippet where you add the user in your auth table
(not the admin).
It might help in understanding the problem.

-Siddharth


On Tue, Apr 30, 2013 at 11:45 PM, Thomas De Reyck <
thomas%dereyck...@gtempaccount.com> wrote:

> Hi everyone,
>
> My very first question here. I hope anyone can help me out with this...
>
> I have created a Django powered site for my company. Everything works
> perfectly, except in our production environment,
> where I have one bug in the admin that is quite annoying:
>
> When I click a user to edit it, the "Staff" and "SuperUser" checkboxes are
> always checked for every user, even when they
> shouldn't be. The database however does record these properties properly,
> and they work correctly in the application. Only
> the admin is displaying them incorrectly in the "edit" page for a user.
> When looking at the user overview in the admin, the
> "staff" property is correctly displayed.
>
> Because of this error we need to be extra cautious when editing users,
> because we don't accidentally want to make anyone
> a staff or superuser.
>
> Does anyone know how I can attempt to debug this? Where should I start?
>
> I am running:
> Django 1.5.1 on Ubuntu 12.04 with SQL Server 2008R2 as my database (via
> pyodbc->UnixODBC->FreeTDS).
>
> Thanks in advance for any hints you can provide!
>
> Kind regards,
> Thomas
>
> --
> 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: django development server timeout too quick

2013-04-25 Thread Siddharth Ghumre
Hi Hadi,

I am using sessions.middleware.SessionIdleTimeout in my app which takes
care of the session management

https://pypi.python.org/pypi/django-session-idle-timeout/1.0.1

Its clean and easy way to handle session timeouts.

-Siddharth



On Wed, Apr 24, 2013 at 11:57 AM, Hadi Sunyoto wrote:

> The problem is like this:
>
> i am using django admin, and in several forms, it might take around 10-20
> minutes to fill up.
> By the time save button is pressed, i am always redirected to login page.
>
> The question is: how can i make the timeout longer (or maybe last forever)
>
> I set the cache to file and session_engine to db
>
> CACHES = {
> 'default': {
> 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
> 'LOCATION': 'some/path',
> 'TIMEOUT': 10,
> }
> }
> SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
>
> What else am i missing here? any direction will be much appreciated
>
> i also have tried to set --noreload in runserver so that file changed does
> not get reloaded, but i still get the same problem.
>
> i don't plan on using apache/ngix/etc because this is only for my personal
> use
>
> --
> 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: handling IntegrityError: Duplicate entry in UserCreationForm

2013-04-25 Thread Siddharth Ghumre
hi Sachin,

Please use django's form clean method in order to validate your phone_num
field.
You can also override the django's clean method by using your own
clean_phone_field method.
Please refer the link:-

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

I am sure that a small googling on overriding the clean method in django
form class will defiantly help you.

-Siddharth


On Wed, Apr 24, 2013 at 8:57 PM, sachin  wrote:

> Hello,
>
> I m extending my auth user model to add addition entries like phone
> numbers and emp_id. In the model I m marking both the fields as unique=True.
> Form generation is using UserCreationForm. But whenever I try to save same
> phone number or emp_id it throws
>
> *IntegrityError: (1062, "Duplicate entry '447' for key 'phone_num'")*
>
> How to handle this error and show it to user during form input?
>
> Also how do the same UserCreationForm validates duplicate entry for
> username etc ??
>
>  --
> 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: (1242, 'Subquery returns more than 1 row')

2013-04-01 Thread Siddharth Ghumre
Hi

As per my view your client query is returning more than one rows from your
database.
Suppose your job = 1 which you are getting from your Report table and the
query ( Job.objects.all().filter(
client=job)..)fetches two or more than two records from your 'job'
table.

Now there can be two scenarios:-
1.You are looking for a single record to be displayed after executing
(Job.objects.all().filter(client=job)..)
In this case you need to use filter query like
Job.objects.all().filter(Q(client=job)(something=something)(something=something)...)
which will give you a unique row as per your filter criteria.

2.You are looking for multiple records to be displayed:-
In this case you need to add a for after your query.
Like
 table1=[]
 client = Job.objects.all().filter(client=job)
 for i in client:
client__client__first_name = i.first_name
client__client__middle_name = i.middle_name
...
...
...


table1.append({"client__client__first_name":client__client__first_name,"
client__client__middle_name": client__client__middle_name,.})


 temp = {'client':table1, 'cubee':cubee, 'Head':Head,
'organisation':organisation,'department':department,}


I hope this might solve your problem.

-Siddharth





On Mon, Apr 1, 2013 at 2:51 AM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> I have the following error in my project
>
> (1242, 'Subquery returns more than 1 row')
>
> my views are as given below
>
> def result_cube(request):
> Id = Cube.objects.aggregate(Max('Report_id'))
> ID = Id['Report_id__max']
> cubee = Cube.objects.filter(Report_id = ID)
> Id = Report.objects.aggregate(Max('id'))
> ID = Id['id__max']
> Head = Report.objects.filter(id = ID)
> organisation = Organisation.objects.all().filter(id = 1)
> department = Department.objects.all().filter(id = 1)
>
> Id = Report.objects.aggregate(Max('job'))
> ID = Id['job__max']
> job = Report.objects.filter(job = ID)
>
> client =
> Job.objects.all().filter(client=job).values('client__client__first_name',
> 'client__client__middle_name', 'client__client__last_name',
> 'client__client__address', 'client__client__city', 'date',
> 'letter_no', 'letter_date')
>
> temp = {'client':client, 'cubee':cubee, 'Head':Head,
> 'organisation':organisation,'department':department,}
> return render_to_response('report/cube.html',
> dict(temp.items() + tmp.items()),
> context_instance=RequestContext(request))
>
>
> Error during template rendering
>
> In template /home/satinder/Automation/templates/report/header.html,
> error at line 12
>
> 2 {% load i18n %}
> 3 
> 4 {% block content %}
> 5 
> 6 {% for Heads in Head %}
> 7 
> 8 No.GNDEC/TCC/R/{{Heads.job_id}} align="right">Dated{{Heads.dispatch_report_date}}
> 9 
> 10  To,
> 12 {% for add in client %}
> 13  {{ add.client__client__first_name}} {{
> add.client__client__middle_name}}
> {{add.client__client__last_name}}
> 14  {{add.client__client__address}}
> 15 {{ add.client__client__city}}
> 16 {% endfor %}
> 17
>
> Can anybody help me to solve this error.
>
>
> --
> Satinderpal Singh
> http://devplace.in/~satinder/wordpress/
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> 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: Data Structure - Orders and multiple items

2013-04-01 Thread Siddharth Ghumre
Sorry for the half response...please ignore the previous message.

class order(models.Model):
order_id = models.IntegerField(unique=True)
customer_id = models.ForeignKey('Customer')
item_id = models.ForeignKey('Item')
qty = models.IntegerField()

This will you give the provision to store multiple items to be added
against each customer and the quantity of the order against each customer.

-Siddharth



On Mon, Apr 1, 2013 at 9:37 AM, Eric Lovrien  wrote:

> I am not sure of how or the best way to structure my data in models.py. I
> would like to have an order and allow multiple items / products to be added
> to an order. I know I can do a ManyToMany field but not sure how I would
> connect a qty to that. I am sure there is some simple way of doing this, or
> a better way to model the data. I know in many ERP systems they have an
> orders table and then an orders details table. Below is just a quick
> mock-up of how i was thinking on to do it until I started thinking about
> the many items and qty to an single order issue came up. Can any one give
> me some tips on how to accomplish this?
>
>
>
> class Item(models.Model):
> name = models.CharField(max_length200)
> description = models.TextField(blank=True)
>
> def __unicode__(self):
>  return self.name
>
> class Customer
> first_name = models.CharField(max_length=100)
> last_name = models.CharField(max_length=100)
> address = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.name
>
> class order(models.Model):
> order = models.IntegerField(unique=True)
> customer = models.ForeignKey('Customer')
>
> --
> 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: Data Structure - Orders and multiple items

2013-04-01 Thread Siddharth Ghumre
Hi

As per my view you can modify your models as follows:-

class order(models.Model):
order_id = models.IntegerField(unique=True)
customer_id = models.ForeignKey('Customer')
item_id = models.ForeignKey('Item')




On Mon, Apr 1, 2013 at 10:30 AM, Lachlan Musicman  wrote:

> On 1 April 2013 15:07, Eric Lovrien  wrote:
> > I am not sure of how or the best way to structure my data in models.py. I
> > would like to have an order and allow multiple items / products to be
> added
> > to an order. I know I can do a ManyToMany field but not sure how I would
> > connect a qty to that. I am sure there is some simple way of doing this,
> or
> > a better way to model the data. I know in many ERP systems they have an
> > orders table and then an orders details table. Below is just a quick
> mock-up
> > of how i was thinking on to do it until I started thinking about the many
> > items and qty to an single order issue came up. Can any one give me some
> > tips on how to accomplish this?
>
>
> Use an intermediary model as described in the docs:
>
>
> https://docs.djangoproject.com/en/1.5/topics/db/models/#extra-fields-on-many-to-many-relationships
>
> This will be your best bet I think.
>
> L.
>
>
>
> >
> >
> >
> > class Item(models.Model):
> > name = models.CharField(max_length200)
> > description = models.TextField(blank=True)
> >
> > def __unicode__(self):
> >  return self.name
> >
> > class Customer
> > first_name = models.CharField(max_length=100)
> > last_name = models.CharField(max_length=100)
> > address = models.CharField(max_length=200)
> >
> > def __unicode__(self):
> > return self.name
> >
> > class order(models.Model):
> > order = models.IntegerField(unique=True)
> > customer = models.ForeignKey('Customer')
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> The new creativity is pointing, not making. Likewise, in the future,
> the best writers will be the best information managers.
>
>
> http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith
>
> --
> 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: how can i prevent a user from viewin a page without using the django @login decorator

2013-01-28 Thread Siddharth Ghumre
Hi

Are you storing the user data in some database table?
If yes, then you can search for the logged in user with the user data
present in database table.
If you dont find a match then you can send to some error page or re-login page.

-Siddharth
On Mon, Jan 28, 2013 at 8:32 AM, Okorie Emmanuel  wrote:
> i have a form that redirect a user to another page
> when it validates
>
>
> but again i discover that a user can view the that page by typing it on his
> or her url
> without following the normal process of validation
>
> how can i stop this, how can i force a user to see that redirect page only
> when he/she  comes only from the main form page, what i mean a user
> can only be redirected to the accept page only when he has the valid
> credentials
> otherwise he/she cannot view the accept page even if he entered the correct
> url
> on his browser.
>
>  i intend doing  that without django @login decorator
>  thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: Modelform and Ajax (Select a valid choice..... Error)

2012-12-13 Thread siddharth ghumre
Hey Chris

Thanks for the replybut i figured it out what was wrong.
:)
-Siddharth
On Thu, Dec 13, 2012 at 6:09 PM, Chris Cogdon  wrote:
> How are you populating the choices in the ChoiceField? Remember, you need to
> do this on BOTH the POST AND the non-POST versions of creating the form.
>
> But ChoiceField is a Form field, not a Model field... so its not perfectly
> clear what you're asking.
>
>
> On Tuesday, December 11, 2012 3:39:48 AM UTC-8, siddharth56660 wrote:
>>
>> Hi,
>>
>> I am facing problem in handling modelform and ajax together.
>> The situation is:-
>> I am using modelform to get display the form as ul in the template.
>> I have 3 ChoiceFields (country, state,city). On select of a country
>> from the dropdown, the valid states dropdown gets populated and on
>> select of a state the respective city dropdown gets populated.
>> For achieving the above functionality I am calling an ajax function
>> which returns me the available data of the other dropdown in Json Form
>> {stat_id, stat_name}
>> I am able to populate the data in next dropdown i.e state and city,
>> but when i click submit form it shows "Select a valid choice. 8 is not
>> one of the available choices"
>> 8 happens to be the stat_id in this case.
>> I have gone through google but dint find anything useful. Help is
>> really appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/NEBq73A9EyEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Modelform and Ajax (Select a valid choice..... Error)

2012-12-11 Thread siddharth ghumre
Hi,

I am facing problem in handling modelform and ajax together.
The situation is:-
I am using modelform to get display the form as ul in the template.
I have 3 ChoiceFields (country, state,city). On select of a country
from the dropdown, the valid states dropdown gets populated and on
select of a state the respective city dropdown gets populated.
For achieving the above functionality I am calling an ajax function
which returns me the available data of the other dropdown in Json Form
{stat_id, stat_name}
I am able to populate the data in next dropdown i.e state and city,
but when i click submit form it shows "Select a valid choice. 8 is not
one of the available choices"
8 happens to be the stat_id in this case.
I have gone through google but dint find anything useful. Help is
really appreciated.

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



Re: sqlsync help

2012-11-16 Thread siddharth ghumre
Hi Friend,

It would be really helpful if you paste the entire error msg.
No one can figure out what went wrong by looking at your previous mail.


On Tue, Nov 13, 2012 at 2:56 AM, Dennis Lee Bieber
 wrote:
> On Mon, 12 Nov 2012 01:47:17 -0800 (PST), hardik juneja
>  declaimed the following in
> gmane.comp.python.django.user:
>
>> i am trying to sync mysql to django using command python mange.py syncdb
>> and it is giving me long list of errors
> 
>> what to do???
>
> Cut the list of errors into your message requesting help?
>
> Otherwise we have the equivalent of: I'm trying to buy groceries but
> my car isn't moving; what's wrong?
>
> Possible answers: Someone stole the tires and the car is up on
> blocks; Out of gas; transmission is still in neutral; you don't have the
> key, hence the engine can't be started...
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: transfer one django app to another server

2012-11-15 Thread siddharth ghumre
You can just copy your app from your local machine to server.
Just keep in mind to do the necessary changes in the settings.py file.
Enjoy :)

On Thu, Nov 15, 2012 at 8:24 PM, Lewis  wrote:
> Hello,
>
> In order to transfer the app from local machine to another server. what
> should I do? Can I just copy everything or do I need to reinstall app that I
> install?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/YzudnzUw9vwJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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