Re: Django Model

2018-05-30 Thread Максим С
Thank you very mutch! It work.

class Domains(models.Model):
domainname = models.CharField(max_length=200, blank=True)
domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
domainwhois = models.DateField(blank=True, null=True)

def save(self, *args, **kwargs):
details = whois.whois(self.domainname)
self.domainwhois = details.expiration_date
super().save(*args, **kwargs)


среда, 30 мая 2018 г., 17:37:00 UTC+3 пользователь Julio Biason написал:
>
> Hi,
>
> If I got this right, what you want to do is save the "domainwhois" with 
> the expiration date of the result of the whois.whois function.
>
> Unfortunately, things don't work in class level like this, because things 
> are static here: whois.whois will be run one single time, not on every 
> object. For that, you'll need to change something in the instance. 
> Fortunately, Django allows access to things in the instance with ``save``:
>
> def save(self, *args, **kwargs):
>details = whois.whois(self.domainname)
>self.domainwhois = details.expiration_date
>super().save(*args, **kwargs)
>
> ("details" and "w" can be removed from the model itself, as they are 
> variables used only for retriving this information). Have a look how models 
> work here: https://docs.djangoproject.com/en/2.0/topics/db/models/
>
> On Wed, May 30, 2018 at 11:12 AM, Максим С  > wrote:
>
>> Hello all.
>>
>> I'm beginer. Sorry. Can anyone help me with this model. It did't 
>> work(TypeError: 
>> expected string or bytes-like object
>>
>> ):
>>
>> import whois
>>
>>
>> class Domains(models.Model):
>> domainname = models.CharField(max_length=200, blank=True)
>> domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
>> details = whois.whois(domainname)
>> w = str(details.expiration_date)
>> domainwhois = models.DateField(default=w)
>>
>> def __str__(self):
>> return self.domainname
>>
>> Domains.save()
>>
>> -- 
>> 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/53525a55-0d68-4a8c-9031-5d7c3baa7064%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> *Julio Biason*, Sofware Engineer
> *AZION*  |  Deliver. Accelerate. Protect.
> Office: +55 51 3083 8101  |  Mobile: +55 51 *99907 0554*
>

-- 
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/d77412bc-9085-4753-815c-8f5527ff412b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


href not working

2018-05-30 Thread Caleb Bryson
So i am trying to create a directory with a Home,Blog,and Contact 
selection. But every time i click on one of them they all go back to the 
home page. How do i fix this, and here is the secton of code below. let me 
know if you need to see more


   
Home
Blog
Contact
   
  

-- 
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/9dc7004b-4fff-412d-8560-6308f13db92c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL Concatenation Issue

2018-05-30 Thread Aditya Singh
For this you have provide an app inside your urls and refer to it as
home:about where home is the app name and about is the page to be rendered.
Also provide namespace in the urls so that the url is linked to the app
name.
Kind Regards,
Aditya

On Thu, May 31, 2018, 7:54 AM Spence Patrick 
wrote:

> Is your link tag href="./about" or href="/about/"
>
> On Wed, May 30, 2018, 19:14  wrote:
>
>> Hello,
>>
>> I'm debugging an issue that I'm having with my URL patterns. In my HTML I
>> have an "about me" page that is linking to an about.html file in my
>> templates/blog/ directory. When I load the homepage and click on the "about
>> me" link than "domain.com/about/" loads, which matches the URL pattern
>> in my blog/urls.py file, and the page renders perfectly fine.
>>
>> However, while on the "about me" page I can't link to any other page
>> because the URL pattern starts to concatenate instead of overwrite (if that
>> makes any sense). For example, if I click on "about me" again than Django
>> tries to load domain.com/about/about and I get an error.
>>
>> I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to
>> programming by the way (to include Python, Django, HTML/CSS).
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/1213b3f9-c74b-4af9-b585-61f2423720f0%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/CAD6-5Ch7%3DSTQGPdPg3iU%3Dvy2H1GMqcFnycBqb5bquXGDDV6ZBA%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/CAEPfumjqtuz9bTfh%2Bfk%3D8iFYOKUQwSGpQqwwuyqX%2BQ%3DABgL3%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL Concatenation Issue

