Re: how to use view function in another function of view in django

2016-06-16 Thread 'Abraham Varricatt' via Django users
I'm going to go out and make a random guess that when you say "use a view 
inside another view" with respect to the code you posted, you want all 
calls to index() or list() to render the base view. In that case just use 
return. i.e.

def index(request):
  return base(request)

Yours,
Abraham V.




On Wednesday, June 15, 2016 at 11:24:18 PM UTC+5:30, hossein wrote:
>
> def base(request):
> j=Job.objects.all()
> a=Ab.objects.all()
> return render(request,'base.html',{'j':j, 'a':a})
>
> def index(request):
> base(request)
> x=X.objects.all()
> return render(request, 'index.html',{'x':x})
>
> def list(request):
> base(request)
> z=Z.objects.all()
> return render(request, 'list.html',{'z':z})
>
>

-- 
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/8330c99d-59ba-45da-b500-b2c40ed95daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: view must be a callable or a list/tuple in the case of include(). in urls.py

2016-09-05 Thread 'Abraham Varricatt' via Django users
Not sure what the issue is without more info about the error, but is the 
regular expression for that view correct? Assuming that you want to divert 
folks to the root of your site can you try the following?

url(r'^/$', views.dashboard, name = 'dashboard')


NOTE: if the error still persists, it will help if you include the full 
traceback in your email.

Yours,
Abraham V.



On Monday, September 5, 2016 at 6:36:37 PM UTC+5:30, arun kumar wrote:
>
> Hi,
>
>I'm working in Django 1.10 and I got the type error  in the below file 
> at this line "* url(r'^$', views.dashboard, name = 'dashboard'),*"
>
> *from django.conf.urls import include, url*
> *from . import views*
>
> *urlpatterns = [*
> *#preview login view*
> *#url(r'^login/$',views.user_login, name='login')*
>
> *# logged - in user dashboard*
> *url(r'^$', views.dashboard, name = 'dashboard'),*
>
> *#login / logout urls*
> *url(r'^login/$', 'django.contrib.auth.views.login', name='login'),*
>
> *url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),*
>
> *
> url(r'^logout-then-login/$','django.contrib.auth.views.logout_then_login', 
> name='logout_then_login')*
>
> *]*
>
> I'm new to Django and stuck because of this 
>

-- 
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/e58d1158-ad6b-47af-8ae9-be77e08e9ee3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hi, i'm new to django i need some mini project which contain atleast 4 page for go through how it works

2016-08-31 Thread 'Abraham Varricatt' via Django users
This might be silly to ask but - can we assume you've completed the django 
tutorial?

On Monday, 29 August 2016 16:56:33 UTC+5:30, rajeshkmr9583 wrote:
>
> Hi, 
>
>  i'm new to Django i need some mini project which contain at least 4 
> page for go through how it works..
>
> 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/30c9a6ac-a9aa-4490-a636-c218c7fba254%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting Start Django

2016-08-31 Thread 'Abraham Varricatt' via Django users
It's nice that you are on Ubuntu. :)  Here is a quick and dirty way to get 
up to speed, (going to assume you will use python3)

# Installing virtualenv globally
$ sudo apt-get update
$ sudo apt-get install python3-pip
$ sudo pip3 install virtualenv

Once you have that done, navigate to an empty directory to create a new 
virtualenv folder, activate it, and install django!

$ mkdir test
$ cd test
$ virtualenv --python=python3 VENV
$ source VENV/bin/activate
(VENV)$ pip install django
(VENV)$ django-admin startproject mysite


...


(VENV)$ deactivate # to turn off the virutualenv, or just close the 
terminal session
$



Yours,
Abraham V.








On Wednesday, 31 August 2016 17:47:18 UTC+5:30, jsroyal wrote:
>
> Hello guys,
> I am newbie in Django and started learning with Standard Documentation 
> version: 
> *1.10.I *already Install Django 1.10 and Python 3.4 in Linux Ubuntu 15.04  
> But in first phage I got some problem 
> I type command 
>
> django-admin startproject mysite
>
> error:
> Cannot find installed version of python-django or python3-django
> Need some help to get out.
> Stay strong 
> JS
>

