Re: template include for Django 1.8

2016-07-13 Thread James Schneider
On Jul 13, 2016 6:54 PM, "Mike Dewhirst"  wrote:
>
> I need to include the contents of a css file in my template [1]
>
> The css content needs to exist within  and
 tags so that the pdf output software I'm using can see the styles.
>
> I can get the correct effect by copying and pasting the contents of the
css file into the template but that way madness lies!
>

Not necessarily. If that's the only location where this CSS is used, then
it may be appropriate to include it directly in the template.

> {% include %} exists but seems designed for other templates. And I can't
find it in the docs.
>

https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include

> Is there a way to include the content of a css file?
>

I'm reasonably confident that the include tag will do exactly what you want
it to do. Django is not going to care whether it is including HTML or CSS
or a recipe for chocolate French fries. It'll only care if other template
tags are included and cause other issues, but otherwise the content is
irrelevant. All the template system does is generate a text file,
ultimately.

I'm assuming this CSS file is located in your template directories and not
in your static files area so that the template system can find it.

-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%2BciUCGXTfH3hg6G105cLbParD1fD2iijbUtE3uJ682E1hNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: static files suspicious operation, os error, and list of paths

2016-07-13 Thread Michal Petrucha
On Tue, Jul 12, 2016 at 02:36:41PM -0700, Malik Rumi wrote:
> Michal,
> 
> > , it looks like somewhere, you're calling ``os.path.join(a, b)``, where
> the second argument starts with a slash
> 
> I've tried it both ways. The way I got findstatic to work was by taking off
> the leading slash, but so far I haven't figured out how to make that work
> so that the files are called.

I'm afraid I still don't have enough information to help you – you
still haven't provided the other details I asked for in my previous
email, i.e. the URL of a failing request, and a full traceback. While
we're at it, showing how you are referencing static files in your
templates wouldn't hurt either.

In the meantime, just two observations.

> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
> 
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'essell',
> 'csvimport2',
> 'debug_toolbar',
> 'account',
> )
> 
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'debug_toolbar.middleware.DebugToolbarMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.middleware.security.SecurityMiddleware',
> )
> 
> STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
> STATIC_URL = '/static/'
> 
> # Extra places for collectstatic to find static files.
> STATICFILES_DIRS = [
> os.path.join(BASE_DIR, 'static'),
> os.path.join(BASE_DIR, 'static/bootstrap'),
> os.path.join(BASE_DIR, 'static/bootstrap/css/'),
> os.path.join(BASE_DIR, 'static/bootstrap/fonts/'),
> os.path.join(BASE_DIR, 'static/bootstrap/js/'),
> os.path.join(BASE_DIR, 'static/css/'),
> os.path.join(BASE_DIR, 'static/email_templates/'),
> os.path.join(BASE_DIR, 'static/fonts/'),
> os.path.join(BASE_DIR, 'static/images/'),
> os.path.join(BASE_DIR, 'static/js/'),
> os.path.join(BASE_DIR, 'static/less/'),
> os.path.join(BASE_DIR, 'static/plugins/'),
> os.path.join(BASE_DIR, 'static/videos/'),
> ]

Do you have any specific reason to make those static files available
in two locations? As in, your videos will be available in both
/static/videos/some-video.wtf, and /static/some-video.wtf. Your
bootstrap assets will be available in three locations (/static/,
/static/bootstrap/, /static/bootstrap/whatever/). I fail to see how
that will lead to anything other than confusion and problems... You
might want to remove everything but the first element in this list,
and always use the full /static/somedir/another/somefile.ext paths to
reference static files.

> # Simplified static file serving.
> # https://warehouse.python.org/project/whitenoise/
> STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

Since you're using whitenoise, have you tried to follow the setup
instructions at http://whitenoise.evans.io/en/stable/django.html in
their entirety? I'm mostly referring to the middleware.

However, as even the whitenoise docs say, before you start playing
around with whitenoise, you should first make sure your basic
staticfiles setup is correct.

Cheers,

Michal

-- 
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/20160714061917.GA16002%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: running django 1.9 problem

2016-07-13 Thread Sergiy Khohlov
Simple way is using virtual environment. In this case version of system is
not important. I'm using Mac for coding without any issues.

