Re: How 2 access the Primary model's ID in the Foreign model??

2019-01-01 Thread mazz ahmed
Hello,
hope everyone doing well. I am working on tornado framework. I want to use
admin panel for that app but I am getting a single solution using
Django alongside of tornado for admin panel. I want to use some package in
the tornado which gives me admin panel.
If anyone knows let me know Please.
Thanks&Regars Mazz Ahmed

On Tue, Jan 1, 2019 at 12:31 PM Peter of the Norse 
wrote:

> Also song.album_id will work as well, and faster too.
>
> Sent from my iPad
>
> > On Dec 4, 2018, at 3:43 PM, Mike Dewhirst  wrote:
> >
> >> On 5/12/2018 7:07 AM, Sourajit Mohanty wrote:
> >> I have 2 model classes Album and Songs(where Song is the Foreign key)
> >> I want to access the Albums ID in the Songs class..
> >> How can I do that??
> >>
> >
> >
> > song = Songs.objects.get(name='Happy birthday')
> > albumid = song.album.id
> >
> > Similarly ...
> >
> > album = song.album
> >
> > This assumes your model code in Songs names the foreign key 'album'
> >
> > --
> > 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/d7e6a11e-e55d-3393-6937-31dee72d4035%40dewhirst.com.au
> .
> > 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/02EB60C5-DA5F-4D9B-9FFC-3797470F8226%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/CABuXbh8g%2Bq8s6iJorf%3DCrBA%2B3tUb24y9UxPoFEbRa8TgpT%2B2cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: MySQL accepts 0 for a primary key but Django does not

2019-01-01 Thread Derek
Hi Simo


My custom app has no particular structure - its really just a collection of 
files and utilities that are commonly used across multiple apps.  It gets 
imported, along with all the others, in the settings file.

When I follow your suggestion of just referring to "custom", I get this 
error:

Traceback (most recent call last):
  File "manage.py", line 14, in 
execute_from_command_line(sys.argv)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 399, in execute_from_command_line
utility.execute()
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 280, in execute
translation.activate('en-us')
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
 
line 130, in activate
return _trans.activate(language)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 188, in activate
_active.value = translation(language)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
 
line 159, in _fetch
app = import_module(appname)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/importlib.py",
 
line 40, in import_module
__import__(name)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/massadmin/__init__.py",
 
line 28, in 
from django.contrib import admin
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
 
line 6, in 
from django.contrib.admin.sites import AdminSite, site
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
 
line 4, in 
from django.contrib.admin.forms import AdminAuthenticationForm
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
 
line 6, in 
from django.contrib.auth.forms import AuthenticationForm
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
 
line 17, in 
from django.contrib.auth.models import User
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
 
line 48, in 
class Permission(models.Model):
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 264, in add_to_class
value.contribute_to_class(cls, name)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/options.py",
 
line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/__init__.py",
 
line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
 
line 198, in __getitem__
backend = load_backend(db['ENGINE'])
  File 
"/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
 
line 131, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'custom' isn't an available 
database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'


On Sunday, 30 December 2018 17:35:36 UTC+2, Simon Charette wrote:
>
> Hello Derek,
>
> Not sure of your custom module structure but you'll want to point ENGINE 
> to 'custom'
> and not 'custom.base' just like you were pointing to 
> 'django.db.backends.mysql' and
> not 'django.db.backends.mysql.base'.
>
> Cheers,
> Simon
>
> Le dimanche 30 décembre 2018 04:01:59 UTC-5, Derek a écrit :
>>
>> Hi Simon
>>
>> Much appreciated.
>>
>> However, I am obviously doing something wrong.  If I save that code into 
>> a file called "base.py" stored in my 'custom' app, and then change my 
>> settings file to have:
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'custom.base',  # WAS: 'django.db.backends.mysql',
>> 'NAME': DB_NAME,
>> 'USER'

Re: MySQL accepts 0 for a primary key but Django does not

2019-01-01 Thread mazz ahmed
Hello,
hope everyone doing well. I am working on tornado framework. I want to use
admin panel for that app but I am getting a single solution using
Django alongside of tornado for admin panel. I want to use some package in
the tornado which gives me admin panel.
If anyone knows let me know Please.
Thanks&Regars Mazz Ahmed


On Tue, Jan 1, 2019 at 2:30 PM Derek  wrote:

