Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi,

Thank you for your response, this works perfectly!

Patrick

On Thursday, February 2, 2017 at 4:07:21 AM UTC+11, pradam.programming 
wrote:
>
> Hi Patrick,
> you can do like this:
> def total(self):
> return ContractItem.objects.filter(contract__subbudget__budge__in=
> self.budget_set.all()).aggregate(Sum('total'))['total__sum']
>
> try like this..!
>
> On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy  > wrote:
>
>> Hi all,
>>
>> Would appreciate some advice on this, I'm having trouble working out the 
>> best way to aggregate across multiple foreign key relationships. I have 
>> come up with the solution below however I'm not sure if this is the correct 
>> way to handle this situation. Any advice would be appreciated.
>>
>> Thanks
>>
>>
>> As an example I have a model structure that is 5 levels deep with foreign 
>> keys between each level, cost information is recorded at the lowest level 
>> (ContractItem) 
>>
>> --- Project
>>|--- Budget
>>   |--- SubBudget
>>  |--- Contract
>> |--- ContractItem - $100
>>
>> If I want to aggregate the total cost up to the top project level I do it 
>> in multiple steps like this:
>>
>> class Project(models.Model):
>> name = models.CharField(max_length=50)
>>
>> def total(self):
>> subbudgets = 
>> SubBudget.objects.filter(budget__in=self.budget_set.all())
>> contracts = Contract.objects.filter(subbudget__in=subbudgets)
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>>
>> Is there a better way of doing this?
>>
>>
>> Full working code:
>>
>> class Project(models.Model):
>> name = models.CharField(max_length=50)
>>
>> def total(self):
>> subbudgets = 
>> SubBudget.objects.filter(budget__in=self.budget_set.all())
>> contracts = Contract.objects.filter(subbudget__in=subbudgets)
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>> def __str__(self):
>> return self.name
>>
>> class Budget(models.Model):
>> project = models.ForeignKey(Project)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> contracts = 
>> Contract.objects.filter(subbudget__in=self.subbudget_set.all())
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>>
>> class SubBudget(models.Model):
>> budget = models.ForeignKey(Budget)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> return 
>> ContractItem.objects.filter(contract__in=self.contract_set.all()).aggregate(Sum('total'))['total__sum']
>>
>>
>> class Contract(models.Model):
>> subbudget = models.ForeignKey(SubBudget)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> return self.contractitem_set.aggregate(Sum('total'))['total__sum']
>>
>> class ContractItem(models.Model):
>> contract = models.ForeignKey(Contract)
>> total = models.DecimalField(default=0.00, decimal_places=2, 
>> max_digits=12)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> -- 
>> 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/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%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/4dbc5abe-e913-44d0-aaee-55679c673b46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Limiting choices in a lookup by exclusion

2017-02-01 Thread Melvyn Sopacua
And there's 2 other options to consider:

 *  The ne lookup is actually the first example in the documentation for 
custom 
lookups[1]. So you get its implementation for free and can consider adding it.
 *  You can extend Field to add exclude_choices() which sets 
limit_choices_to to the 
negation of the argument as below - so wrap it with ~Q().
All depending on how isolated your case is in the project/app.

On Tuesday 31 January 2017 23:48:28 C. Kirby wrote:
> django doesn't have an ne operator in the orm. You want to use a
> negated Q object for your limit_choices_to. try:
> 
> from django.db.models import Q
> 
> phone = models.ManyToManyField(Phone, limit_choices_to = ~Q(type_id =
> 'C'))
> On Wednesday, February 1, 2017 at 6:17:52 AM UTC+2, Gordon Burgess wrote:
> > I have this code, and with Django 1.10 it works as expected:
> > 
> > class Location(models.Model):
> > name = models.CharField(max_length = 32, unique = True)
> > street = models.CharField(max_length = 32)
> > detail = models.CharField(max_length = 32, blank = True, null =
> > True)
> > city = models.CharField(max_length = 32)
> > state = USStateField()
> > zip = USZipCodeField()
> > phone = models.ManyToManyField(Phone, limit_choices_to =
> > 
> > {'type_id':'H'})
> > 
> > but what I'd like to do is restrict the choices of phone numbers for
> > Locations to those that aren't 'C' (cell phones) - I've found some
> > hints,> 
> > but they're all for older versions of Django - it seems like:
> > phone = models.ManyToManyField(Phone, limit_choices_to =
> > 
> > {'type_id__ne':'C'})
> > 
> > ought to work - but this provokes a TypeError:
> > 
> > Related Field got invalid lookup: ne
> > 
> > Thanks!

-- 
Melvyn Sopacua


[1] https://docs.djangoproject.com/en/1.10/howto/custom-lookups/

-- 
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/2680435.EONmJTctep%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Melvyn Sopacua
On Wednesday 01 February 2017 02:40:48 Thames Khi wrote:

> I tried to use locally installed bootstrap. My render HTML function is
> calling my page. However using the relative path or even if add the
> complete path, nothing works.

Save some time down the road:
https://github.com/dyve/django-bootstrap3

> Is there any decent documentation and examples of using locally
> installed bootstrap with django?

Answered by Andreas.
-- 
Melvyn Sopacua

-- 
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/1929686.oNzz5hNHJJ%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug in queryset "gte" function

2017-02-01 Thread Dylan Reinhold
After you changed it did you migrate the database? What database are you
using?

Dylan

On Wed, Feb 1, 2017 at 9:05 AM,  wrote:

> What you say does sound plausible since previously the field was a
> timestamp that I modified into a date, but then, what can I do?
>
> On Wednesday, February 1, 2017 at 11:47:02 AM UTC-5, Dylan Reinhold wrote:
>>
>> Your date field is probably a date-time field in your database.
>> So your filter is going to be looking for 2016-12-03 00:00:00 thru
>> 2016-12-04 00:00:00.
>>
>> Dylan
>>
>>
>> On Wed, Feb 1, 2017 at 6:16 AM,  wrote:
>>
>>> Hi, guys.
>>>
>>> If I'm not madly blind (which has been the case before, you know), there
>>> is a bug in the "__gte" function for the orm queryset. To name it, whenever
>>> I call the function, it gives the same result that the "__gt" function,
>>> that is, greater than or equal to, is behaving the same as greater than.
>>>
>>> In my specific case, I want to do a query over my database that return
>>> the rows registered between the 3th of december and the 4th, for which I
>>> have written:
>>>
>>> Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")
>>>
>>> such queryset returns an empty set, even though I know there are
>>> registers within those two dates. Then I checked, and did only:
>>>
>>> Warehouse.objects.filter(date__gte="2016-12-03")
>>>
>>> and it returned rows with dates 2016-12-04 and higher, so... well, that
>>> the bug as far I can see.
>>>
>>> Thanks for your replies and if someone can directly verify and report
>>> the bug, that would be awesome.
>>>
>>> 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...@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/ms
>>> gid/django-users/2109d071-2065-4ebe-8608-6bdc30d0e64e%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/82c100ef-192b-49e5-84e9-9c8e17b6d42f%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/CAHtg44DWo-%3D8_SGPrUodAH7kgaWwDE7FdUF-SA1EOh9y6VfDKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Email attachments in Django1.10 failing

2017-02-01 Thread E kamande
Hi Kindly need help to be able attaching a logo and a pdf when emailing, I 
have been following this great articles 1 

 
and 2 

 
 but it seems am always getting something wrong.
Here is a sample code of mine , It fails the following error 
 " is not JSON 
serializable"

connection = mail.get_connection()
msg = EmailMultiAlternatives(
subject, from_email, receiver)

msg.attach_alternative(mail_body, 'text/html')
image = MIMEImage(insurer.company_logo.read())
image.add_header('Content-ID', '<{}>'.format('logo.png'))

msg.attach('logo.png',image, 'image/png')
msg.send()
connection.send_messages([msg])



-- 
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/422ff42f-6d18-4d4b-8fd6-0bef2a40c15d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


sqlmigrate does not quote default string values

2017-02-01 Thread Michael Grijalva
Not sure if this is considered a bug, but the SQL output from sqlmigrate 
contains a small syntax error with default string values:

Add a new column as so:
class City(models.Model):
...
name = models.CharField(max_length=100, default='a b c d')

Create migration, and run sqlmigrate command:
BEGIN;
--
-- Add field name to city
--
ALTER TABLE `map_city` ADD COLUMN `name ` varchar(100) DEFAULT a b c d NOT 
NULL;
ALTER TABLE `map_city` ALTER COLUMN `name ` DROP DEFAULT;
COMMIT;

Notice 'a b c d' is missing quotes. When this migration is actually applied 
it runs through cursor.execute, which properly quotes the value.

I realize sqlmigrate is only for getting a preview of the SQL, but other 
parts like the table name and columns are correctly quoted, so why not the 
default?

-- 
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/666712e2-1fad-49c1-8885-8296c040f491%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: video tutorial dating site

2017-02-01 Thread engross web host
Thank you Aaton, will work with this any other comment is welcome by others