-- 
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/28f0e8f0-9183-42f9-97fd-365286f432d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-15 Thread 'Abraham Varricatt' via Django users
The idea of doing a POST request during template rendering seems weird. As 
others have mentioned - that's not the place for it. 

But perhaps you issue could be a matter of performing your POST operation 
on the client side, instead of the django server? In that case, it might be 
worth investigating if you could code in some JS inside your template so 
that when the client's browser loads it, the POST operation is called and 
changes are made appropriately on the site. 

Yours,
Abraham V.


On Saturday, 10 September 2016 23:15:28 UTC+5:30, Al Johri wrote:
>
> I'm experimenting with creating templates out of subtemplates. These 
> subtemplates can be either (a) simple text or (b) a hash representing a 
> sentence (i.e. {subject: "Dog", verb: "eat", object: "my {{var}}", tense: 
> "past"}). I would like to run the hashes through a realization engine which 
> would render as "Dog ate my homework" given a context dictionary of {var: 
> "homework"}. The realization engine is accessed via a REST API.
>
> Does that make sense?
>
> On Friday, September 2, 2016 at 1:38:39 AM UTC-4, Constantine Covtushenko 
> wrote:
>>
>> Hi All,
>> There is no valuable reason to do it in the template. And no matter how 
>> to ate using it, cause template should only present view model(s).
>>
>> But if you tell us your intention may be we can suggest a better place 
>> for such request?
>>
>> Regards,
>>
>> On Sep 2, 2016 6:03 AM, "Al Johri"  wrote:
>>
>>> Ludovic,
>>>
>>> I'm using the templates for a different purpose, not in a web framework 
>>> or view.
>>>
>>> Thanks,
>>>
>>> Al
>>>
>>> On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote:

 I wouldn't do it this way. 
 Personally, I would make the POST request in the view function, put 
 the return value in the context. The template isn't a good place to 
 have logic. It should only take data and format them. 

 2016-09-01 5:33 GMT+02:00 Al Johri : 
 > Hi Django Users, 
 > 
 > I want to make a custom template tag where the tag's renderer needs 
 to make 
 > a POST request. 
 > 
 > 
 https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
  
 > 
 https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations
  
 > 
 > Is it possible to render the nodes of a template in multiple threads? 
 I 
 > would ideally like those POST requests to happen at the same time. 
 > 
 > Does anyone know of some similar project? 
 > 
 > Thanks, 
 > 
 > Al 
 > 
 > -- 
 > 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/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%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...@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/7eaa219b-ddee-4fa2-8ffb-37d04f168965%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/80de9c3d-5ca6-40ba-b521-9cb719a25f9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Package a virtualenv to deploy across multiple systems?

2016-09-21 Thread 'Abraham Varricatt' via Django users
Hello,

Do we have any standard/recommended way to distribute the python virtualenv 
used in a django application across multiple servers?

I'm able to write a provisioning script to do the following on a server,

(for brevity, this is just a high-overview)
* Clone the master branch of my django project
* Download, compile and alt-install python 3.5 from sources
* Create a virtualenv folder and configure my environment according to the 
requirements.txt of my django project
* setup httpd conf files, restart server .. etc

The OS I'm primarily targeting is centos7. For that matter, I'm doing my 
compiling on a centos7 box as well. 

My concern is that it feels wasteful to repeat the above steps on every 
system if I'm trying to scale across multiple machines. Is it possible to 
just provision the virtualenv on a single system, zip the folder and 
copy-paste to whichever systems I want to deploy to? Are there any concerns 
I need to be aware of, if I'm going by this approach?

Confused about django provisioning options,
Abraham V.

-- 
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/31679960-a802-469c-aea9-6431ea765735%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drawback of delete all migrations file

2016-12-09 Thread 'Abraham Varricatt' via Django users
Hello Sylvain,

I think you have two concerns here,

On Friday, December 9, 2016 at 1:39:50 PM UTC-5, Sylvain Dégué wrote:

> SO im thinking about reset completly my production database and remove all 
> the migrations to start fresh. I dont have much data in the production 
> database so its probably the best time.