2018-05-30 Thread Spence Patrick
Is your link tag href="./about" or href="/about/"

On Wed, May 30, 2018, 19:14  wrote:

> Hello,
>
> I'm debugging an issue that I'm having with my URL patterns. In my HTML I
> have an "about me" page that is linking to an about.html file in my
> templates/blog/ directory. When I load the homepage and click on the "about
> me" link than "domain.com/about/" loads, which matches the URL pattern in
> my blog/urls.py file, and the page renders perfectly fine.
>
> However, while on the "about me" page I can't link to any other page
> because the URL pattern starts to concatenate instead of overwrite (if that
> makes any sense). For example, if I click on "about me" again than Django
> tries to load domain.com/about/about and I get an error.
>
> I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to
> programming by the way (to include Python, Django, HTML/CSS).
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1213b3f9-c74b-4af9-b585-61f2423720f0%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/CAD6-5Ch7%3DSTQGPdPg3iU%3Dvy2H1GMqcFnycBqb5bquXGDDV6ZBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread 岳贝
The date = models.DataTimeField() should be date = models.DateTimeFild() ?
https://docs.djangoproject.com/en/2.0/ref/models/fields/#datetimefield

Caleb Bryson  于2018年5月31日周四 上午9:45写道:

> I am getting a attribute error when i try to run my server. does anyone
> know what i can change in this code to fix that?
>
> from django.db import models
>
> class Post(models.Model) :
> title = models.Charfield(max_length=140)
> body = models.Textfield()
> date = models.DataTimeField()
>
> def __str__(self):
> return self.title
>
> --
> 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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/CAC5CVE1XAmFN-jgjy03Ggn%3D1rtf-1qTDVcpCtb_suJ2-k6gaDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Spence Patrick
The f in field should be capitalized

On Wed, May 30, 2018, 20:10 Caleb Bryson  wrote:

> it is still saying "AttributeError: model 'django.db.models' has no
> attribute 'Charfeild'
>
> On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>>
>> On 31/05/2018 11:45 AM, Caleb Bryson wrote:
>> > I am getting a attribute error when i try to run my server. does
>> > anyone know what i can change in this code to fix that?
>>
>> Try indenting the __str__ method so it is within the scope of the Post
>> class
>>
>> >
>> > from django.db import models
>> > class Post(models.Model) :
>> > title = models.Charfield(max_length=140)
>> > body = models.Textfield()
>> > date = models.DataTimeField()
>> > def __str__(self):
>> > return self.title
>> > --
>> > 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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>> > <
>> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com?utm_medium=email_source=footer>.
>>
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e2d17976-18e1-4120-950d-1457858f012b%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/CAD6-5Chfe5X_J8KbfWs7Otz7W45T4QVfYULW4UDkYU%3D2AAaZrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Caleb Bryson
I think it was because i did not use camel casing so CharField instead of 
Charfield. I will continue the tutorial and see if that works


On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>
> On 31/05/2018 11:45 AM, Caleb Bryson wrote: 
> > I am getting a attribute error when i try to run my server. does 
> > anyone know what i can change in this code to fix that? 
>
> Try indenting the __str__ method so it is within the scope of the Post 
> class 
>
> > 
> > from django.db import models 
> > class Post(models.Model) : 
> > title = models.Charfield(max_length=140) 
> > body = models.Textfield() 
> > date = models.DataTimeField() 
> > def __str__(self): 
> > return self.title 
> > -- 
> > 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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/931b7ebc-430d-4e6c-802f-db0f0c2a1a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Caleb Bryson
it is still saying "AttributeError: model 'django.db.models' has no 
attribute 'Charfeild'