12 лип. 2016 14:28 "Nicolas Favede"  пише:

> hi i am a bit used to python i have a mac coming with 2.7.6 version and
> install 3.4 that i can use if i call
> i installed with difficulties django 1.9
> it came
> there /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
> don't ask me why
> now i cannot import or work with
> PLEASE SOME 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b98bbc7f-111f-4d00-ab5d-23519ed67b46%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/CADTRxJMovX8jqUFQ1bJ%2Bwr6PP_0GR4kPPrTUaq2PQKwR%2B%2BDiWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


template include for Django 1.8

2016-07-13 Thread Mike Dewhirst

I need to include the contents of a css file in my template [1]

The css content needs to exist within  and 
 tags so that the pdf output software I'm using can see the styles.


I can get the correct effect by copying and pasting the contents of the 
css file into the template but that way madness lies!


{% include %} exists but seems designed for other templates. And I can't 
find it in the docs.


Is there a way to include the content of a css file?

Thanks

Mike


[1] without using the normal href="{{STATIC_URL}}styles.css" />


--
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/211bd384-b32f-f6ea-9ee8-3c6766ca8d25%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: django_bootstrap_calendar and admin backend

Hello Ludovic, what part of the code would you like me to post ? 

-- 
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/6dfb8f1c-70be-433f-b2fc-e79a3c1507f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Easiest way to ajax enable django forms

I want functionality such as add/delete line items to an order , do not 
want a form resubmit every time an item is added . What is the best way to 
do this without having to use angular/ react 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9fdac377-aeb0-4b5c-b3fc-f57a64b4f5f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I am not sure what “: command not found” means when I run virtualenvwrapper mkvirtualenv command

I am learning Linux and how to set-up a Django environment for the first 
time. I am not sure what “: command not found” means when I run 
virtualenvwrapper commands. Below is the command line sequence:

root@intranet-django:/home/lv/# workon
root@intranet-django:/home/lv/# mkvirtualenv temp
Using base prefix ‘/usr’
New python executable in /root/.virtualenvs/temp/bin/python3
Also creating executable in /root/.virtualenvs/temp/bin/python
Installing setuptools, pip, wheel…done
:command not found
root@intranet-django:/home/lv/# workon
temp
root@intranet-django:/home/lv/#

-- 
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/8161687f-10f4-4534-8ac2-a880c36e03a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question regarding uninstalling Django system-wide.

Thanks Mike

On Tuesday, July 12, 2016 at 8:03:18 PM UTC-4, Mike Dewhirst wrote:
>
> On 13/07/2016 1:55 AM, Leo wrote: 
> > I am learning how to use Django. With my first attempt I did not use a 
> > virtual environment instead installed Django system-wide. Now I have 
> > learned to utilize virtual environments. Can you help me learn how to 
> > uninstall the system-wide Django instance? Also, I can't recall if I 
> > used pip or apt-get. Or do I need to be concerned with this at all, 
> > meaning will the base install conflict with instances installed in the 
> > virtual environments? 
>
> sudo pip uninstall django 
>
> sudo apt-get remove django 
>
> The base install is unnecessary if Django is installed in the venv and 
> it should not conflict. 
>
> It is best to avoid any base installs unless you *know* they will be 
> used by all venvs 
>
>
> > 
> > 
> > Your help is appreciated. 
> > 
> > Leo 
> > 
> > -- 
> > 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 https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
> > 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/99ad53fd-8951-46f1-90d8-b88f760ee586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django PostGis BUG?



I'm trying to create my database tables (*python manage.py migrate*) using 
Postgis. However it fails because the driver try to connect do default 
database "postgres" which is not my default name. I'm using django==1.8 and 
psycopg2==2.6.2 