>
> Is there any drawback to flushing the database and removing the migrations 
> files 


What is impact of removing migrations?
The migrations store information about how you changed your database schema 
over time. If this historical information is un-necessary for you, then 
there's no point in having it around.

What is impact of flushing the database?
This is something only you can answer - we have no knowledge of your 
business, and only you will know how best to support your customers. But 
since we are talking about a production database, might I offer an 
alternative? Take a backup of your database and store it somewhere. You 
don't need to keep it running, but having it around might be useful later 
on. 

Yours,
Abraham V.

-- 
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/0218756e-00b4-46ab-9eea-e1f01b491117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filling out a form using a json file

2016-12-12 Thread 'Abraham Varricatt' via Django users
Hello Jochen,

On Monday, December 12, 2016 at 9:17:11 AM UTC-5, joche...@gmail.com wrote:
>
>
> for editing Objects, but it seems that those views can only deal with 
> objects that already are in the database.  So is there a more 
> idiomatic way to solve this or am I stuck with the above solution? 
>

What about using the forms validate() method? i.e. if the user has not 
filled in all the JSON details, return a validation error. This should give 
them the opportunity to make edits or re-type as needed.

 

> On another note, there are several Models I want to work with in 
> this way so it would be even better if I could select the model 
> class according to the contents of the json file. 
>

This sounds like a validation job to me. Just put in all the logic checks 
into the validate() method. Bear in mind that you are likely to receive bad 
input, so handle accordingly. 

Yours sincerely,
Abraham V.

-- 
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/ed0b8b47-9922-45e1-9899-745ff6197275%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to swap 1.8 and 1.10/1.11 Admin static files

2017-05-30 Thread 'Abraham Varricatt' via Django users
How ... did you impose our will on this user? ;) I'd like to hear more ... 
for peaceful research purposes, of course.

-Abraham V.


On Monday, May 29, 2017 at 9:19:01 PM UTC-4, Mike Dewhirst wrote:
>
> Cancel this question. We will force the user to comply with our reality. 
>
> Cheers 
>
> Mike 
>
> On 16/05/2017 5:42 PM, Mike Dewhirst wrote: 
> > I have a user who is keen to revert to the "old" 1.8 look and feel for 
> > his company now that we have upgraded to 1.10. 
> > 
> > First question is it even possible? 
> > 
> > I have tested this using blunt force and at first glance it *seems* 
> > possible in both directions. However I have a suspicion there might be 
> > tie-ins I have not discovered. Also. I haven't yet tried 1.11. 
> > 
> > If it is feasible ... 
> > 
> > Second question is how to do it. 
> > 
> > I have stared long and hard at settings. I have this ... 
> > 
> > STATICFILES_DIRS = [ 
> > os.path.join(BASE_DIR, 'static/').replace('\\', '/'), 
> > os.path.join(BASE_DIR, 'company/static/').replace('\\', '/'), 
> > os.path.join(BASE_DIR, 'substance/static/').replace('\\', '/'), 
> > os.path.join(BASE_DIR, 'workplace/static/').replace('\\', '/'), 
> > ] 
> > 
> > and 
> > 
> > STATICFILES_FINDERS = [ 
> > 'django.contrib.staticfiles.finders.FileSystemFinder', 
> > 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
> > ] 
> > 
> > and I can get the user (company) from the request and I can create a 
> > company subdir under 'company/static//' if that's where I 
> > should be putting the admin files from 1.8. But then how do I tweak 
> > the settings so the Admin uses the preferred company static files for 
> > just that user? 
> > 
> > Maybe instead, there is a company specific preference I can establish 
> > to provide '/static/admin_1.8' for that user? 
> > 
> > Maybe I need to have company-specific Admin templates which override 
> > the block which reads the static files based on a company preference? 
> > 
> > Any hints? 
> > 
> > Thanks 
> > 
> > Mike 
> > 
>
>

-- 
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/a1d84a3a-049b-4ba4-9641-579dab3e5f53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ANN: django-admin-tools 0.8.1 released

2017-05-30 Thread 'Abraham Varricatt' via Django users
By chance do you have any screenshots in your documentation?

-Abraham V.