On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>
> On 31/05/2018 11:45 AM, Caleb Bryson wrote: 
> > I am getting a attribute error when i try to run my server. does 
> > anyone know what i can change in this code to fix that? 
>
> Try indenting the __str__ method so it is within the scope of the Post 
> class 
>
> > 
> > from django.db import models 
> > class Post(models.Model) : 
> > title = models.Charfield(max_length=140) 
> > body = models.Textfield() 
> > date = models.DataTimeField() 
> > def __str__(self): 
> > return self.title 
> > -- 
> > 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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e2d17976-18e1-4120-950d-1457858f012b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Mike Dewhirst

On 31/05/2018 11:45 AM, Caleb Bryson wrote:
I am getting a attribute error when i try to run my server. does 
anyone know what i can change in this code to fix that?


Try indenting the __str__ method so it is within the scope of the Post class



from django.db import models
class Post(models.Model) :
title = models.Charfield(max_length=140)
body = models.Textfield()
date = models.DataTimeField()
def __str__(self):
return self.title
--
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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/16cd9f05-39ae-735b-d2eb-f9802c043a8e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Attribute error

2018-05-30 Thread Caleb Bryson
I am getting a attribute error when i try to run my server. does anyone 
know what i can change in this code to fix that?

from django.db import models

class Post(models.Model) :
title = models.Charfield(max_length=140)
body = models.Textfield()
date = models.DataTimeField()

def __str__(self):
return self.title

-- 
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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Syntax error

