reg: django Model for MCQs type project

2019-11-19 Thread 'Amitesh Sahay' via Django users
Hello Members,
I have below requirements for a project where I need to develop the model based 
on "multiple Choice Questions". Below are the criteria:-
   
   - Admin can create/edit/delete(soft delete only) a "Test" in the form of 
MCQs.
   - Admin can then create/edit/delete a "Question" to each test. Each question 
contains the actual question, the correct answer and 3 incorrect answers. An 
admin can mark a question as mandatory or optional. An optional question can be 
skipped by the student.
   - Admin can also set the marks for each question
   - Student can view a testStudent can attempt a test. Every test can be 
attempted multiple times. Each attempt is scored and saved separately. 
   - Since the questions are in MCQ format, the students answers are 
auto-evaluated by the application.

This is something very new for me. So, I am little reluctant on how to create 
the model for the above requirement. Here I do not need to develop any 
authentication environment. 

Any help would be highly appreciated.



Regards,
Amitesh

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/717890174.2580735.1574227227426%40mail.yahoo.com.


Re: mysql data connectivity problem

2019-11-19 Thread Manish Maurya
https://docs.djangoproject.com/en/2.2/ref/databases/#oracle-notes
"you need to open your settings.py file in that you have database
cinfiguration and you can see on goole also"

On Wed, 20 Nov 2019 at 08:28, Desh Deepak  wrote:

> You need to changes Database section inside settings.py
>
> On Tue, 19 Nov 2019, 18:59 Prof soul,  wrote:
>
>> Hi i'm soul i'm new to django and late, i got an idea to handle the
>> django but  there is still lack of database  connectivity with django
>> anybody know about it in easy manner
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/9b619168-8796-4d81-a728-ec34cd9eac11%40googlegroups.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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ0m4xhMFbzYTjSzNPHVqk6iKUEaKOPjocCKv8eF_EHSjRkkqw%40mail.gmail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANyc5fdwHCgSdDa5%3DEV8sLA%3DcSgbZeUX9UFD9GkRk-uyP1q1vQ%40mail.gmail.com.


Re: Directly Accessing Dictionary Values

2019-11-19 Thread Suraj Thapa FC
Return the unique key object... Like
return render(request, 'abc.html',unique_key)

On Wed, 20 Nov 2019, 9:18 am Andrew Stringfield, 
wrote:

> Hello all,
>
>  I am trying to access Dictionary values directly.  Here is my view:
>
> def unique_key_query(request, unique_key):
> unique_key_object =
> simpleformmodel.objects.all().filter(id=unique_key)
> context = {'unique_key_object': unique_key_object}
> return render(request, "bash_file_page.html", context)
>
> Here is my template:
> {% if unique_key_object %}
> {% for question in unique_key_object %}
> {{ question.filename }}
> {% endfor %}
> {% else %}
> No data is available.
> {% endif %}
>
> I can access Dictionary values with a for loop, but I just do not want to
> do that.  How can I access the values directly?
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b8ee9cc4-1d49-4464-b181-583042182576%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPjsHcEmLcopcjj27CJL2sxPs_io1S--DfrVDFnkh%2Bbmcyciag%40mail.gmail.com.


Directly Accessing Dictionary Values

2019-11-19 Thread Andrew Stringfield
Hello all,

 I am trying to access Dictionary values directly.  Here is my view:

def unique_key_query(request, unique_key):
unique_key_object = 
simpleformmodel.objects.all().filter(id=unique_key)
context = {'unique_key_object': unique_key_object}
return render(request, "bash_file_page.html", context)

Here is my template:
{% if unique_key_object %}
{% for question in unique_key_object %}
{{ question.filename }}
{% endfor %}
{% else %}
No data is available.
{% endif %}

I can access Dictionary values with a for loop, but I just do not want to 
do that.  How can I access the values directly?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b8ee9cc4-1d49-4464-b181-583042182576%40googlegroups.com.


Re: mysql data connectivity problem

2019-11-19 Thread Desh Deepak
You need to changes Database section inside settings.py

On Tue, 19 Nov 2019, 18:59 Prof soul,  wrote:

> Hi i'm soul i'm new to django and late, i got an idea to handle the django
> but  there is still lack of database  connectivity with django anybody know
> about it in easy manner
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9b619168-8796-4d81-a728-ec34cd9eac11%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ0m4xhMFbzYTjSzNPHVqk6iKUEaKOPjocCKv8eF_EHSjRkkqw%40mail.gmail.com.


Re: mysql data connectivity problem

2019-11-19 Thread Franz Ulenaers
Hi,
Do you want to write a python program which read a sqlite3 database and 
maybe do some updates and/or create new records in the database ?



>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8bdbafa4-9815-4683-b0f2-d86068614799%40googlegroups.com.


Migrations appear to run twice when running tests

2019-11-19 Thread Rich Rauenzahn

I'm trying to figure out why my migrations appear to run twice when unit 
testing.I do have multiple dbs with custom routers to route to 
different databases.