On Wednesday, February 1, 2017 at 2:30:57 AM UTC+1, engross web host wrote:
>
> am new using python(django) i built an app lately but i want to build a 
> dating site using django. I will be comfortable with video tutorials. Any 
> help please???
>

-- 
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/bdd455bd-0ad7-4830-a967-1900517e86be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Andreas Kuhne
Great to see that I could be of help :-)

Regards,

Andréas

2017-02-01 21:35 GMT+01:00 Thames Khi :

> Thank you so much, you are a legend, sir! I can now continue my learning
> and combine my python database code with django.
>
> I am very grateful, thank you for taking the time to explain this to me.
>
> Kind Regards,
>
> TiKhi
>
>
> On Wednesday, February 1, 2017 at 8:11:52 PM UTC, Thames Khi wrote:
>>
>> Thanks very much, I will give this a try now.
>>
>> On Wednesday, February 1, 2017 at 3:58:54 PM UTC, Andréas Kühne wrote:
>>>
>>> The setting you have to specify are:
>>>
>>> STATIC_URL and STATIC_ROOT.
>>>
>>> STATIC_URL is the url base for creating paths for the webserver to the
>>> static files. Usually you just leave this at '/static/' - however you could
>>> also set this to a completely different domain (if for example you were
>>> serving static files via cloudfront or other CDN's, or a different server).
>>>
>>> STATIC_ROOT is where you want the collectstatic command to copy all
>>> files to. Usually a directory within your project. I usually set this to
>>> STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
>>>
>>> You don't need to set STATICFILES_DIRS at all - because that is only
>>> when you want to add files that do not reside within one of your
>>> applications static dir.
>>>
>>> Also when you use join, you shoiuldn't use absolute paths - you have
>>> written : os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/") - you
>>> should only use the relative path compared to where your project resides.
>>>
>>> Finally - you should put the bootstrap files in a static directory (or a
>>> subdirectory to static) under one of you applications. Then run
>>> collectstatic - and you will get the files copied to the place you will
>>> serve them from (this is not necessary when running in debug though).
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2017-02-01 16:00 GMT+01:00 Thames Khi :
>>>
 Thank you very much for your reply. I think I have missed something as
 the python is duplicating the files and sticking them into a path I
 specified. Here are my steps based on the document and what happens.

 1)  updated the urls.py in the project:

 from django.conf.urls.static import static

 urlpatterns = [

 url(r'^data/', include('data.urls')),
 url(r'^$', views.home, name='home'),
 url(r'^admin/', admin.site.urls),
 ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

 2) In settings,py added the following:


 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/1.10/howto/static-files/

 STATIC_URL = '/static/'
 #STATICFILES_DIRS = '/static/'
 STATICFILES_DIRS = [
 os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/"),

 ]
 STATIC_ROOT = "C:/workarea/AWSTest/web/bootstrap/"

 url(r'^admin/', admin.site.urls),
 ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

 C:\workarea\AWSTest\web\data\static\home


 3) In your templates, either hardcode the url..

 I am not sure about this as I do not want to hardcode things in my
 templates unless it means the html page then thats cool.

 4) python manage.py collectstatic

 This went and copied all the files and folders from apps and project
 folders and put them in ./web/bootstrap

 in the app (data) I have also got static files in:

 web\bootstrap\data\static\home (root http:/myweb.com/)


 Why do I need to specify all these directories and why do I need copies
 of the static files in my app folder and my static root folder? I think I
 need to find a video tutorial :(


 On Wednesday, February 1, 2017 at 10:48:53 AM UTC, Andréas Kühne wrote:
>
> Hi,
>
> You will have to follow the following information:
> https://docs.djangoproject.com/en/1.10/howto/static-files/
>
> Make sure that the css files and js files are in the static directory.
> Then you can use {% static "css/bootstrap.min.css" %} for the filepath to
> the static files. The static files shouldn't have absolute file paths
> because you are accessing them from the webserver and the paths are
> relative to the current base url (or html file). There is no difference
> between bootstrap and other css / js files in this regard.
>
> Regards,
>
> Andréas
>
> 2017-02-01 11:40 GMT+01:00 Thames Khi :
>
>> Hi,
>>
>> I tried to use locally installed bootstrap. My render HTML function
>> is calling my page. However using the relative path or even if add the
>> complete path, nothing works.
>>
>> If the html page is opened directly it works.
>>
>> Is there any decent documentation and examples of using locally
>> installed bootstrap with django?
>>
>> Thank you 

Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Thames Khi
Thank you so much, you are a legend, sir! I can now continue my learning 
and combine my python database code with django. 

I am very grateful, thank you for taking the time to explain this to me.

Kind Regards,

TiKhi

On Wednesday, February 1, 2017 at 8:11:52 PM UTC, Thames Khi wrote:
>
> Thanks very much, I will give this a try now.
>
> On Wednesday, February 1, 2017 at 3:58:54 PM UTC, Andréas Kühne wrote:
>>
>> The setting you have to specify are:
>>
>> STATIC_URL and STATIC_ROOT. 
>>
>> STATIC_URL is the url base for creating paths for the webserver to the 
>> static files. Usually you just leave this at '/static/' - however you could 
>> also set this to a completely different domain (if for example you were 
>> serving static files via cloudfront or other CDN's, or a different server).
>>
>> STATIC_ROOT is where you want the collectstatic command to copy all files 
>> to. Usually a directory within your project. I usually set this to 
>> STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
>>
>> You don't need to set STATICFILES_DIRS at all - because that is only 
>> when you want to add files that do not reside within one of your 
>> applications static dir. 
>>
>> Also when you use join, you shoiuldn't use absolute paths - you have 
>> written : os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/") - you 
>> should only use the relative path compared to where your project resides.
>>
>> Finally - you should put the bootstrap files in a static directory (or a 
>> subdirectory to static) under one of you applications. Then run 
>> collectstatic - and you will get the files copied to the place you will 
>> serve them from (this is not necessary when running in debug though).
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-02-01 16:00 GMT+01:00 Thames Khi :
>>
>>> Thank you very much for your reply. I think I have missed something as 
>>> the python is duplicating the files and sticking them into a path I 
>>> specified. Here are my steps based on the document and what happens.
>>>
>>> 1)  updated the urls.py in the project:
>>>
>>> from django.conf.urls.static import static
>>>
>>> urlpatterns = [
>>> 
>>> url(r'^data/', include('data.urls')),
>>> url(r'^$', views.home, name='home'),
>>> url(r'^admin/', admin.site.urls),
>>> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>>
>>> 2) In settings,py added the following:
>>>
>>>
>>> # Static files (CSS, JavaScript, Images)
>>> # https://docs.djangoproject.com/en/1.10/howto/static-files/
>>>
>>> STATIC_URL = '/static/'
>>> #STATICFILES_DIRS = '/static/'
>>> STATICFILES_DIRS = [
>>> os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/"),
>>> 
>>> ]
>>> STATIC_ROOT = "C:/workarea/AWSTest/web/bootstrap/"
>>>
>>> url(r'^admin/', admin.site.urls),
>>> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>>
>>> C:\workarea\AWSTest\web\data\static\home
>>>
>>>
>>> 3) In your templates, either hardcode the url..
>>>
>>> I am not sure about this as I do not want to hardcode things in my 
>>> templates unless it means the html page then thats cool.
>>>
>>> 4) python manage.py collectstatic
>>>
>>> This went and copied all the files and folders from apps and project 
>>> folders and put them in ./web/bootstrap
>>>
>>> in the app (data) I have also got static files in:
>>>
>>> web\bootstrap\data\static\home (root http:/myweb.com/)
>>>
>>>
>>> Why do I need to specify all these directories and why do I need copies 
>>> of the static files in my app folder and my static root folder? I think I 
>>> need to find a video tutorial :(
>>>
>>>
>>> On Wednesday, February 1, 2017 at 10:48:53 AM UTC, Andréas Kühne wrote:

 Hi,

 You will have to follow the following information:
 https://docs.djangoproject.com/en/1.10/howto/static-files/

 Make sure that the css files and js files are in the static directory. 
 Then you can use {% static "css/bootstrap.min.css" %} for the filepath to 
 the static files. The static files shouldn't have absolute file paths 
 because you are accessing them from the webserver and the paths are 
 relative to the current base url (or html file). There is no difference 
 between bootstrap and other css / js files in this regard.

 Regards,

 Andréas

 2017-02-01 11:40 GMT+01:00 Thames Khi :

> Hi,
>
> I tried to use locally installed bootstrap. My render HTML function is 
> calling my page. However using the relative path or even if add the 
> complete path, nothing works. 
>
> If the html page is opened directly it works.
>
> Is there any decent documentation and examples of using locally 
> installed bootstrap with django?
>
> Thank you very much. 
>
> -- 
> 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 

Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Thames Khi
Thanks very much, I will give this a try now.

On Wednesday, February 1, 2017 at 3:58:54 PM UTC, Andréas Kühne wrote:
>
> The setting you have to specify are:
>
> STATIC_URL and STATIC_ROOT. 
>
> STATIC_URL is the url base for creating paths for the webserver to the 
> static files. Usually you just leave this at '/static/' - however you could 
> also set this to a completely different domain (if for example you were 
> serving static files via cloudfront or other CDN's, or a different server).
>
> STATIC_ROOT is where you want the collectstatic command to copy all files 
> to. Usually a directory within your project. I usually set this to 
> STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
>
> You don't need to set STATICFILES_DIRS at all - because that is only when 
> you want to add files that do not reside within one of your applications 
> static dir. 
>
> Also when you use join, you shoiuldn't use absolute paths - you have 
> written : os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/") - you should 
> only use the relative path compared to where your project resides.
>
> Finally - you should put the bootstrap files in a static directory (or a 
> subdirectory to static) under one of you applications. Then run 
> collectstatic - and you will get the files copied to the place you will 
> serve them from (this is not necessary when running in debug though).
>
> Regards,
>
> Andréas
>
> 2017-02-01 16:00 GMT+01:00 Thames Khi :
>
>> Thank you very much for your reply. I think I have missed something as 
>> the python is duplicating the files and sticking them into a path I 
>> specified. Here are my steps based on the document and what happens.
>>
>> 1)  updated the urls.py in the project:
>>
>> from django.conf.urls.static import static
>>
>> urlpatterns = [
>> 
>> url(r'^data/', include('data.urls')),
>> url(r'^$', views.home, name='home'),
>> url(r'^admin/', admin.site.urls),
>> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>
>> 2) In settings,py added the following:
>>
>>
>> # Static files (CSS, JavaScript, Images)
>> # https://docs.djangoproject.com/en/1.10/howto/static-files/
>>
>> STATIC_URL = '/static/'
>> #STATICFILES_DIRS = '/static/'
>> STATICFILES_DIRS = [
>> os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/"),
>> 
>> ]
>> STATIC_ROOT = "C:/workarea/AWSTest/web/bootstrap/"
>>
>> url(r'^admin/', admin.site.urls),
>> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>>
>> C:\workarea\AWSTest\web\data\static\home
>>
>>
>> 3) In your templates, either hardcode the url..
>>
>> I am not sure about this as I do not want to hardcode things in my 
>> templates unless it means the html page then thats cool.
>>
>> 4) python manage.py collectstatic
>>
>> This went and copied all the files and folders from apps and project 
>> folders and put them in ./web/bootstrap
>>
>> in the app (data) I have also got static files in:
>>
>> web\bootstrap\data\static\home (root http:/myweb.com/)
>>
>>
>> Why do I need to specify all these directories and why do I need copies 
>> of the static files in my app folder and my static root folder? I think I 
>> need to find a video tutorial :(
>>
>>
>> On Wednesday, February 1, 2017 at 10:48:53 AM UTC, Andréas Kühne wrote:
>>>
>>> Hi,
>>>
>>> You will have to follow the following information:
>>> https://docs.djangoproject.com/en/1.10/howto/static-files/
>>>
>>> Make sure that the css files and js files are in the static directory. 
>>> Then you can use {% static "css/bootstrap.min.css" %} for the filepath to 
>>> the static files. The static files shouldn't have absolute file paths 
>>> because you are accessing them from the webserver and the paths are 
>>> relative to the current base url (or html file). There is no difference 
>>> between bootstrap and other css / js files in this regard.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2017-02-01 11:40 GMT+01:00 Thames Khi :
>>>
 Hi,

 I tried to use locally installed bootstrap. My render HTML function is 
 calling my page. However using the relative path or even if add the 
 complete path, nothing works. 

 If the html page is opened directly it works.

 Is there any decent documentation and examples of using locally 
 installed bootstrap with django?

 Thank you very much. 

 -- 
 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/a1b01bab-5236-4bb7-95cf-77c4ee7cc29e%40googlegroups.com
  
 

Re: Send mail bug needs password passed as bytearray

2017-02-01 Thread elliot
Thanks for getting back to me. 

I guess I have gotten myself confused. Im using 1.10.5 and have been 
looking at the master version on github. My work around has the emails 
working so I'll just leave it and get with the times and work with python 3 
in the future.

On Thursday, February 2, 2017 at 1:12:53 AM UTC+13, Tim Graham wrote:
>
> Following the Django 1.11 alpha release, the stable/1.11.x branch was 
> created and master became Django 2.0 pre-alpha.
>
> You can read more details about how that works at 
> https://docs.djangoproject.com/en/dev/internals/release-process/#release-process
>
> On Tuesday, January 31, 2017 at 9:24:13 PM UTC-5, 
> ell...@makecollective.co.nz wrote:
>>
>> Really? I should look at moving to python 3 but my understanding was that 
>> python 2.7 would be supported until Django 2.0 according to the docs 
>> 
>>
>> On Wednesday, February 1, 2017 at 1:21:21 PM UTC+13, Tim Graham wrote:
>>>
>>> Oh, I see, you're using bytearray to try to workaround the issue. Well, 
>>> Django master no longer supports Python 2.7, that's why force_str() was 
>>> removed. Is there a problem with Django master and Python 3?
>>>
>>> On Tuesday, January 31, 2017 at 7:16:41 PM UTC-5, 
>>> ell...@makecollective.co.nz wrote:

 Neither.

 I haven't seen anything with webfaction and I have used webfaction in 
 the past on several projects and not had any trouble.

 On Wednesday, February 1, 2017 at 12:12:56 PM UTC+13, Tim Graham wrote:
>
> I've never seen a password as a bytearray. Is there webfaction 
> documentation about this?
>
> On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, 
> ell...@makecollective.co.nz wrote:
>>
>> myMail = EmailMessage('subject', 'message', 'some...@address.com', ['
>> mye...@address.com'])
>> myMail.send()
>>
>> The error I'm getting:
>>
>>   File 
>> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py"
>> , line 342, in send
>>
>> return self.get_connection(fail_silently).send_messages([self])
>>
>>   File 
>> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
>> , line 100, in send_messages
>>
>> new_conn_created = self.open()
>>
>>   File 
>> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
>> , line 67, in open
>>
>> self.connection.login(self.username, self.password)
>>
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
>> , line 607, in login
>>
>> (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
>>
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
>> , line 571, in encode_cram_md5
>>
>> response = user + " " + hmac.HMAC(password, challenge).hexdigest
>> ()
>>
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py"
>> , line 75, in __init__
>>
>> self.outer.update(key.translate(trans_5C))
>>
>> TypeError: character mapping must return integer, None or unicode
>>
>> There was solution from this ticket 
>>  with the same problem. 
>> But then the fixed commit was removed here 
>> 
>> .
>>
>> The settings needed to send emails now
>>
>> EMAIL_USE_TLS = True
>> EMAIL_HOST = 'smtp.webfaction.com'
>> EMAIL_HOST_USER = ''
>> EMAIL_HOST_PASSWORD = bytearray('**', 'utf-8')
>> EMAIL_PORT = 587
>>
>> So 2 questions:
>>
>> Am I missing something simple?
>>
>> Is this a bug and needs a ticket?
>>
>> Cheers
>>
>

-- 
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/04b63e2f-82db-4869-abd0-5b98b51d0d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Link to urls containing slug

2017-02-01 Thread Matthew Pava
Hi David,
Thank you for the clarification, but it doesn’t change my response much.
Use the {% url %} tag in your detail view template.
Job 
Application Form

I thought you had a JobApplication model, but you can use the Job model just as 
above.  Use the job object you passed into the detail view to obtain the job_id 
and slug of the job.
Thank you,
Matthew

From: 'David Turner' via Django users [mailto:django-users@googlegroups.com]
Sent: Wednesday, February 1, 2017 1:44 AM
To: django-users@googlegroups.com
Subject: Re: Link to urls containing slug

Hi Matthew

I think I might not have explained my issue fully.
Within my jobs models.py I have the following:
def get_absolute_url(self):
kwargs = {
  'job_id': self.job_id,
  'slug': self.slug,
   }
return reverse('job_detail', kwargs=kwargs)

I have the following urls patterns:
url(r'^$', views.JobListView.as_view(), name='job_list'),
url(r'^(?P[-\w]*)/(?P[-\w]*)/$', views.JobDetail.as_view(), 
name='job_detail'),

At this stage everything works fine so that clicking on a job in the job list 
takes you through to the detail for that job.
I have then created an application form for the jobs as follows:
def job_application(request, job_id, slug):
# Retrieve job by id
job = get_object_or_404(Job, job_id=job_id)
sent = False

if request.method == 'POST':
# Form was submitted
form = JobForm(request.POST)
if form.is_valid():
# Form fields passed validation
cd = form.cleaned_data
job_url = request.build_absolute_uri(job.get_absolute_url())
subject = '{} ({}) Application for  "{}"'.format(cd['name'], 
cd['email'], job.title)
message = 'Application for "{}" at {}\n\n{}\'s comments: 
{}'.format(job.title,  job_url, cd['name'], cd['comments'])
from_email = ''
to_list = ['']
send_mail(subject, message, from_email, to_list)
sent = True
else:
form = JobForm()
return render(request, 'jobs/job_application.html', {'job': job, 'form': 
form, 'sent': sent})

The url for this form is:
url(r'^(?P[-\w]*)/(?P[-\w]*)/job_application/$', 
views.job_application, name='job_application'),

I can go to this link directly in my browser as follows:
http://localhost:8000/jobs/1/slug-name/job_application/
What I am looking to achieve is a link within the job detail page for that 
specific job that takes you through to the application fom for that job.

Any advice gratefully appreciated.

On 31 January 2017 at 16:32, Matthew Pava 
> wrote:
Hi David,
Please make sure you have a get_absolute_url method on your JobApplication 
model in order for that to work and that you passing job_application in through 
the context in the template.
If you don’t have that method, you could use the {% url %} tag, but you would 
have to provide the pk and slug as arguments.
{{ job_application }}

Good luck!

From: 'David Turner' via Django users 
[mailto:django-users@googlegroups.com]
Sent: Tuesday, January 31, 2017 9:09 AM
To: django-users@googlegroups.com
Subject: Re: Link to urls containing slug


I had tried that but unfortunately it doesn't work but thanks anyway.

On 31/01/2017 14:57, Matthew Pava wrote:
Assuming I’m understanding your question correctly, all you need to do is 
reference get_absolute_url in your template.
Something like so:

{{ job_application }}

From: 'dtdave' via Django users [mailto:django-users@googlegroups.com]
Sent: Tuesday, January 31, 2017 8:46 AM
To: Django users
Subject: Link to urls containing slug


Within my model I have the following that links through to a detail page.

def get_absolute_url(self):



kwargs = {

  'job_id': self.job_id,

  'slug': self.slug,

   }

return reverse('job_detail', kwargs=kwargs)



Everything works fine with this.



Within my urls.py I have the following:

url(r'^$', views.JobListView.as_view(), name='job_list'),

url(r'^(?P[-\w]*)/(?P[-\w]*)/$', views.JobDetail.as_view(), 
name='job_detail'),

url(r'^(?P[-\w]*)/(?P[-\w]*)/job_application/$', 
views.job_application, name=‘job_application'),



Then within my views.py the following:

def job_application(request, job_id, slug):

# Retrieve job by id

job = get_object_or_404(Job, job_id=job_id)

“””Other code here



However, I am having problems linking to this from my template in my detail 
page.

What structure should I be using to link to the job application from the job 
detail page?



I can access the url by going to

http://localhost:8000/jobs/1/name-of-job/job_application/



Any advice would be appreciated
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

Re: Channels - query_string

2017-02-01 Thread Andrew Godwin
Hi,
You're right - a lot of the information only appears in the first "connect"
message. If you want to persist it, you can use a channel session:
http://channels.readthedocs.io/en/stable/getting-started.html#persisting-data

This will let you save information (such as the token, or even a User
object) into the session in the connect consumer, and then let you use it
in other consumers that have the same decorator.

Andrew


On Wed, Feb 1, 2017 at 5:34 AM, Sgiath  wrote:

> Hi,
> I am trying to use the query_string parameter and I want to ask what is
> the correct way how to use it.
> I am using JsonWebsocketConsumer and when debugging I noticed that on the
> Handshake the message content contains path, headers, query_string, client,
> server, reply_channel and order.
> But every other message contains just reply_channel, path, order and text
> .
> How should I correctly use it? Specifically I want authenticate user based
> on the query_string (I send token in it) I can do that in connection
> phase but what should I do next? On every other message the user is
> AnnonymousUser because there is no query_string. Should I save
> query_string into channel_session? Should I save user into channel_session
> ?
> BTW I cannot use user from http session because I am connecting to WS from
> the mobile app.
>
> 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/a30535e3-29e1-4547-af70-0e391d1b80d3%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/CAFwN1uqLaM6NJ1HiGwZA2b0jt_CxHah%3DO6HSk6dCfqyz_-Qsog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: formset in form_class

2017-02-01 Thread schaf . mh
Hi All,
problem solved.
The problem was the default value None for the form_class parameter at 
get_form.
It works when changing:
def get_form(self, form_class=None):
to:
def get_form(self, form_class=LayoutFormSet):

Cheers
Schaf


Am Dienstag, 31. Januar 2017 17:55:15 UTC+1 schrieb scha...@gmail.com:
>
> Hi All,
> in a view deriving from UpdateView the form_class attribute gets assigned 
> with a formset.
> the View then overrides the get_form function.
> class RLFormView(LoginRequiredMixin, StaffuserRequiredMixin, UpdateView):
> template_name = 'abc/layout.html'
> form_class = LayoutFormSet
> fields = '__all__'
> 
> def get_form(self, form_class=None):
> if self.request.POST:
> return form_class(self.request.POST)
> else:
> initial = [{'param': 'a',
> 'choosen': 'value'}]
> return form_class(initial=initial)
>
>
> I'm just wondering if this is a nice way of using the formset? Normally a 
> form is assigned to form_class.
>
> Thanks for hints
> Schaf
>

-- 
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/3f60667e-4891-46da-834f-d9a80c0f4d8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread pradam programmer
Hi Patrick,
you can do like this:
def total(self):
return ContractItem.objects.filter(contract__subbudget__budge__in=
self.budget_set.all()).aggregate(Sum('total'))['total__sum']

try like this..!

On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy  wrote:

> Hi all,
>
> Would appreciate some advice on this, I'm having trouble working out the
> best way to aggregate across multiple foreign key relationships. I have
> come up with the solution below however I'm not sure if this is the correct
> way to handle this situation. Any advice would be appreciated.
>
> Thanks
>
>
> As an example I have a model structure that is 5 levels deep with foreign
> keys between each level, cost information is recorded at the lowest level
> (ContractItem)
>
> --- Project
>|--- Budget
>   |--- SubBudget
>  |--- Contract
> |--- ContractItem - $100
>
> If I want to aggregate the total cost up to the top project level I do it
> in multiple steps like this:
>
> class Project(models.Model):
> name = models.CharField(max_length=50)
>
> def total(self):
> subbudgets = SubBudget.objects.filter(budget__in=self.budget_set.
> all())
> contracts = Contract.objects.filter(subbudget__in=subbudgets)
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
>
> Is there a better way of doing this?
>
>
> Full working code:
>
> class Project(models.Model):
> name = models.CharField(max_length=50)
>
> def total(self):
> subbudgets = SubBudget.objects.filter(budget__in=self.budget_set.
> all())
> contracts = Contract.objects.filter(subbudget__in=subbudgets)
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
> def __str__(self):
> return self.name
>
> class Budget(models.Model):
> project = models.ForeignKey(Project)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> contracts = Contract.objects.filter(subbudget__in=self.subbudget_
> set.all())
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
>
> class SubBudget(models.Model):
> budget = models.ForeignKey(Budget)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> return ContractItem.objects.filter(contract__in=self.contract_
> set.all()).aggregate(Sum('total'))['total__sum']
>
>
> class Contract(models.Model):
> subbudget = models.ForeignKey(SubBudget)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> return self.contractitem_set.aggregate(Sum('total'))['total__sum']
>
> class ContractItem(models.Model):
> contract = models.ForeignKey(Contract)
> total = models.DecimalField(default=0.00, decimal_places=2,
> max_digits=12)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> --
> 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/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%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/CAGGVXBNTWdS1ESfBWF2hQVqz2zoPYmURCkWY8j8b-wfiVzBQnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug in queryset "gte" function

2017-02-01 Thread jjddgg9999
What you say does sound plausible since previously the field was a 
timestamp that I modified into a date, but then, what can I do?

On Wednesday, February 1, 2017 at 11:47:02 AM UTC-5, Dylan Reinhold wrote:
>
> Your date field is probably a date-time field in your database.
> So your filter is going to be looking for 2016-12-03 00:00:00 thru 
> 2016-12-04 00:00:00.
>
> Dylan
>
>
> On Wed, Feb 1, 2017 at 6:16 AM,  wrote:
>
>> Hi, guys.
>>
>> If I'm not madly blind (which has been the case before, you know), there 
>> is a bug in the "__gte" function for the orm queryset. To name it, whenever 
>> I call the function, it gives the same result that the "__gt" function, 
>> that is, greater than or equal to, is behaving the same as greater than. 
>>
>> In my specific case, I want to do a query over my database that return 
>> the rows registered between the 3th of december and the 4th, for which I 
>> have written:
>>
>> Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")
>>
>> such queryset returns an empty set, even though I know there are 
>> registers within those two dates. Then I checked, and did only:
>>
>> Warehouse.objects.filter(date__gte="2016-12-03")
>>
>> and it returned rows with dates 2016-12-04 and higher, so... well, that 
>> the bug as far I can see.
>>
>> Thanks for your replies and if someone can directly verify and report the 
>> bug, that would be awesome. 
>>
>> 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...@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/2109d071-2065-4ebe-8608-6bdc30d0e64e%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/82c100ef-192b-49e5-84e9-9c8e17b6d42f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Possible bug in queryset "gte" function

2017-02-01 Thread Dylan Reinhold
Your date field is probably a date-time field in your database.
So your filter is going to be looking for 2016-12-03 00:00:00 thru
2016-12-04 00:00:00.

Dylan


On Wed, Feb 1, 2017 at 6:16 AM,  wrote:

> Hi, guys.
>
> If I'm not madly blind (which has been the case before, you know), there
> is a bug in the "__gte" function for the orm queryset. To name it, whenever
> I call the function, it gives the same result that the "__gt" function,
> that is, greater than or equal to, is behaving the same as greater than.
>
> In my specific case, I want to do a query over my database that return the
> rows registered between the 3th of december and the 4th, for which I have
> written:
>
> Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")
>
> such queryset returns an empty set, even though I know there are registers
> within those two dates. Then I checked, and did only:
>
> Warehouse.objects.filter(date__gte="2016-12-03")
>
> and it returned rows with dates 2016-12-04 and higher, so... well, that
> the bug as far I can see.
>
> Thanks for your replies and if someone can directly verify and report the
> bug, that would be awesome.
>
> 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/2109d071-2065-4ebe-8608-6bdc30d0e64e%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/CAHtg44AFWBeVBEpiwpOLrW8%2BjmSTE0wPF4ErjWbSyC2VEY-qjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Possible bug in queryset "gte" function

2017-02-01 Thread jjddgg9999
Hi, guys.

If I'm not madly blind (which has been the case before, you know), there is 
a bug in the "__gte" function for the orm queryset. To name it, whenever I 
call the function, it gives the same result that the "__gt" function, that 
is, greater than or equal to, is behaving the same as greater than. 

In my specific case, I want to do a query over my database that return the 
rows registered between the 3th of december and the 4th, for which I have 
written:

Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")

such queryset returns an empty set, even though I know there are registers 
within those two dates. Then I checked, and did only:

Warehouse.objects.filter(date__gte="2016-12-03")

and it returned rows with dates 2016-12-04 and higher, so... well, that the 
bug as far I can see.

Thanks for your replies and if someone can directly verify and report the 
bug, that would be awesome. 

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/2109d071-2065-4ebe-8608-6bdc30d0e64e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Andreas Kuhne
The setting you have to specify are:

STATIC_URL and STATIC_ROOT.

STATIC_URL is the url base for creating paths for the webserver to the
static files. Usually you just leave this at '/static/' - however you could
also set this to a completely different domain (if for example you were
serving static files via cloudfront or other CDN's, or a different server).

STATIC_ROOT is where you want the collectstatic command to copy all files
to. Usually a directory within your project. I usually set this to
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

You don't need to set STATICFILES_DIRS at all - because that is only when
you want to add files that do not reside within one of your applications
static dir.

Also when you use join, you shoiuldn't use absolute paths - you have
written : os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/") - you should
only use the relative path compared to where your project resides.

Finally - you should put the bootstrap files in a static directory (or a
subdirectory to static) under one of you applications. Then run
collectstatic - and you will get the files copied to the place you will
serve them from (this is not necessary when running in debug though).

Regards,

Andréas

2017-02-01 16:00 GMT+01:00 Thames Khi :

> Thank you very much for your reply. I think I have missed something as the
> python is duplicating the files and sticking them into a path I specified.
> Here are my steps based on the document and what happens.
>
> 1)  updated the urls.py in the project:
>
> from django.conf.urls.static import static
>
> urlpatterns = [
>
> url(r'^data/', include('data.urls')),
> url(r'^$', views.home, name='home'),
> url(r'^admin/', admin.site.urls),
> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>
> 2) In settings,py added the following:
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/1.10/howto/static-files/
>
> STATIC_URL = '/static/'
> #STATICFILES_DIRS = '/static/'
> STATICFILES_DIRS = [
> os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/"),
>
> ]
> STATIC_ROOT = "C:/workarea/AWSTest/web/bootstrap/"
>
> url(r'^admin/', admin.site.urls),
> ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
>
> C:\workarea\AWSTest\web\data\static\home
>
>
> 3) In your templates, either hardcode the url..
>
> I am not sure about this as I do not want to hardcode things in my
> templates unless it means the html page then thats cool.
>
> 4) python manage.py collectstatic
>
> This went and copied all the files and folders from apps and project
> folders and put them in ./web/bootstrap
>
> in the app (data) I have also got static files in:
>
> web\bootstrap\data\static\home (root http:/myweb.com/)
>
>
> Why do I need to specify all these directories and why do I need copies of
> the static files in my app folder and my static root folder? I think I need
> to find a video tutorial :(
>
>
> On Wednesday, February 1, 2017 at 10:48:53 AM UTC, Andréas Kühne wrote:
>>
>> Hi,
>>
>> You will have to follow the following information:
>> https://docs.djangoproject.com/en/1.10/howto/static-files/
>>
>> Make sure that the css files and js files are in the static directory.
>> Then you can use {% static "css/bootstrap.min.css" %} for the filepath to
>> the static files. The static files shouldn't have absolute file paths
>> because you are accessing them from the webserver and the paths are
>> relative to the current base url (or html file). There is no difference
>> between bootstrap and other css / js files in this regard.
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-02-01 11:40 GMT+01:00 Thames Khi :
>>
>>> Hi,
>>>
>>> I tried to use locally installed bootstrap. My render HTML function is
>>> calling my page. However using the relative path or even if add the
>>> complete path, nothing works.
>>>
>>> If the html page is opened directly it works.
>>>
>>> Is there any decent documentation and examples of using locally
>>> installed bootstrap with django?
>>>
>>> Thank you very much.
>>>
>>> --
>>> 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/ms
>>> gid/django-users/a1b01bab-5236-4bb7-95cf-77c4ee7cc29e%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

Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Thames Khi
Thank you very much for your reply. I think I have missed something as the 
python is duplicating the files and sticking them into a path I specified. 
Here are my steps based on the document and what happens.

1)  updated the urls.py in the project:

from django.conf.urls.static import static

urlpatterns = [

url(r'^data/', include('data.urls')),
url(r'^$', views.home, name='home'),
url(r'^admin/', admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

2) In settings,py added the following:


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'
#STATICFILES_DIRS = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "C:/workarea/AWSTest/web/"),

]
STATIC_ROOT = "C:/workarea/AWSTest/web/bootstrap/"

url(r'^admin/', admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

C:\workarea\AWSTest\web\data\static\home


3) In your templates, either hardcode the url..

I am not sure about this as I do not want to hardcode things in my 
templates unless it means the html page then thats cool.

4) python manage.py collectstatic

This went and copied all the files and folders from apps and project 
folders and put them in ./web/bootstrap

in the app (data) I have also got static files in:

web\bootstrap\data\static\home (root http:/myweb.com/)


Why do I need to specify all these directories and why do I need copies of 
the static files in my app folder and my static root folder? I think I need 
to find a video tutorial :(


On Wednesday, February 1, 2017 at 10:48:53 AM UTC, Andréas Kühne wrote:
>
> Hi,
>
> You will have to follow the following information:
> https://docs.djangoproject.com/en/1.10/howto/static-files/
>
> Make sure that the css files and js files are in the static directory. 
> Then you can use {% static "css/bootstrap.min.css" %} for the filepath to 
> the static files. The static files shouldn't have absolute file paths 
> because you are accessing them from the webserver and the paths are 
> relative to the current base url (or html file). There is no difference 
> between bootstrap and other css / js files in this regard.
>
> Regards,
>
> Andréas
>
> 2017-02-01 11:40 GMT+01:00 Thames Khi :
>
>> Hi,
>>
>> I tried to use locally installed bootstrap. My render HTML function is 
>> calling my page. However using the relative path or even if add the 
>> complete path, nothing works. 
>>
>> If the html page is opened directly it works.
>>
>> Is there any decent documentation and examples of using locally installed 
>> bootstrap with django?
>>
>> Thank you very much. 
>>
>> -- 
>> 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/a1b01bab-5236-4bb7-95cf-77c4ee7cc29e%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/27b4ff88-fd37-4996-945e-440c48b6c241%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread pradam programmer
from django.db.models import Q
def total(self):
subbudgets = SubBudget.objects.filter()
contracts = Contract.objects.filter(subbudget__in=subbudgets)
return
ContractItem.objects.filter(contract__subbudget__budget__in=self.budget_set.
all()).aggregate(Sum('total'))['total__sum']

On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy  wrote:

> Hi all,
>
> Would appreciate some advice on this, I'm having trouble working out the
> best way to aggregate across multiple foreign key relationships. I have
> come up with the solution below however I'm not sure if this is the correct
> way to handle this situation. Any advice would be appreciated.
>
> Thanks
>
>
> As an example I have a model structure that is 5 levels deep with foreign
> keys between each level, cost information is recorded at the lowest level
> (ContractItem)
>
> --- Project
>|--- Budget
>   |--- SubBudget
>  |--- Contract
> |--- ContractItem - $100
>
> If I want to aggregate the total cost up to the top project level I do it
> in multiple steps like this:
>
> class Project(models.Model):
> name = models.CharField(max_length=50)
>
> def total(self):
> subbudgets = SubBudget.objects.filter(budget__in=self.budget_set.
> all())
> contracts = Contract.objects.filter(subbudget__in=subbudgets)
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
>
> Is there a better way of doing this?
>
>
> Full working code:
>
> class Project(models.Model):
> name = models.CharField(max_length=50)
>
> def total(self):
> subbudgets = SubBudget.objects.filter(budget__in=self.budget_set.
> all())
> contracts = Contract.objects.filter(subbudget__in=subbudgets)
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
> def __str__(self):
> return self.name
>
> class Budget(models.Model):
> project = models.ForeignKey(Project)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> contracts = Contract.objects.filter(subbudget__in=self.subbudget_
> set.all())
> return ContractItem.objects.filter(contract__in=contracts).
> aggregate(Sum('total'))['total__sum']
>
>
> class SubBudget(models.Model):
> budget = models.ForeignKey(Budget)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> return ContractItem.objects.filter(contract__in=self.contract_
> set.all()).aggregate(Sum('total'))['total__sum']
>
>
> class Contract(models.Model):
> subbudget = models.ForeignKey(SubBudget)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> def total(self):
> return self.contractitem_set.aggregate(Sum('total'))['total__sum']
>
> class ContractItem(models.Model):
> contract = models.ForeignKey(Contract)
> total = models.DecimalField(default=0.00, decimal_places=2,
> max_digits=12)
> name = models.CharField(max_length=50)
>
> def __str__(self):
> return self.name
>
> --
> 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/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%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/CAGGVXBMTGigxzNwU7p0%2BvX90DyHO%2BeBfV2J5HzinMggDV2KyqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi all,

Would appreciate some advice on this, I'm having trouble working out the 
best way to aggregate across multiple foreign key relationships. I have 
come up with the solution below however I'm not sure if this is the correct 
way to handle this situation. Any advice would be appreciated.

Thanks


As an example I have a model structure that is 5 levels deep with foreign 
keys between each level, cost information is recorded at the lowest level 
(ContractItem) 

--- Project
   |--- Budget
  |--- SubBudget
 |--- Contract
|--- ContractItem - $100

If I want to aggregate the total cost up to the top project level I do it 
in multiple steps like this:

class Project(models.Model):
name = models.CharField(max_length=50)

def total(self):
subbudgets = 
SubBudget.objects.filter(budget__in=self.budget_set.all())
contracts = Contract.objects.filter(subbudget__in=subbudgets)
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']


Is there a better way of doing this?


Full working code:

class Project(models.Model):
name = models.CharField(max_length=50)

def total(self):
subbudgets = 
SubBudget.objects.filter(budget__in=self.budget_set.all())
contracts = Contract.objects.filter(subbudget__in=subbudgets)
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
   
def __str__(self):
return self.name

class Budget(models.Model):
project = models.ForeignKey(Project)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
contracts = 
Contract.objects.filter(subbudget__in=self.subbudget_set.all())
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']


class SubBudget(models.Model):
budget = models.ForeignKey(Budget)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
return 
ContractItem.objects.filter(contract__in=self.contract_set.all()).aggregate(Sum('total'))['total__sum']


class Contract(models.Model):
subbudget = models.ForeignKey(SubBudget)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
return self.contractitem_set.aggregate(Sum('total'))['total__sum']

class ContractItem(models.Model):
contract = models.ForeignKey(Contract)
total = models.DecimalField(default=0.00, decimal_places=2, 
max_digits=12)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

-- 
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/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Channels - query_string

2017-02-01 Thread Sgiath
Hi,
I am trying to use the query_string parameter and I want to ask what is the 
correct way how to use it.
I am using JsonWebsocketConsumer and when debugging I noticed that on the 
Handshake the message content contains path, headers, query_string, client, 
server, reply_channel and order.
But every other message contains just reply_channel, path, order and text. 
How should I correctly use it? Specifically I want authenticate user based 
on the query_string (I send token in it) I can do that in connection phase 
but what should I do next? On every other message the user is AnnonymousUser 
because there is no query_string. Should I save query_string into 
channel_session? Should I save user into channel_session?
BTW I cannot use user from http session because I am connecting to WS from 
the mobile app.

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/a30535e3-29e1-4547-af70-0e391d1b80d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making email required

2017-02-01 Thread Larry Martell
On Wed, Feb 1, 2017 at 5:32 AM,   wrote:
> You can define a single form to use for creating and updating users like
> this:
>
> class CustomUserChangeForm(UserChangeForm):
>  class Meta:
>
>
>  model = User
>
>
>  fields = ('email', 'password', 'first_name', 'last_name', 'photo',
> 'is_active', 'is_staff', 'user_permissions')
>
>
>
>
>
>
>
>
>
>
> class CustomUserAdmin(UserAdmin):
>
>
>  # Override standard fields
>
>
>  form = CustomUserChangeForm
>
>
>  fieldsets = None
>
>
>  add_fieldsets = (None, {
>
>
>  'classes': ('wide',),
>
>
>  'fields': ('email', 'password1', 'password2', 'first_name', 'last_name',
> 'is_staff'),
>
>  }),
>
> Setting fieldsets = None on the CustomUserAdmin makes it inherit the fields
> from your form to use when updating a user, and setting add_fieldsets to the
> fields you want lets you specify the fields you want to use when creating a
> user.
>
> The problem you are having is that Django only recognizes a field named
> 'password' as a special case, and not 'password1' and 'password2', so the
> latter two are only to be used when you actually do need to input the
> unhashed password,
>
>
>
> On Tuesday, January 31, 2017 at 9:58:27 PM UTC+1, larry@gmail.com wrote:
>>
>> I want to make the email field required in the user admin add and
>> change pages. Following some posts I read on stackoverflow I did this:
>>
>> class MyUserCreationForm(UserCreationForm):
>> def __init__(self, *args, **kwargs):
>> super(MyUserCreationForm, self).__init__(*args, **kwargs)
>> # make user email field required
>> self.fields['email'].required = True
>>
>> class UserAdmin(BaseUserAdmin):
>> form = MyUserCreationForm
>> add_form = MyUserCreationForm
>> add_fieldsets = ((None, {'fields': ('username', 'email',
>> 'password1', 'password2'), 'classes': ('wide',)}),)
>>
>> admin.site.unregister(User)
>> admin.site.register(User, UserAdmin)
>>
>> This works fine in add user, but in change user I get the user's
>> encrypted password shown in the password field, instead of what you
>> normally see:
>>
>> algorithm: pbkdf2_sha256 iterations: 24000 salt: ** hash:
>> **
>> Raw passwords are not stored, so there is no way to see this user's
>> password, but you can change the password using this form.
>>
>> And when I try to save from the change screen it says "Please correct
>> the errors below." even though there are no errors shown.
>>
>> How can I fix these issues in the change form?

Thanks. I got this working. I did something like this:

from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User

class EmailRequiredMixin(object):
def __init__(self, *args, **kwargs):
super(EmailRequiredMixin, self).__init__(*args, **kwargs)
# make user email field required
self.fields['email'].required = True


class MyUserCreationForm(EmailRequiredMixin, UserCreationForm):
pass


class MyUserChangeForm(EmailRequiredMixin, UserChangeForm):
pass


class EmailRequiredUserAdmin(UserAdmin):
form = MyUserChangeForm
add_form = MyUserCreationForm
add_fieldsets = ((None, {'fields': ('username', 'email',
'password1', 'password2'),
'classes': ('wide',)}),)

admin.site.unregister(User)
admin.site.register(User, EmailRequiredUserAdmin)

-- 
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/CACwCsY5%2BSjNR1AZ%3Dr_t-nk5O7Rt77NBh%2BO%2Bvt%2BrCrxu0jN4xsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Stuck at Tutorial 1

2017-02-01 Thread ludovic coues
Sharing the contents of polls/urls.py could help but I assume you didn't
make any errors on the first line. To be sure, you can add a comment on the
first line and leave the second line blank.
If you still have an error on line 1, it might be related to how you save
your file. Python might not like utf8 with BOM.

I hope that helps you

On 1 Feb 2017 1:32 p.m., "Zhou Sicong"  wrote:

> Hi,
>
>   I tried doing exactly everything as told in Tutorial 1 (
> https://docs.djangoproject.com/en/1.10/intro/tutorial01/)
>   I use idle to write the polls.py and urls.py
>   Do i totally overwrite the code already in those file or leave them
> alone and add on the codes in the tutorial.
>
>   Because i always get this when i start run the server again. What could
> possibly be the error?
>
>
>
> Performing system checks...
>
> Unhandled exception in thread started by  check_errors..wrapper at 0x03C7D978>
> Traceback (most recent call last):
>   File "c:\django\django\utils\autoreload.py", line 226, in wrapper
> fn(*args, **kwargs)
>   File "c:\django\django\core\management\commands\runserver.py", line
> 125, in inner_run
> self.check(display_num_errors=True)
>   File "c:\django\django\core\management\base.py", line 356, in check
> include_deployment_checks=include_deployment_checks,
>   File "c:\django\django\core\management\base.py", line 343, in
> _run_checks
> return checks.run_checks(**kwargs)
>   File "c:\django\django\core\checks\registry.py", line 78, in run_checks
> new_errors = check(app_configs=app_configs)
>   File "c:\django\django\core\checks\urls.py", line 13, in
> check_url_config
> return check_resolver(resolver)
>   File "c:\django\django\core\checks\urls.py", line 23, in check_resolver
> return check_method()
>   File "c:\django\django\urls\resolvers.py", line 247, in check
> for pattern in self.url_patterns:
>   File "c:\django\django\utils\functional.py", line 31, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "c:\django\django\urls\resolvers.py", line 398, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File "c:\django\django\utils\functional.py", line 31, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File "c:\django\django\urls\resolvers.py", line 391, in urlconf_module
> return import_module(self.urlconf_name)
>   File "C:\Users\SzeChong\AppData\Local\Programs\Python\
> Python35-32\lib\importlib\__init__.py", line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in
> _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 662, in exec_module
>   File "", line 222, in
> _call_with_frames_removed
>   File "C:\mysite\mysite\urls.py", line 20, in 
> url(r'^polls/', include('polls.urls')),
>   File "c:\django\django\conf\urls\__init__.py", line 39, in include
> urlconf_module = import_module(urlconf_module)
>   File "C:\Users\SzeChong\AppData\Local\Programs\Python\
> Python35-32\lib\importlib\__init__.py", line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in
> _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 658, in exec_module
>   File "", line 764, in get_code
>   File "", line 724, in
> source_to_code
>   File "", line 222, in
> _call_with_frames_removed
>   File "C:\mysite\polls\urls.py", line 1
> Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900
> 32 bit (Intel)] on win32
>  ^
> SyntaxError: invalid syntax
>
> --
> 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/CAF_57Gsq7nM5bJNGhhdoomQV9ywJ6pN5A
> gOfdGVYXe2jzFn4sg%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 

Re: Stuck at Tutorial 1

2017-02-01 Thread Nibil M S
There is some syntax error in the file. Please ensure that your file is 
following python syntax. I hope you know basics of python.





 On Wed, 01 Feb 2017 13:17:39 +0530 Zhou Sicong 
genie10...@gmail.com wrote 




Hi, 



  I tried doing exactly everything as told in Tutorial 1 
(https://docs.djangoproject.com/en/1.10/intro/tutorial01/)

  I use idle to write the polls.py and urls.py

  Do i totally overwrite the code already in those file or leave them alone and 
add on the codes in the tutorial. 



  Because i always get this when i start run the server again. What could 
possibly be the error?







Performing system checks...



Unhandled exception in thread started by function 
check_errors.locals.wrapper at 0x03C7D978

Traceback (most recent call last):

  File "c:\django\django\utils\autoreload.py", line 226, in wrapper

fn(*args, **kwargs)

  File "c:\django\django\core\management\commands\runserver.py", line 125, in 
inner_run

self.check(display_num_errors=True)

  File "c:\django\django\core\management\base.py", line 356, in check

include_deployment_checks=include_deployment_checks,

  File "c:\django\django\core\management\base.py", line 343, in _run_checks

return checks.run_checks(**kwargs)

  File "c:\django\django\core\checks\registry.py", line 78, in run_checks

new_errors = check(app_configs=app_configs)

  File "c:\django\django\core\checks\urls.py", line 13, in check_url_config

return check_resolver(resolver)

  File "c:\django\django\core\checks\urls.py", line 23, in check_resolver

return check_method()

  File "c:\django\django\urls\resolvers.py", line 247, in check

for pattern in self.url_patterns:

  File "c:\django\django\utils\functional.py", line 31, in __get__

res = instance.__dict__[self.name] = self.func(instance)

  File "c:\django\django\urls\resolvers.py", line 398, in url_patterns

patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

  File "c:\django\django\utils\functional.py", line 31, in __get__

res = instance.__dict__[self.name] = self.func(instance)

  File "c:\django\django\urls\resolvers.py", line 391, in urlconf_module

return import_module(self.urlconf_name)

  File 
"C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
 line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

  File "frozen importlib._bootstrap", line 986, in _gcd_import

  File "frozen importlib._bootstrap", line 969, in _find_and_load

  File "frozen importlib._bootstrap", line 958, in 
_find_and_load_unlocked

  File "frozen importlib._bootstrap", line 673, in _load_unlocked

  File "frozen importlib._bootstrap_external", line 662, in exec_module

  File "frozen importlib._bootstrap", line 222, in 
_call_with_frames_removed

  File "C:\mysite\mysite\urls.py", line 20, in module

url(r'^polls/', include('polls.urls')),

  File "c:\django\django\conf\urls\__init__.py", line 39, in include

urlconf_module = import_module(urlconf_module)

  File 
"C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
 line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

  File "frozen importlib._bootstrap", line 986, in _gcd_import

  File "frozen importlib._bootstrap", line 969, in _find_and_load

  File "frozen importlib._bootstrap", line 958, in 
_find_and_load_unlocked

  File "frozen importlib._bootstrap", line 673, in _load_unlocked

  File "frozen importlib._bootstrap_external", line 658, in exec_module

  File "frozen importlib._bootstrap_external", line 764, in get_code

  File "frozen importlib._bootstrap_external", line 724, in 
source_to_code

  File "frozen importlib._bootstrap", line 222, in 
_call_with_frames_removed

  File "C:\mysite\polls\urls.py", line 1

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 
bit (Intel)] on win32

 ^

SyntaxError: invalid syntax





--

 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/CAF_57Gsq7nM5bJNGhhdoomQV9ywJ6pN5AgOfdGVYXe2jzFn4sg%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 

Re: Validating and cleaning related models ...

2017-02-01 Thread Bernd Wechner
Melvyn,

Thanks. Alas That was but one example in an apocryphal model set, and I 
have rather more relationship criteria to test in a more complex nest of 
models. I'm still drilling down into Django to see what I can uncover. 
Notably form.instance for the main form and all the related formsets, to 
see what I can divine from that. But I'm still wondering if there isn't a 
rather standard solution to the problem of when and where to test for 
relationships between models I guess, before they are saved, at the point 
of validation. 

It's looking like maybe I have to RY a bit not DRY ;-), as in override and 
add to some form handling code somewhere. I'm speculating for now. It's a 
bit of a slog. But form instances may provide some DRY fruit, we'll see, 
though I have to override post() to access the form in my Generic view, I 
can't see it in the Model.clean() context and it's too late by the time I'm 
in form_valid() or form_invalid(). 

On Thursday, 26 January 2017 02:51:51 UTC+11, Melvyn Sopacua wrote:
>
>  
>
> So, this criterion boils down to:
>
> * the submitted inline album form has one or more albums OR
>
> * the musician exists and has one or more albums
>
>  
>
> Order of the logic may differ pending the common case, but validation will 
> be:
>
>- Inspect the form count 
>
> 
>  
>of the album form set (total minus initial). This may require tweaking 
>(added empty rows, duplicates) but you get the gist. Valid if > 0.
>
>
>- Get the musician from the database, using whatever uniquely 
>identifies a musician in the main form. Typical queryset.get() in a try 
>block. Valid if exists and album_set is not None.
>
>
>- Invalid
>
>  
>
> This can be done in the main view's form_valid().
>
>  
>
> I do not see a solid way to handle this at the model level, because you 
> will have to save at least an album to validate the rule and both the 
> artist and an album in the case of a new artist.
>
> If you define a through model (in case this is a ManyToMany), you can 
> query that model directly instead of having to go through a possibly 
> missing attribute.
>
> The same applies to querying the Album model directly (in case it is a 
> reverse foreign key).
>
>  
>
> However this still means that it will yield no results if either the 
> artist does not exist or no albums for the artist exist. The model has no 
> clear path to validate the incoming data of a related model - that's what 
> the form should do.
>
>  
>
> From a higher level - it is trivial to generate a list of artists without 
> albums, so maybe implementing a procedure that generates that list for 
> content maintainers to process is the better way to guard integrity, since 
> that also covers the case of a DBA "deleting all albums before 1970".
>
>  
>
> -- 
>
> Melvyn Sopacua
>

-- 
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/064f415a-406a-4742-8841-753baabdecc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Stuck at Tutorial 1

2017-02-01 Thread Zhou Sicong
Hi,

  I tried doing exactly everything as told in Tutorial 1 (
https://docs.djangoproject.com/en/1.10/intro/tutorial01/)
  I use idle to write the polls.py and urls.py
  Do i totally overwrite the code already in those file or leave them alone
and add on the codes in the tutorial.

  Because i always get this when i start run the server again. What could
possibly be the error?



Performing system checks...

Unhandled exception in thread started by .wrapper at 0x03C7D978>
Traceback (most recent call last):
  File "c:\django\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
  File "c:\django\django\core\management\commands\runserver.py", line 125,
in inner_run
self.check(display_num_errors=True)
  File "c:\django\django\core\management\base.py", line 356, in check
include_deployment_checks=include_deployment_checks,
  File "c:\django\django\core\management\base.py", line 343, in _run_checks
return checks.run_checks(**kwargs)
  File "c:\django\django\core\checks\registry.py", line 78, in run_checks
new_errors = check(app_configs=app_configs)
  File "c:\django\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
  File "c:\django\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
  File "c:\django\django\urls\resolvers.py", line 247, in check
for pattern in self.url_patterns:
  File "c:\django\django\utils\functional.py", line 31, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\django\django\urls\resolvers.py", line 398, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
  File "c:\django\django\utils\functional.py", line 31, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\django\django\urls\resolvers.py", line 391, in urlconf_module
return import_module(self.urlconf_name)
  File
"C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load
  File "", line 958, in _find_and_load_unlocked
  File "", line 673, in _load_unlocked
  File "", line 662, in exec_module
  File "", line 222, in
_call_with_frames_removed
  File "C:\mysite\mysite\urls.py", line 20, in 
url(r'^polls/', include('polls.urls')),
  File "c:\django\django\conf\urls\__init__.py", line 39, in include
urlconf_module = import_module(urlconf_module)
  File
"C:\Users\SzeChong\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load
  File "", line 958, in _find_and_load_unlocked
  File "", line 673, in _load_unlocked
  File "", line 658, in exec_module
  File "", line 764, in get_code
  File "", line 724, in source_to_code
  File "", line 222, in
_call_with_frames_removed
  File "C:\mysite\polls\urls.py", line 1
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900
32 bit (Intel)] on win32
 ^
SyntaxError: invalid syntax

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


Re: Send mail bug needs password passed as bytearray

2017-02-01 Thread Tim Graham
Following the Django 1.11 alpha release, the stable/1.11.x branch was 
created and master became Django 2.0 pre-alpha.

You can read more details about how that works at 
https://docs.djangoproject.com/en/dev/internals/release-process/#release-process

On Tuesday, January 31, 2017 at 9:24:13 PM UTC-5, 
ell...@makecollective.co.nz wrote:
>
> Really? I should look at moving to python 3 but my understanding was that 
> python 2.7 would be supported until Django 2.0 according to the docs 
> 
>
> On Wednesday, February 1, 2017 at 1:21:21 PM UTC+13, Tim Graham wrote:
>>
>> Oh, I see, you're using bytearray to try to workaround the issue. Well, 
>> Django master no longer supports Python 2.7, that's why force_str() was 
>> removed. Is there a problem with Django master and Python 3?
>>
>> On Tuesday, January 31, 2017 at 7:16:41 PM UTC-5, 
>> ell...@makecollective.co.nz wrote:
>>>
>>> Neither.
>>>
>>> I haven't seen anything with webfaction and I have used webfaction in 
>>> the past on several projects and not had any trouble.
>>>
>>> On Wednesday, February 1, 2017 at 12:12:56 PM UTC+13, Tim Graham wrote:

 I've never seen a password as a bytearray. Is there webfaction 
 documentation about this?

 On Tuesday, January 31, 2017 at 6:06:04 PM UTC-5, 
 ell...@makecollective.co.nz wrote:
>
> myMail = EmailMessage('subject', 'message', 'some...@address.com', ['
> mye...@address.com'])
> myMail.send()
>
> The error I'm getting:
>
>   File 
> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/message.py"
> , line 342, in send
>
> return self.get_connection(fail_silently).send_messages([self])
>
>   File 
> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
> , line 100, in send_messages
>
> new_conn_created = self.open()
>
>   File 
> "/Users/Elliot/.virtualenvs/allright/lib/python2.7/site-packages/django/core/mail/backends/smtp.py"
> , line 67, in open
>
> self.connection.login(self.username, self.password)
>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
> , line 607, in login
>
> (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py"
> , line 571, in encode_cram_md5
>
> response = user + " " + hmac.HMAC(password, challenge).hexdigest()
>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py"
> , line 75, in __init__
>
> self.outer.update(key.translate(trans_5C))
>
> TypeError: character mapping must return integer, None or unicode
>
> There was solution from this ticket 
>  with the same problem. 
> But then the fixed commit was removed here 
> 
> .
>
> The settings needed to send emails now
>
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp.webfaction.com'
> EMAIL_HOST_USER = ''
> EMAIL_HOST_PASSWORD = bytearray('**', 'utf-8')
> EMAIL_PORT = 587
>
> So 2 questions:
>
> Am I missing something simple?
>
> Is this a bug and needs a ticket?
>
> Cheers
>


-- 
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/ca2043b0-43d4-4a13-8502-64f0516f07dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Andreas Kuhne
Hi,

You will have to follow the following information:
https://docs.djangoproject.com/en/1.10/howto/static-files/

Make sure that the css files and js files are in the static directory. Then
you can use {% static "css/bootstrap.min.css" %} for the filepath to the
static files. The static files shouldn't have absolute file paths because
you are accessing them from the webserver and the paths are relative to the
current base url (or html file). There is no difference between bootstrap
and other css / js files in this regard.

Regards,

Andréas

2017-02-01 11:40 GMT+01:00 Thames Khi :

> Hi,
>
> I tried to use locally installed bootstrap. My render HTML function is
> calling my page. However using the relative path or even if add the
> complete path, nothing works.
>
> If the html page is opened directly it works.
>
> Is there any decent documentation and examples of using locally installed
> bootstrap with django?
>
> Thank you very much.
>
> --
> 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/a1b01bab-5236-4bb7-95cf-77c4ee7cc29e%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/CALXYUbndPa6D6V-yM7Fz1z57wkNYm%2BGaH_H-xO%2BqSGYSY%3DxyFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


good doc and example on how to use bootstrap with DJango

2017-02-01 Thread Thames Khi
Hi,

I tried to use locally installed bootstrap. My render HTML function is 
calling my page. However using the relative path or even if add the 
complete path, nothing works. 

If the html page is opened directly it works.

Is there any decent documentation and examples of using locally installed 
bootstrap with django?

Thank you very much. 

-- 
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/a1b01bab-5236-4bb7-95cf-77c4ee7cc29e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making email required

2017-02-01 Thread jorrit787
You can define a single form to use for creating and updating users like 
this:

class CustomUserChangeForm(UserChangeForm): 
 class Meta: 
 

 model = User 
 

 fields = ('email', 'password', 'first_name', 'last_name', 'photo', 
'is_active', 'is_staff', 'user_permissions') 
 

 
 
 

 
 
 

class CustomUserAdmin(UserAdmin): 
 

 # Override standard fields 
 

 form = CustomUserChangeForm 
 

 fieldsets = None 
 

 add_fieldsets = (None, { 
 

 'classes': ('wide',), 
 

 'fields': ('email', 'password1', 'password2', 'first_name', 'last_name', 
'is_staff'), 
 
 }),

Setting fieldsets = None on the CustomUserAdmin makes it inherit the fields 
from your form to use when updating a user, and setting add_fieldsets to 
the fields you want lets you specify the fields you want to use when 
creating a user.

The problem you are having is that Django only recognizes a field named 
'password' as a special case, and not 'password1' and 'password2', so the 
latter two are only to be used when you actually do need to input the 
unhashed password,
 

On Tuesday, January 31, 2017 at 9:58:27 PM UTC+1, larry@gmail.com wrote:
>
> I want to make the email field required in the user admin add and 
> change pages. Following some posts I read on stackoverflow I did this: 
>
> class MyUserCreationForm(UserCreationForm): 
> def __init__(self, *args, **kwargs): 
> super(MyUserCreationForm, self).__init__(*args, **kwargs) 
> # make user email field required 
> self.fields['email'].required = True 
>
> class UserAdmin(BaseUserAdmin): 
> form = MyUserCreationForm 
> add_form = MyUserCreationForm 
> add_fieldsets = ((None, {'fields': ('username', 'email', 
> 'password1', 'password2'), 'classes': ('wide',)}),) 
>
> admin.site.unregister(User) 
> admin.site.register(User, UserAdmin) 
>
> This works fine in add user, but in change user I get the user's 
> encrypted password shown in the password field, instead of what you 
> normally see: 
>
> algorithm: pbkdf2_sha256 iterations: 24000 salt: ** hash: 
> ** 
> Raw passwords are not stored, so there is no way to see this user's 
> password, but you can change the password using this form. 
>
> And when I try to save from the change screen it says "Please correct 
> the errors below." even though there are no errors shown. 
>
> How can I fix these issues in the change form? 
>

-- 
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/fa5d3129-06ca-4d83-9309-322411ffa0ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Web-based Voting System for our capstone project

2017-02-01 Thread Avraham Serour
I recommend instead of tweaking the admin app to just making your own
dashboard template.

You can start learning django by doing the official tutorial at
djangoproject.com

On Tue, Jan 31, 2017 at 2:44 PM, Genaro Lubong  wrote:

> I just want to ask, how can I customize my admin page and make some
> dashboard about the students(who have already voted and those who haven't
> yet), colleges and everything in my web app. As well as, how to print
> reports. I am very willing to be taught and learn from you guys, I am just
> a newbie to django, and advance thank you 
>
> --
> 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/CACY%3DutHvCCf0Kdsp9bhYEadsssVMbJ8x
> E%3D7g3X64XnD4iH60Hw%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/CAFWa6tJP7FXKeRr9qScjkZm-_GdhjUEt2x3x1mDPp7EcmAFCPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.