2018-05-30 Thread Caleb Bryson
it did thanks :). and changing the { to ( helped also for anyone view for 
future reference
. 

On Wednesday, May 30, 2018 at 8:48:53 PM UTC-4, Michael MacIntosh wrote:
>
> Hi Caleb,
>
> I think there should be a comma here 
>
> basic.html' {'content'
>
> so it should be
>
> basic.html', {'content'
> Hope that helps!
>
> On 5/30/2018 5:45 PM, Caleb Bryson wrote:
>
> I can not seem to figure out what the syntax error is in line 7 of this 
> code, can anyone help 
>
> from django.shortcuts import render
> def index(request):
> return render(request, 'hybridair/home.html')
> def contact(request):
> return render(request, 'hybridair/basic.html' {'content' : ['contact the 
> team at', 'mar...@flymat21.com ']})
> -- 
> 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/efe2686c-1e4d-477e-8057-90a81b1bef00%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> -- 
> This message has been scanned for viruses and dangerous content by 
> *E.F.A. Project* , and is believed to be 
> clean. 
> Click here to report this message as spam. 
> 
>  
>
>
>

-- 
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/5131b543-4ac1-49a9-8bc2-4bed615606d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


URL Concatenation Issue

2018-05-30 Thread johnregis021
Hello,

I'm debugging an issue that I'm having with my URL patterns. In my HTML I 
have an "about me" page that is linking to an about.html file in my 
templates/blog/ directory. When I load the homepage and click on the "about 
me" link than "domain.com/about/" loads, which matches the URL pattern in 
my blog/urls.py file, and the page renders perfectly fine.

However, while on the "about me" page I can't link to any other page 
because the URL pattern starts to concatenate instead of overwrite (if that 
makes any sense). For example, if I click on "about me" again than Django 
tries to load domain.com/about/about and I get an error.

I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to 
programming by the way (to include Python, Django, HTML/CSS).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1213b3f9-c74b-4af9-b585-61f2423720f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Syntax error

2018-05-30 Thread Michael MacIntosh

Hi Caleb,

I think there should be a comma here

basic.html' {'content'

so it should be

basic.html', {'content'

Hope that helps!

On 5/30/2018 5:45 PM, Caleb Bryson wrote:
I can not seem to figure out what the syntax error is in line 7 of 
this code, can anyone help


from django.shortcuts import render
def index(request):
return render(request, 'hybridair/home.html')
def contact(request):
return render(request, 'hybridair/basic.html' {'content' : ['contact 
the team at', 'mar...@flymat21.com']})

--
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/efe2686c-1e4d-477e-8057-90a81b1bef00%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.

--
This message has been scanned for viruses and dangerous content by
*E.F.A. Project* , and is believed to be 
clean.
Click here to report this message as spam. 
 



--
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/f0630b9d-7eb2-b919-5cbe-1fdb1695e551%40linear-systems.com.
For more options, visit https://groups.google.com/d/optout.


Syntax error

2018-05-30 Thread Caleb Bryson
I can not seem to figure out what the syntax error is in line 7 of this 
code, can anyone help

from django.shortcuts import render

def index(request):
return render(request, 'hybridair/home.html')

def contact(request):
return render(request, 'hybridair/basic.html' {'content' : ['contact the 
team at', 'mar...@flymat21.com']})

-- 
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/efe2686c-1e4d-477e-8057-90a81b1bef00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Model

2018-05-30 Thread Sadialiou Diallo



> import whois
>
>
> class Domains(models.Model):
> domainname = models.CharField(max_length=200, blank=True)
> domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
> details = whois.whois(domainname)
> w = str(details.expiration_date)
> domainwhois = models.DateField(default=w)
>
> def __str__(self):
> return self.domainname
>
> Domains.save()
>
>

after you definded the save method  



domaine=Domaine()
domaine.domainename=.
domaine.domaineuser=User.objects.last()
domaine.details=...

domaine.save()

-- 
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/3d70235f-5c03-4f1d-85e6-b1132fde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Model

2018-05-30 Thread Julio Biason
Hi,

If I got this right, what you want to do is save the "domainwhois" with the
expiration date of the result of the whois.whois function.

Unfortunately, things don't work in class level like this, because things
are static here: whois.whois will be run one single time, not on every
object. For that, you'll need to change something in the instance.
Fortunately, Django allows access to things in the instance with ``save``:

def save(self, *args, **kwargs):
   details = whois.whois(self.domainname)
   self.domainwhois = details.expiration_date
   super().save(*args, **kwargs)

("details" and "w" can be removed from the model itself, as they are
variables used only for retriving this information). Have a look how models
work here: https://docs.djangoproject.com/en/2.0/topics/db/models/

On Wed, May 30, 2018 at 11:12 AM, Максим С  wrote:

> Hello all.
>
> I'm beginer. Sorry. Can anyone help me with this model. It did't 
> work(TypeError:
> expected string or bytes-like object
>
> ):
>
> import whois
>
>
> class Domains(models.Model):
> domainname = models.CharField(max_length=200, blank=True)
> domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
> details = whois.whois(domainname)
> w = str(details.expiration_date)
> domainwhois = models.DateField(default=w)
>
> def __str__(self):
> return self.domainname
>
> Domains.save()
>
> --
> 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/53525a55-0d68-4a8c-9031-5d7c3baa7064%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101   |  Mobile: +55 51
*99907 0554*

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


Re: Problem in part 6, CSS doesn't work

2018-05-30 Thread Mikko Meronen
Hi,

The css file is in .../polls/static/polls/style.css

And here is the full code of .../polls/templates/polls/index.html:

{% load static %}



{% if latest_question_list %}

{% for question in latest_question_list %}
{{
question.question_text }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}



And this is the PowerShell I get when opening the webpage:

[30/May/2018 17:26:42] "GET /polls/ HTTP/1.1" 200 169
[30/May/2018 17:26:42] "GET /polls/static/polls/style.css HTTP/1.1" 404 1681
Not Found: /favicon.ico
[30/May/2018 17:26:43] "GET /favicon.ico HTTP/1.1" 404 2088


-Mikko

2018-05-30 2:16 GMT+03:00 Vijay Khemlani :

> That's only for production environments, for development you don't need to
> run that command
>
> Where did you finally put the css file and what path did you put in the
>  tag?
>
> On Tue, May 29, 2018 at 1:46 PM Mikko Meronen 
> wrote:
>
>> Hi,
>>
>> Thank you, but I should have those correct.
>>
>> I did some googling and ran following: python manage.py collectstatic
>>
>> And I got this:
>>
>> Django-project\lib\site-packages\django\contrib\staticfiles\storage.py",
>> line 43, in path
>> raise ImproperlyConfigured("You're using the staticfiles app "
>> django.core.exceptions.ImproperlyConfigured: You're using the
>> staticfiles app without having set the STATIC_ROOT setting to a filesystem
>> path.
>>
>> If any advices available, I would appreciate it a lot, thank you.
>>
>> -Mikko
>>
>> 2018-05-29 10:18 GMT+03:00 s.f.wrobel via Django users <
>> django-users@googlegroups.com>:
>>
>>> Make sure that you add the following line to your settings.py:
>>>
>>> INSTALLED_APPS = [
>>> 'YOUR_APP_NAME',
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> ]
>>>
>>> In your case YOUR_APP_NAME should be polls.
>>> Only with this line set, django looks in polls/static/polls/ for static
>>> (e.g .css) files.
>>>
>>> --
>>> 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/1ce28246-ddf6-48b2-9811-988678beb65c%
>>> 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/CAGD0jjJUHeZD2ep52j-NArHPjEibVMK3Jiiqor4O4BEuS2_
>> gtw%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/CALn3ei2ujyB0g4fV-Ow2ogcgkv8%
> 3D_XfvK2rzHTtfPjGAyJz%3DAQ%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/CAGD0jjLyHF_NCtSFRRYZ18CViNDvPb81S78%2BYcV7zKyAfSxj-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Model

2018-05-30 Thread Максим С
Hello all.

I'm beginer. Sorry. Can anyone help me with this model. It did't 
work(TypeError: 
expected string or bytes-like object

):

import whois


class Domains(models.Model):
domainname = models.CharField(max_length=200, blank=True)
domainuser = models.ForeignKey(User, on_delete=models.CASCADE)
details = whois.whois(domainname)
w = str(details.expiration_date)
domainwhois = models.DateField(default=w)

def __str__(self):
return self.domainname

Domains.save()

-- 
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/53525a55-0d68-4a8c-9031-5d7c3baa7064%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get the primary key of the underlying model in a ModelForm?

2018-05-30 Thread Mark Phillips
Mathew,

Thanks!

Mark

On Tue, May 29, 2018 at 2:18 PM, Matthew Pava  wrote:

> You can access self.instance, which should have all the fields populated
> for that model instance.  So you can access it via self.instance.pk.
>
>
>
> Keep in mind, though, that if you are creating the Document, you will not
> have a pk until after the save is committed, so it won’t be accessible in
> the clean method.  If you are updating a document, then pk will populated.
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *Mark Phillips
> *Sent:* Tuesday, May 29, 2018 4:15 PM
> *To:* django users
> *Subject:* How to get the primary key of the underlying model in a
> ModelForm?
>
>
>
> I have a model, Document, and an associated DocumentForm(forms.
> ModelForm), and a DocumentAdmin(admin.ModelAdmin). In the clean method of
> the DocumentForm, I need to get the document_id (ie primary key) of the
> underlying Document, but it is not included in the field set for that form.
> I need the primary key, because one of the fields on the form belongs to
> another model (it is a JSON field), and I need to save that field in the
> other model when the DocumentForm is saved.
>
>
>
> How do I access the primary key of the underlying Model in a ModelForm?
>
>
>
> Thanks!
>
>
>
> Mark
>
> --
> 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/CAEqej2OAvc78CgykeYYs5Wvc-MPQRR0Lnhp5NYQt3hpVf_cv8w%
> 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/1a98417972974d919030e6a5ed76cced%40ISS1.ISS.LOCAL
> 
> .
> 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/CAEqej2PT6C-PiM45nJD2%3D6GyFwXWspYKMJxVE8f4EJyaVTDQYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11 admin Bug!! list_filter get duplicated in other models admin

2018-05-30 Thread Jason
maybe.  Best thing for you to do would make an example and write a ticket 
about it at https://code.djangoproject.com/

On Wednesday, May 30, 2018 at 1:58:28 AM UTC-4, ebuild wrote:
>
> This is happening only after updated to from 1.8 to 1.11, using Eclipse.
> I have multiple model admin with different list_filter, what is happening 
> is that when I go to* modelA admin* page which has* list_filter* and then 
> navigate to *modelB admin* I got the list_filter of *modelA *displayed 
> instead of the* modelB*'s one. If I make a selection from one of the 
> displayed filters the url get appended with "*?e=1*" but no error 
> displayed in the console
>
> The same happens if  I restart the server and navigate to* modelB admin* 
> first and then go to* modelA admin* the* list_filter of B* get displayed.
>
> Any clue ??
>

-- 
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/76a5367e-5deb-43a1-a1da-838fa11af62a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.11 admin Bug!! list_filter get duplicated in other models admin

2018-05-30 Thread Jason
maybe.  Best thing for you to do would make an example and write a ticket 
about it at https://code.djangoproject.com/

On Wednesday, May 30, 2018 at 1:58:28 AM UTC-4, ebuild wrote:
>
> This is happening only after updated to from 1.8 to 1.11, using Eclipse.
> I have multiple model admin with different list_filter, what is happening 
> is that when I go to* modelA admin* page which has* list_filter* and then 
> navigate to *modelB admin* I got the list_filter of *modelA *displayed 
> instead of the* modelB*'s one. If I make a selection from one of the 
> displayed filters the url get appended with "*?e=1*" but no error 
> displayed in the console
>
> The same happens if  I restart the server and navigate to* modelB admin* 
> first and then go to* modelA admin* the* list_filter of B* get displayed.
>
> Any clue ??
>

-- 
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/4e8c8f33-6a65-4448-916f-eb5454808535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Admin site: pass data from AdminModel object to ModelForm object (or another way to pass data to "add" form)

2018-05-30 Thread Артур Скок
Globally, we need call "add" form for model in admin site, but with options 
selected by user: 
1. user checks items in "changelist" of objects RepoFile
2. select action "create job"
3. redirect user to standard "add" form for new object DeviceCronJob where 
field download_files already checked by selected files.
May be there is another way to do it. Variants that i tried is below.

I have add form for appropriate model. This model contains multichoice 
field:
*models.py:*



*class DeviceCronJob(models.Model):...download_files = 
models.TextField(max_length=250, blank=True, verbose_name=_("Files for 
downloading"))*

*forms.py:*

class DeviceCronJobAddForm(forms.ModelForm):
download_files = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple(), 
choices=[(file.hash, "%s [%s]" % (file.full_name,file.link)) 
for file in RepoFile.objects.filter()]
)

All work fine if i use standard admin "add".
I have other model RepoFile and customized Action: "Create download cronjob 
in template". On selecting files and pushing this action i need to pass 
selected files to DeviceCronJobAddForm.
i tried this:
*admin.py*
class DeviceCronJobAdmin(ModelAdmin):
model = DeviceCronJob
add_form = DeviceCronJobAddForm
list_display = ('cron_date', 'template', 'description', 
'download_files', 'cron_user', 'cron_path', 'cron_mode', 'cdate')
...
def get_form(self, request, obj=None, **kwargs):
defaults = {}
setted = request.GET.get('setted','').split(",")
if obj is None: # if add new
if len(setted):
defaults.update({'form': self.add_form(setted=setted)})
else:
defaults.update({'form': self.add_form})
else: # if change view
defaults.update({
'form': self.add_form,
})
defaults.update(kwargs)
return super(DeviceCronJobAdmin, self).get_form(request, obj, 
**defaults)

*models.py:*
class DeviceCronJobAddForm(forms.ModelForm):
...
def __init__(self, *args, **kwargs):
files = kwargs.pop('setted','')
# actions with files
super(DeviceCronJobAddForm, self).__init__(*args, **kwargs)

but it raises error: unknown setted in* super(DeviceCronJobAddForm, 
self).__init__(*args, **kwargs)*
Also i tried pass selected files like GET arguments, but Form has not 
access to request object

-- 
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/f0bafe2d-4ee7-4a65-a20d-553ffd8a63e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.