On Tuesday, May 30, 2017 at 8:39:54 AM UTC-4, izi wrote:
>
> Hello, 
>
> We are happy to announce the availability of the version 0.8.1 of 
> django-admin-tools: 
> https://pypi.python.org/pypi/django-admin-tools/0.8.1 
>
> Django-admin-tools is a collection of extensions/tools for the default 
> django administration interface, it includes: 
> * a full featured and customizable dashboard, 
> * a customizable menu bar, 
> * tools to make admin theming easier. 
>
> This version fixes some issues and adds support for Django 1.11. 
>
> Thanks to all the people who contributed to this release. 
>
> The project is hosted on Github: 
> https://github.com/django-admin-tools/django-admin-tools 
>
> Django-admin-tools is generously documented, you can browse the 
> documentation online here: 
> https://django-admin-tools.readthedocs.org/ 
>
> Regards, 
>
> -- 
> The django-admin-tools team 
> https://github.com/django-admin-tools/ 
>
>

-- 
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/d8180d1e-301a-4c51-9040-7a5397f76b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: uWSGI ModuleNotFoundError Django 1.11

2017-06-02 Thread 'Abraham Varricatt' via Django users
Consider thinking of the problem this way - you are trying to tell uwsgi to 
run a django project located within a certain directory using a virtualenv 
located in another directory. 

What James is asking is, if you have checked that the virtualenv you are 
using has all the dependencies to run your django project. A trivial way to 
do this check, is to simply activate the virtualenv and try runnig the 
debug 'runserver' command on your project directory. If that works, you 
know that your project and virtualenv are good, so the larger issue must be 
with the uwsgi config. 

At least, that's how I would go about debugging this matter.

-Abraham V.


On Thursday, June 1, 2017 at 6:03:34 PM UTC-4, F. Nikita Thomas wrote:
>
> Here's the directory listing for my virtual environment:
> (projectenv) [user@echo project]$ ls -al projectenv/bin/
> total 84
> drwxrwxr-x 3 user user  4096 Jun  1 14:28 .
> drwxrwxr-x 5 user user  4096 Jun  1 14:26 ..
> -rw-rw-r-- 1 user user  2095 Jun  1 14:26 activate
> -rw-rw-r-- 1 user user  1037 Jun  1 14:26 activate.csh
> -rw-rw-r-- 1 user user  2191 Jun  1 14:26 activate.fish
> -rw-rw-r-- 1 user user  1137 Jun  1 14:26 activate_this.py
> -rwxrwxr-x 1 user user   301 Jun  1 14:28 django-admin
> -rwxrwxr-x 1 user user   159 Jun  1 14:28 django-admin.py
> -rwxrwxr-x 1 user user   268 Jun  1 14:26 easy_install
> -rwxrwxr-x 1 user user   268 Jun  1 14:26 easy_install-3.6
> -rwxrwxr-x 1 user user   240 Jun  1 14:26 pip
> -rwxrwxr-x 1 user user   240 Jun  1 14:26 pip3
> -rwxrwxr-x 1 user user   240 Jun  1 14:26 pip3.6
> drwxrwxr-x 2 user user  4096 Jun  1 14:28 __pycache__
> lrwxrwxrwx 1 user user 9 Jun  1 14:26 python -> python3.6
> lrwxrwxrwx 1 user user 9 Jun  1 14:26 python3 -> python3.6
> -rwxrwxr-x 1 user user 17776 Jun  1 14:26 python3.6
> -rwxrwxr-x 1 user user  2354 Jun  1 14:26 python-config
> -rwxrwxr-x 1 user user   247 Jun  1 14:26 wheel
>
>
> I followed the steps listed here :  
> https://www.digitalocean.com/community/tutorials/how-to-use-mysql-or-mariadb-with-your-django-application-on-ubuntu-14-04
>  
>
> On Thursday, June 1, 2017 at 5:47:25 PM UTC-4, F. Nikita Thomas wrote:
>>
>> No such thing as a dumb question, how  do I check? 
>>
>> On Thursday, June 1, 2017 at 5:36:23 PM UTC-4, James Schneider wrote:
>>>
>>> *** Operational MODE: single process ***
 Traceback (most recent call last):
   File "./project/wsgi.py", line 12, in 
 from django.core.wsgi import get_wsgi_application
 ModuleNotFoundError: No module named 'django'
 unable to load app 0 (mountpoint='') (callable not found or import 
 error)
 *** no app loaded. going in full dynamic mode ***
 *** uWSGI is running in multiple interpreter mode ***
 spawned uWSGI worker 1 (and the only) (pid: 22388, cores: 1)
 ^C

 Shouldn't it see the Django installation in the virtualenv? I haven't 
 had this much fun since I had my wisdom teeth removed  Thanks again!