If i look the documentation of psycopg (
http://initd.org/psycopg/docs/module.html) The basic connection parameters 
are:

dbname – the database name (only in the dsn string)database – the database name 
(only as keyword argument)user – user name used to authenticate
password – password used to authenticate
host – database host address (defaults to UNIX socket if not provided)
port – connection port number (defaults to 5432 if not provided)

Here is my database connection: 

DATABASES = {
 'default': {
 'ENGINE': 'django.contrib.gis.db.backends.postgis', 
 'NAME': '',
 'USER': '',
 'PASSWORD': '',
 'HOST':  ‘bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'
 'PORT': '5432', 
 
'URI':'postgis://myuser:mypassw...@bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com:5432/bdsn15qbq8xaqoa'}}

I have added some trace to the connexion and as we can see, the driver uses 
*postgres* as name.

[('dbname', '**postgres**'), ('user', 'myuser'), ('password', 'mypassword'), 
('host', 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', 
'5432’)]

After some research, i have edited the file :

 *vi django/db/backends/postgresql_psycopg2/base.py*


Function : 


def get_connection_params(self):

settings_dict = self.settings_dict

# None may be used to connect to the default 'postgres' db

if settings_dict['NAME'] == '':

from django.core.exceptions import ImproperlyConfigured

raise ImproperlyConfigured(

"settings.DATABASES is improperly configured. "

"Please supply the NAME value.")

conn_params = {

'database': settings_dict['NAME'] or 'postgres',

}

print settings_dict

conn_params.update(settings_dict['OPTIONS'])

conn_params.pop('isolation_level', None)

if settings_dict['USER']:

conn_params['user'] = settings_dict['USER']

if settings_dict['PASSWORD']:

conn_params['password'] = force_str(settings_dict['PASSWORD'])

if settings_dict['HOST']:

conn_params['host'] = settings_dict['HOST']

if settings_dict['PORT']:

conn_params['port'] = settings_dict['PORT']

return conn_params


*AND ADDED : *


*   if settings_dict['DBNAME']:*

*conn_params['dbname'] = settings_dict['DBNAME']*

Now if i relaunch the database creation : python manage.py migrate it is 
working fine using the good connection URI. 

[('dbname', '**mydatabase**'), ('user', 'myuser'), ('password', 'mypassword'), 
('host', 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', 
'5432’) 

It is a bug ? 

Thanks a lot 
Christophe

-- 
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/d57803ab-eeb1-4f5a-a0ca-2725730178a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


djangoCMS 3.3.1 released

Hello all,

We've released djangoCMS 3.3.1
Version 3.3.1 fixes dozens of issues with djangoCMS providing additional 
stability for the 3.3.x milestone.
It also offers a few notable improvements to UI/UX for end-users and 
additional capabilities for project developers.
You can read more in our blog post 

.

Cheers,
Paulo

-- 
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/7b8937ba-1968-4ad8-aa1f-93461537978a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How manually, in Django 1.9, determinate all urls in a project without the django-extension`s command show_urls?

How about just to look at django-extension source code? It's open source
after all...

On Mon, Jul 4, 2016 at 8:48 AM, Seti Volkylany 
wrote:

> I don`t found answer for Django 1.9 there
> http://stackoverflow.com/questions/1275486/django-how-can-i-see-a-list-of-urlpatterns
> and there
> http://stackoverflow.com/questions/1828187/determine-complete-django-url-configuration
> .
>
> --
> 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/8648b67c-a5ff-471c-b940-81dbce18d0b2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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/CAHn91ocM_aq1P6etA2bngoFVuDQwY%3Dwd1PpWr5OYt1GAfgCLzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I fetch table values in pdf using django?

http://stackoverflow.com/questions/25665/python-module-for-converting-pdf-to-text



2016-07-12 10:19 GMT-03:00 Derek :

> Here's a good tutorial:
>
>
> https://assist-software.net/blog/how-create-pdf-files-python-django-application-using-reportlab
>
>
> On Tuesday, 12 July 2016 13:29:00 UTC+2, Aslam Sha wrote:
>>
>>
>> How do I fetch table values in pdf using django?
>>
>> ** I AM USING REPORTLAB FOR PDP*
>>
> --
> 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/b6c6c51e-c8c5-4c53-9d2b-39d6c3adf37d%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Ricardo Daniel Quiroga

-- 
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/CAO2-wHYtxDz4_qWz5wRNcd1EvKVmUA98TRY0vd1497oUHMtYpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django migration to postgres - 502 badgateway error in ngnix

Am migrating to postgres.

My local configuration is runnign without ngnix and my complete migration 
porcess is working fine in my development machine.

During deployment to production, where the ngnix is configured to run 
django - I get the error as: 

"upstream prematurely closed connection while reading response header from 
upstream"

This has happened when I do the deployment of postgres settings in the 
settings. The upstream is pointing to "uwsgi" config. 

Not sure, whether its an existing issue.
Can someone help me. Is someone facing the same issue out there? 

-- 
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/be71645e-9c64-4864-9ae9-83dacf4d2f5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[no subject]



--
| Tim Dyer | Sounds Like Design | 07739048398 | t...@soundslikedesign.co.uk

--
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/93fd86f2-952f-9fd2-61f7-e4bb84772ae5%40soundslikedesign.co.uk.
For more options, visit https://groups.google.com/d/optout.


Re: How can I change the TabularInline "title" on Django Admin?

On Tue, Jul 12, 2016 at 2:42 PM, Fellipe Henrique 
wrote:


> On Tue, Jul 12, 2016 at 1:52 PM, Ramiro Morales  wrote:
>
>> Where the 'Conjunto de dados' seen in the screenshot title comes from? Is
>> the code you posted actually in sync with it?
>
>
> Sorry about that, I take the screenshot before change these text to
> "DataSet"...
>
> [image: Inline image 1]
>
> My problem is, the second "Dataset" (on light gray line) and
> "Dataset_users object"* *
> 
> 



I've prepared this simplified app.

Note: All the is completely centered around controlling the labels in the
admin views, this can mean things get completely ugly on ther UI areas.

The Dataset model setup is basically what you posted originally, the Sample
model is very similar to Dataset but the M2M relationship between User and
Sample is defined through an explicit SampleUserRel model. See


https://docs.djangoproject.com/en/1.9/topics/db/models/#intermediary-manytomany


https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.ManyToManyField.through

and


https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#working-with-many-to-many-intermediary-models

sections of the Django documentation.

#
# models.py
from __future__ import unicode_literals

from django.db import models
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class User(models.Model):
username = models.CharField(max_length=200, blank=True, null=True)
email = models.EmailField(blank=False, unique=True)

def __str__(self):
return self.email


@python_2_unicode_compatible
class Dataset(models.Model):
active = models.BooleanField(default=True)
title = models.CharField(max_length=250)
users = models.ManyToManyField(User)

def __str__(self):
return self.title


@python_2_unicode_compatible
class Sample(models.Model):
active = models.BooleanField(default=True)
title = models.CharField(max_length=250)
users = models.ManyToManyField(User, through='SampleUserRel')

def __str__(self):
return self.title


@python_2_unicode_compatible
class SampleUserRel(models.Model):
user = models.ForeignKey(User)
sample = models.ForeignKey(Sample, verbose_name='this can be set with
the verbose_name option of the FK field to the remote model in the
intermediate model')

def __str__(self):
return "this can be set with the intermediate model's __str__
method"

#
# admin.py
from django.contrib import admin

from .models import Dataset, User, Sample, SampleUserRel


class DatasetInline(admin.TabularInline):
model = Dataset.users.through
verbose_name = 'this can be set with
{Stacked,Tabular}Inline.verbose_name'
verbose_name_plural = 'this can be set with
{Stacked,Tabular}.verbose_name_plural'


class SampleUserRelInline(admin.TabularInline):
model = SampleUserRel
extra = 1
verbose_name = "this can be set with intermediate's model verbose_name
and overridden with {Stacked,Tabular}Inline.verbose_name"
verbose_name_plural = "this can be set with intermediate model's
verbose_name_plural and overridden with
{Stacked,Tabular}Inline.verbose_name_plural"


class UserAdmin(admin.ModelAdmin):
list_display = ('email',)
inlines = [DatasetInline, SampleUserRelInline]


admin.site.register(User, UserAdmin)
admin.site.register([Dataset, Sample])

Btw, something like this is what we talk about when we ask for an excerpt
of the code with only the relevant parts, please take the time to prepare
things by stripping code unrelated to the issue at hand before posting your
code. Help us to help you.

The above setup results in the following Change User view:

[image: Inline image 1]

Hoping this is of help,

-- 
Ramiro Morales
@ramiromorales

-- 
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/CAO7PdF_dupadcYtQpwWaCOBxTZ13G-rHh%2B4u2sQLbMwa0UJwnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I change the TabularInline "title" on Django Admin?

On Tue, Jul 12, 2016 at 8:39 PM, Lachlan Musicman  wrote:

> There's a ticket for this in the tracker iirc, but I can't find it now. I
> think the reason is because that's the name of the DB field - it's not
> localizable (in so much as we don't localize db field names).
>

That was mi recollection too. But I've been unable to find it.

Regards,

-- 
Ramiro Morales
@ramiromorales

-- 
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/CAO7PdF9ExFBK48FYB4q%2BOHDFxPxM0KoY6-0DbTn-Aip2U4q1jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django_bootstrap_calendar and admin backend

Code would be more useful to understand what is happening.

Or you can use the django test client [1] to see what the view is
returning as context. The list of event might be empty.

[1] 
https://docs.djangoproject.com/en/1.9/intro/tutorial05/#the-django-test-client

2016-07-12 16:49 GMT+02:00 Cronos Cto :
> Ok so I was able to fix one of my problems, consisted in framework not
> recognizing the database, had to delete it and migrate everything again.
> Right now I can add events in my backend, but when I check my website the
> day where I have set the  event lights up, but does not show title, hour or
> anything...
>
>
> --
> 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/09215dec-54a1-48ea-8b47-bb71a40ce453%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%2BTabas14xsff%2BkKoWrrXi5G92vL7UkkKPw8-VxyTBSY6Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: install of django 1.9

Assuming you have created a virtual env with `virtualenv myvenv`
 *  activate the virtualenv: `source myvenv/bin/activate`
 *  install django: `pip install django`
 * create a django project: `djang-admin startproject myproject`
 * move into that project: `cd myproject`
 * create an app for your project: `python manage.py myapp`
 * start the django dev server: `python manage.py runserver`

Activating the virtualenv is important.
When myvenv is activated, you use pip and python from myvenv, not from
your system. Everything should be a lot easier if you do that.
Also, you only need to activate the virtualenv for using pip, python
and command installed with pip in the virtualenv. You don't need to
worry about that when editing file.
You need to activate the virtualenv for running pip, django-admin and manage.py.

2016-07-12 11:23 GMT+02:00 Nicolas Favede :
> hi everybody
> i install with difficulties butdjango 1.9 on my imac
> i am used to python
>run on 2.7.6 coming with terminal but i also installed 3,4 version that i
> call and use when i want
> django came there   library/frameworks/python
> frameworks/version3.4/lib/python3.4/django
> don't ask me why
> now i cannot import django  or if i can cannot use admincmd
> i create a myvenv where i try to start project but very difficult
> PLEASE SOME 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/99957129-04ad-4d5a-9bba-6819fd93e5af%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%2BTYwVEBJCWxQQFYwVE0hK4%3DN7P57AymRsSGEsN8ijdX0eQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Custom Models

Hi,

If you find yourself doing that a lot in your project, yes a custom manager 
is the way to go. Keep in mind that you can more then one manager attached 
to your model, but the order matters 
. 
For the admin purposes, you can attach the default manager to your model, 
and call it by overriding the get_queryset() ModelAdmin method from here 


# models.py
class Article(models.Model):
   
   objects = ExcludeExpiredManager()
   with_expired_objects = models.Manager()

# admin.py
class ArticleAdmin(admin.ModelAdmin):

def get_queryset(self, request):
qs = self.model.with_expired_objects.get_queryset()
ordering = self.get_ordering(request)
if ordering:
qs = qs.order_by(*ordering)
return qs

On a personal note, I prefer defining custom queryset and use the 
as_manager() 

 method 
to get the manager, but in your case you might need the from_queryset() 
, 
but I've never used it myself.

Hope that helps

On Tuesday, 12 July 2016 12:54:26 UTC+1, AT wrote:
>
> Being new to Django I wonder if someone could point me in the right 
> direction and I apologise in advance if this is an obvious question.
>
> I have a model with a field that sets an expiry date.
>
> In my ListView I have the following:
> queryset = 
> Article.objects.filter(expiry_date__gt=datetime.now()).order_by('expiry_date')
> Every thing works fine at this point.
>
> Would it be better to include this in a custom manager instead and if so 
> how is this handled in the view or is it done just by including:
> model = Article
>
> A second point is, if I do this will the expired articles still be 
> accessible via the admin?
>
> Many 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bcb12d7b-41ad-4de8-8afa-74b3de9d5707%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.