test error

2018-10-20 Thread Tim Vogt (Tim Vogt)
I try to make a test with has an error
any suggestions?
tim


expected_author = f'{post.author}
^
SyntaxError: EOL while scanning string literal


--
Ran 1 test in 0.000s

FAILED (errors=1)
Destroying test database for alias 'default'...
MacBook-Pro-15-Officerebel:blogapi timvogt$


from django.test import TestCase
from django.contrib.auth.models import User

from .models import Post

class BlogTests(TestCase):

@classmethod 
def setUpTestData(cls):
#Create a user
testuser1 = User.objects.create_user(
username='testuser1', password='abc123')
testuser1.save()

# Create a blog post
test_post = Post.objects.create(
author=testuser1, title='Blog title', body='Body content...')
test_post.save()

def test_blog_content(self):
post = Post.objects.get(id=1)
expected_author = f'{post.author}'
expected_title = f'{post.title}'
expected_body = f'{post.body}'
self.assertEquals(expected_author, 'testuser1')
self.assertEquals(expected_title,'Blog title')
self.assertEquals(expected_body, 'Body content ...')

-- 
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/FCBEF0A0-EDB1-4842-BB4E-42249F3F48EB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why is the static file not loading.i need solution

2018-10-20 Thread Gabriel Stone
Also in your href try using a forward slash not a back slash to make
references

On Sat, 20 Oct 2018 at 5:45 PM, Siddharth Tamang <
tamangsiddhart...@gmail.com> wrote:

> Have you defined your static files entry in settings.py?
>
> On Sat, Oct 20, 2018 at 9:05 PM Obodoma Uzondu Vincent <
> uobodoma...@gmail.com> wrote:
>
>> THIS IS THE HTML FILE
>> 
>> login
>> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css;
>> integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
>> crossorigin="anonymous">
>> {% load static %}
>> > type="text/css">
>>   
>>   
>>
>> 
>>   welcome
>>   Welcome to my page!
>>   Success
>> 
>>   
>> THIS IS THE CSS FILE
>> h1 {
>> color: red;
>>   }
>>
>> --
>> 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/CACsKspkppG6UHwhfXko0z5DO%2BXkk9LvxLwO6dmEjkARRbm7PjA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified Solutions Architect - Associate
>
> --
> 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/CADBOudswAoq9ncZzBkAbGXUgZ6btX36740tF3L46yQJcK2Lq8A%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/CAL-5MpX1c0St%2B6hD%3DabBLVmE6yVc%3DSrBhX4Q4S%2Bd1eqtPJ40vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why is the static file not loading.i need solution

2018-10-20 Thread Siddharth Tamang
Have you defined your static files entry in settings.py?

On Sat, Oct 20, 2018 at 9:05 PM Obodoma Uzondu Vincent <
uobodoma...@gmail.com> wrote:

> THIS IS THE HTML FILE
> 
> login
> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css;
> integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
> crossorigin="anonymous">
> {% load static %}
>  type="text/css">
>   
>   
>
> 
>   welcome
>   Welcome to my page!
>   Success
> 
>   
> THIS IS THE CSS FILE
> h1 {
> color: red;
>   }
>
> --
> 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/CACsKspkppG6UHwhfXko0z5DO%2BXkk9LvxLwO6dmEjkARRbm7PjA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thank you
Siddharth Tamang
AWS Certified Solutions Architect - Associate

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


why is the static file not loading.i need solution

2018-10-20 Thread Obodoma Uzondu Vincent
THIS IS THE HTML FILE

login
https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css;
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
{% load static %}

  
  


  welcome
  Welcome to my page!
  Success

  
THIS IS THE CSS FILE
h1 {
color: red;
  }

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


Re: Using Primary key in two fields

2018-10-20 Thread Vishvajit Pathak
Hi Rakhee,
Could you try following ? : 

icatid = models.BigIntegerField(db_column='ICatID') makedate = 
models.DateTimeField(db_column='MakeDate') revdate = 
models.DateTimeField(db_column='RevDate', blank=True, null=True) makeid = 
models.BigAutoField(db_column='MakeId') class Meta: unique_together = 
(('icatid', 'makeid'),) 