I've tried debugging and tracing the routers to see if that's where the 
issue lies, but I don't know enough about the migration process to know 
what to look for.  

...I'm surprised it even works given that the database is already migrated 
once -- shouldn't the 2nd migrations fail?

I'm not expecting an answer -- I think there's not enough information.  

But where should I dig?

Rich


$ ./manage-coverage test --noinput -v 2
nosetests --logging-level=INFO --progressive-advisories --with-timer 
--timer-top-n=10 --with-prowl-report --with-timed-setup-report --with-id 
--id-file=/opt/gitlab-runner/NCiG8AGt/1/redacted-automation/reddash/djproj/.noseids
 
-v --verbosity=2
Using --with-id and --verbosity=2 or higher with nose-progressive causes 
visualization errors. Remove one or the other to avoid a mess.
Creating test database for alias 'default' ('reddash_cicd_3')...
Operations to perform:
  Synchronize unmigrated apps: api, bugzilla, celery, 
django_db_constraints, django_extensions, django_filters, django_nose, 
drf_yasg, humanize, messages, redauto, polymorphic, rest_framework, saml2, 
staticfiles, timezone_field
  Apply all migrations: accounts, admin, auth, contenttypes, dashboards, 
django_celery_beat, django_celery_results, reversion, sessions, tracking
Synchronizing apps without migrations:
  Creating tables...
Running deferred SQL...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying accounts.0001_initial... OK
  Applying tracking.0001_initial... OK
  Applying accounts.0002_auto_20160929_2021... OK
  Applying accounts.0003_auto_20190225_2216... OK
  Applying accounts.0004_token... OK
  Applying accounts.0005_auto_20190306_1804... OK
  Applying tracking.0002_apirequestlog_department... OK
  Applying accounts.0006_dedupe_20190422_1447... OK
  Applying accounts.0007_auto_20190422_1459... OK
  Applying accounts.0008_auto_20190730_2235... OK
  Applying accounts.0009_auto_20190802_1750... OK
  Applying accounts.0010_auto_20190906_0024... OK
  Applying accounts.0011_user_is_redauto... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying dashboards.0001_initial... OK
[...]
  Applying dashboards.0110_auto_20191118_1742... OK
  Applying django_celery_beat.0001_initial... OK
  Applying django_celery_beat.0002_auto_20161118_0346... OK
  Applying django_celery_beat.0003_auto_20161209_0049... OK
  Applying django_celery_beat.0004_auto_20170221_... OK
  Applying django_celery_beat.0005_add_solarschedule_events_choices... OK
  Applying django_celery_beat.0006_auto_20180210_1226... OK
  Applying django_celery_results.0001_initial... OK
  Applying reversion.0001_squashed_0004_auto_20160611_1202... OK
  Applying sessions.0001_initial... OK
  Applying tracking.0003_auto_20190822_1229... OK
  Applying tracking.0004_auto_20191030_2030... OK
  Applying tracking.0005_auto_20191030_2030... OK
  Applying tracking.0006_remove_apirequestlog_server_name... OK
  Applying tracking.0007_auto_20191030_2038... OK
Creating test database for alias 'bugzilla' (':memory:')...
Operations to perform:
  Synchronize unmigrated apps: api, bugzilla, celery, 
django_db_constraints, django_extensions, django_filters, django_nose, 
drf_yasg, humanize, messages, redauto, polymorphic, rest_framework, saml2, 
staticfiles, timezone_field
  Apply all migrations: accounts, admin, auth, contenttypes, dashboards, 
django_celery_beat, django_celery_results, reversion, sessions, tracking
Synchronizing apps without migrations:
  Creating tables...
Creating table bugs
Creating table bug_fix_by_map
Creating table products
Creating table phases
Creating table versions
Running deferred SQL...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying accounts.0001_initial... OK
  Applying tracking.0001_initial... OK
  Applying accounts.0002_auto_20160929_2021... OK
  

Re: mysql data connectivity problem

2019-11-19 Thread Suraj Thapa FC
Refer the docs... Its easy

On Tue, 19 Nov 2019, 8:16 pm o1bigtenor,  wrote:

> On Tue, Nov 19, 2019 at 7:30 AM Prof soul  wrote:
> >
> > Hi i'm soul i'm new to django and late, i got an idea to handle the
> django but  there is still lack of database  connectivity with django
> anybody know about it in easy manner
> >
> No expert here but I do know that there are lots of pages in the docs
> on database connections most topics with lots of details.
> There are also more than a few, rather more detailed in fact,
> questions that I've seen here on the help site.
>
> Perhaps you need to show what you've actually done, what you are
> expecting AND what you are seeing to get good answers to your
> question.
>
> Please try again.
>
> Regards
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPpdf59%3D0jMxtH0HTWhNetfJJfD%3D1MPby%3DEQJ08LuQvOE9V0ow%40mail.gmail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPjsHcEKzEG_hNb3__T0NKRASnviofZo4og%3DdH-6snJo%2BptVeg%40mail.gmail.com.