> Hi Simo
>
>
> My custom app has no particular structure - its really just a collection
> of files and utilities that are commonly used across multiple apps.  It
> gets imported, along with all the others, in the settings file.
>
> When I follow your suggestion of just referring to "custom", I get this
> error:
>
> Traceback (most recent call last):
>   File "manage.py", line 14, in 
> execute_from_command_line(sys.argv)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 280, in execute
> translation.activate('en-us')
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
> line 130, in activate
> return _trans.activate(language)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 188, in activate
> _active.value = translation(language)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 159, in _fetch
> app = import_module(appname)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/utils/importlib.py",
> line 40, in import_module
> __import__(name)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/massadmin/__init__.py",
> line 28, in 
> from django.contrib import admin
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py",
> line 6, in 
> from django.contrib.admin.sites import AdminSite, site
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/sites.py",
> line 4, in 
> from django.contrib.admin.forms import AdminAuthenticationForm
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/forms.py",
> line 6, in 
> from django.contrib.auth.forms import AuthenticationForm
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/forms.py",
> line 17, in 
> from django.contrib.auth.models import User
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
> line 48, in 
> class Permission(models.Model):
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
> line 96, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py",
> line 264, in add_to_class
> value.contribute_to_class(cls, name)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/models/options.py",
> line 124, in contribute_to_class
> self.db_table = truncate_name(self.db_table,
> connection.ops.max_name_length())
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/__init__.py",
> line 34, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
> line 198, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File
> "/home/gamesbook/.venvs/s2s/local/lib/python2.7/site-packages/django/db/utils.py",
> line 131, in load_backend
> raise ImproperlyConfigured(error_msg)
> django.core.exceptions.ImproperlyConfigured: 'custom' isn't an available
> database backend.
> Try using 'django.db.backends.XXX', where XXX is one of:
> u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
>
>
> On Sunday, 30 December 2018 17:35:36 UTC+2, Simon Charette wrote:
>>
>> Hello Derek,
>>
>> Not sure of your custom module structure but you'll want to point ENGINE
>> to 'custom'
>> and not 'custom.base' just like you were pointing to
>> 'django.db.backend

Posting data from templates to views.py without using forms.

2019-01-01 Thread Surajeet Das
Well , I want to post data from templates to views.py by clicking a button 
without using forms. Basically the button should not be of type submit 
because I don't want the page to be refreshed .I want to view the data from 
database after the query in the same page. 

-- 
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/9c195b3e-ab87-4a5a-a82d-ed8c5885477b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Posting data from templates to views.py without using forms.

2019-01-01 Thread pradam
Hi Surjeet,

Then you should rely on ajax call or angularjs using ng-click.

On Tue, Jan 1, 2019 at 8:16 PM Surajeet Das  wrote:

> Well , I want to post data from templates to views.py by clicking a button
> without using forms. Basically the button should not be of type submit
> because I don't want the page to be refreshed .I want to view the data from
> database after the query in the same page.
>
> --
> 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/9c195b3e-ab87-4a5a-a82d-ed8c5885477b%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/CAGGVXBM2y9bKUUq%2Bg-uwFLJhAZw7B%2B%3DqmDH6LUbVRtdmF4_0hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Posting data from templates to views.py without using forms.

2019-01-01 Thread pradam
Hi Surjeet,

Then you should rely on ajax call or angularjs using ng-click.

On Tue, Jan 1, 2019 at 8:16 PM Surajeet Das  wrote:

> Well , I want to post data from templates to views.py by clicking a button
> without using forms. Basically the button should not be of type submit
> because I don't want the page to be refreshed .I want to view the data from
> database after the query in the same page.
>
> --
> 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/9c195b3e-ab87-4a5a-a82d-ed8c5885477b%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/CAGGVXBMzhWJZmP5uG_V5G%2B18hxELgTg2ozX2JKRcsQc1pdcNnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Zip file upload

2019-01-01 Thread Suresh
hi guys,
How to upload zip file and save unzip file in django?

-- 
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/b1643e14-b517-43f1-b8f5-b471ee3dadef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Zip file upload

2019-01-01 Thread Joel Mathew
No ready made solution. You have to come up with your own solution. Use
form to upload file

On Wed, 2 Jan, 2019, 9:57 AM Suresh  hi guys,
> How to upload zip file and save unzip file in django?
>
> --
> 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/b1643e14-b517-43f1-b8f5-b471ee3dadef%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/CAA%3Diw_-5uxLEfzkbYpyN-6Tn52ass6RxJTWw8oP_L_wsZ7F-rQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.