On Wednesday, 17 October 2018 11:25:48 UTC+5:30, Rakhee Menon wrote:
>
> Hi Everyone,
>
> I have a scenario where one field needs to be a primary key and another 
> field needs to be an AutoFieldand Autofield requires a condition 
> primary_key = true
>
> I get this error 
> django_reports.MstCompositionFm.makeid: (fields.E100) AutoFields must set 
> primary_key=True.
> django_reports.MstSalarystructure: (models.E026) The model cannot have 
> more than one field with 'primary_key=True'
>
> This is my case:
>
> icatid = models.BigIntegerField(db_column='ICatID', primary_key=True)
> makedate = models.DateTimeField(db_column='MakeDate') 
> revdate = models.DateTimeField(db_column='RevDate', blank=True, null=True) 
>
> makeid = models.BigAutoField(db_column='MakeId', primary_key=False)
>
> It would be of great help if anyone could figure out whats the solution
>
> Thanks in Advance,
> Rakhee
>
>

-- 
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/a864b7d5-11e0-4964-b272-00a70e445e88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Displaying items differently on one template based on age

2018-10-20 Thread Daniel Veazey
Ah, very good. I understand now. Thank you both for your help.

On Friday, October 19, 2018 at 10:49:28 PM UTC-5, Daniel Veazey wrote:
>
> I'm using 2.1. I have a list of blog posts, and I want to display them 
> differently based on their age. The most recent post will be displayed 
> prominently, and the 10 most recent posts after that will be displayed in 
> two columns below it. The way I'm passing the view to the template is:
>
> class PostListView(ListView):
> model = Post
> template_name = 'mainapp/home.html'
>
>
> def get_context_data(self, **kwargs):
> context = super().get_context_data(**kwargs)
> context['latest'] = Post.objects.all().order_by('-date_posted')[0]
> context['first_column'] = Post.objects.all().order_by(
> '-date_posted')[1:6]
> context['second_column'] = Post.objects.all().order_by(
> '-date_posted')[6:10]
> return context
>
> Then I use 'latest', 'first_column' and 'second_column' in the template to 
> display those things in their separate divs.
>
> Doing it this way works, but I am very new and I think I might have bodged 
> it when there's a better way to do it. Any suggestions?
>

-- 
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/e717f4e2-769a-4331-a9ce-37b4ca3883e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: generate username and password

2018-10-20 Thread ludovic coues
Si le but est simplement de faire plaisir a la base de données, il est
possible d'utiliser l'email comme nom d'utilisateur.

Pour le mot de passe, c'est une mauvaise idée. Mais c'est possible, par
exemple avec le module secrets en python 3.6

https://docs.python.org/3.6/library/secrets.html#recipes-and-best-practices

On Fri, Oct 19, 2018, 16:00  wrote:

> parce que je veux pas que le username soit créer manuellement mais
> automatiquement par random. Car ça serait difficile que pour chaque
> inscription je créer manuellement le username pour pouvoir lui envoyé dans
> son mail afin qu'il puisse se connecter.
>
> Le vendredi 19 octobre 2018 01:24:54 UTC, fatoubi...@gmail.com a écrit :
>>
>> Bonjour! Je voudrais lorsqu'un utilisateur s'inscrit avec ses
>> informations personnelles puis soumet le formulaire, je lui génère un nom
>> d'utilisateur et un mot de passe qu'on envoie dans son mail fourni.
>>
> --
> 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/50fa5b8a-c5c3-4e64-aef3-53c6c1197d0b%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/CAEuG%2BTas5iXJaLObcpKW%2BS9aRmaiLROg7D5hjFi3tbKe-0ObDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Prepopulate blog in b.entry_set.all()[i].blog ?

2018-10-20 Thread Carsten Fuchs

Can anyone help please?

Am 2018-10-11 um 16:58 schrieb Carsten Fuchs:

Dear Django group,

with Django 1.11.15, using the example models Blog and Entry at 
 
for reference, I have code like this:


     b = Blog.objects.get(name="...")
     for e in b.entry_set.all():
     print(e.blog)

Obviously, e.blog == b, but I found that for each e, the access to 
e.blog causes a subquery to fetch the blog object.


While I understand the concepts of select_related() and 
prefetch_related(), I was surprised that the e.blog attributes are not 
prepopulated with b. Why is that and what is the proper way to fix the 
problem?


Best regards,
Carsten



--
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/80c901cb-33c3-8ba8-a359-393cf00ca53d%40cafu.de.
For more options, visit https://groups.google.com/d/optout.


Re: error 501

2018-10-20 Thread Neethi Ramaiah
i have installed django fully and correctly on windows step by step when 
lastly i m trying to run.. i m not getting this error

On Friday, 19 October 2018 16:59:10 UTC+5:30, Neethi Ramaiah wrote:
>
> how to solve this error Error response
>
> Error code 501.
>
> Message: Unsupported method ('GET').
>
> Error code explanation: 501 = Server does not support this operation.
>
>
>

-- 
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/f2b1ade5-7893-491c-832f-6f99ad4e3b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.