>>>
>>> Dumb question. Have you verified that Django is installed in the 
>>> virtualenv being used by uwsgi? You should be able to enter the virtualenv 
>>> and run that specific import command that is outlined. 
>>>
>>> -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/819a28c1-12f0-478f-bfa0-218c9323b14d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


count from multiple tables in a single query?

2017-05-31 Thread 'Abraham Varricatt' via Django users
Hello,

Is it possible to get the count of entries from multiple tables in a single 
query call? I'm looking at the official docs on aggregation and I can't 
find anything. For example assume I have the following 2 tables,

class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()

class Publisher(models.Model):
name = models.CharField(max_length=300)
num_awards = models.IntegerField()


If I want to get the total count from both tables it can be done like this,

author_count = Author.objects.count()
publisher_count = Publisher.objects.count()

My concern is that this results in two different queries to the database. 
Can it be done with a single query call?


Yours,
Abraham V.

-- 
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/5ffdbc1a-fb84-4bff-a711-eaad77c3ae15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User has no dcf_profile : RelatedObjectDoesNotExist

2017-06-16 Thread 'Abraham Varricatt' via Django users

On Friday, June 16, 2017 at 7:06:33 AM UTC-4, Nabil BOUDERBALA wrote:
>
> After extending an existing user model, I get RelatedObjectDoesNotExist 
> exception with a value User has no dcf_profile. I seems that dcf_profile 
> isn't created automatically for each user.
>

It took me awhile to figure out that dcf_profile is the text you use as 
related_name for the User model. 


 

> Please take a look at my model, view and form below and tell me how can I 
> correct my views file?
>
My views.py :
>
> @method_decorator(login_required)def dispatch(self, *args, **kwargs):
> if not self.request.user.dcf_profile.allow_add_item():
>
>
It looks like this is where you are having trouble. The code is trying to 
call the dcf_profile attribute/method from the user object - which doesn't 
exist. 

Your end goal appears to be to call the all_add_item() function. Why not 
grab an instance of your CustomUser first and invoke it on that? Something 
like,

def dispatch(self, *args, **kwargs):
user = self.request.user
my_user = CustomUser.objects.get(auth_user_ptr=user)  # Assuming you 
have entry in your database
if not my_user.allow_add_item():


Yours,
Abraham V.

-- 
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/022133ae-25f4-4bc4-82ce-aee7726932b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Images are not displaying

2017-06-16 Thread 'Abraham Varricatt' via Django users
If this is a production deployment, you probably need to run collectstatic 
and test if static files are being served correctly - more a deployment 
issue than a django matter. 

But, if you are testing with 'runserver' on a development system ... 
without exact knowledge of your folder structure, it's going to be 
difficult to help you - since this appears to be a pathing issue. 

However,

On Friday, June 16, 2017 at 7:06:17 AM UTC-4, Santosh Yelamarthi wrote:
>
>
> I created templates directory and i put my *home.html* over there 
> **
> **
> **
> **
> **
> **
>
> I created static folder and i put my image *logo.jpg* over there
>

If this is all you did, then shouldn't the src path be "static/logo.jpg" ?

Yours,
Abraham V.

-- 
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/db89c6a7-9a68-4a5e-afb2-072316102bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Link to download

2017-05-05 Thread 'Abraham Varricatt' via Django users
That's an interesting project!

If I use WhiteNoise as part of a production deploy somewhere, can I skip 
(or ignore) running 'manage.py collectstatic' ? 

Yours,
Abraham V.