Admin form in intermediate page

2019-11-19 Thread Thiago Luiz Parolin
I have a form in admin that when selecting a particular action,
presents an intermediate page with numeric fields to be filled and
saved in the selected records.
How can I save each record of my queryset with its respective field on
this intermediate page?
I have almost everything working, just assigning each field of the
intermediate page to its record that I don't know how to do
Does anyone have any ideas?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANbmKyvU63mL9wN1wSthGjkoEtrkq72FeB3LQyBmtTBViVqqOQ%40mail.gmail.com.


Re: mysql data connectivity problem

2019-11-19 Thread o1bigtenor
On Tue, Nov 19, 2019 at 7:30 AM Prof soul  wrote:
>
> Hi i'm soul i'm new to django and late, i got an idea to handle the django 
> but  there is still lack of database  connectivity with django anybody know 
> about it in easy manner
>
No expert here but I do know that there are lots of pages in the docs
on database connections most topics with lots of details.
There are also more than a few, rather more detailed in fact,
questions that I've seen here on the help site.

Perhaps you need to show what you've actually done, what you are
expecting AND what you are seeing to get good answers to your
question.

Please try again.

Regards

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPpdf59%3D0jMxtH0HTWhNetfJJfD%3D1MPby%3DEQJ08LuQvOE9V0ow%40mail.gmail.com.


mysql data connectivity problem

2019-11-19 Thread Prof soul
Hi i'm soul i'm new to django and late, i got an idea to handle the django 
but  there is still lack of database  connectivity with django anybody know 
about it in easy manner

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b619168-8796-4d81-a728-ec34cd9eac11%40googlegroups.com.


How to cast Faker data with Factory Boy ?

2019-11-19 Thread Olivier
Hello,

I'm discovering Factory Boy with a Django 2.2 project.
Factory Boy now ships with Faker which is very convenient to generate test 
data.

Faker generates string of all kinds to match phone numbers, postal or IP 
addresses.

How do you use Faker/Factory Boy to cast generated data into a specific 
type for which a constructor accepting a string  as its unique argument, 
exists ?
For instance, Faker generates IP addresses which are simple strings.
I would prefer to convert this string into a Python ipaddress.IPv4Address().

How can I do that ?
For reference, I opened the issue [1] on Faker's Github site.


[1] https://github.com/joke2k/faker/issues/1057

Best regards

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7e28909-660b-4115-8a81-a6a48e0d8330%40googlegroups.com.


Re: reg: creating blog topic in database

2019-11-19 Thread 'Amitesh Sahay' via Django users
I have got a work around though, and yes, those two links were handy.



Regards,
Amitesh
 

On Monday, 18 November, 2019, 6:27:01 PM IST, 'Amitesh Sahay' via Django 
users  wrote:  
 
 Hi, 

To be honest, I have tried following the django docs link that you have shared. 
But I failed to understand the relevance . I have little knowledge. So, I might 
be little clueless here.



Regards,
Amitesh
 

On Saturday, 16 November, 2019, 5:00:11 PM IST, Integr@te System 
 wrote:  
 
 Hi Issuer
Follow to part 3 - 4 and check docs for some thing else around you need
https://docs.djangoproject.com/en/2.2/ref/templates/language/
https://docs.djangoproject.com/en/2.2/intro/tutorial04/

On Sat, Nov 16, 2019, 16:40 'Amitesh Sahay' via Django users 
 wrote:

Hello All,
I have created the two models to create post on desired topic, as well as to 
get the comments from the visitors. But, I am not able to figure out, how to 
connect that model to my HTML page. 

I know how to create a static HTML pages for each topic,and write page content 
in  tags. which I have been thinking to do until now, but it seems to be 
a time taking and non-productive way. So, now I would like to write posts in my 
database model which I have registered in admin.py. 

Any idea, how can I achieve this, as this would be a like generating dynamic 
HTML pages based on models.

I am not sure if I was able to explain my requirements. May be as I am not 
getting right words to express them. Please ask me questions if any confusion, 
I will try to answer them. 

Below is my models.py 

from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User


class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date='publish')
author = models.ForeignKey(User, related_name='blog_posts', 
on_delete=models.CASCADE)
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, 
default='draft')

class Meta:
ordering = ('-publish',)

def __str__(self):
return self.title


class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', 
on_delete=models.CASCADE)
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)

class Meta:
ordering = ('created',)

def __str__(self):
return self.email
Regards,
Amitesh


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1799372727.1057468.1573897086523%40mail.yahoo.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWr7Tt14R-o8Jz0_mAZYV2KeDm5CkwBfqQBm9T8PkjaC%3Dw%40mail.gmail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/294189113.1738336.1574081785206%40mail.yahoo.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/371936794.2325659.1574168366621%40mail.yahoo.com.