On Wednesday, 3 May 2017 15:13:36 UTC-4, Dan Tagg wrote:
>
> You might want to check out WhiteNoise (
> https://whitenoise.readthedocs.io/en/stable/) perhaps in conjunction with 
> a CDN
>
> On 3 May 2017 at 19:35, Tim Chase  > wrote:
>
>> On 2017-05-02 19:11, Antonis Christofides wrote:
>> > response = HttpResponse(csvfile.read(), content_type='text/csv')
>>
>> Beware that, if your content can get huge (some of our reports can
>> run to hundreds of megabytes), you might want to investigate
>> something like the "sendfile" alternatives or spew it out as generator
>> instead of doing .read() to suck the whole thing into memory.
>>
>> -tkc
>>
>>
>>
>> --
>> 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/20170503133519.05365d67%40bigbox.christie.dr
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178 
> Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374
>

-- 
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/18c9354a-0325-4e53-ad4c-2bda5e7a2877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: about tutorial "app reusable section" issue

2017-05-01 Thread 'Abraham Varricatt' via Django users
Hello Xuanbei,

You are most likely getting that erro because you still have 'polls' 
mentioned inside INSTALLED_APPS within your settings.py file. 

On a different note, can you link to the tutorial you are following? I 
don't recall the official django tutorial instructing to install polls via 
pip. Instead, the tutorial teaches you to build the polls app.

Yours,
Abraham V.


On Sunday, April 30, 2017 at 10:20:34 AM UTC-4, Xuanbei Lu wrote:
>
> Hi Django experts,
>
> I'm new to django. I followed up the tutorial and everything is right on 
> the way until the re-use app section. According to the tutorial, after 
> packaging and installing the polls app using pip, I removed the directory 
> 'polls' in 'mysite'. Then when I try to run "python manage.py runserver", 
> it reported error as "No module named 'polls'". I just do exactly the 
> same things as the tutorial said, could any one share me with some 
> experience about the root cause?
>
> thank you in advance!!
>
> xuanbei
>

-- 
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/e23ebfd4-16e4-4a46-a103-698d9e61db6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: count from multiple tables in a single query?

2017-05-31 Thread 'Abraham Varricatt' via Django users
Hello James/Matthew,

I was afraid to hear that. The models are unrelated and I do not want to 
take the trouble of dropping out of the ORM. Since it's a web-service I'm 
building, a work-around is to cache results, but I was challenged to find a 
single DB call solution and wanted to be sure that it wouldn't be possible 
with the ORM. 

Thanks for replying!

Looking into caches,
Abraham V.


On Wednesday, 31 May 2017 16:31:04 UTC-4, Matthew Pava wrote:
>
> Hi Abraham,
>
> If the models are related, you can use double underscore notation with the 
> Count aggregate function.
>
> If the models are unrelated, then I’m fairly certain that you can only use 
> separate queries to get your results.
>
>  
>
>  
>
> *From:* 'Abraham Varricatt' via Django users [mailto:
> django...@googlegroups.com ] 
> *Sent:* Wednesday, May 31, 2017 2:14 PM
> *To:* Django users
> *Subject:* count from multiple tables in a single query?
>
>  
>
> Hello,
>
> Is it possible to get the count of entries from multiple tables in a 
> single query call? I'm looking at the official docs on aggregation and I 
> can't find anything. For example assume I have the following 2 tables,
>
> *class* *Author*(models.Model):
> name = models.CharField(max_length=100)
> age = models.IntegerField()
>
> *class* *Publisher*(models.Model):
> name = models.CharField(max_length=300)
> num_awards = models.IntegerField()
>
>
> If I want to get the total count from both tables it can be done like this,
>
> author_count = Author.objects.count()
> publisher_count = Publisher.objects.count()
>
>
> My concern is that this results in two different queries to the database. 
> Can it be done with a single query call?
>
>
> Yours,
> Abraham V.
>
> -- 
> 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 djang...@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/5ffdbc1a-fb84-4bff-a711-eaad77c3ae15%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/5ffdbc1a-fb84-4bff-a711-eaad77c3ae15%40googlegroups.com?utm_medium=email_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/7b99f473-0ea3-4d0a-acd2-08b05c96d687%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.